Ask Your Question

Revision history [back]

Is the camera static or not? If yes, just create a static mask for the line. If the camera is moving, you need to detect lines (with HOUGH transform for example and/or made a model of your road, etc.)

After that, you need to detect a car? So as you seem to have done: subtract the background (in the specified area) and compute the gravity center for the trajectory, and find the contours to see if the line is crossed.

If you need to detect precisely car (think about the shadows you have in the green area), have a look at the car detector (HAAR cascade classifier provides an already train car XML for cars detection).