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!