- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried to run the pre-trained model 'license-plate-recognition-barrier-0001'. But got error like:
$ python3 lr.py
6768
(1, 3, 24, 94)
Traceback (most recent call last):
File "lr.py", line 19, in <module>
blob = cv.dnn.blobFromImage(frame, size=(24, 94), ddepth=cv.CV_8U)
cv2.error: OpenCV(4.1.1-openvino) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/imgproc/src/resize.cpp:3363: error: (-215:Assertion failed) !dsize.empty() in function 'resize'
My python script:
import cv2 as cv
import numpy as np
# Load the model.
net = cv.dnn.readNet('./FP16/license-plate-recognition-barrier-0001.xml',
'./FP16/license-plate-recognition-barrier-0001.bin')
# Specify target device.
net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
# Read an image.
image = cv.imread('prepimg.jpg')
image = cv.resize(image, (94, 24))
cv.imwrite('mid-image.jpg',image)
image = image[np.newaxis, :, :, :] # Batch size axis add
image = image.transpose((0, 3, 1, 2))
print('image.size',image.size)
print('image.shape',image.shape)
if image is None:
raise Exception('Image not found!')
# Prepare input blob and perform an inference.
blob = cv.dnn.blobFromImage(image, size=(24, 94), ddepth=cv.CV_8U)
net.setInput(blob)
out = net.forward()
The python script was modified from the example. And form the log, I am sure that the image file was loaded, and the shape should be right. I just cannot find why this error happened. Have someone saw this error before?
Thanks,
Runze
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Zhang Runze,
Have you tried the blob = cv.dnn.blobFromImage(image, size=(94, 24), ddepth=cv.CV_8U)? Since for the blobFromImage it accepts the size of (Width, Height). From you original data, looked like your model width is 94 and height is 24.
You can refer to the "preparing input" section in the link below:
https://www.arunponnusamy.com/yolo-object-detection-opencv-python.html ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Cary P, thanks for helping!
But the error is same after I changed the code.
python3 lr.py
image.size 6768
image.shape (1, 3, 24, 94)
Traceback (most recent call last):
File "lr.py", line 20, in <module>
blob = cv.dnn.blobFromImage(image, size=(94, 24), ddepth=cv.CV_8U)
cv2.error: OpenCV(4.1.1-openvino) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/imgproc/src/resize.cpp:3363: error: (-215:Assertion failed) !dsize.empty() in function 'resize'
Cary P. (Intel) wrote:Hi, Zhang Runze,
Have you tried the blob = cv.dnn.blobFromImage(image, size=(94, 24), ddepth=cv.CV_8U)? Since for the blobFromImage it accepts the size of (Width, Height). From you original data, looked like your model width is 94 and height is 24.
You can refer to the "preparing input" section in the link below:
https://www.arunponnusamy.com/yolo-object-detection-opencv-python.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Zhang, Runze
Are you sure your image is valid ? Please study the following issue ticket. Also OpenVino 2019R3 was just released. Please upgrade if you haven't already.
https://github.com/the-house-of-black-and-white/opencv-dnn-demo/issues/1
Thanks,
Shubha

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page