Problem using start and getsnapshot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 12 Feb. 2024
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.
Siehe auch
Kategorien
Mehr zu National Instruments Frame Grabbers finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!