09-14-2011 02:24 PM
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
09-15-2011 04:16 AM
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
09-15-2011 11:33 AM
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
09-15-2011 11:58 AM
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
09-16-2011 03:19 PM
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
09-20-2011 11:33 AM
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
09-20-2011 11:36 AM
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
09-20-2011 11:59 AM
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