LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Image subtraction from a video produces output as flickering Image

Solved!
Go to solution

Hi All ,

 

I have a case in which I ahve to acquire 2 video from 2 USB camera simultaneaoulsy and subtract the latest frame from the Image template, But the out after subtraction or abs difference is the flcikering image rather then a stable image. attached is a vi please let me know where I am doing wrong.

 

Thanks.

Download All
0 Kudos
Message 1 of 10
(3,217 Views)

Hi,

 

Try connecting up the "Img Dst" terminals, e.g. on the "IMAQ Absolute Difference". Connect them to new images (add some more "IMAQ Create"s with different names).

 

At the moment, each loop has only one image, so the top loop for example:

 

grabs an image from camera, changes image type, extracts colour plane, then subtracts the image

 

Currently for each of those operations it overwrites the old image with the new image.

 

Does changing this remove the flickering?

0 Kudos
Message 2 of 10
(3,201 Views)

Image Reference wires in LabVIEW are pointers to the picture, not actually the image data itself, so if you don't explicitly Create Image to hold the two images you want to subtract AND the destination resulting image, you will get the flashing blinking because you are viewing an image area that is being constantly overwritten during the run of the vi.

 

A good strategy to use when dealing with image processing tasks in LabVIEW is to create one image named "DisplayImage", or even better "{vi name}_DisplayImage".  After all of the image processing tasks, put one last Copy Image vi to copy your results into the DisplayImage memory space.  Since the front panel display is connected to this space, you only see results of the copy, and not all the other stuff that is happening behind the scenes.

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 3 of 10
(3,193 Views)

@MoviJOHN wrote:

Image Reference wires in LabVIEW are pointers to the picture, not actually the image data itself, so if you don't explicitly Create Image to hold the two images you want to subtract AND the destination resulting image, you will get the flashing blinking because you are viewing an image area that is being constantly overwritten during the run of the vi.

 

A good strategy to use when dealing with image processing tasks in LabVIEW is to create one image named "DisplayImage", or even better "{vi name}_DisplayImage".  After all of the image processing tasks, put one last Copy Image vi to copy your results into the DisplayImage memory space.  Since the front panel display is connected to this space, you only see results of the copy, and not all the other stuff that is happening behind the scenes.


Hi Orbital and MoviJOHN,

 

Thanks for the suggestion, I tried those things but its more worse as now I couldnt see the subtracted image at all, also Please note I am subtracting a still image from a video .

 

Thanks,

 

Ankitg

0 Kudos
Message 4 of 10
(3,188 Views)

If you are still seeing flickering, then you have not correctly followed my suggestion.  Trust me on this.

 

1. You do not need two while loops.  Put everything in one loop.

2.  You are not making use of the Image Dst connectory on your IMAQ Cast Image, IMAQ ExtractSingleColorPlane, and  IMAQ Absolute Difference.  You need to have a separate IMAQ CreateImage for EACH of these.

 

Maybe I was not as clear as I could have been in explaining Image References in LV.  The image display on the front pane displays whatever the image reference points to.  It does not matter what point in the program you are in.  When you Grab, the image changes.  When you cast, the image changes.  When you extract, the image changes.  When you difference, the image changes.  If you do not use a separate Image Dst reference for each step, you will always see the flicker in the display, because the update to the image display is not a procedural thing.

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 5 of 10
(3,177 Views)

@MoviJOHN wrote:

If you are still seeing flickering, then you have not correctly followed my suggestion.  Trust me on this.

 

1. You do not need two while loops.  Put everything in one loop.

2.  You are not making use of the Image Dst connectory on your IMAQ Cast Image, IMAQ ExtractSingleColorPlane, and  IMAQ Absolute Difference.  You need to have a separate IMAQ CreateImage for EACH of these.

 

Maybe I was not as clear as I could have been in explaining Image References in LV.  The image display on the front pane displays whatever the image reference points to.  It does not matter what point in the program you are in.  When you Grab, the image changes.  When you cast, the image changes.  When you extract, the image changes.  When you difference, the image changes.  If you do not use a separate Image Dst reference for each step, you will always see the flicker in the display, because the update to the image display is not a procedural thing.


Hi MoviJOHN,

 

Thank you for the suggestion, I did as you said but in using only one loop I can only see the subtracted image from one camera  not from the other, but once I hit stop button  the subtracted image comes up in the second camera display window.Is there something I am doing wrong.Please let me know

 

Ankit

0 Kudos
Message 6 of 10
(3,173 Views)

You are constantly calling the IMAQ CreateImage vi inside your loop.  You need to bring all of those outside, and only call them once.

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 7 of 10
(3,167 Views)

@MoviJOHN wrote:

You are constantly calling the IMAQ CreateImage vi inside your loop.  You need to bring all of those outside, and only call them once.


Hi MoviJOHN,

 

Thanks a lot and sorry for the confusion, so you meant I should only have once instance of IMAQ Creat Image and wire the new Image output from that to all of the Image Dest  input for the respective camera.

 

- Ankit

0 Kudos
Message 8 of 10
(3,161 Views)
Solution
Accepted by topic author AnkitG

MoviJOHN meant that each Create Image should be outside the while loop, so that each one only executes once. I have done this change for the last VI you uploaded, see the attached file "subtract4.vi". Does that work?

0 Kudos
Message 9 of 10
(3,156 Views)

@Orbital wrote:

MoviJOHN meant that each Create Image should be outside the while loop, so that each one only executes once. I have done this change for the last VI you uploaded, see the attached file "subtract4.vi". Does that work?


Hi Orbital,

 

Thanks a lot, it does work now .

 

Ankit

0 Kudos
Message 10 of 10
(3,151 Views)