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>yes you can do this by first finding the fps of your videos using</p>

<pre><code>int fps = (int) cvGetCaptureProperty(capture1, CV_CAP_PROP_FPS);
</code></pre>

<p>now calculate the number of frames you want to capture, </p>

<pre><code>numberOfFrames = fps*time
</code></pre>

<p>this time is the time for which you want to capture one video.Thus calculate starting and end frame for each videostream. Then capture these frames as images in Mat and use VideoWriter to write</p>

python opencv video video-capture