02-22-2010 10:44 AM
Hi all,
I'm trying to continuously acquire frames from a webcam, display them, and also display the absolute difference between subsequent frames. The last part isn't working: the display stays white. Does anyone has any suggestions as to what is going wrong? I'm pretty new at this, so I'm probably overlooking something basic. If it's possible, I don't want to use the grab VI twice, because that would lower the frame rate.
I have attached my VI.
Koen
Solved! Go to Solution.
02-22-2010 12:13 PM
Create three images: Current, Last, and Difference. Each time through the loop, acquire an image to Current. Use Abs Difference to calculate the difference of Current and Last using Difference as the destination image. Finally, use IMAQ Copy to copy Current to Last.
This will give you a new Difference image every time through the loop.
Bruce
02-22-2010 05:11 PM
Thank you very much! That solved my problem
One additional question: in terms of performance, if you don't really use the colour data, do you know if it matters much (in general, or in this specific case) whether you first convert the frames to intensity-images or not?
02-22-2010 05:46 PM
I was looking at it more closely, and I noticed that it doesn't seem to work for every frame. Even if there is movement, there are only occasional flashes in "webcam 2". Any ideas why the second display isn't changing continuously when you move the camera around, like the first display does?
Attached is an updated VI.
02-22-2010 07:07 PM - edited 02-22-2010 07:14 PM
The program is not sequenced properly. There is nothing to make the difference be calculated before Last is replaced by Current. If the replacement occurs first, the difference will be zero. If the subtraction is first, everything works as desired.
You could either use a flat sequence structure to make things happen in the desired order, or you connect the error output from the subtraction to the error input on the copy.
In answer to your other question, converting to intensity before everything else is just fine. It uses less memory to store a grayscale image, and the operations will be faster.
Bruce
02-23-2010 04:57 AM