I used for the first time OpenCV on GPU and I get the following error "Could not convert integer 3221226505. Path 'exitCode'. Value was either too large or too small for an Int32"
The Yolo model works fine on CPU (but slow) and I also tested OpenCV on GPU on separate operations and it works.
The code is:
cap = cv2.VideoCapture(path
net = cv2.dnn.readNet('yolov4-tiny-custom_best.weights','yolov4-tiny-custom.cfg')
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
model = cv2.dnn_DetectionModel(net)
model.setInputParams(size=(800,480), scale=1/255)
while True:
ret, frame = cap.read()
(class_ids,score,bboxes) = model.detect(frame)
for class_id, score, bbox in zip(class_ids,score,bboxes):
(x,y,w,h) = bbox
cv2.rectangle(frame, (x,y), (x+w, y+h), (200, 0, 50), 2)
cv2.imshow("Frame", frame)
cv2.waitKey(1)
I tried to:
- change net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA) with net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA_FP16) and I get the message that my GPU doesn't support FP16 it reverts to FP32
- use different yolov4-tiny.cfg files and different resolutions for the images
I found other question regarding this message but it was for different programing languages and other situations, and I don't know what to change to fix it for object detection with OpenCV and Python.