error: (-215:Assertion failed) !ssize.empty() in function 'resize' on oak lite

问题描述 投票:0回答:0

我正在使用 oak-d 相机在实时视频中进行手部跟踪,使用树莓派 4 模型 b,我正在使用本指南来帮助自己 https://core-electronics.com.au/guides/hand -识别-树莓派/

我真的是编程新手,我不知道如何解决我的问题

import mediapipe
import cv2

drawingModule = mediapipe.solutions.drawing_utils
handsModule = mediapipe.solutions.hands

cap = cv2.VideoCapture(-1, 2)
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')

with handsModule.Hands(static_image_mode=False, min_detection_confidence=0.7, min_tracking_confidence=0.7, max_num_hands=1) as hands:

while True:
           ret, frame = cap.read()

           frame1 = cv2.resize(frame, (640, 480))

           results = hands.process(cv2.cvtColor(frame1, cv2.COLOR_BGR2RGB))

           if results.multi_hand_landmarks != None:
              for handLandmarks in results.multi_hand_landmarks:
                  drawingModule.draw_landmarks(frame1, handLandmarks, handsModule.HAND_CONNECTIONS)

           cv2.imshow("Frame", frame1);
           key = cv2.waitKey(1) & 0xFF

           if key == ord("q"):
              break

那是我正在使用的程序和

这是我的错误调用

信息:为 CPU 创建了 TensorFlow Lite XNNPACK 委托。 追溯(最近一次通话): 文件“/home/pi/Desktop/Simple-Hand-Tracker.py”,第 25 行,位于 frame1 = cv2.resize(frame, (640, 480)) cv2.error:OpenCV(4.7.0)/tmp/pip-wheel-fdgo_zet/opencv-python_6c7f06c066bf4042bf75513f11218d60/opencv/modules/imgproc/src/resize.cpp:4062:错误:(-215:断言失败)!ssize.empty () 在函数“调整大小”中

我试过使用

cap = cv2.VideoCapture(-1, 2)

cap = cv2.VideoCapture(0)

cap = cv2.VideoCapture(-1)

cap = cv2.VideoCapture(cv2.CAP_V4L2)

这些都不起作用

给我更少错误的是 -1、2 和 cv2.CAP_V4L2

我还在命令行上使用了 sudo modprobe bcm2835-v4l2,但它没有改变任何东西

python opencv computer-vision cv2 mediapipe
© www.soinside.com 2019 - 2024. All rights reserved.