ammoradi / farsi-car-number-plate-recognition

Iranian cars number plate detection and recognition
25 stars 3 forks source link

ValueError: could not broadcast input array from shape (32,29) into shape (32,32) #2

Open parsibox opened 5 years ago

parsibox commented 5 years ago
python3.6 main.py 
Using TensorFlow backend.

(32, 32)
[2.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 29)
Traceback (most recent call last):
  File "main.py", line 53, in <module>
    prediction = classifier.knn_classify(number)
  File "/home/mohsen/Desktop/python/farsi-car-number-plate-recognition/classifier.py", line 68, in knn_classify
    test_data[0] = img
ValueError: could not broadcast input array from shape (32,29) into shape (32,32)
ammoradi commented 5 years ago

@parsibox can I see a sample of your dataset?

parsibox commented 5 years ago

i do not change any thing i run your sample code

ammoradi commented 5 years ago

@parsibox Ok. I will check this case and update repo if I made a mistake.

parsibox commented 5 years ago

1 thi is my image image image image

parsibox commented 5 years ago

did you try it?

ammoradi commented 5 years ago

@parsibox i have not free time until next week.

parsibox commented 5 years ago

ok i wait for you

ammoradi commented 5 years ago

the bug is from the detector. it should not detect the blue part of the flag but it does! I will try to fix this.

parsibox commented 5 years ago

thanks i need this code

parsibox commented 5 years ago

i am still waiting for you

ammoradi commented 5 years ago

@parsibox could you please upload your testing image somewhere and give me a download link?

parsibox commented 5 years ago

this is my image https://user-images.githubusercontent.com/12513476/59562875-7914e100-9047-11e9-9de3-c44222eeced0.jpg

parsibox commented 5 years ago

https://srv-file4.gofile.io/download/JZ4cSa/1.jpg

parsibox commented 5 years ago

i am still waiting for you

SabraHashemi commented 3 years ago

i am still waiting for you

did you solve this problem? i had same problem

parsibox commented 3 years ago

no

SabraHashemi commented 3 years ago

no

i think we can rewrite this resize function tarfget is to resize any image to 32*32

SabraHashemi commented 3 years ago

def __resize_image(src_image, dst_image_height, dst_image_width): src_image_height = src_image.shape[0] src_image_width = src_image.shape[1]

if src_image_height > dst_image_height or src_image_width > dst_image_width:
    height_scale = dst_image_height / src_image_height
    width_scale = dst_image_width / src_image_width
    scale = min(height_scale, width_scale)
    img = cv2.resize(src=src_image, dsize=(0, 0), fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)
else:
    img = src_image

img_height = img.shape[0]
img_width = img.shape[1]

dst_image = np.zeros(shape=[dst_image_height, dst_image_width], dtype=np.uint8)

y_offset = (dst_image_height - img_height) // 2
x_offset = (dst_image_width - img_width) // 2

dst_image[y_offset:y_offset+img_height, x_offset:x_offset+img_width] = img

return dst_image
ammoradi commented 3 years ago

@parsibox @sabrabano0 I was far from this subject for years. let me read the principles used in this project and try to fix this bug. maybe I should refactor or rebase this project. because it is not funny to deal with this problem with knn or a simple cnn it should be under sth like YOLO or SSD hand!

SabraHashemi commented 3 years ago

@parsibox @sabrabano0 I was far from this subject for years. let me read the principles used in this project and try to fix this bug. maybe I should refactor or rebase this project. because it is not funny to deal with this problem with knn or a simple cnn it should be under sth like YOLO or SSD hand!

Not so complicated, as I mentioned above the problem is in the function resize. You have included resizing for bigger image than 32 x 32 but not for smaller like 24 x 32.