I am trying to make a yolov5 custom detection tool. When i try to run it i get this error:- cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4062: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
I also get these two errors in the terminal before this error :-
C:\Users\Kilometre Morales/.cache\torch\hub\ultralytics_yolov5_master\export.py` is shadowing the library module 'export'. Consider renaming or moving it!
global cap_msmf.cpp:1759 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638
My webcam turns on fine if i remove everything related to pytorch.
Here is my code :-
import cv2
import torch
path='C:/Users/Kilometre Morales/Documents/Science Exhibition code/yolov5/yolov5win11customobj- main/best.pt'
model = torch.hub.load('ultralytics/yolov5','custom', path, force_reload=True)
cap=cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
cv2.resize(frame,(1020,500))
cv2.imshow("frame",frame)
if cv2.waitKey(1)&0xFF==27:
break
cap.release()
cv2.destroyAllWindows()
I tried to make a yolov5 custom object detector. I was expecting it to run my webcam with no issues and then i could proceed with further coding. But i got this error when i runned the code.