简体   繁体   English

带有Gstreamer管道的Python

[英]Python with Gstreamer pipeline

I'm working on an Udoo trying to get the camera to take a picture that I can manipulate inside Python. 我正在开发一个Udoo,试图让相机拍摄可以在Python中操作的图片。

So far, the camera works with 到目前为止,该相机可以与

gst-launch-1.0 imxv4l2videosrc ! imxipuvideosink

I can also take a single picture with 我也可以用

gst-launch-1.0 imxv4l2videosrc num-buffers=1 ! video/x-raw ! jpegenc ! filesink location=output.jpg

From here it seems like you can read straight from a gstreamer stream in Python with OpenCV. 这里开始 ,您似乎可以使用OpenCV从Python的gstreamer流中直接读取。

Here is my python code: 这是我的python代码:

import cv2
cam = cv2.VideoCapture("imxv4l2videosrc ! video/x-raw ! appsink")
ret, image = cam.read()

However, ret is False , and image is nothing. 但是,ret是False ,图像什么也不是。

Some places say this only works with OpenCV 3.0+, and others say 2.4.x, but I can't seem to find an actual answer to what version it works on. 有些地方说这仅适用于OpenCV 3.0+,而另一些地方说是2.4.x,但我似乎无法找到其适用版本的实际答案。

If I need to update to OpenCV 3.0, which part to I update? 如果我需要更新到OpenCV 3.0,我要更新哪一部分? I downloaded OpenCV via the apt repositories under the package python-opencv. 我通过apt-repository在python-opencv包下下载了OpenCV。 So do I need to update Python? 那我需要更新Python吗? Can I just build OpenCV from source, and Python will automatically be using the newest version? 我可以仅从源代码构建OpenCV,Python会自动使用最新版本吗? I'm so confused. 我很混乱。

The Ubuntu/Debian version is old 2.4.x, to get the last one you need to compile it from source. Ubuntu / Debian版本是旧的2.4.x,要获取最后一个版本,您需要从源代码进行编译。

Here two tutorials on how to do that: 这里有两个关于如何做到这一点的教程:

  1. https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.html#installing-opencv-from-source https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.html#installing-opencv-from-source
  2. http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/ http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/

The first is for Python 2.7 on Fedora , the second for Python 3.4 on Ubuntu . 第一个用于Fedora上的Python 2.7 ,第二个用于Ubuntu上的Python 3.4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM