Preview function looks darker after initial use

3 views (last 30 days)
Hello,
I have been using the image acquisition toolbox with a GigE camera (Basler ace acA2000-50gm, 8-bit Mono). In the workflow, I use preview function to obtain a live image and then take a snapshot. When I first use the preview function the image looks bright (I am using the microscope's light to adjust the brightness), however, when I use the function again the image looks darker. I had to crank up the light to see what is going on in the image. Then, the acquisition starts and the image is all white. I realized that if I turn the camera on and off between trials the preview function shows the bright image.
I was wondering if there was a way to use preview function more efficiently?
Here are the code snippets that I use in my workflow:
imaqreset;
obj.vid = videoinput('gige', 1, 'Mono8');
obj.vid.FramesPerTrigger = 1;
obj.src = getselectedsource(obj.vid);
obj.src.PacketSize = 9000;
%obj.CamVideoRecord
obj.CamSingleShot(snapshot_file)
function CamSingleShot(obj,snapshot_file) %name for snapshot
snapshot_file = regexprep(snapshot_file,'.mat', '.png');
obj.vid.FramesPerTrigger = 1;
obj.vid.TriggerRepeat = Inf;
obj.src.AcquisitionFrameRateEnable = 'True';
obj.src.AcquisitionFrameRateAbs = 30.000300003;
preview(obj.vid)
[icondata,iconcmap] = imread("trees.tif");
uiwait(msgbox('Press OK to take a snapshot',...
"Message","custom",icondata,summer));
singleshot = getsnapshot(obj.vid);
imwrite(singleshot,snapshot_file)
stoppreview(obj.vid)
end

Accepted Answer

Image Analyst
Image Analyst on 5 Jan 2023
Have you tried setting the Exposure property to some known constant?
  2 Comments
Utku Gulbulak
Utku Gulbulak on 5 Jan 2023
Hello @Image Analyst, thank you for your response and suggestion. I was triggering the camera with a TTL pulse and changed the ExposureMode to 'Timed'. I use the imaqreset function reset the camera for the next run. However, the ExposureMode was not going back to the default values. I am checking the exposure mode before during the class construction. This seems to be working. Do you have an idea why the imaqreset was not returning the camera to the default settings?
if strcmp(obj.src.ExposureMode, 'Timed') ~= 1
obj.src.ExposureMode = "Timed";
obj.src.ExposureTimeAbs = 10000;
obj.src.ExposureTimeRaw = 10000;
end
Image Analyst
Image Analyst on 6 Jan 2023
I'm not really sure but it could be that imaqreset just resets the properties of the adapter (middleware between MATLAB and your camera's hardware). It could be that nothing ever actually gets sent to the camera itself. You might have to work with the tech support team at Mathworks that specializes in cameras.

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!