07-21-2006 09:29 AM
The problem:
I am having a problem with the output image flickering when I subtract the
current frame from the last frame.
The goal:
I want to do a background subtraction from the current frame to detect motion.
The background image should be replaced with the last acquired image.
The setup:
I acquire and image, type cast it to grayscale U8 and use the Canny Edge
Detection sub vi to find the edges in the image. The output from the Canny Edge
Detection is then wired to the IMAQ Subtract 'image source A' input. The
output on the Canny Edge Detection Vi also gets wired to a shift
register. This shift register is wired to the 'image source B' input for
the IMAQ subtract.
Note: A new image was created before the while loop
begins for the 'Image Dst' input on the IMAQ subtract. All images are
grayscale u8. There is an image display indicator wired to the output of
the Canny Edge detector, a image display indicator wired to the output of the
shift register as well as another image display indicator wired to the output
of the IMAQ subtract. To help clarify I am attaching an image to show how things
look in the code.
The results:
This should work but when I run the vi I just get a black image in
the image display from the subtracted image output. The only way I could
get an image to appear in the IMAQ subtract output was if I made a copy of the
Canny Edge detection output using the IMAQ copy sub vi and took the output from
the IMAQ copy and wired it to the shift register instead of directly form the
Canny Edge detection output. This seems to work great; I am able to
subtract the background from moving objects except the image
flickers. For some reason, the image goes blank (black) on the
subtracted image display every now and then and I am not sure why. I know that it shouldn't go black
because even if I focus my camera on a unmoving object
I get a faint snowy out line of the object from the noise of the camera -
this is fine.
Discussion:
What am I doing wrong? Do I get this flickering because I am using the
IMAQ copy for every iteration of the while loop? Should I not use shift
registers with an IMAQ image? Should I be using some kind of buffer
system? Is there a better method?.....
Thanks in advance!
07-24-2006 09:58 AM
11-20-2008 05:08 PM
Hi there,
I'm developing a similar algorithm because I need to detect movement in video data. I subtracted the current frame to the previous frame as in your vi, but my application should run in real time and a shift register in the while loop seems to be to slow (a mean of 43 ms). Do you know if there are alternative ways to make the difference between the two frames that are computationally faster than shift register?
Thanks so much
Mattia
11-21-2008 02:41 AM
Hi, Greg,
You should not use Shift Register with IMAQ Images (at least not for holding previous image as you want), because IMAQ Image is reference to the image, not image data itself. Unitialized shift register with IMAQ Image especially bad, because you will get "Not an Image" error at first iteration.
I will recommend to use solution with buffer. Organize images into array, then framegrabber will write image directly to the ring buffer, so you will have your previous image on every iteration, then you can perform processing / subtract.
Andrey.
11-24-2008 06:48 PM
Hi Andrey,
I'm sorry but I'm not so good with labview. Could you be more detailed in your description about using the buffer to subtract the frames?
right now I acquire the frames using the IMAQdxOpen Camera.vi, IMAQdx Configure Grab.vi and IMAQdx Grab.vi. IMAQdx Grab.vi is inside a while loop that stops when the conditional terminal receives a stop input.
Thank so much for your help
Mattia
11-25-2008 01:16 AM
Hi, Mattia,
you wrote: "...shift register in the while loop seems to be to slow (a mean of 43 ms)..."
Attached very simple VI with illustration of the "double buffer" motion detection . I use Shift Register for storing reference to to the previous image. This example able to run up to 800FPS rate on my PC. It means that shift register not very slow. See attachment.
Andrey.
11-25-2008 05:32 PM
Andrey,
it was my fault, because I wasn't still working in real time but with an AVI file and counting the time due to the shift register AND the time due to the avi frame decompression.
Now it is working great in real time following your example!thanks for your help.
Mattia
01-06-2009 03:36 AM
Hi there,
I'm new in labview and I should solve a problem of frame subtraction. I'm not able to handle the current and previous frames through each iteration. I saw this post and the attached VI but I'm running labview 8.5...Could somebody save the attached VI for labview 8.5 or create a snapshot and post it again?
thank you so much for your help!
gato
01-08-2009 02:50 AM
Hi,
I'd like to help you but I'm not working anymore with Labview 8.6 because I've finished my thesis and I don't have access to the lab.
I'm sorry.
Mat