03-24-2010 03:22 PM
I have two questions
1. Can Session ID (IMAQdx) be shared among threads (getting image - reading device buffer) without use of any synchronizing mechanism such as semaphore ?
2. How come a valid session created by open acceptable by read attributes, configure, and start acquisition but not acceptable by grab ?
The Caller and the Called function (VI) snapshot are attached as jpeg pictures.
Caller Function: Main.vi
Called Function: Live Stream Cam1 (Guppy) R3.vi
Inputs (Arguments):
1. Reference (pointer) to Camera Session ID addressed as "Guppy Session ID"
2. Reference (pointer) to Image Display for Camera 1 addressed as "Guppy Stream Display"
3. Reference (pointer) to Image Display for Test Subject (Zoomed test subject in image) addressed as "Test Subject Display"
4. Boolean value addressed as "CAM Session"
Outputs:
1. Image captured by the function
Purpose: To grab image from Cam1 and display image on the user screen and as well output it for data interprettation
Logic Description: For easy explanation, have marked areas with circled number.
(1) When this VI is called for first time, it creates an empty image and keeps updating that image every time its called. A breakpoint is set to halt the program on 1st execution.
(2) Guppy Session ID, a reference to camera session, is checked for a valid reference. This test pass and enters 'False' case structure.
(3) The value referenced by Guppy Session ID is checked for valid camera session. Since the reference (pointer) is not yet initialized, this test fails and enters 'True' case structure.
(4) A new camera session is created using 'open' and 'configure' vi's of IMAQdx and then checked for any error or if newly created camera session is invalid. This test pass and enters 'False' case structure.
(5) The newly created camera session is used to initialize and start acquisition. Also the newly created camera session is stored as initialized value pointed by the reference - Guppy Session ID. The probe-12 is seen to have no errors. When an attempt to grab image is made, an error occurs as seen on probe-13 stated as "Invalid Pointer" with code as -1074360317.
(6) This is where the probe points display the data.
(7) Don't mind the 'CAM Session' logic.
Can someone please throw some light? If you need more inputs feel free to ask.
Thanks,
Tirthankar
03-25-2010 02:22 AM
03-25-2010 09:08 AM
Hi Tirthankar,
To answer your first question regarding the thread-safety of IMAQdx, yes, you can safely share a session ID among multiple threads, loops, or any other execution paths in LabVIEW or C++.
The second question regarding your "Invalid Pointer" error was a little odd, so I did some digging and I believe I have a good guess as to the issue in your code. It turns out that if you pass an uninitialized image reference into Get Image you get that exact error. It seems like we should be giving a more descriptive error than that but that is the current behavior. My hunch would be that something in your code around (1) is incorrect. Are you sure on the second iteration you are wiring the image reference through the shift registers? Are you sure you are not deleting that image anyplace else in your code?
Eric