安装gstreamer对opencv python包的支持 [英] Install gstreamer support for opencv python package

查看:1260
本文介绍了安装gstreamer对opencv python包的支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从源代码构建了自己的opencv python软件包.

I have built my own opencv python package from source.

import cv2
print(cv2.__version__)

打印:3.4.5

现在我面临的问题是有关opencv的VideoCapture类中的gstreamer的使用.我试图让这个最小的工作示例在python3上运行

Now the issue I am facing is regarding the use of gstreamer from the VideoCapture class of opencv. I am trying to get this mimimum working example running on python3

cap = cv2.VideoCapture("videotestsrc ! appsink")

if not cap.isOpened():
    print("Cannot capture test src. Exiting.")
    quit()

while True:
    ret, frame = cap.read()
    if ret == False:
        break
    cv2.imshow("CVtest",frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

捕获失败,在上面产生了我的打印件(请参见if语句).我检查了:

Capture fails, producing my print above (see if statement). I checked:

import cv2
print(cv2.getBuildInformation())

打印:

Video I/O:
DC1394:                      NO
FFMPEG:                      NO
  avcodec:                   NO
  avformat:                  NO
  avutil:                    NO
  swscale:                   NO
  avresample:                NO
GStreamer:                   NO
libv4l/libv4l2:              NO
v4l/v4l2:                    linux/videodev2.h

看到这一点,绝对有道理,我的gstreamer管道不起作用.我确保在ccmake的OpenCV期间将WITH_GSTREAMER设置为ON(已经).问题仍然存在.我什至尝试将WITH_GSTREAMER_0_10设置为ON.从cv2 python模块启用gstreamer仍然不走运.

Seeing that, it made absolute sense that my gstreamer pipeline didn't work. I ensured WITH_GSTREAMER was set to ON during ccmake of OpenCV (which it already was). Still the issue maintained. I even tried setting WITH_GSTREAMER_0_10 to ON as well. Still no luck having gstreamer enabled from the cv2 python module.

在任何人建议使用pip3安装cv2之前.我也尝试过.从pip获取软件包的问题是,它根本不允许您配置gstreamer支持.

Before anyone suggests using pip3 to install cv2. I tried that, too. The issue with getting the package from pip is, it doesn't let you configure gstreamer support at all.

任何人都可以在这里提供帮助吗?

Can anyone provide help here?

推荐答案

I was able to solve the issue, with a bit of help from the opencv support forum. Looking at the cmake output hints at the problem:

-- 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
-- Checking for module 'gstreamer-pbutils-0.10'
--   No package 'gstreamer-pbutils-0.10' found

在ccmake期间,我已将WITH_GSTREAMER和WITH_GSTREAMER_0_10都设置为ON.似乎cmake比gstreamer1.0更喜欢gstreamer0.10标志.由于我只安装了gstreamer1.0,因此opencv完全无法设置gstreamer依赖项.

During ccmake, I had set both WITH_GSTREAMER as well as WITH_GSTREAMER_0_10 to ON. Seems that cmake prefers the gstreamer0.10 flag over the one for gstreamer1.0. Since I only have gstreamer1.0 installed, opencv entirely failed setting up the gstreamer dependencies.

我确保要鞭打所有以前部署的二进制文件:

I made sure to whipe all previously deployed binaries:

cd <opencv-src>/build 
sudo make uninstall

然后,我仅使用调整后的设置重新安装(鉴于以上知识):

Then I simply reinstalled, with the adjusted settings (given my knowledge above):

ccmake ..
make -j8
sudo make install

当我

import cv2
print(cv2.getBuildInformation())

我的控制台现在输出

Video I/O:
DC1394:                      NO
FFMPEG:                      NO
  avcodec:                   NO
  avformat:                  NO
  avutil:                    NO
  swscale:                   NO
  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)
libv4l/libv4l2:              NO
v4l/v4l2:                    linux/videodev2.h


最重要的是,如果确实需要gstreamer1.0,请不要在cmake期间将WITH_GSTREAMER_0_10设置为ON.在这种情况下,您只需将WITH_GSTREAMER设置为


Bottom line is, do not set WITH_GSTREAMER_0_10 to ON during cmake, if you actually want gstreamer1.0. In that case you must only set WITH_GSTREAMER ON

这篇关于安装gstreamer对opencv python包的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