Firefly开源社区

标题: 关于新发布20180416固件版本上安装支持gstreamer的opencv [打印本页]

作者: 一只大犀牛    时间: 2018-4-17 18:23
标题: 关于新发布20180416固件版本上安装支持gstreamer的opencv
本帖最后由 一只大犀牛 于 2018-4-17 18:33 编辑

使用新发布的sdk,版本:Firefly-RK3399-ubuntu16.04-20180416112819.img;
该img自带gstreamer,测试可以硬解码,非常给力。
            现在想源码编译安装opencv,让opencv打开gstreamer的支持,这样opencv就能直接使用gstreamer硬解码。
但是源码编译opencv的时候,出现错误。
编译命令如下:
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_GSTREAMER=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DFIND_LIBRARY=/usr/lib/aarch64-linux-gnu/ \
-DWITH_GTK=ON  -DWITH_GTHREAD=ON ..

出现以下错误:
-- Checking for module 'gtk+-3.0'
--   No package 'gtk+-3.0' found
-- Checking for module 'gtk+-2.0'
--   No package 'gtk+-2.0' found
-- Checking for module 'gthread-2.0'
--   No package 'gthread-2.0' found
-- Checking for module 'gstreamer-base-1.0'
--   No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
--   No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
--   No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
--   No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
--   No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
--   No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
--   No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
--   No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
--   No package 'gstreamer-riff-0.10' found
但是我能在/usr/lib/aarch64-linux-gnu/目录下,找到这些so。为什么找不到?
向各位大神请教一下,怎么在这个img版本上安装支持自带gstreamer的opencv?
作者: 一只大犀牛    时间: 2018-4-19 14:38
安装缺少的一些库后,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")
Could NOT find JPEG (missing:  JPEG_LIBRARY JPEG_INCLUDE_DIR)
Could NOT find Jasper (missing:  JASPER_LIBRARIES JASPER_INCLUDE_DIR)
Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.8")
Checking for module 'gtk+-3.0'
  No package 'gtk+-3.0' found
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 'libgphoto2'
  Found libgphoto2, version 2.5.9
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 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)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Module opencv_videostab disabled because opencv_features2d dependency can't be resolved!
Processing WORLD modules...
    module opencv_core...
    module opencv_imgproc...
    module opencv_photo...
    module opencv_video...
    module opencv_imgcodecs...
    module opencv_videoio...
    module opencv_highgui...
Processing WORLD modules... DONE
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/core/src/convert.sse4_1.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/core/src/convert.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/mathfuncs_core.sse2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/mathfuncs_core.avx.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/mathfuncs_core.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/stat.sse4_2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/stat.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/corner.avx.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/resize.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/resize.sse4_1.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/imgwarp.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/imgwarp.sse4_1.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/undistort.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/modules/imgproc/src/filter.avx2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/accum.sse2.cpp
Excluding from source files list: /home/firefly/Workspace/opencv-3.4.0/build/modules/world/accum.avx.cpp

General configuration for OpenCV 3.4.0 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2018-04-17T03:05:12Z
    Host:                        Linux 4.4.77 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.4.0)
    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 -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -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 -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -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 -fdata-sections    -fvisibility=hidden -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 -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          dl m pthread rt
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 core highgui imgcodecs imgproc photo video videoio world
    Disabled:                    calib3d features2d flann js ml objdetect python_bindings_generator shape stitching superres
    Disabled by dependency:      videostab
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 ts viz
    Applications:                -
    Documentation:               NO
    Non-free algorithms:         NO

  GUI:
    GTK+:                        YES (ver 2.24.30)
      GThread :                  YES (ver 2.52.3)
      GtkGlExt:                  NO
    VTK support:                 NO

Media I/O:
    ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        libjpeg (ver 90)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.2.54)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    GStreamer:                  
      base:                      YES (ver 1.12.2)
      video:                     YES (ver 1.12.2)
      app:                       YES (ver 1.12.2)
      riff:                      YES (ver 1.12.2)
      pbutils:                   YES (ver 1.12.2)
    libv4l/libv4l2:              NO
    v4l/v4l2:                    linux/videodev2.h
    gPhoto2:                     YES

  Parallel framework:            pthreads

  Trace:                         YES (built-in)

  Other third-party libraries:
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  YES (carotene (ver 0.0.1))

  OpenCL:                        YES (no extra features)
    Include path:                /home/firefly/Workspace/opencv-3.4.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            /usr/bin/python2.7

  Matlab:                        NO

  Install to:                    /usr/local
