I'm looking into CCTV, and am interested in minimising costs by having a motion tracking camera cover an area that would otherwise utilise multiple cameras.

There is already something like this on the market manufactured by a company called NightWatcher (I think). However, it does not track, it merely senses using 3 PIR's and points the camera in 1 of 3 positions. Ping ponging between them if the subject is between sensors.

I like the idea of this, but not the drawbacks, and was wondering if there was anything I could do with an arduino or similar to achieve a better result.

I stumbled across this, but am not entirely sure about it. Also this is for outside application, and that thread is for indoor (if that makes a difference).



Just in case I have mislead you, I want to have a unit where sensors detect movement and then a camera to face that position.

  • $\begingroup$ Do you want the camera to move? I'm not sure if I understand. $\endgroup$
    – holmeski
    Commented May 20, 2015 at 20:06
  • $\begingroup$ Sorry, Yes - I would like the camera to move. The problem with the equipment on the market is the ping-pong effect, best demonstrated with actual footage (found this on YouTube). >>> Video <<< As you an see, that unit only has 3 positions, and the footage when the unit moves in unusable. $\endgroup$ Commented May 20, 2015 at 23:47
  • $\begingroup$ What problem are you hoping to solve with this system? $\endgroup$
    – holmeski
    Commented May 20, 2015 at 23:55
  • $\begingroup$ It's just that ip cameras are super cheap. $\endgroup$
    – holmeski
    Commented May 20, 2015 at 23:56
  • $\begingroup$ Yes I can get "super cheap" cameras, but I want a quality HD picture of ~3MP. Apart from the extra storage space that multiple cameras will use depending on recording settings and overwrite interval, there is also the fact they cost a lot more. 1 camera will be enough if the motion detect is Ok $\endgroup$ Commented May 21, 2015 at 0:22

3 Answers 3


You can do all this with the right software, no sensors required (or the sensors could be other cameras).

The technique you're looking for is known as Frame Differencing - it basically means taking a frame of camera footage and using it as a masking filter on the next frame, this reveals the pixels which have changed in the current frame, these are usually pixels representing observed objects which have moved.

This gives you motion detection and can be done with fairly low resolution 'sensor' cameras, which then tell your main high resolution camera which way to face.

The 'ping-pong' effect would be mitigated by always having the motion target in the center of the main camera's view and only using the interpreted data from the sensor cameras to calculate the object's position.

  • $\begingroup$ That assumes the camera is always facing the target. It needs the sensors to turn the camera to face a target of it is not in front of the camera. I think people are misunderstanding what I am looking for. I want sensors to detect movement and aim a camera at the movement. I am not worried about picking out movement in the recorded image. $\endgroup$ Commented May 21, 2015 at 15:11
  • $\begingroup$ @Escribblings you misunderstand me, your main camera (which moves) is pointed at the motion by the Frame Differencing 'sensor cameras' which would be fixed in position (watching, say, a compass direction from the main camera) and when they detect motion - they instruct the main camera to swing around to face it. $\endgroup$ Commented May 21, 2015 at 15:45

Basically you need to solve 3 different problems:

Find the right camera setup and recording strategy I'm not an expert in this field so I won't say anything to this

Second get the information about a person on the camera. Basically to follow a person in the picture you have to know that there is a person in the picture. So you need something like a machine vision (Let computer decide whether there is a person or not). If you know there is a person you can get there position in the picture easily

The last problem is that you need a motor which moves the camera around. For this application a simple hobby servo motor is sufficient. The motor needs a small controller and some "strategy" how the motor let the camera follow the person.

My first approach to this problems would use a raspberry pi because of two reasons:
It provides the ability to control small servo motors
It can perform simple machine vision tasks

The raspberry is able to use the opencv library easily and there tons of projects how to do people recognition with opencv on the internet.

At the end of the day you will get a pixel value from the recognition algorithm. This value will tell you, that there is a person in the picture and where. You just need to rotate the camera so far that the person is in the center of your image. This is pretty simple done by using a proprtional controller.

The first problem I see, which you will encounter with this implementation is how the camera will behave when there are 2 or more people in the field of view. But there you can find a solution, too.

  • $\begingroup$ Interesting, but I presume that means using cameras to detect the person. What if the camera isn't facing them? The PiR method isn't pretty, but allows for one camera. To be fair, I don't mind if it follows anything that moves, I just want to stop the ping pong effect shown in the video I posted above. I might even be able to adapt the retail equipment, the do a camera mount with no camera or light so you can add your own, and that is peanuts compared to the full product. $\endgroup$ Commented May 21, 2015 at 10:11
  • $\begingroup$ Why not performing oscilating movement when the camera has no target? $\endgroup$
    – TobiasK
    Commented May 22, 2015 at 5:59

I find it is all fine and good to discuss a problem but sometimes users need a working example albeit not in their preferred programming language. I have used face detection tracking for robotics behaviors but this has many problems like lighting, faces not visible, profile or back of head Etc.

Motion tracking is better. Using example code I developed some Raspberry Pi camera python code to do real time motion tracking based on diff file method mentioned above. Code is on github https://github.com/pageauc/motion-track and YouTube video here https://youtu.be/09JS7twPBsQ (most of my stuff has a video associated with it)

The python code can be modified to run on other platforms and systems. From this demo I developed a real time object speed camera and a simple hotspot game that can be found in the same repo. Recently I have been working on Camera Tracking. Instead of tracking motion in the FOV (field of view) I track actual camera movement. This uses a little different technique than image diff method. I am working on further developing this to use in robotics where there are no wheel encoders. This would use the background to find high value target search rectangles from the video background image (not signs or symbols) to aid in correcting navigation errors for straight line and turns. See my github repo for details and more explanation Real time speed on a RPI 3 is quite good.

So these are a few real world examples to your question that may be useful if you also have the prerequisite programming skills and/or learn time. Camera Pan/tilt servo system can actively scan an area and detect and track moving object(s) using just a computer controlled camera setup without the need for special sensors although this would be useful for night operation.

Now I don't claim to be the best coder but a lot of googling will get you a long way there if you keep trying. I also like to post video of projects although they can go out of date after a while. My experience with some opencv video is that quite often there is no code repo reference. Just video with no good sound or vocal explanation and poorly demonstrated. This is like showing a video of cars driving by quickly to explain how vehicle chassis, electrical and power train systems work. Just my observation.

A lot of times products don't do what you would like or are too expensive. Developing your own solution is sometimes not the best approach if you factor in your time and effort unless you do it as a hobby. For example, I would not think of developing a custom dash cam solution since there are many good, inexpensive product solutions on the market.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.