필터 지우기
필터 지우기

Problem using start and getsnapshot

조회 수: 1 (최근 30일)
Emilie
Emilie 2024년 2월 12일
댓글: Emilie 2024년 2월 12일
Hello,
I am trying to take pictures with a Basler Camera using a trigger sent by an Arduino card via the serial port (the camera and the arduino are connected to my laptop but are not connected together).
My code works sometimes, but most of the time it doesn't... I keep getting various error messages from my code, but I can't find the solution. I also have to unplug and plug again the arduino card everytime I want to run my code.
Here is an example of an error message I get:
Error using imaqdevice/start
Multiple image acquisition objects cannot access the same device simultaneously.
Error in testTriggerBasic (line 7)
start(vid);
Warning: Error updating Image.
Here is my code:
s=serialport('COM4', 9600);
vid=videoinput("gentl",1,"Mono8");
triggerconfig(vid,"immediate"); %I don't if this line is necessary%
start(vid);
stopprog=0;
while stopprog<100000 %I did this just so that the loop would end and the last lines could be executed
if s.NumBytesAvailable>0
data=read(s,s.NumBytesAvailable, 'uint8');
image=getsnapshot(vid);
imshow(image)
end
stopprog=stopprog+1;
end
stop(vid);
delete(vid);
clear(vid);
clear(s);
Thank you for your help.

답변 (1개)

Walter Roberson
Walter Roberson 2024년 2월 12일
You have an existing videoinput active. For example you might have used control-C to stop acquisition, and so missed out on deleting the object.
The easiest approach is to exit MATLAB and restart it.
  댓글 수: 1
Emilie
Emilie 2024년 2월 12일
Thank you for your answer, but even after restarting matlab and making sure the videoinput wasn't active, I still get the same error message... I managed to make it work once this morning but I have no idea how.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by