Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

GetImagePixelPointer in IMAQ Vision hangs while trying to get a pixel pointer.

I have written several dll functions to do specific image processing. I have been successfully calling these dlls for some time. In rewriting my code to parallelize some activity, a single instance has come up where GetImagePixelPointer starts to execute but never returns. The instance appears to be related to a single image. I have looked backwards in my code and I am pretty sure that I unmap the pixel pointer from the previous time it gets used.
Does anyone have any advice? What would cause GetImagePixelPointer to hang in the Map mode?
0 Kudos
Message 1 of 4
(4,194 Views)
I have some more details for the problem.

First off, I forgot to mention previously that I am running IMAQ Vision version 5 with LabVIEW 5.1.1.

The problem happens when I (1) call IMAQ GetPixelValue and then (2) call IMAQ GetImagePixelPtr using the same image. GetImagePixelPtr will only hang when using the same image previously used to call GetPixelValue. I can use other images to call GetImagePixelPtr in between 1 and 2 and it will work fine. If I remove GetPixelValue from my program, then everything works just fine.

I have also written a tester program that just tests this "bug". I create images, run GetPixelValue, and then run GetImagePixelPtr. The tester works fine.

Does anyone have any insight about why GetImagePixelPtr might hang? I think that would be a gr
eat help in tracking down the problem.
0 Kudos
Message 2 of 4
(4,194 Views)
Hey Matt,

You mentioned things were working fine until you parallelized the code (you made multiple threads I assume). You also mentioned when you tried reproducing the problem, it worked fine. It sounded like if you took out the call to GetPixelValue in your original code that didn't work, it worked (is this correct). One of the problems I could see that having multiple threads might cause is if you create the image in a different thread than where you try and get the pixel pointer. The different threads have their own place on the heap and one thread's memory allocations may not be available to other threads.

If you're still having problems, see if you can make a small snippet to reproduce (you will probably have to use multiple threads to reproduce this problem)

Hope
this helps,
Brad Buchanan
National Instruments
0 Kudos
Message 3 of 4
(4,194 Views)
I have solved my problem. I am not sure exactly what I did; however, I did rearrange the order of some of the function calls.

In response to Brad's help (thanks by the way), the image creation occurred (I believe) in the same thread. When the error was happening, I also happened to be creating images in other threads that I used the same processing on in that thread. This worked just fine.

I believe that the problem is related to GetImagePixelPointer, GetPixelValue, and some third function and their order of execution, but beyond that I don't know and don't plan to do too much digging at this time.

Matt
0 Kudos
Message 4 of 4
(4,194 Views)