bahrain-uob / eco-guard-challenge

This repository is for the Eco Guard challenge
1 stars 1 forks source link

Automatic License Plate Recognition Implementation #51

Closed mohammedalsaeed-uob closed 5 months ago

mohammedalsaeed-uob commented 7 months ago
mohammedalsaeed-uob commented 7 months ago

Added new resource to use in implementation. https://github.com/Muhammad-Zeerak-Khan/Automatic-License-Plate-Recognition-using-YOLOv8

mohammedalsaeed-uob commented 7 months ago

Brainstormed a few tasks:

  1. Add function to delete snapshots captured by Unregistered Cars Consumer
  2. Add function to retain snapshots captured by Yellow Lane Violation Consumer
  3. Create Folders for Separate Violations in S3 Violation Bucket
  4. Create DynamoDB table for Yellow Lane Violation License Plate Storage
  5. Edit function to check for unregistered car violation

(will add these as their own issues)

mohammedalsaeed-uob commented 7 months ago

We successfully developed Consumer 1.

mohammedalsaeed-uob commented 7 months ago

Inquiry @maramesk @cerashdan

The model is alright, but it's not the most accurate: It sometimes captures extra characters. We have the option of training it on Bahraini cars. Our question is: Is that a priority? There are two key points to consider here

Should we focus some of our efforts on training the model now? Or should we come back to it at a later time when we've made more the other consumers (for the other violations)?

P.s. After you respond we will close this issue, since the task itself is complete. Just leaving it opened to discuss this point.

maramesk commented 7 months ago

@mohammedalsaeed-uob The returning students from the Amakin Challenge (currently working in BQA) have implemented accurate plate detection on Bahraini plate numbers, reach out to them to check their approach. They did not have to train their own model on Bahraini plates and I don't think its feasible for you to do so either.

mohammedalsaeed-uob commented 6 months ago

@maramesk Will do, thank you.

cerashdan commented 6 months ago

Adding few more pointers to guide you:

  1. When solving computer vision problems, think about your scene and try to eliminate unnecessary information. If you have a scene with many cars, try the following:

Using textract for every frame is unpractical as you are processing a video. This problem could easily be solved using ML approaches running on the consumer itself.

cerashdan commented 6 months ago

Automatic License/Number Plate Recognition (ANPR/ALPR) is a solved problem in Computer Vision, have a look at:

https://pyimagesearch.com/2020/09/21/opencv-automatic-license-number-plate-recognition-anpr-with-python/

More specifically this section: Lines 30 and 31 perform a blackhat morphological operation to reveal dark characters (letters, digits, and symbols) against light backgrounds (the license plate itself). As you can see, our kernel has a rectangular shape of 13 pixels wide x 5 pixels tall, which corresponds to the shape of a typical international license plate

Screenshot 2024-05-05 133842

This blog post above, shows you how to solve this problem purely using Computer Vision approaches without using ML Models/Training.

mohammedalsaeed-uob commented 6 months ago

@cerashdan Thank you for sharing these invaluable pointers and resources. I would like to point out that we are not using Textract on every frame, so no need to worry about that. After adjusting the code, it generally works much better now. Thank you once again.

mohammedalsaeed-uob commented 6 months ago

Currently migrating our functions and code to SST/CDK per the following: -edit lambda to get queue URL on stack creation (husain) -edit lambda to get permissions with iam role (husain) ✅ -create ec2 /computer stack (mohammed) -create ssm/run command and userdata (mohammed) -edit S3 notification to trigger correct lambda (husain)✅

then we can close this issue.

HusainAdel commented 6 months ago

87 and #88 branches for dyanamo, s3, lambda functions