![](/img/trans.png)
[英]Pyglet does not play music in terminal (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.