相关文章推荐
追风的茶壶  ·  史上最強 ...·  9 月前    · 
知识渊博的红金鱼  ·  Nintendo ...·  9 月前    · 
阳刚的红茶  ·  白云区纪委监察委·  1 年前    · 
要出家的钥匙扣  ·  2021-07-28_system.runt ...·  1 年前    · 

I’m trying to detect gamepieces with the code at the bottom; it simply takes the frame from camera, detects the object in frame and shows it.

import cv2
from roboflow import Roboflow
rf = Roboflow(api_key="9QtTqKO1kLdvctLfx0YR")
project = rf.workspace().project("frc-charged-up-game-pieces")
model = project.version(7).model
capture = cv2.VideoCapture(0)
while True:
    capture = cv2.VideoCapture(0)
    ret, frame=capture.read()
    a = model.predict(frame , confidence=40, overlap=30).json()
    cv2.imshow("Webcam",a)
    cv2.waitKey(100)
capture.release()
cv2.destroyAllWindows()

But it gives this error :

Traceback (most recent call last):
  File "C:\Users\narog\Desktop\opencv\main.py", line 13, in <module>
    cv2.imshow("Webcam",a)
cv2.error: OpenCV(4.8.0) :-1: error: (-5:Bad argument) in function 'imshow'
> Overload resolution failed:
>  - mat is not a numpy array, neither a scalar
>  - Expected Ptr<cv::cuda::GpuMat> for argument 'mat'
>  - Expected Ptr<cv::UMat> for argument 'mat'

How can I fix this, or there are any other ways to do object detection?