Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqFlip does not always work...

I'm using the Vision function imaqFlip to flip an image about its horizontal axis. I found that I need to use the same Image* variable for the source and destination image otherwise it does not work. Lately I've found that the image does not always get flipped.

 

Here's a code snippet:

 

IMAQdxGetImage (gImaqSession, gpLiveImage, IMAQdxBufferNumberModeNext, 0, &bufferNumber);

imaqFlip (gpLiveImage, gpLiveImage, IMAQ_HORIZONTAL_AXIS);

imaqDisplayImage (gpLiveImage, LiveImageWin, TRUE);

 

Seems pretty simple, eh? But at random times the image does not get flipped. Any clues as to why this may happen or how I can code around it would be very much appreciated.

 

Thanks!

 

Jesse

0 Kudos
Message 1 of 8
(3,511 Views)

Is there a loop around this code? Assuming the image display is not in snapshot mode, it will update to reflect changes to the image content. If you are then acquiring into the same image later on, the display might show this temporarily. You could flip the image into a different buffer (maybe check the error code returned if that is failing?) that you then display or swap between two buffers on each iteration.

 

Eric

0 Kudos
Message 2 of 8
(3,507 Views)

Eric,

 

   Thanks for the tip. When I first attempted to implement the flipping I was unable to get it to work when I used a different buffer for the output image. It only flipped when I used the same buffer for both input and output.

 

   However, I'll give it another go and see if it works this time.

 

Thanks!

 

Jesse

0 Kudos
Message 3 of 8
(3,500 Views)

Eric,

 

   Just read your post again. Yes, I'm running this in a loop, so your explaination makes sense. One question I have: What is Display Snapshot mode?

 

   Thanks!

 

Jesse

0 Kudos
Message 4 of 8
(3,498 Views)

I'm not sure offhand how it's exposed in C, but the image windows need buffering to store the image data so they can redraw as needed. In one mode the buffer is is image buffer itself (so no extra copy is needed, but if the image changes so does the display) and the other is to make an explicit copy every time you display into a private buffer.

 

Eric

0 Kudos
Message 5 of 8
(3,490 Views)

Eric,

 

   It's been my experience working with both LabView and CVI that most LV vi's have a counterpart C-function. Please share with me the name of the VI that sets the display mode as you've described, so that changing the underlying image buffer will automatically trigger an update of the display window.

 

   If this works in the manner you've discussed, I should be able to move the call to imaqDisplayImage outside the loop as an initialization step. The loop would then snap a new image and the window should automatically update with the new image.

 

Thanks!

 

Jesse

0 Kudos
Message 6 of 8
(3,479 Views)

Hi Jesse,

 

Note that even if the underlying buffer is shared with the image display, changing the image contents does not guarantee a redraw. It will only redraw if Windows needs it to or you signal it to be updated by explicitly telling it to display the image.

 

Eric

0 Kudos
Message 7 of 8
(3,477 Views)

Ah, that would explain the random nature of the problem. So, it seems the best way to deal with my issue would be to declare and init another image buffer and use that to feed the display window after flipping the captured image into it.

 

Thanks for all your help.

 

Jesse

0 Kudos
Message 8 of 8
(3,475 Views)