Problem using start and getsnapshot
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!