LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Motion detection

Hi,
As part of my final year project at uni, i have been tasked with developing a home security system using a USB web camera to detect movement, save the footage to the computer hard disk and trigger an alarm.
To detect the movement, I plan to use the ActiveX control from INVENTeering.com to obtain JPEG images from the web camera. My first problem (i'm sure they'll be many more in this project) is how to compare the images to detect the movement. I've heard this can be done using IMAQ but I'd rather not (just because i've never used it before). Is there any other way to compare the pictures directly? Can I convert the images to a pixmap and compare those? Any help would be greatfully appreciated. Also, can anyone think how I might save the
webcam footage to hard disk. I've thought of saving the jpegs individually but I guess this would become really jerky when I need to playback the footage? Any ideas?
Cheers,
Steve
0 Kudos
Message 1 of 3
(5,609 Views)
Dear Steve,

The easiest way to compare two or more images is to use subtraction i.e. subtract the current image from the previous image and the result will be the difference between the two. If the two frames/images are identical then the subtraction will effectively produce a blank image, while if there is a disturbance (for example an object has been moved), the resulting image will identify the area within the image in which there has been a disturbance.

As far as using tools within LabVIEW, yes you can use the functions found within IMAQ Vision such as IMAQ Subtract. Don't be put off if you haven't used IMAQ Vision before as the toolkit is relatively straightforward to use once some basic principles surrounding image manipulation have been understood. You would need to convert your images into the native IMAQ data type, although there are VIs within the toolkit that will allow you to convert a 2D array into an IMAQ image and vice versa.

The approach would be to convert your image captured via the web cam into a 2D array/pixmap and then convert this array into the IMAQ data type using IMAQ Array To Image. One of the nice things about IMAQ Vision is the ability to display the resulting images in windows which will allow a certain amount of user interaction such as zooming, annotation and so on.

If you still don't wish to use IMAQ Vision, all is not lost! The image subtraction process is simply a case of subtracting two arrays according to the following rule:

result pixel (0,0) = current pixel (0,0) - previous pixel (0,0)

Obviously this would need to be replicated N times over depending on the size of the images that you are manipulating.

So using the manual process, convert your images into suitable 2D arrays and then use the operator VIs inside of LabVIEW to perform the manipulation for you (fortunately the VIs are polymorphic so this should help avoid building/rebuilding the arrays). The results could then be shown on an intensity graph (modified to provide a "picture" indicator - but might have problems getting square pixels when you resize the indicator) or you could convert the resulting data for display on a proper picture indicator.

As far as saving the images to disk, calculating the required storage space should be easy - N images x M kB/image. Bare in mind that most home security systems are not running at 30 frames/second - perhaps as low as 1 frame every 2 secound. This will obviously have a big impact on your storage requirements - something for you to think about here! When you watch the shows on TV playing back robberies and other events captured on security systems, you will notice that you do not get full frame rate replay and that people's movement is very jerky.

Also consider storing information for a finite period of time. For example, store images for 1 month/week/day (whatever is appropriate) and if nothing happens within this period e.g. no robbery! then you can record over this information. If an "event" does occur, simply archive this information to CD and then carry on as before.

Hope this points answer your questions and good luck with the project.

Jeremy
0 Kudos
Message 2 of 3
(5,609 Views)
Dear Steve,

The easiest way to compare two or more images is to use subtraction i.e. subtract the current image from the previous image and the result will be the difference between the two. If the two frames/images are identical then the subtraction will effectively produce a blank image, while if there is a disturbance (for example an object has been moved), the resulting image will identify the area within the image in which there has been a disturbance.

As far as using tools within LabVIEW, yes you can use the functions found within IMAQ Vision such as IMAQ Subtract. Don't be put off if you haven't used IMAQ Vision before as the toolkit is relatively straightforward to use once some basic principles surrounding image manipulation have been understood. You would need to convert your images into the native IMAQ data type, although there are VIs within the toolkit that will allow you to convert a 2D array into an IMAQ image and vice versa.

The approach would be to convert your image captured via the web cam into a 2D array/pixmap and then convert this array into the IMAQ data type using IMAQ Array To Image. One of the nice things about IMAQ Vision is the ability to display the resulting images in windows which will allow a certain amount of user interaction such as zooming, annotation and so on.

If you still don't wish to use IMAQ Vision, all is not lost! The image subtraction process is simply a case of subtracting two arrays according to the following rule:

result pixel (0,0) = current pixel (0,0) - previous pixel (0,0)

Obviously this would need to be replicated N times over depending on the size of the images that you are manipulating.

So using the manual process, convert your images into suitable 2D arrays and then use the operator VIs inside of LabVIEW to perform the manipulation for you (fortunately the VIs are polymorphic so this should help avoid building/rebuilding the arrays). The results could then be shown on an intensity graph (modified to provide a "picture" indicator - but might have problems getting square pixels when you resize the indicator) or you could convert the resulting data for display on a proper picture indicator.

As far as saving the images to disk, calculating the required storage space should be easy - N images x M kB/image. Bare in mind that most home security systems are not running at 30 frames/second - perhaps as low as 1 frame every 2 secound. This will obviously have a big impact on your storage requirements - something for you to think about here! When you watch the shows on TV playing back robberies and other events captured on security systems, you will notice that you do not get full frame rate replay and that people's movement is very jerky.

Also consider storing information for a finite period of time. For example, store images for 1 month/week/day (whatever is appropriate) and if nothing happens within this period e.g. no robbery! then you can record over this information. If an "event" does occur, simply archive this information to CD and then carry on as before.

Hope this points answer your questions and good luck with the project.

Jeremy
Message 3 of 3
(5,609 Views)