Ask Your Question

Revision history [back]

Unable to stitch images together AND also OpenCV Error: Assertion failed (image->depth == 8) in writeFrame, file /home/opencv/modules/videoio/src/cap_ffmpeg.cpp, line 272

The background

  • I use OpenCV 3.3.1 on Kubuntu 16.4.04 LTS.
  • I'm trying to stitch videos together and use https://github.com/opencv/opencv/blob/master/samples/cpp/stitching_detailed.cpp as the base code to stitch high resolution videos together. The goal is to be able to eventually stitch H.264 & H.265 videos together.
  • Specifically I am trying to stitch the videos from: http://www.kolor.com/wiki-en/action/view/Autopano_Video_-_Benchmarking
  • I use the default values set in stitching_detailed.cpp, except for features_type which I've set to "surf" (instead of "orb" which was the default).
  • I have been successful in stitching small images together and now am trying to stitch a set of videos downloaded from the web.
  • And yes, I'm pretty much a newbie with OpenCV

At this point I have been able to read a frame out of the incoming video streams and the two issues I have are:

  • The error: OpenCV Error: Assertion failed (image->depth == 8) in writeFrame, file /home/opencv/modules/videoio/src/cap_ffmpeg.cpp, line 272. My questions are: Please help me understand what is image -> depth and why does it HAVE to be 8. If I were to remove this line and recompile opencv, it goes through (though there are other failures elsewhere).
  • The output image (after stitching) is blank - I have yet to debug why at this point and so this is second priority at the moment. I'll come back to this once I've put in a bit of effort there.

The following is the print output from running my code (all these messages are directly from stitching_detailed.cpp).

$ ./stitch 
non-free module not available in this distribution.
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Input: rows: 1440 col: 1920 channels: 3 type: 16
Input: depth: 0
Finding features...
Features in image #1: 1363
Features in image #2: 305
Features in image #3: 2166
Features in image #4: 3592
Features in image #5: 1706
Features in image #6: 2162
Finding features, time: 1.20169 sec
Pairwise matching
Pairwise matching, time: 0.609997 sec
Saving matches graph...
Initial camera intrinsics #3:
K:
[1565, 0, 447;
 0, 1565, 335.5;
 0, 0, 1]
R:
[1, 0, 0;
 0, 1, 0;
 0, 0, 1]
Initial camera intrinsics #6:
K:
[1565, 0, 447;
 0, 1565, 335.5;
 0, 0, 1]
R:
[1, 0, 0;
 0, 1, 0;
 0, 0, 1]
Camera #3:
K:
[1565, 0, 447;
 0, 1565, 335.5;
 0, 0, 1]
R:
[1, -1.8626451e-09, 0;
 1.8626451e-09, 1, 0;
 0, 0, 1]
Camera #6:
K:
[1565, 0, 447;
 0, 1565, 335.5;
 0, 0, 1]
R:
[0.15256038, -0.012306342, 157.01453;
 0.012306342, 0.15256038, -17.506771;
 0, 0, 1]
Warping images (auxiliary)... 
Warping images, time: 0.190221 sec
Compositing...
Compositing image #3
Multi -band blender, number of bands: 8
Compositing image #6
Compositing, time: 8.12115 sec
Output: rows: 5988 col: 6190 channels: 3 type: 19
Input: depth: 3
Writing output frame
OpenCV Error: Assertion failed (image->depth == 8) in writeFrame, file /home/opencv/modules/videoio/src/cap_ffmpeg.cpp, line 272
Segmentation fault (core dumped)

I'm hoping to use the details here to capture my experience of stitching MPEG videos together and eventually develop a tutorial that opencv can eventually use.