OpenCV on R24.2.1 - I420 to appsink

Hi,

I was referred to the link below to improve performance by getting rid of ‘videoconvert’ in gstreamer pipeline.

https://devtalk.nvidia.com/default/topic/1024245/jetson-tx2/opencv-3-3-and-integrated-camera-problems-/post/5210698/#5210698

Using the latest JetPack, and building OpenCV 3.3 from source I was able to use the on-board camera without ‘videoconvert’ in gstreamer pipeline as it can output NV12/I420 to appsink.

But now I am using R24.2.1 because Leopard Imaging drivers for their cameras work only on R24.2.1. I built OpenCV 3.3 again using the same instructions but for a lot of the required packages it said package was not found. And maybe because of that, OpenCV fails to start gstreamer pipeline without ‘videoconvert’.

What can I do to make OpenCV accept I420 format on R24.2.1/TX1?

Thanks!

Hi vchinta,

I think it would be better to install OpenCV 3.3 on your 24.2.1. Could you point out what package you are missing?

I followed all the steps again so that I can point out which packages I was missing but I was unable to reproduce “package unavailable” again. I attached cmake output below hoping that can be helpful.

One thing I noticed was that even though I use -DWITH_CUDA=ON, Use Cuda is set to NO.

cmake \
>     -DCMAKE_BUILD_TYPE=Release \
>     -DCMAKE_INSTALL_PREFIX=/usr \
>     -DBUILD_PNG=OFF \
>     -DBUILD_TIFF=OFF \
>     -DBUILD_TBB=OFF \
>     -DBUILD_JPEG=OFF \
>     -DBUILD_JASPER=OFF \
>     -DBUILD_ZLIB=OFF \
>     -DBUILD_EXAMPLES=OFF \
>     -DBUILD_opencv_java=OFF \
>     -DBUILD_opencv_python2=OFF \
>     -DBUILD_opencv_python3=OFF \
>     -DBUILD_PERF_TESTS=OFF \
>     -DBUILD_TESTS=OFF \
>     -DENABLE_NEON=ON \
>     -DENABLE_PRECOMPILED_HEADERS=OFF \
>     -DWITH_OPENCL=OFF \
>     -DWITH_OPENMP=OFF \
>     -DWITH_FFMPEG=ON \
>     -DWITH_GSTREAMER=ON \
>     -DWITH_GSTREAMER_0_10=OFF \
>     -DWITH_CUDA=ON \
>     -DWITH_GTK=ON \
>     -DWITH_VTK=OFF \
>     -DWITH_TBB=ON \
>     -DWITH_1394=OFF \
>     -DWITH_OPENEXR=OFF \
>     -DWITH_LIBV4L=ON \
>     -DWITH_OPENGL=ON \
>     -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
>     -DCUDA_ARCH_BIN=5.3 \
>     -DCUDA_ARCH_PTX="" \
>     -DINSTALL_C_EXAMPLES=OFF \
>     -DINSTALL_TESTS=OFF \
>     ../opencv
-- Looking for ccache - not found
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.8") 
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Checking for module 'libgphoto2'
--   No package 'libgphoto2' found
-- Found TBB: /usr/lib/aarch64-linux-gnu/libtbb.so
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing:  Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) 
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
-- Could NOT find Pylint (missing:  PYLINT_EXECUTABLE) 
-- Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
-- Excluding from source files list: /home/ubuntu/opencv/modules/core/src/convert.sse4_1.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/core/src/convert.avx2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/core/mathfuncs_core.sse2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/core/mathfuncs_core.avx.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/core/mathfuncs_core.avx2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/core/stat.sse4_2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/core/stat.avx2.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/resize.sse4_1.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/filter.avx2.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/imgproc/src/undistort.avx2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/imgproc/accum.sse2.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/imgproc/accum.avx.cpp
-- Excluding from source files list: /home/ubuntu/opencv/modules/objdetect/src/haar.avx.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: /home/ubuntu/build/modules/dnn/layers/layers_common.avx2.cpp
-- Torch importer has been enabled. To run the tests you have to install Torch ('th' executable should be available) and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.
-- 
-- General configuration for OpenCV 3.3.0-dev =====================================
--   Version control:               3.3.0-534-g1ba29cc
-- 
--   Platform:
--     Timestamp:                   2017-10-12T19:17:39Z
--     Host:                        Linux 3.10.96-test aarch64
--     CMake:                       3.5.1
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    NEON FP16
--       required:                  NEON
--       disabled:                  VFPV3
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 5.3.1)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections    -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections    -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections    -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections    -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt /usr/lib/aarch64-linux-gnu/libtbb.so
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 core flann imgproc ml objdetect photo video dnn imgcodecs shape videoio highgui superres features2d calib3d stitching videostab
--     Disabled:                    js world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 ts viz
-- 
--   GUI: 
--     QT:                          NO
--     GTK+ 3.x:                    YES (ver 3.18.9)
--     GThread :                    YES (ver 2.48.1)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.2.54)
--     TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
--     JPEG 2000:                   /usr/lib/aarch64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     NO
--     GDAL:                        NO
--     GDCM:                        NO
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 56.60.100)
--       avformat:                  YES (ver 56.40.101)
--       avutil:                    YES (ver 54.31.100)
--       swscale:                   YES (ver 3.1.101)
--       avresample:                NO
--     GStreamer:                   
--       base:                      YES (ver 1.8.3)
--       video:                     YES (ver 1.8.3)
--       app:                       YES (ver 1.8.3)
--       riff:                      YES (ver 1.8.3)
--       pbutils:                   YES (ver 1.8.3)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.10.0) / libv4l2 (ver 1.10.0)
--     XIMEA:                       NO
--     Xine:                        NO
--     Intel Media SDK:             NO
--     gPhoto2:                     NO
-- 
--   Parallel framework:            TBB (ver 4.4 interface 9002)
-- 
--   Trace:                         YES ()
-- 
--   Other third-party libraries:
--     Use Intel IPP:               NO
--     Use Intel IPP IW:            NO
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Lapack:                  NO
--     Use Eigen:                   YES (ver 3.2.92)
--     Use Cuda:                    NO
--     Use OpenCL:                  NO
--     Use OpenVX:                  NO
--     Use custom HAL:              YES (carotene (ver 0.0.1))
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.11)
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.1)
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Matlab:                        Matlab not found or implicitly disabled
-- 
--   Documentation:
--     Doxygen:                     NO
-- 
--   Tests and samples:
--     Tests:                       NO
--     Performance tests:           NO
--     C/C++ Examples:              NO
-- 
--   Install path:                  /usr
-- 
--   cvconfig.h is in:              /home/ubuntu/build
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CUDA_ARCH_BIN
    CUDA_ARCH_PTX


-- Build files have been written to: /home/ubuntu/build

I was able to solve the CUDA part.

I still get

-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found

And the rest of the “–Excluding from source files list: …” lines. Do these have anything to do with not accepting I420?

Do you have the v4l dev libraries installed?

$ sudo apt-get install libv4l-dev

Yes I do! Installed before building OpenCV 3.3

I was able to find the packages that I am missing

E: Unable to locate package libavcodec-dev
E: Unable to locate package libavformat-dev
E: Unable to locate package libswscale-dev
E: Unable to locate package v4l-utils
E: Unable to locate package qv4l2
E: Unable to locate package v4l2ucp