Noob question: Can I use this to count cars passing my house?

I would like to use this to count traffic as it passes by my house.


  • Daytime only
  • Not too worried about torrentially rainy or snowy days
  • Camera perpendicular and 10’ (~3m) from side of 20’ wide (~6m) road - no sidewalk
  • Car speeds <40 mph (65 km/hr)
  • Cars and light trucks (no semis)

Here are the goals in increasing level of difficulty:

  1. Count any motor vehicle that passes in front of my house
  2. Record direction (left or right) and estimate speed
  3. Characterize cars, trucks, motorcycles

I know this is not an out of the box capability, but could the OpenMV Cam M7 be trained to do this?

Thanks, Chip

Detecting a moving object going left or right isn’t hard. With the telescope lens you can get this working easier buy having the camera look at one place. However, noise rejection is really difficult.

The first thing you should do is to setup a rig with the camera looking outside. Buy a telephoto lens so you can zoom in on one area. Once you’ve done that record a mjpeg clip of cars passing by, and then post it. I can get more of an idea of the challenges if you do this.


Thank you for the response. I was asking this question as I listened to the Embedded podcast with Kwabena Agyeman and it seemed that this device might work for my application. I was posting this question so I could decide whether to buy the OpenMV cam.

so, does this seem like a feasible application? Or, can I get the mjpeg with my current camera and then see if this will work.

Also, wouldn’t a wide angle lens allow more time for the camera to recognize the car? I am new to this so I am curious as to why the zoom might be better.



It depends on the distance. For a fast FPS you want to stay in the 160x120 range. At that resolution if you use a wide angle lens you’re not going to really be able to see anything farther than about 8 ft or so away without having noise issues (10 pixels of an object for example is usually not enough, it will need to be closer). Anyway, basically I’m asking how you want to mount the camera. It’s still a sensor at the end of the day and you have to setup it up in a system where it can work right. If you plan to mount it inside your house more than 30 ft from the road then it’s going to have a hard time seeing enough to detect cars.

… Anyway, I’m trying not to lead you down a false path here :slight_smile:. Um, can you take some pictures with a regular camera of what the OpenMV Cam will be looking at, where you will place it, etc?


Thank you for your help and advice on this. Here is a picture from my iPhone from the spot and with the orientation I plan to use for this sensor.

Here is the URL in case the image feature in this forum does not like dropbox: Dropbox - File Deleted



Ah, okay, so you plan to put it near the road. Yes, the camera can be used for detecting cars and their direction from that spot.

There are a lot of different techniques you can use to detect cars and their directions… Adaptive frame differencing is one thing you can do. Probably layered with find_displacement will give you the movement direction.

Basically, you’d set the resolution to something like 80x60 pixels and use a wide angle lens. Then, since you’re at a low resolution you can store multiple frames in RAM very using the SD card as a storage area. Anyway, you’d keep track of the last frame and do frame differencing between the last frame and the current frame. Then if there’s a difference between two frames you can pass that to find displacement which will run phase correlation on two successive difference images to determine the vector of movement.

You can also do stuff based on color tracking differences between frames, etc. I’m not sure what exactly the best approach is.