刘骏森 发表于 2024-3-16 09:10:44

[已解决]行空板使用摄像头OpenCV错误

本帖最后由 刘骏森 于 2024-5-19 12:53 编辑

报错段代码:cap = cv2.VideoCapture(0)
def video_head():    u_gui.clear()
    cap = cv2.VideoCapture(0)
    cap.set(cv2.CAP_PROP_BUFFERSIZE,1)
    cap.open(0)
    while cap.isOpened():
      ret,img = cap.read()
      if ret:
            h,w,c = img.shape
            w1 = h*240//320
            x1 = (w-w1)//2
            img = img[:,x1:x1+w1]
            img2 = cv2.resize(img, (240, 320))
      if button_b.is_pressed():
            cap.release()
            break
报错信息:
[ WARN:0@145.288] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video0): can't open camera by index global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range[ WARN:0@145.293] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video0): can't open camera by index global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range




111111112 发表于 2025-3-14 09:02:31

怎么解决的呀?

shzrzxlee 发表于 2025-3-14 11:46:37

AI编程trae CN版本
页: [1]
查看完整版本: [已解决]行空板使用摄像头OpenCV错误