synchronised double webcam acquisition
3 次查看(过去 30 天)
显示 更早的评论
I have to acquire image sequences from two webcams at the same time.
Synch is very important since I am dealing with stereo vision applied to a moving target.
By using preview I can see two synchronized video streaming. I have checked the synch by filming a chronometer.
When I use ‘start’ and ‘getdata’ to retrieve the two videos I experience about two seconds delay between the two sequences as if they have been acquired one after the other.
How can I manage to have two synchronized video?
Code attached.
Thank you in advance!
camera=setup_webcam
Rcam=camera(1);
Lcam=camera(2);
Rcam.FramesPerTrigger = 30;
Lcam.FramesPerTrigger = 30;
preview(camera)
start(camera)
stoppreview(camera);
diskLoggerR = VideoWriter('Rvvvvvv, 'Uncompressed AVI');
open(diskLoggerR);
dataR = getdata(camera(1), camera(1).FramesAvailable);
numFrames = size(dataR, 4);
for ii = 1:numFrames
writeVideo(diskLoggerR, dataR(:,:,:,ii));
end
close(diskLoggerR);
diskLoggerL = VideoWriter(‘Lvvvv’, 'Uncompressed AVI');
open(diskLoggerL);
dataL = getdata(camera(2), camera(2).FramesAvailable);
numFrames = size(dataL, 4);
for ii = 1:numFrames
writeVideo(diskLoggerL, dataL(:,:,:,ii));
end
close(diskLoggerL);
0 个评论
采纳的回答
Walter Roberson
2016-3-12
I suspect that you will not be able to do this with webcam . If you were using cameras which supported hardware trigger, then you could wire up a trigger and trigger them at the same time, and read in the data. As it is now, you are using software trigger and there is no promise made that software triggers will even attempt to synchronize multiple cameras even when given as a vector to start(). Cameras that support external trigger are not necessarily much more expensive than webcam but they are seldom marketed as "webcam".
0 个评论
更多回答(1 个)
Florian Enner
2016-5-14
编辑:Florian Enner
2016-5-14
I've uploaded a submission that supports streaming from webcams and ip cameras with very low overhead. We've used it for stereo vision before on relatively slow targets. You should be able to synchronize to within 1 frame, but depending on the speed of your target that may not be enough. It's probably worth a try.
% Connect to cameras
cam1 = HebiCam('<address1>');
cam2 = HebiCam('<address2>');
% Main Loop
while true
img1 = getsnapshot(cam1);
img2 = getsnapshot(cam2);
% ... do vision stuff ...
end
Let me know if that works for you.
0 个评论
另请参阅
类别
在 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!