How can I continuously acquire image with GigE camera?

3 visualizaciones (últimos 30 días)
Minh Nguyen
Minh Nguyen el 17 de Feb. de 2015
Respondida: Samar el 27 de Mzo. de 2025
Hello, I am working with Basler Camera to acquire image to Matlab. When I configure the image properties, and start the acquisition, it is done correctly. However, whenever I try the second time, there will be a message: "Could not connect to the image acquisition device. Device may be in use.". Normally, I use "imaqreset" and start everything again, it will be fine. According to my understanding, it should not happen this way and it is really uncomfortable when I have to start from the beginning. Could you explain me and give my some suggestions on how I can solve this problem? Thank you. (this is just one example) vid = videoinput('gige', 1, 'Mono8'); src = getselectedsource(vid); src.PacketSize = 8000; framesToAcquire = 20; framesPerSecond = CalculateFrameRate(vid, framesToAcquire); delay = CalculatePacketDelay(vid, framesPerSecond); src.PacketDelay = delay; start(vid) wait(vid); set(vid, 'FramesPerTrigger', inf) start(vid) Error event occurred at 11:38:20 for video input object: Mono8-gige-1. Could not connect to the image acquisition device. Device may be in use.
  1 comentario
文 沈
文 沈 el 30 de Abr. de 2022
你好,请问你解决问题了吗?我也碰到了这样的问题

Iniciar sesión para comentar.

Respuestas (1)

Samar
Samar el 27 de Mzo. de 2025
This error occurs when the video object is not stopped, deleted and cleared from the workspace after every use. This must be done at the end of the script failing which can cause the camera or video input resource to remain locked or busy, preventing other applications or MATLAB sessions from accessing it. This can be problematic if you need to use the camera again immediately or in another application.
To avoid the problem stated above, use the following code as reference.
Code:
% Create video input object
vid = videoinput('winvideo', 1); % Adjust adaptor and device ID as needed
% Configure video input object (e.g., set trigger, frames per trigger)
triggerconfig(vid, 'manual');
start(vid);
% Your code goes here
% Stop, delete, and clear the video object
stop(vid);
delete(vid);
clear vid;
Refer to the example given in the MathWorks documentation for more information:
You can also type help videoinputin the command window of MATLAB for understanding the syntax and examples of the function.
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by