How to record live video with a buffer?
Show older comments
Hello, I have the following problem. I want to record the 1st second of real time video <-- that's my buffer. Now, I'd like to display in my GUI (1/10, which is actually 100 msec) of my buffer data. Repeat it 10 times. At the same time, I'd to record a new 2nd second to fill in the buffer. My question is, how can I simultaneously display data on in the GUI (pulling from the buffer), and recording new data (pushing to the buffer)?
I want to do this, so my Real Time Display would look smooth as new data coming in.
THANKS
Answers (1)
Walter Roberson
on 15 Feb 2016
0 votes
Have you considered using the computer vision toolbox? You can step() your video acquisition device to get a frame and in the same cycle step your video output to display a frame, potentially a frame you recorded earlier.
6 Comments
Mark Golberg
on 15 Feb 2016
Walter Roberson
on 15 Feb 2016
for K = 1 : 500
if K <= 400
frame(:,:,:,K) = step(video_acquisition_object);
end
if K > 100
step(video_output_object, frame(:,:,:,K-100);
end
end
Mark Golberg
on 15 Feb 2016
Walter Roberson
on 15 Feb 2016
No I cannot help with that. I would need to know the wiring diagrams of your computer and I would need to do a bunch of studying to figure out whether it is even possible for your system to truly handle multiple interrupts at literally the same time. The last operating system I studied delegated interrupt handling to a single CPU, making truly simultaneous device handling impossible. (Which reminds me that you have not indicated which operating system you are using, or the number of cores you have available... or whether the external devices are on their own busses... or whether you are communicating with the devices by USB or GigE or PCIx or ...)
The most I could offer would be to show how to run the acquisitions in different processes, which is something that would probably slow the approach down due to the time needed to communicate the data between processes. The more convenient way of handling this would be with the Parallel Computing Toolbox; we do not know if you have that. Calling out to a mex routine that uses one of the thread libraries is possible, but not always straight forward.
Mark Golberg
on 22 Feb 2016
Walter Roberson
on 24 Feb 2016
parpool(2,'local')
spmd
if labindex == 1
for Number_of_times = 1 : 15
for framenum = 1 : 10
frames(:,:,:,framenum) = get a frame
end
labSend(2, frames); %send it to the other proccess
end
else %labindex must be 2
for Number_of_times = 1 : 15
frames = labReceive(1);
... do some calculation on the frames
...
end
end
end
Categories
Find more on National Instruments Frame Grabbers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!