Trigger camera at evenly spaced times

I have a USB camera and I am trying to acquire images at a certain frame rate. However, for this particular camera (Thorlabs DCC1545M) when I use the get() command, FrameRate is not shown as a parameter I can change.
Since I can't change the frame rate directly, I am trying to figure how how I can trigger it to acquire a single image every XX seconds. I'm aiming for a frame rate of 460, so XX ~ 2.3 ms. InitialTriggerTime is read only and since the default frame rate is lower than I want, I can't just skip a certain number of frames. I know the camera is capable of this frame rate using a ROI.
Does anyone have any suggestions?

1 Comment

Hi Laura,
How did you manage to make Matlab to recognize your camera (Thorlabs DCC1545)?

Sign in to comment.

Answers (2)

I had a look at the camera's manual here: http://www.thorlabs.us/Thorcat/15900/15982-D02/index.html
It apparently comes with an SDK. If you know C, it's pretty trivial to MEX up a simple wrapper to setup the ROI and frame rate.
There are some relevant API calls:
is_AOI()
is_SetFrameRate()
is_SetExposureTime()
Apparently you can interface with VB / ActiveX. This might be easier to do via MatLab, especially if you are not familiar with C.
As for your snapshot idea, I would be very surprised if you could set up a reliable trigger to snapshot an image 460 times a second.

6 Comments

I have no knowledge of C programming, so if you could spell this out a bit for me that would be great.
%Say I create a video object in Matlab, can preview the stream, and change a few parameters.
vid = videoinput('winvideo',1,'RGB8_1280x1024');
preview(vid)
set(vid,'ROIposition',[100 100 500 500])
%now I want to change the frame rate. What piece of code goes here?
%now I want to capture data with Matlab
set(vid,'FramesPerTrigger',100)
start(vid)
data = getdata(vid,100);
Can I switch back and forth between the C and Matlab without resetting the camera properties? Mostly I just need to know how to "MEX up a simple rapper".
Thanks for your help!
Nah, if you're not a C programmer it will be a frightful exercise. You could maybe look at using the ActiveX interface. This might help: <http://www.codeproject.com/Articles/5848/Using-ActiveX-Control-Inside-MATLAB>.
Tuning a camera device for high frame rates generally requires some lower-level control. I've never done this in MatLab so I am probably not the one to answer your question.
Saying that, it might be possible with your method. What are the properties of your video object? If you go: set(vid) on its own, what comes up? If not frame rates etc, do you get a pixel clock? I wonder also if there's a device you can specify other than 'winvideo'. Does the 'imaqhwinfo' command show any other devices?
Another method I've used on cameras in the past is to use software that came with the cameras to set up the image properties, frame rate etc. Some cameras will allow this, by retaining their most recent state after reconnecting with a different client (ie MatLab).
the device options are:
winvideo, coreco,ni,matrox
When I look at the info on each one, the only one with a deviceID is winvideo. The others are listed as {1x0 cell} which as far as I can tell doesn't have any information in it, so I can't create a video object.
Under get(vid) I can't access the pixel clock or frame rate.
And opening the camera in Matlab appears to reset all the properties so they don't carry over.
So it looks like Thorlabs doesn't have a custom adapter written especially for MATLAB, so you'll have to do everything the SPI/SDK, unless you're happy with the winvideo adapter. But winvideo won't let you do specialized, custom things with your camera like the SDK will. It's possible they do have a special MATLAB adapter but you have to download it from their web site - it's worth asking them.
Hi everyone, I have problem, how to run Thorlabs camera on matlab: I installed camera’s driver and package & Microsoft Visual C++ (2005/2008/2010 redistributed edition), but i can’t connect the camera to matlab. What is routine way to run these codes? We use matlab 2011a, a thorlabs DCC1545M camera (USB2), and want to capture image in matlab or maybe have live view. It is essential to control camera parameters. I would be thankful for any helps.
Ichi , have you figured out how to connect the camera to malab , your help would be really appreciated !!
Phong

Sign in to comment.

Image Analyst
Image Analyst on 22 Apr 2012
Laura: the free run frame rate for your camera at 1280x1024 pixels is 25 frames per second. I think the only way you can get up to 460 frames per second, if it's even possible (which it may not be), is to grab a smaller chunk of the CMOS sensor. That's usually how cameras go to higher frame rates than the free run frame rate. 460 fps is fairly high unless you have a special high speed camera.
I don't know if this camera has a MATLAB adapter written for it - they are usually written by the camera manufacturer. If it does, the image matrix size and frame rate may or may not be an exposed property or method that you can adjust. If they aren't you'll have to make API calls to the SDK. Hopefully the manufacturer can help you with that.

1 Comment

I would expect a resolution of about 300x200 at 460fps. Hopefully there is a pretty big lens attached to this camera, or some really good lighting.

Sign in to comment.

Asked:

on 18 Apr 2012

Commented:

on 10 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!