I am constantly getting this error:
“cv2.error: OpenCV(4.9.0) D:aopencv-pythonopencv-pythonopencvmoduleshighguisrcwindow.cpp:971: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow'”
I have gone through all the other fixes for this, which actually worked for a day and then didn’t (such as updating the version to name/version#). But now, even after not changing the code, I am getting the error again.
Here is sections of my code:
upload_url = “”.join([
“https://detect.roboflow.com/”,
“basketball-cv/3”,
“?api_key=”,
“*************”,
“&format=image”,
“&stroke=5”
])
async def infer(requests):
# Get the current image from the webcam
ret, img = video.read()
# Resize (while maintaining the aspect ratio) to improve speed and save bandwidth
height, width, channels = img.shape
scale = ROBOFLOW_SIZE / max(height, width)
img = cv2.resize(img, (round(scale * width), round(scale * height)))
# Encode image to base64 string
retval, buffer = cv2.imencode('.jpg', img)
img_str = base64.b64encode(buffer)
# Get prediction from Roboflow Infer API
resp = await requests.post(upload_url, data=img_str, headers={
"Content-Type": "application/x-www-form-urlencoded"
})
# Parse result image
image = np.asarray(bytearray(resp.content), dtype="uint8")
image = cv2.imdecode(image, cv2.IMREAD_COLOR)
return image
…
cv2.imshow(‘image’, image)
What is the issue?
I tried changing version number, updating the Size and API key
AJC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.