Is there any OCR that can be trained for new symbols? - image-processing

Is there any free/open source OCR available that can be trained for new symbols and can also output the coordinates of symbol found in the target image? I have read that tesseract OCR can be trained, but can it give me coordinates after OCR? any example? I need the code/steps to train a ocr using an image that contains one sybmol. There are around 20 symbols each in one image to be trained. and then use the trained OCR to detect those sybmols in the target image and if found, then give coordinates too.

You can train Tesseract to recognize new symbols. The hocr format contains the coordinates of the recognized words.
https://github.com/tesseract-ocr/tesseract/wiki/Training-Tesseract
http://vietocr.sourceforge.net/training.html
https://github.com/tesseract-ocr/tesseract/wiki/Command-Line-Usage#hocr-output

Related

How to configure a convolution network that maps sentences to a label?

I'd like to train a model which maps a sentence to a label (e.g. "Canon EOS 77D DSLR Camera" maps to a label "Digital Camera").
I understand that strings need to be converted to a vector first. I found an example of word2vec which does this.
I then found a separate example on how to build a convolution network.
That said, I don't understand how to put it all together. Given:
A text file containing: sentence,label
A word2vec trained against all sentences, labels
How do I parse the text file into vectors (taken from word2vec) and pass it into a convolution network for training?
Answering my own question:
Convert sentences, labels to vectors using Word2Vec: [example]
Use CnnSentenceDataSetIterator to feed training/test data into a convolution network using the aforementioned Word2Vec: [example]
There is also an example using ParagraphVectorsClassifier that does this without a convolution network.

using svmlight model file in opencv

I have been working on training pedestrian detection classifier based on HOG features. Presently I have done the followings:
a) Extracted HOG features of all files i.e. Positive and Negative and saved those features with label i.e. +1 for positive and -1 for negative in file.
b)downloaded svmlight, extracted binaries i.e. svm_learn, svm_classify.
c) passed the "training file" (features file) to svm_learn binary which produced a model file for me.
d) passed "test file" to svm_classify binary and got result in predictions file.
Now my question is that "What to do next and how?". i think i know that now i need to use that "model file" and not "predictions file" in openCV for detection of pedestrian in video but somewhere i read that openCV uses only 1 support vector but i got 295 SV, so how do i convert it into one proper format and use it and any further compulsory steps if any.
I do appreciate your kindness!
It is not true that OpenCV (presumably you are talking about CvSVM) uses only one support vector. As pointed out by QED, what OpenCV does do is to optimize a linear SVM down to one support vector. I think the idea here is that the support vectors define the classification margin, but to do the actual classification only the separating hyperplane is needed and that can be defined with one vector.
Since you have a svmlight model file, and CvSVM can't read that, you have the following options:
train a CvSVM and save the mode as a CvStatsModel file, that you can load tha tlater to get the support vecotrs.
write some code to convert an svmlight model file into a CvStatsModel file (but for this you have to understand both formats).
get source for svmlight, the bit that reaads the modelfile, and integrate it into your OpenCV application
You may use LIBSVM instead, but really you are then faced with the same problems as svmlight.
For ideas on how to convert the support vectors so you can use them with the HOG detector see Training custom SVM to use with HOGDescriptor in OpenCV

Library for SVM and ANN with graphical toolkit

Well Hello everybody. I am doing a project that consist in dectect objects using kinect and svm and ann machine learning. I want if it is posible to give the names of library for svm and ann with graphical tool because I want only to train ann with that library and save in .xml then load .xml with opencv!!
SVM is a classifier used to classify samples based upon their feature vectors. So, your task is to convert the images into feature vectors which can be used by SVM for its training and testing.
Ok, to create feature vector from your images there are several possibilites and i am going to mention some very common technique:
A very easy method is to create normalized hue-histogram of your each image. Let's say, you have created hue-histogram with 5-bins. So, based upon your image color there will be some values in these 5 bins. Lets say the values look like this { 0.32 0.56 0 0 0.12 }. So, now this is your one input vector with 5 dimensions (i.e. number of bins). You have to do the same procedure for all training samples and then you will do it for test image too.
Extract some feature from your input samples (e.g. by using SIFT, SURf) and then create there descriptor using SIFT/SURF. And, then you can use these descriptors as the input to your SVM for training.

How to train HOG and use my HOGDescriptor?

I want to training data and use HOG algorithm to detect pedestrian.
Now I can use defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); in opencv to detection, but the result is not very good to my testing video. So I want to do training use my database.
I have prepared 1000+ positive sample, and 1000+ negative samples. They are cropped to size 50 * 100, and I have do the list file.
And I have read some tutorials on the internet, they all so complex, sometimes abstruse. Most of them are analyze the source code and the algorithm of HOG. But with only less examples and simple anylize.
Some instruction show that libsvm\windows\svm-train.exe can be used to training, Can anyone gives an examples according to 1000+ 50*100 positive samples?
For example, like haartraing, we can do it from opencv, like haartraining.exe –a –b with some parameters, and get a *.xml as a result which will be used to people detection?
Or is there any other method to training, and detection?
I prefer to know how to use it and the detail procedures. As the detail algorithm, it is not important to me. I just want to implement it.
If anyone know about it, please give me some tips.
I provided some sample code and instructions to start training your own HOG descriptor using openCV:
See https://github.com/DaHoC/trainHOG/wiki/trainHOG-Tutorial.
The algorithm is indeed too complex to provide in short, the basic idea however is to:
Extract HOG features from negative and positive sample images of identical size and type.
Use the extracted feature vectors along with their respective classes to train a SVM classifier, in this step you can use the svm-train.exe with a generated file of the correct format containing the feature vectors and their classes (or directly include and address the libsvm library class in your sources).
The resulting SVM model and support vectors are calculated into a single descriptor vector that can be used with the openCV detector.
Best regards

train a classifer with SVM-light for object detection

I am working with SVM-light. I would like to use SVM-light to train a classifier for object detection. I figured out the syntax to start a training:
svm_learn example2/train_induction.dat example2/model
My problem: how can I build the "train_induction.dat" from a
set of positive and negative pictures?
There are two parts to this question:
What feature representation should I use for object detection in images with SVMs?
How do I create an SVM-light data file with (whatever feature representation)?
For an intro to the first question, see Wikipedia's outline. Bag of words models based on SIFT or sometimes SURF or HOG features are fairly standard.
For the second, it depends a lot on what language / libraries you want to use. The features can be extracted from the images using something like OpenCV, vlfeat, or many others. You can then convert those features to the SVM-light format as described on the SVM-light homepage (no anchors on that page; search for "The input file").
If you update with what language and library you want to use, we can give more specific advice.

Resources