How to have different preview windows for a single video object?
2 views (last 30 days)
Siddharth Bhutiya on 17 Aug 2018
When you preview the video from a "videoinput" object, MATLAB will continuously retrieve the image data from the webcam and display it on the screen. So, you will not be able to create another preview using the same videoinput object as that object will already be in use by the previous preview window.
However, in order to display two preview windows simultaneously you can try the following workaround and see if it fits your workflow.
vid = videoinput('winvideo',1);
im_handle1 = image(zeros(1280,720));
im_handle2 = image(zeros(1280,720));
function my_callback_fcn(obj, event, himage)
The "UpdatePreviewWindowFcn" callback function will be executed every time a new frame is obtained from the webcam. So, we can create two image handles that will act as our preview windows and inside the callback function we update the "CData" for both the image handles, so that it displays the most recent frame. In this way you can display the same video on two different windows simultaneously.
Please note that if a frame is retrieved before the "UpdatePreviewWindowFcn" callback for the previous frame is completed, then that frame will be dropped.