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

OpenCV hmm text detection algorithm is not working on simple image

user1477
1#
user1477 Published in May 26, 2018, 9:40 pm

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;
fs.release();
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

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO