AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

LPR YOLO #6580

Open ivanh23 opened 4 years ago

ivanh23 commented 4 years ago

Hello , i am using yolov3 for license plate detection (the letters and numbers) and i have a little problem , i have small python script that runs yolo and show outputs, but the letters and numbers are not in order , for example , they should be GE-987 -UU but instead they are 7GU9E , how can i fix this ? in the detector test in darknet folder they are shown correctly , but i cant make it in the python script

Thank you

mehboobillahi56 commented 4 years ago

@ivanh23 If am not wrong Yolo detects randomly in the image so what you have to do is arrange them according to the X&Y value of the bbox.

for example -> if bbox.X is minimum place it 1st. something like that should solve your problem.

RedaAlb commented 3 years ago

@ivanh23 The detections are random, so you will have to do what @mehboobillahi56 suggested, ordering by the x coordinate of each bounding box (BB). However, this will only work if you have license plates (LP) that are one row. Sometimes, an LP will have the characters in two rows, in this case, ordering by the x coordinate will not work. A way I overcame this was to first find the top left most character by finding the euclidean distance from each character BB to the top left corner of the LP BB, the BB with the shortest distance will be the top left most character, hence the first character of the LP. Then, to determine if the LP is one or two rows, consider the bottom edge of the first character BB, if more than two(threshold) BBs are below this edge, then we can assume that it is a two row LP. Once we know the LP is made up of two rows, we order all BBs by the y coordinates, find the peak in those y coordinates and that is where the split of the first row and second row will be. Then you order each row based on the x coordinate and combine both ordered rows to form the final full LP characters in the correct order.

Note, I use the top left corner coordinates of each BB and not the centre, expect when finding how many BBs are below the bottom edge of the first character, where the centre of the BB is used in that case.

This is how I did it, please let me know if there is a simpler way of doing this, because I think I might be missing a very simple solution.

stephanecharette commented 3 years ago

I strongly suggest you have a "plate" class as well to encompass the whole thing. Will prevents lots of problems, like accidentally picking up letters and numbers on the sides or back of vehicles. See this example: https://www.ccoderun.ca/programming/ml/iranian_plates.html