Gstreamer Python FIFO OpenCV

Gstreamer Python FIFO OpenCV

提问人:David Williams 提问时间:11/17/2023 最后编辑:Christoph RackwitzDavid Williams 更新时间:11/17/2023 访问量:34

问:

好的,快速解释我的问题。 我有一个 gstreamer 管道,我需要将其分解成 FIFO 文件的 tee 以将流写入其中。如果我通过命令行启动流并将其输入到我的 python 代码中,它是这样的:

运行时,Gstreamer 窗口会显示 xvimagesink

gst-launch-1.0 v4l2src ! tee name=t \
t. ! queue ! image/jpeg,width=1280,height=720,framerate=60/1 ! jpegdec ! xvimagesink 
t. ! queue ! image/jpeg,width=1280,height=720,framerate=60/1 ! filesink location=/tmp/cv_fifo1 

这是我的 python 代码中的一个管道:

# Define the GStreamer pipeline and Code (simple for testing)

import cv2

# Define the GStreamer pipeline
pipeline = (
    "filesrc location=/tmp/cv_fifo1 ! "
    "jpegdec ! "
    "videoconvert ! "
    "appsink"
)

# Create a VideoCapture object with the pipeline
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

# Check if the VideoCapture object was successfully created
if not cap.isOpened():
    print("Failed to open pipeline")
    exit()

# Read and display video frames in a loop
while True:
    ret, frame = cap.read()
    if not ret:
        break

    cv2.imshow('Frame', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the VideoCapture object and close the window
cap.release()
cv2.destroyAllWindows()

代码输出:

[ WARN:[email protected]] global cap_gstreamer.cpp:2784 handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesrc0 reported: Could not open file "/tmp/cv_fifo1" for reading.
[ WARN:[email protected]] global cap_gstreamer.cpp:1679 open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:[email protected]] global cap_gstreamer.cpp:1164 isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:[email protected]] global cap.cpp:204 open VIDEOIO(GSTREAMER): backend is generally available but can't be used to capture by name

回溯(最近一次调用最后一次): 窗口显示(来自 Gstreamer),表示第一个“发球台”已成功制作,但我正在抓住吸管使其同步到 FIFO 文件。它具有要访问的所有权限(FIFO 文件)。有没有人在编码和 AV 领域可以给我一些提示?

我相信它要么与它处理 jpeg 和写入/或读取它们的方式有关,但我不知道

一如既往地感谢你们!

OpenCV的 gstreamer的 先进先出

评论

0赞 SeB 11/21/2023
尝试使用 .然后运行您的 opencv 应用程序,VideoCapture 应等待可用数据打开。然后运行您的发件人。rm /tmp/cv_fifo1; mkfifo /tmp/cv_fifo1

答: 暂无答案