I am trying to add bounding boxes to an image using onnxruntime and opencv to be detect objects with the yolov2 neural network. Instead, I get an error at runtime.
I converted the input image into a compatible tensor / numpy array to feed into the model. Once I knew everything worked perfectly without bugs, I added the following code to add the bounding boxes:
while True:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
for x, y, w, h in pred_onnx:
cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), 2)
roiGray = gray[y:y+h, x:x+w]
roiColor = img[y:y+h, x:x+w]
cv2.imshow("Detect", cv2.resize(img, (500, 500)))
cv2.waitKey(0)
I was expecting the image to show (green) bounding boxes. Instead, I get this error:
File "C:\Users\MyName\Desktop\OnnxCV\onnxcv\object_detector.py", line 27, in <module>
for x, y, w, h in pred_onnx:
ValueError: not enough values to unpack (expected 4, got 1)
The full code is here if it helps.