Home OpenCV hmm text detection algorithm is not working on simple image
Reply: 1

OpenCV hmm text detection algorithm is not working on simple image

Alex Zhukovskiy
Alex Zhukovskiy Published in 2018-02-13 16:05:37Z

I'm trying to write simple program to recognize some simple patterns. It works fine with tesseract, but for some reason it doesn't work with Hmm. Here is sample code:

std::string image_path = "assets/ubuntu.png";
std::string filename = "assets/OCRHMM_transitions_table.xml";
auto image_source = cv::imread(image_path);
cv::Mat image;
cv::cvtColor(image_source, image, 6);
cv::Mat transition_p;
cv::FileStorage fs(filename, cv::FileStorage::READ);
fs["transition_probabilities"] >> transition_p;
cv::Mat emission_p = cv::Mat::eye(62,62,CV_64FC1);
std::string voc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
auto classifier = cv::text::loadOCRHMMClassifierNM("assets/OCRHMM_knn_model_data.xml.gz");
auto ocr = cv::text::OCRHMMDecoder::create(classifier, voc, transition_p, emission_p);

std::string output;
std::vector<cv::Rect> boxes;
std::vector<std::string> words;
std::vector<float> confidences;
ocr.get()->run(image, output, &boxes, &words, &confidences);
std::cout << output;

and sample image:

Expected output: uBuntu

Actual output: m

What's wrong with this code? I just tried to adopt demo sample.

Here is OCRHMM_transitions_table.xml and OCRHMM_knn_model_data.xml.gz which was used (I actually took them from this sample too).

OpenCV version 3.4.0

mw-b Reply to 2018-02-13 16:49:51Z

Cascade classfier look like not trained enough.Why don't you use another classfier?It detects u half of m

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310067 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO