繁体   English   中英

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

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

我正在使用OpenCV同时从三个USB摄像头读取实时视频。 这个实时视频源被逐帧解析为无人机检测设备的神经网络(使用英特尔的OpenVINO神经网络)。

仅使用一台摄像机时,屏幕上会弹出以下警告,但程序似乎仍能完美执行:

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

但是,当同时使用所有三个摄像机时,终端中会出现以下错误,并且程序根本不运行:

(python3:4041):GStreamer-CRITICAL **:gst_element_get_state:断言'GST_IS_ELEMENT(element)'失败VIDEOIO ERROR:V4L:无法通过索引0打开摄像机threeCam_droneDetection.py:90:DeprecationWarning:IENetwork的from_ir()方法是弃用。 请使用IENetwork类构造函数创建有效的IENetwork实例net = IENetwork.from_ir(model = model_xml,weights = model_bin)相机无法正常工作

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

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

我尝试使用代码试图解决问题,但是当使用程序中的所有三个摄像头时,这个GStreamer错误不断出现。 我甚至制作了一个单独的程序来简单地调出一个实时的摄像头输入(除了用cv2.imshow()将它们输出到屏幕之外没有对框架做任何事情,这个程序执行cv2.imshow()完美。所以我认为我有些不对劲我没有参加无人机检测计划。

以下是我为三相机实时无人机检测编写的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]

我真的很感激一些关于如何去除这些GStreamer错误并让相机工作的建议。 谢谢!

你能检查传入的视频流吗? 您可以在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