Detection and recognition text from Tyres (python) - python-3.x

Hi i have bunch of images of tyres, we need to detect and recognize the text on the tyres,
here i am facing difficulties to detect the text, because the text and background of the tyre are same, i have tried with EAST text detector and yolo text detector ( without own data train ),
is there any better solutions to detect the text from these kind of background images
here i need to detect only the 10 digit serial number like "75R-0006884"
edit: pre processed image

Some preprocessing before passing the images in through a non-retrained deep network might help! Try binarizing/grayscaling the image and playing with those thresholds to see what gives maximum contrast.
But I gotta say, you might have to retrain an existing network to achieve good performance.

Related

Text/Image processing in Python

Brief introduction:
I'm trying to get certain texts from an image of a lot of texts.
By just thinking, there should be at least two ways to handle this problem:
One way is first segmenting the images by text areas — for example, train the neural network with a bunch of sample images that contain the sample texts, and then let the trained model locate corresponding text areas in the real image, then crop that area out from the image, save it — and secondly use, for instance, pytesseract to convert image to string.
The other way is to reverse the processes. First convert the image into strings, then train the neural network with sample real texts, then let the trained model find corresponding texts in texts converted from images.
So, my questions are listed below:
Can this problem be solved without training a neural network? Will it be more efficient than NN, in terms of time taken to run the program and accuracy of results?
Among the two methods above I wrote, which one is better, in terms of time taken to run the program and accuracy of results?
Any other experienced suggestions?
Additional background information if needed:
So, I have a number of groups of screenshots of different web pages, each of which has a lot of texts on it. And I want to extract certain paragraphs from that large volume of texts. The paragraphs I want to extract express similar things but under different contexts.
For example, on a large mixed online forum platform, many comments are made on different things, some on landscapes of mountains, some politics, some sciences, etc... As that platform cannot only have one page, there must be hundreds of pages where countless of users make their comments. Now I want to extract the comments on politics specifically from the entire forum, i.e. from all the pages that platform has. So I would use Python + Selenium to scrape the pages and save the screenshots. Now we need to go back to the questions asked above. What to do now?
Update:
Just a thought went by. Probably a NN trained by images that contain texts cannot give a very accurate location of wanted texts, as the NN might be only looking for arrangements of pixels instead of the words, or even meaning, that compose the sentences or paragraphs. So maybe the second method, text processing, may be better in this case? (like NLP?)
So, you decided not to parse text, but save it as an image and then detect text from this image.
Text -> Image -> Text
It is worst scenario for parsing webpages.
While dealing with OCR you must expect many problems, such as:
High CPU consumption;
Different fonts;
Hidden elements (like 'See full text');
And the main one - you can't OCR with 100% accuracy.
If you try to create common parser, that should crawl only required text from any page given without any "garbage" - it is almost utopic idea.
As far as i know, something about this is 'HTML Readability' technology (Browsers like Safari and Firefox uses it). But how it will work with forums i can't say. Forums is very special format of pages.

How to create your own dataset with Python for Deep Learning (Keras / Tensorflow) in Road Line detection

I am given the task to find road lines on an image for a class project.
I want to start writing Convolutional Neural Network to do the task, but I am not sure how to create a dataset.
Let's say I have to find lines on this image (originally I have been given arround 1000 images of traffic where road lines could be detected):
To be able to do that I have to create a dataset. What to do? Should I take some random images and cut regions where I can see the road lines? What size should the training images be? How would I label the line to stand out from the background?
Also, I presume cutting lines from an image is an okay way when the line is segmented, but I cannot do that for a full line, can I?
It depends a lot on the assignment details. What does "find road lines on an image" mean?
Depending on the answer to the above question, you could divide the image in a 4x4 or 5x5 grid and try to find the cells on that grid that contain road lines.
To accomplish that you could manually label some of the cells (you might want to create a small GUI to facilitate this part) and train your CNN with the labeled data.

Small object detection using deep learning

I have to count the number of checked and unchecked boxes in a paper sheet.The size of the checkbox is very small.Which will be the best object detection algorithms for this or any other approach.I have some images on which I can do customized training.Note my task is only object detection & recognition not localization.One approach is to extract the portion of the image which is containing the check boxes & apply contours to classify which is checked or unchecked.My question how I will extract that portion of an image which is containing scanned document or sheet.
I think you have to use Convolutional Neural Network it is the best object detection algorithm that I have ever used, although the matter of small objects this algorithm is so good at identifying small hidden patterns so, I think its work best for you, just try it.

Haar Cascade Training for Parts of a Known Object

I am working on a project where I am trying to extract key features of a bicycle from an overall image. I am currently investigating the use of Haar Cascades to train my computer to find certain regions of interest from said bicycles, e.g. the pedal-sprocket, seat, handle-bars. Then I will extract local features from these sub regions accordingly. The purpose is to create an overall descriptor of a particular bicycle so I can try to match it throughout a sample set of images of other bicycles.
My questions are as follows: Can I train a Haar classifier to look for a sub-component of an overall object? For example, say I want to look for the handlebars on a bicycle. How should I design the training? Should I detect the bicycle first, and then detect the handlebars within the overall bicycle region (Similar to detecting the eyes within a face in terms of facial recognition)? Since I know beforehand that all my images will contain a picture of a bicycle, I'm not sure if there is any point in detecting the bicycle to begin with and then looking for sub components.
In terms of training a Haar cascade and creating an XML that I can use (in OpenCV 3.1 and Python 3.6), could I just set up the positive and negative images with pictures of bicycles and no bicycles respectively? With the difference being that I isolate the particular area of interest by cropping the image appropriately each time (e.g. where the handlebars are)?
Also open to any recommendations about how others might solve the general problem of extracting key features for object matching. This is just one approach I am currently investigating. Thanks!

Reducing / Enhancing known features in an image

I am microbiology student new to computer vision, so any help will be extremely appreciated.
This question involves microscope images that I am trying to analyze. The goal I am trying to accomplish is to count bacteria in an image but I need to pre-process the image first to enhance any bacteria that are not fluorescing very brightly. I have thought about using several different techniques like enhancing the contrast or sharpening the image but it isn't exactly what I need.
I want to reduce the noise(black spaces) to 0's on the RBG scale and enhance the green spaces. I originally was writing a for loop in OpenCV with threshold limits to change each pixel but I know that there is a better way.
Here is an example that I did in photo shop of the original image vs what I want.
Original Image and enhanced Image.
I need to learn to do this in a python environment so that I can automate this process. As I said I am new but I am familiar with python's OpenCV, mahotas, numpy etc. so I am not exactly attached to a particular package. I am also very new to these techniques so I am open to even if you just point me in the right direction.
Thanks!
You can have a look at histogram equalization. This would emphasize the green and reduce the black range. There is an OpenCV tutorial here. Afterwards you can experiment with different thresholding mechanisms that best yields the bacteria.
Use TensorFlow:
create your own dataset with images of bacteria and their positions stored in accompanying text files (the bigger the dataset the better).
Create a positive and negative set of images
update default TensorFlow example with your images
make sure you have a bunch of convolution layers.
train and test.
TensorFlow is perfect for such tasks and you don't need to worry about different intensity levels.
I initially tried histogram equalization but did not get the desired results. So I used adaptive threshold using the mean filter:
th = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 3, 2)
Then I applied the median filter:
median = cv2.medianBlur(th, 5)
Finally I applied morphological closing with the ellipse kernel:
k1 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
dilate = cv2.morphologyEx(median, cv2.MORPH_CLOSE, k1, 3)
THIS PAGE will help you modify this result however you want.

Resources