HBadertscher / Matlab_BaslerCamDriver

A universal MATLAB driver for Basler cameras
MIT License
21 stars 5 forks source link

trigger mode #21

Closed cluo31 closed 7 years ago

cluo31 commented 7 years ago

Hi,

Recently I have been trying to set up a Basler USB3.0 camera, and I encountered a problem with the TriggerMode parameter: it cannot be set as ‘On' for data acquisition. To be specific, the TriggerMode parameter can be set as ‘On’ using either the baslerSetParameter function or the Pylon software (the status of the parameter is verified in Pylon). However, once the baslerGetParameter function or the baslerGetData function or the baslerSetParameter function (setting up other parameters) is applied to the camera, this TriggerMode parameter would automatically be ‘Off’. Besides, other parameters such as ‘Width’ and ‘PixelFormat’ work fine with all the functions above.

My naive guess would be that the camera initialization overwrites some settings, but couldn't figure out why and where it is. Would you have any suggestions? Thanks a lot!

HBadertscher commented 7 years ago

Hi,

I actually don't have a camera here with me to test this, but as you say, it appears that this flag is reset to 'Off' each time the camera is initialized. I am not very happy with the current architecture: a new camera object is initialized for each function call, leading to overhead and problems like the one you have here. I am planning to do a refactoring, though I definitely won't have time before next year.

A work-around you could do is to add a "TriggerMode" parameter to the BaslerGetData function, and after initializing the camera, call BaslerHelper::set_parameter to set the TriggerMode to 'on' if needed. Are you more or less familiar with C++, so you could try this yourself? If not, I can add do it for you, but I won't be able to test anything...

cluo31 commented 7 years ago

Thank you very much! It works!

HBadertscher commented 7 years ago

Great to hear! If you want to, you can fork this repository, add your changes, and create a pull-request. That way everybody can profit from your work.

cluo31 commented 7 years ago

It's pretty simple: just add the following line into baslerGetData.cpp right after the camera’s initialization procedure (around line 100):

BaslerHelper::set_parameter(&camera,”TriggerMode”,”On”,b_verbose);

I am very new to this website and know very little about pull requests. Will work on that later :)