How to use image OCR for videos? - python

Currently I am working on automatic number plate recognition system. I have used yolov7 for number plate detection and Text detection facility from Google vision API. I have tested the whole system with test images. Now I am willing to develop the system to detect and read number plates in video sources. I could do the detection part for the video and where I am stuck is using the OCR for the detected bound box in the video.
For images, I first apply the trained YOLOv7 model and extract the number plate and save the detected number plate as a cropped part from the original image in the directory. And then the OCR is applied for that cropped part(Number Plate) and the text is read.
Test Sample:
NP detection:
Detected NP: (OCR is applied to this cropped image)
Detected Text:
I could detect the number plates from the videos but could not find a way to freeze the frame where a number plate is detected and apply ocr or any other way to read the number plate.
Is there a way to achieve this? any help would be highly appreciated.

Try getting the coordinates of the bounding box from each frame where the bounding box is appeared and apply OCR.

Related

Cropping license plate based on blue sides

I'm currently working on license plate recognition with OpenCV and Tesseract.
The process is: search for rectangles in the image and search for the license plate. Get the contours, crop it, preprocess and after, analyze the characters.
The code is actually giving accurate results with traineddata but I have a problem with the detection of the license plate if something (even so little) is on the contour like in this picture:
So I thought about another way to do that: every plate in my country has two blue side bars. If I can detect them (two rectangles placed at a specific distance between each other), I can just crop and work on that. Less work for all the preprocessing and a more accurate result.
With the inrange method i obtained this:
But now I'm blocked and i don't actually know what to do.

How to Crop face and its parts?

I am building a face remake application from where the user remakes face by scrolling through different facial parts to make a face (basically, mix-matching eyes, nose, lips of some other person), until now I wrote an algorithm that divides the facial parts like eyes, nose from the image using Python's Dlib and OpenCv, but due to images being ill-captured facial features cropped aren't aligned. So when I create a database of eyes, nose, lips, and face, while remaking they aren't gonna look like a face when placed at their position.
This is the Original Image
These are the Eyes(Titled)
The Nose Cropped(tilted)
And Lips(tilted)
This image is what I ended up to extract just the face part(NEED ALTERNATIVE IDEA FOR THIS (%)
So my plan was to use this last image as the base for remaking the face.
To tackle the tilting, I applied the face alignment algorithm so that when I crop the eyes in a rectangle image is perfectly straight. But this is what I am getting:
The face is straight but the image being tilted the pockets of black color are added around it, now as this is unavoidable, I NEED HELP REGARDING, HOW CAN I PREPARE THE FACE WITH NO FACIAL PARTS?
NOTES:
1.) Image cropping should not crop out any part of the face.
2.) Thought of using Grabcut to separate face and background, but validating nearly 10,000 images, I need a higher accuracy module, Or would Grabcut be fine(NEED SUGGESTION)?
Dont mind the smudge, but this is somewhat I need the output from the Algorithm

OCR on images using python and opencv

I am a newbie to computer vision, image processing and OCR. As a part of task, i need to perform the OCR on attached emails. However, the problem is ROI is not constant in all images. For example, in all images we need to extract the information related with patient Yadav.
This needs to be achieved in Python and OpenCV. Please help. I have already tried the approach as given below:
Change DPI
Grayscale
Binarize
However, facing the problem with layout or zone analysis.
Thanks for help.
Welcome to the computer vision world.
I think you're not understanding your problem well enough. Just trying something and check whether it work will never work.
At first read how tesseract (OCR engine) do to improve their accuracy at https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality
Ok, then what make OCR do not work on your data. As you can see your data is clean, and there is nearly none of noise. So it is the border of printed email (as "ROI" in your question) does not correctly line up.
So have can we make the ROI line up correctly . we could use some perspective transformation. i took an example from https://www.pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/
So how can we perform perspective transformation. We have to find the 4 corners of the ROI and move it back to corners of the image. To find 4 corner of the ROI you could find some contours .
So here the summary, here is the steps.
1. Find the ROI (white color) using color segmentation
2. Find the contour which cover the ROI
3. Find 4 corners of the ROI's contour
4. Apply perspective transform
5. Run tesseract on transformed image
Hope that help

Decompose a Image into its character images

I am very new to image processing and try to build a OCR for specific font using opencv and Python.
I am able to reduce the image below:
to this:
I have already written a small neural network to deduce character images into its respective English characters. Can someone help me to crop the cropped B/W image further into small images with just the characters?
The one way I could think of is by moving pixel by pixel and stop when a black pixel occurs. Is there any other way?
I think you should try cv::blobDetector
https://www.learnopencv.com/blob-detection-using-opencv-python-c/
Or just cv::findcountours with CV_EXTERNAL flag:
http://docs.opencv.org/3.1.0/df/d0d/tutorial_find_contours.html

How to check the input image is matched with the cropped face pic or not?

I would like to check whether a given image is matched with a cropped face image. I tried to crop the face from the image using OpenCV Python. Now i want to check if the input image is a match with the cropped face or not. What methods can I use with OpenCV to achieve this?
For sufficiently small (and not scientifically accurate) purposes, you could use OpenCV's template matching.
Feature extraction and matching may give you more accurate results in many cases. Face detector comes in as a part of OpenCV. Face recognition, however, is a much larger problem altogether.

Categories