OpenCV Handwriting Selection quiz (b) Character recognition

Source: Internet
Author: User
Tags svm

OpenCV Handwriting Selection quiz (b) Character recognition

The choice question basically only need to recognize ABCD and empty five content, theoretically should recognize the rate is higher, the identification code refers to the online search code, because the reference URL is more, now also can not clear is the reference where the code, here does not thank each.

Basic steps:

First, the recognition function accepts the gray image of General 64x64;

Second, binary and inverse color for white on black background;

Three, find the minimum bounding rectangle of the character, and the size is normalized to 32x32;

Four, calculate the hog characteristic of the image;

Five, the Hog feature is identified by SVM classifier to determine whether the current image belongs to ABCD or blank;

The entire identification code is still relatively simple. This is due to the opencv of the classifier, in addition to the image preprocessing code, the actual identification code only a few lines;

Part of the Code

CVSVM SVM;intsvm_inited =0;intSvm_init (Char*data_filename) {svm.load (data_filename);//"Hog_svm_data.xml"svm_inited =1; return 0;}//intSvm_recognition (iplimage*image) {    if(svm_inited! =1){        return-1; }    //pretreatmentiplimage* test_img = Cvcreateimage (Cvsize ( +, +),8,1); Preproc_img (image, test_img);//processing for white on black background, and size normalization#ifdef _win32 cvshowimage ("Image", test_img); Cvwaitkey (0);#endif    //Feature ExtractionHogdescriptor *hog =NewHogdescriptor (Cvsize ( +, +), Cvsize ( -, -), Cvsize (8,8), Cvsize (8,8),9); Vector<float> descriptors;//Store ResultsHog->compute (test_img, descriptors, Size (1,1), Size (0,0));//Hog Feature CalculationCvreleaseimage (&AMP;TEST_IMG);//free up memory by releasing unwanted images//generate the feature data matrix to be detectedCvmat * Mat_samples = Cvcreatemat (1, Descriptors.size (), CV_32FC1); intn =0;  for(vector<float>::iterator iter = Descriptors.begin (); Iter! = Descriptors.end (); iter++) {Cvmset (Mat_samples,0, N, *ITER); N++; }    //Identify    intret = svm.predict (mat_samples);//Test ResultsCvreleasemat (&mat_samples); returnret;}

OpenCV Handwriting Selection quiz (b) Character recognition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.