-----------------------------------------------------------------

Configuring done

这样编译可以成功,但是运行如下代码的时候,提示错误,具体如下:
代码:
#include <iostream>
#include <opencv2/opencv.hpp>

cv::Mat frame;
cv::VideoCapture capture;

long g_count = 0;

int main()
{
        std::cout<<"open cam "<<std::endl;
        if(!capture.open("test.mp4"))
        {
                std::cout<<"open cam failed"<<std::endl;
                //return -1;
        }

        while(1)
        {
                std::cout<<"capture frame "<<std::endl;
                capture>>frame;
                if(frame.cols > 0 && frame.rows > 0)
                {
                        std::cout<<"imshow frame "<<std::endl;
                        cv::imshow("0",frame);
                }
                if(cv::waitKey(30)==27) break;
        }
        return 0;
}

报错:
mpi: mpp version: 5849089 author: Herman Chen [mpp]: Add temporally patch for blocking issue
hal_h264d_api: hal_h264d_init mpp_buffer_group_get_internal used ion In
mpp_rt: NOT found ion allocator
mpp_rt: found drm allocator
OpenCV Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /home/firefly/Workspace/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp, line 1869
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

/home/firefly/Workspace/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp:1869: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
in function handlemessage

这是错在哪里?gstreamer没装好?

作者: power1077    时间: 2018-4-20 09:17
lz您好
我也在试新版里面内建的gstreamer,但硬解是有问题的
能帮忙看下吗?
指令如下
gst-launch-1.0 rtspsrc location='rtspt://rtsplink:554/user=&password=&channel=&stream=.sdp' ! rtph264depay ! mppvideodec ! rkximagesink
但都没有出现串流画面, 卡在 mpp_rt: found drm allocator
用ctrl C 中断后,跳出 "gst_mpp_allocator_start: assertion 'size != 0' failed"
作者: power1077    时间: 2018-4-20 09:22
我之前安装过opencv 3.4.1,配上FFMpeg与Gstreamer,当时gstreamer是用源码compile过来的 ,
包含各个插件(plugins) ,源码直接 ./autogen.sh   ->  make -j6  ->   make install 即可
FFmpeg是用Longchair的版本,(https://github.com/LongChair/FFmpeg)
configure时要enable rkmpp选项 就有硬解
您可以试下
作者: 一只大犀牛    时间: 2018-4-20 11:47
power1077 发表于 2018-4-20 09:17
lz您好
我也在试新版里面内建的gstreamer,但硬解是有问题的
能帮忙看下吗?

我用的这个,可以播放:gst-launch-1.0 playbin uri=rtsp://admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream
作者: 一只大犀牛    时间: 2018-4-20 12:29
power1077 发表于 2018-4-20 09:22
我之前安装过opencv 3.4.1,配上FFMpeg与Gstreamer,当时gstreamer是用源码compile过来的 ,
包含各个插件 ...

opencv调ffmpeg实现硬解,这就很好了。那硬件编码呢?您当时试了吗?
作者: power1077    时间: 2018-4-23 09:47
硬件編碼會卡在drm allocator
具體我這篇有log : http://dev.t-firefly.com/thread-13573-1-1.html
FFmpeg調用硬解也是類似的錯誤信息

作者: zouxf    时间: 2018-4-27 17:41
去掉这个试试看  -DFIND_LIBRARY=/usr/lib/aarch64-linux-gnu/ \

作者: 一只大犀牛    时间: 2018-4-28 16:33
zouxf 发表于 2018-4-27 17:41
去掉这个试试看  -DFIND_LIBRARY=/usr/lib/aarch64-linux-gnu/ \

重新刷了一次20180426的一体化固件,安装libgtk2.0-dev和gstreamer-base1.0,编译可以支持gstreamer,但是测试demo的时候,还是报错,跟之前差不多,如下:
Unable to stop the stream: Inappropriate ioctl for device
OpenCV Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /home/firefly/Documents/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp, line 1869
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

/home/firefly/Documents/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp:1869: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
in function handlemessage

感觉还是gstreamer本身有问题,希望能在帮忙看看,多谢哈
作者: junhe    时间: 2018-5-28 17:23
本帖最后由 junhe 于 2018-5-28 17:25 编辑

@一只大犀牛,大哥,搞定了么?分享一下吧




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1