LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error with IMAQdx get image2 when trying to grab and snap at the same time

Hi, 

I am making a VI where I use the IMAQdx Grab.vi to show continuously in the front panel an image that is being recorded by a video camera. I'm also using IMAQdx Snap.vi to take three acquisitions with the same camera when a switch is activated. This three acquisitions are saved in a specified folder and are also displayed on the front panel. I've attached the VI.

Here is the problem I have: when I run the program and I don't activate the snap function, it works perfectly and display the continuous image in the front panel; however when I activate the snap function with the switch, the three images are saved and displayed in the front panel but the display of the continuous image stops and then, when it stops running, I get the #1074360317 error (screenshot attached).

Do you have any input about what could be generating this error?

Download All
0 Kudos
Message 1 of 6
(3,584 Views)

I don't think you can "grab" and "snap" simultaneously, nor should you need to do that.  I've not tried to do this, myself, but I have saved videos (which involves multiple "grab" images) and can well imagine how I would do a "grab and save selected snapped images".  

 

When you want to save a Video, you set up a Grab, allocate some buffers for you images, and then pass the Image (number) that you want to save to a "Save image to an AVI file".  In your case, you would pass the Image to a "Save a JPEG (or other single-image format) file".  Are you saving three sequential images (i.e. a very short AVI video)?  Then you could simply "save a very short video" (and I'm sure there are examples of how to make and save AVIs in the Example Finder).

 

Bob Schor

0 Kudos
Message 2 of 6
(3,544 Views)

Thank you for your quick answer,

 

No, I'm not saving three sequential images like a short video. I'm using this in a larger VI where I have to control a motorized translation stage that is fixed to a microscope plate and a camera fixed to the microscope eyepiece, so I can analyze the whole surface of a chip placed in a chip holder fixed to the translation stage. 

 

In that VI I want to display continuously in the front panel the current image recorded with the camera (this would be the "grab" in the example above) and also the successive images that I am acquiring after every movement of the chip holder (this would be the "snap"); i want to save those images in files too.


So, what would appear in the image made by grab it's indeed a video, but what would appear in the image made with snap are different images from the different positions of the chip holder. 


And now I'm thinking that I'm not really using grab and snap simultaneously. I start using grab, then using snap (in the while loop of the example above) and when the snap finishes I want to continue with the grab. I mean, when the snap is running, it's ok if the grab is not working (in the grab image of the front panel remains the last image recorded by the camera before the snap starts). The problem is that when the snap stops (i.e., the while loop ends), the grab doesn't start again and I get the error that I mentioned before.

Also, I can't save the images directly from the grab image using "IMAQ Write File" because the process of saving images is in a while loop (together with the process of moving the chip holder with the motor), but the grab function has to be out of this loop, so the image it produces doesn't change while the motor is moving.

0 Kudos
Message 3 of 6
(3,515 Views)

I'm sorry I wasn't clear enough.  Here is my understanding of your task (which might be wrong ...) --

  • You have one Camera pointed at one Target, which may or may not be moving.
  • You want to capture images of the Target, some in the form of a Video (presumably while it is moving) and others single Images (presumably while it is not moving).
  • For simplicity, I'm going to assume that the Camera doesn't move when switching from "Grab" (Target moving) to "Snap" (Target stationary).

Here's what I would do:

  • Assume there is a period M (Moving) when you want to Grab images at, say, 30 Frames/second.  Following this, there is another period S (Stationary) where you want to Snap images, say 4 images at 20 second intervals.
  • Start the Video Camera recording at 30 FPS, displaying the images on a Display.  Define a File-naming Scheme for the M (moving) and S (Stationary) Images.
  • At the time you want to acquire M Images, open an AVI file and pass the Camera's Buffer Numbers to the "Write AVI" routine.  Close AVI when the M period ends (and think about how you want to name the next video during the next M period).
  • You are now in the Stationary phase.  Keep the Camera running at 30 FPS.  Send one buffer to a routine to be written as a JPEG or PNG (a "static" Image).  20 seconds later (or 20*30 = 600 Frames (or Buffers) later, save a second "Snap" Image.  Continue until you have all the static Images you need.
  • If you want to continue with another M + S series, you'll need to come up with another set of file names.  Keep the Camera running at 30 FPS, and whenever you are ready, start saving the next M series, close the Video, and save an image every 600 as a "Snap" single image.

So the basic idea is you start the Video camera going, updating a display.  Whenever you need to save the Video, you direct the Frame Buffers to a Video-saving routine (you should probably use a Producer/Consumer pattern to export the Buffers).  When the Grab phase is over, close the Video and save isolated single Buffers as Snapped (or Stationary, or Static) Images using a suitable Image format (e.g. PNG).  Repeat as needed.

 

This process can be modeled as a State Machine, and can be implemented (in LabVIEW) using a variety of tools.

 

Bob Schor

0 Kudos
Message 4 of 6
(3,303 Views)

Hi, you have done something with videos! I have a problem with the acquisition of images that I want then store into a video. I can't understand why the video's duration is less than what I impose with my timer, it doesn't matter which number of images or timer input I impose (I would like to obtain a video of 10s). The acquisition is never in real time. I'm imposing a 30fps. Could you share your code with me, please? 

0 Kudos
Message 5 of 6
(2,932 Views)

@Roberta34 wrote:

Hi, you have done something with videos! I have a problem with the acquisition of images that I want then store into a video. I can't understand why the video's duration is less than what I impose with my timer, it doesn't matter which number of images or timer input I impose (I would like to obtain a video of 10s). The acquisition is never in real time. I'm imposing a 30fps. Could you share your code with me, please? 


This is a completely different, unrelated problem.  Please create your own topic so there will be no confusion between the two issues.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(2,921 Views)