LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frame subtraction from incoming video stream

Hello, I'm trying to use Labview with the Vision add on to capture a single frame, store it in Labview and the subtract that frame from the incoming video. Many replies to previous posts on this issue have had the suggestion of simply using IMAQ subtract to do this. I have tried this  method in addition to the Goden Template subtract in Machine Vision and the IMAQ Image to array function. Regardless of the method, I am continuously running into "invalid image" errors or black image boxes as a result. I think I'm close, but that I'm missing something fundamental. Any feedback would be appreciated. I am using a Flir Chamelion USB camera, RGB U32 format at 5MP.

Thanks.

0 Kudos
Message 1 of 5
(223 Views)

I opened your VI, and immediately closed it again!  Yikes, wires everywhere, labels overlapping, who can figure this out?

 

But before I even get to the code (thanks, by the way, for including it!), there's a more fundamental question -- what do you really want to do?

 

You say you have a Video, want to "capture a single frame", and "subtract it from the incoming Video".  What do you mean by "subtract"?  I can think of multiple meanings:

  • A "Video" consists of (static) Images that exists as a function of time.  You can "subtract" by removing one (or more) of these Images, shortening the length of the Video.
  • An "Image" consists of Pixels which have RGB (or Grayscale) Values.  You can "subtract" by doing a Pixel-by-Pixel subtraction of the Pixel values.
  • You can do other Pixel-by-Pixel operations, such as Logical operations, or scaling/clipping operations.
  • You might want to work on a portion of the Video Image -- that's yet another way "Space" comes into the picture (so to speak) of this question.

I have a suggestion that may help you, and will certainly help us to understand (and, perhaps, provide advice to) your question.  Obtain (or create) an Image, call it "Single Frame".  Obtain (or create) another Image, called "Video Image".  You now have two IMAQ Images, presumably both RGB (or whatever you are using).  Apply the operation you want to perform, and display the result.  Is it what you are after?  If so, figure out how to perform this on an incoming Video on a Frame-by-Frame basis.

 

Bob Schor

 

 

 

0 Kudos
Message 2 of 5
(152 Views)

Bob,

  Sorry about the VI. I tend to work in a spaghetti against the wall manner and clean up after. I'll address your questions one at a time. I hope this isn't a repeat, I tried to reply before but it doesn't seem to have posted. In future I'll try to submit a vi that contains a single issue that I'm working on.

 

I work for a company that tests optics with lasers. What we want is to be able to view a live stream from a camera of the part to be tested. We want to take one frame from that camera as a reference and then compare that image to the incoming stream. This should allow us to compare before and after images while we are irradiating a part. In the past I have done a pixel-by-pixel subtraction of the reference image from the incoming stream. The previous version of our software was coded in C# using a third party library function. The library function I used there can't be applied here.

 

I tried your suggestion of the two static images which worked and I think I may have figured out the problem. I was using the Vision Express Vision Assistant to acquire the images for my program. This appears to be interfering with my processing by keeping the camera open for itself on a continuous loop. I think I may have to abandon that fork and move over to using the NI-IMAQdx functions. I'm going to try the next iteration on a continuous grab from the camera and see how that goes.

 

Thanks,

Andrew

 

0 Kudos
Message 3 of 5
(135 Views)

never hardly ever use Express VIs.  

 

Bob Schor

0 Kudos
Message 4 of 5
(125 Views)

Bob,

  I'm beginning to see why. I've tried to use the express VI's in the past and have found they don't always do what I want them to do, or have weird quirks like keeping the camera occupied all the time. I believe I've solved my issue so I'm posting the simplified solution here in case others need to do what I did. I ended up using NI-IMAQdx functions, Image Processing functions, and an example I found on efficiently displaying the video data. While this solution is not my full solution, it works as is. My full solution contains a case structure that allows me to switch between straight video display, setting different background images and the image compare function, but it's a little messier.

Thanks for the help,

Andrew

0 Kudos
Message 5 of 5
(102 Views)