简体   繁体   English

通过OpenCV使用实时三相机进纸时出现GStreamer-CRITICAL错误

[英]GStreamer-CRITICAL Error when Utilizing live Three-Camera Feed via OpenCV

I am using OpenCV to read live video feed from three usb cameras at the same time. 我正在使用OpenCV同时从三个USB摄像头读取实时视频。 This live video feed is parsed frame-by-frame into a neural network for a drone detection device (using a neural network with OpenVINO by Intel). 这个实时视频源被逐帧解析为无人机检测设备的神经网络(使用英特尔的OpenVINO神经网络)。

When using only a single camera, the following warning pops up on the screen, but the program seems to still execute flawlessly: 仅使用一台摄像机时,屏幕上会弹出以下警告,但程序似乎仍能完美执行:

(python3:4235): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed (python3:4235):GStreamer-CRITICAL **:gst_element_get_state:断言'GST_IS_ELEMENT(element)'失败

However, when utilizing all three cameras at the same time, the following errors appear in the terminal and the program does not run at all: 但是,当同时使用所有三个摄像机时,终端中会出现以下错误,并且程序根本不运行:

(python3:4041): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed VIDEOIO ERROR: V4L: can't open camera by index 0 threeCam_droneDetection.py:90: DeprecationWarning: from_ir() method of IENetwork is deprecated. (python3:4041):GStreamer-CRITICAL **:gst_element_get_state:断言'GST_IS_ELEMENT(element)'失败VIDEOIO ERROR:V4L:无法通过索引0打开摄像机threeCam_droneDetection.py:90:DeprecationWarning:IENetwork的from_ir()方法是弃用。 Please use IENetwork class constructor to create valid IENetwork instance net = IENetwork.from_ir(model=model_xml, weights=model_bin) A camera is not working 请使用IENetwork类构造函数创建有效的IENetwork实例net = IENetwork.from_ir(model = model_xml,weights = model_bin)相机无法正常工作

(python3:4041): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed (python3:4041):GStreamer-CRITICAL **:gst_element_get_state:断言'GST_IS_ELEMENT(element)'失败

(python3:4041): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed (python3:4041):GStreamer-CRITICAL **:gst_element_get_state:断言'GST_IS_ELEMENT(element)'失败

I have tried playing around with the code in attempt to fix the problem, but this GStreamer error keeps coming up when utilizing all three cameras in the program. 我尝试使用代码试图解决问题,但是当使用程序中的所有三个摄像头时,这个GStreamer错误不断出现。 I even made a separate program to simply bring up a live camera feed (without doing anything with the frames except just outputting them to the screen with cv2.imshow() and this program executes flawlessly. So I assume that there is something wrong that I am not catching in the drone detection program. 我甚至制作了一个单独的程序来简单地调出一个实时的摄像头输入(除了用cv2.imshow()将它们输出到屏幕之外没有对框架做任何事情,这个程序执行cv2.imshow()完美。所以我认为我有些不对劲我没有参加无人机检测计划。

The following are snippets from the python script I wrote for the three-camera live drone detection: 以下是我为三相机实时无人机检测编写的python脚本的片段:

#Initialize camera frame dimension variables
camera_width = 244
camera_height = 244

#Initialize 3 cameras and set their frame dimensions
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, camera_width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, camera_height)

cap2 = cv2.VideoCapture(1)
cap2.set(cv2.CAP_PROP_FRAME_WIDTH, camera_width)
cap2.set(cv2.CAP_PROP_FRAME_HEIGHT, camera_height)

cap3 = cv2.VideoCapture(2)
cap3.set(cv2.CAP_PROP_FRAME_WIDTH, camera_width)
cap3.set(cv2.CAP_PROP_FRAME_HEIGHT, camera_height)
while True:
    #Read camera frames and return value (sees if cameras are working)
    ret, liveframe = cap.read()
    ret2, liveframe2 = cap2.read()
    ret3, liveframe3 = cap3.read()

    #Breaks script if any of the cameras are not working
    if (not ret or not ret2 or not ret3):
        print("A camera is not working")
        break
 # Run inference
    res = exec_net.infer(inputs={input_blob: processedImg})
    res2 = exec_net.infer(inputs={input_blob: processedImg2})
    res3 = exec_net.infer(inputs={input_blob: processedImg3})

    # Access the results and get the index of the highest confidence score
    output_node_name = list(res.keys())[0]
    res = res[output_node_name]

    output_node_name2 = list(res2.keys())[0]
    res2 = res2[output_node_name2]

    output_node_name3 = list(res3.keys())[0]
    res3 = res3[output_node_name3]

    # Predicted class index.
    idx = np.argsort(res[0])[-1]
    idx2 = np.argsort(res2[0])[-1]
    idx3 = np.argsort(res3[0])[-1]

I would really appreciate some suggestions of how I could go about removing these GStreamer errors and getting the cameras to work. 我真的很感激一些关于如何去除这些GStreamer错误并让相机工作的建议。 Thank you! 谢谢!

Can you check the incoming video streams? 你能检查传入的视频流吗? You can find more info at http://answers.opencv.org/question/199105/videoio-error-v4l-cant-open-camera-by-index-0/ 您可以在http://answers.opencv.org/question/199105/videoio-error-v4l-cant-open-camera-by-index-0/找到更多信息。

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

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