Video Stitching from multiple cameras
<p>I wanted to stitch a video from multiple cameras. While stitching I wanted to switch view from one camera to another. Is it possible to do it in OpenCv? </p>

<p>For example I have 3 video paths(videos having same duration) and wanted to create a single video summary by switching between the videos. To start with I have created 3 video capture objects as shown below.</p>

<pre><code>cap0=cv2.VideoCapture(path1)
cap1=cv2.VideoCapture(path2)
cap2=cv2.VideoCapture(path3)
</code></pre>

<p>similary, I also created </p>

<pre><code>ret,frame0=cap0.read()
ret,frame1=cap1.read()
ret,frame3=cap2.read()
</code></pre>

<p>Now initially I will have frames from that are read by cap0 and passed into VideoWriter object. After some time I wanted to insert frames that are read from path2 from the time where I switched from path 1. like If I wrote frames till 3 sec from path 1,I wanted to insert frames of path 2 from the 4 sec till 6 sec</p>

<p>Now if I switch back again to path1 then I wanted to insert frames from the 7 sec by skipping the frames of path1 from 4sec to 6 sec.</p>

<p>Is there any way doing this like may be skipping the frames or any other alternative</p>

<p>Since you have written while stitching so I assume you want to make a sort of gui and see the results of switching at different time, otherwise Garvita Tiwari answer's seems to be correct.</p>

<p>One way of doing is to use createTrackbar of a variable(say) vid_no with its value ranging from 0 to num_Cams - 1.Now u can simply use if else depending upon the value of variable vid_no to capture  frames from the desired video.
Format for using Trackbar in OpenCv</p>

<pre><code>createTrackbar("select_Video", "control", &amp;vid_no, num_Cams - 1);
</code></pre>

python opencv video video-capture