From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Thorlabs camera acquisition

Solved!
Go to solution

I got a very complex Labview software that I have to customize, and I'm finding it very hard - I'm not a LV expert at all... I don't know if it is polite to ask for help in such a complicated case, because I dont know how to reduce the problem to a simple question, but here it goes...

The software if free to download from ThorLabs (link) and is used to drive their Scientific Camera.

When you install it and install the SDK.zip and LabView.zip examples, you have a main program TLCameraMain.vi  driving the camera.

From what I understand, after initialization and start of acquisition, the camera images are continuously shown in a picture control, while an Event structure keeps watch of user actions (stop button, change of exposure parameters...).

 

I need to perform an action (calculation of average brightness) on each image, but for the life of me I could not find an event loop where the images are sequentially obtained... it must be in some subVI.

So I thought to add an Event Case, activating on the "Frame Number" value change.

My problem is that the Case never activates, even if the "Frame Number" value keeps on increasing, as shown in the program.

 

As I said, sorry if I cannot be clearer - I hope somebody can make sense of it

 

0 Kudos
Message 1 of 10
(8,213 Views)

Thorlabs makes cameras that are compatible with LabVIEW and their Vision Development Module (which, I believe, requires an additional NI License).  The software they provided is designed for the LabVIEW developer to make full use of all the Bells and Whistles Thorlab provides to tweak all of the settings and parameters of their cameras.  To put it another way, it is to help those who already know LabVIEW and LabVIEW Vision get started with their hardware.

 

In your case, however, you (probably) want to do something simpler -- use the Camera to gather Images and do calculations on those images.  You may or may not care whether you do this using LabVIEW or some other platform (Matlab?  C++?) that can "hook" into the Thorlabs SDK and allow you to acquire and do certain analyses on the Images.

 

If you have LabVIEW in house, and also have the license(s) for the Vision Development Module and (optionally) the Vision Acquisition Software (NI's Device Driver), I would talk to your LabVIEW Developers and discuss developing IMAQ/IMAQdx code to acquire and process the Images you need.  My guess is if you go this way, you will be using the "comprehensive" (and largely redundant) routine you posted (thanks, by the way, for doing that!!) as a reference to pull out just the minimum you need for your application.

 

I recommend that you try to develop a document detailing what you want to do.  Describe the Camera, the parameters you need for data acquisition (Frame Rate if Video, Acquisition rate if "Time-Lapse" individual images), how (or even if) you plan to save/store the Images, the format of the Images (Greyscale, RBG, etc.), the pixel size of the Image (check your Camera specs).  Describe the processing you want to do on the Images (you mentioned average brightness -- have you thought about how you are going to calibrate this?  how the light source plays a role?  how you take that into account?).  Once you have this, go find a LabVIEW Guru in your company/institution and discuss your options -- LabVIEW developers are often "up" for interesting challenges (and this one, while a stretch for a novice, shouldn't faze someone with a few years of LabVIEW experience).

 

Do you know if MAX (NI's Measurement and Automation Explorer) can "see" the Camera when it is plugged into the PC?  If so, you can see if MAX can acquire an Image for you (this tells you something about whether or not you have some of the NI licenses you might need).

 

Bob Schor

Message 2 of 10
(8,202 Views)

Hi alzyx,

 

I have used some Thorlabs Cameras in the past. I'm not a huge fan of them (they're expensive and it makes the software more difficult). However, I do have a function that converts a picture (which is actually a string underneath!) into a 2D numeric array, which should allow you to run analysis on it. Please find it attached.

0 Kudos
Message 3 of 10
(8,181 Views)

Hi Bob,

 

I have never used Thorlabs cameras with NI's Vision Acquisition stuff before, are you sure they are compatible? The cameras ship with a DLL to access the cameras.

0 Kudos
Message 4 of 10
(8,177 Views)

I also haven't used ThorLab, but I've got a colleague who does all kinds of Video Imaging (often in the near IR) using all kinds of strange cameras, and I think I've heard of ThorLabs from him.  I recently moved a few hundred miles away from him, so I can't just wander down to his lab and ask as easily as before ...  Which means I'm also not sure if IMAQ or IMAQdx will work with them (which is why I asked if MAX could "see" them -- an Ounce of Experimentation is Worth a Pound of Manuals.

 

Bob Schor

0 Kudos
Message 5 of 10
(8,171 Views)

hi guys, thank you for your help...

 


@Bob_Schor  ha scritto:

In your case, however, you (probably) want to do something simpler -- use the Camera to gather Images and do calculations on those images. 


quite the reverse: the thorlabs software provides part of what I need, and I will have to add what I'missing...

 

 


@Bob_Schor  ha scritto:

If you have LabVIEW in house, and also have the license(s) for the Vision Development Module and (optionally) the Vision Acquisition Software (NI's Device Driver), 


yes, the licenses are available, fortunately

 

 


@Bob_Schor  ha scritto:

Do you know if MAX (NI's Measurement and Automation Explorer) can "see" the Camera when it is plugged into the PC?  If so, you can see if MAX can acquire an Image for you (this tells you something about whether or not you have some of the NI licenses you might need).


Apart from the fact that the original code from Thorlabs works flawlessly - NIMax sees the camera under "devices and interfaces", but clicking on it gives me an 0x80040275 error (but it's not only me, link)

 

@gregoryj  ha scritto:

However, I do have a function that converts a picture (which is actually a string underneath!) into a 2D numeric array, which should allow you to run analysis on it. Please find it attached.

Thank you! I will certainly try to use it - but my main problem is that at the moment I'm unable to catch the program at the moment a picture is available, and make it  do something additional (like, say, process the image).

I added to the Event structure in the main file am event for the change of the frame number variable - which is updated by the OnImageFrameAvailable event callback - but it never fires.

 

 


 

 

 

 

 

0 Kudos
Message 6 of 10
(8,149 Views)
Solution
Accepted by topic author alzyx

I wouldn't create a separate event structure just for that. You can put it wherever you update the picture control which is your image. LabVIEW is a dataflow language, so if your function (subVI) is waiting for the image data, it will run when the data is available.

Message 7 of 10
(8,142 Views)

I finally solved it, and as you correctly say a case structure wasnt necessary.

The problem is that the main program's case structure deals with everything from exposure parameter changes, to initialization, start/stop acquisition... but the main acquisition loop is hidden in a register event callback - something I never heard about before - that executes a subVI (OnImageFrameAvailable.vi) at each frame available. 

 

By adding references to additional objects I needed (a waveform chart, an indicator...) to this subVI's input parameters, and working on their property nodes, I was able to make it work...

 

0 Kudos
Message 8 of 10
(8,134 Views)

It would be a real help to other members of the LabVIEW Community who might also be using a ThorLabs camera if you posted the VI (or VIs) that you used to get the camera to work for you.  Knowing that there is a solution is Good News, but actually providing the solution (which took a fair amount of effort and quite a few posts to achieve) will be even more useful.

 

Bob Schor

0 Kudos
Message 9 of 10
(8,124 Views)

@Bob_Schor  ha scritto:

It would be a real help to other members of the LabVIEW Community who might also be using a ThorLabs camera if you posted the VI (or VIs) that you used to get the camera to work for you.  Knowing that there is a solution is Good News, but actually providing the solution (which took a fair amount of effort and quite a few posts to achieve) will be even more useful.

 


you're right, sorry...

TLSC is the main, and OnImageFrameAvailable is the subVI where I was able to insert a few of the additional things I need to perform on the image

 

0 Kudos
Message 10 of 10
(8,120 Views)