Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:32:37+00:00 2026-05-31T01:32:37+00:00

I’m trying to create a simple OCR application with SVM, openCV, C++ and Visual

  • 0

I’m trying to create a simple OCR application with SVM, openCV, C++ and Visual Studio 2008 (mfc app).

My training samples are binary images of machine-printed digits (0-9). I want to use DAGSVM for this multi-class problem. So I need to create 45 SVMs, each of which is the SVM of 2 class (SVM(0,1), SVM(0,2)… SVM(8,9)).

Here’s how things are going:

SVM’s parameters:

CvSVMParams params;
params.svm_type    = CvSVM::C_SVC;
params.kernel_type = CvSVM::LINEAR;
params.term_crit   = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

Data of training images of class i are stored in matrix trainData[i] (each row is the pixels of a 28×28 image, which means the matrix has 784 cols).
When training each SVM, I create 2 matrix called curTrainData & curTrainLabel.

for (int i = 0; i < 9; i++)
    for (int j = i+1; j < 10; j++)
    {
        curTrainData.create(trainData[i].rows + trainData[j].rows, 784, CV_32FC1);
        curTrainLabel.create(curTrainData.rows, 1, CV_32FC1);

        // merge 2 matrix: trainData[i] & trainData[j]
        for (int k = 0; k < trainData[i].rows; k++)
        {
            curTrainLabel.at<float>(k, 0) = 1.0; // class of digit i
            for (int l = 0; l < 784; l++)
                curTrainData.at<float>(k,l) = trainData[i].at<float>(k,l);
        }
        for (int k = 0; k < trainData[j].rows; k++)
        {
            curTrainLabel.at<float>(k + trainData[i].rows, 0) = -1.0; // class of digit j
            for (int l = 0; l < 784; l++)
            curTrainData.at<float>(k + trainData[i].rows,l) = trainData[j].at<float>(k,l);
        }

        svms[i][j].train(curTrainData, curTrainLabel, Mat(), Mat(), params);
    }

I got error at the call svms[i][j].train…. The full error is:

Unhandled exception at 0x75b5d36f in svm.exe: Microsoft C++ exception: cv::Exception at memory location 0x0022af8c..

To tell the truth I don’t fully understand SVM implemented in openCV and I can’t find any example of them working with objects in images.

I’m really grateful if someone can tell me what is (are) wrong 🙁

Update 09/03:
I had mistaken. The error comes from:

str.Format(_T("Results\trained_%d_%d.xml"), i, j);  
svms[i][j].save(CT2A(str));

str is a CString variable.

It remains even if I change to:

svms[i][j].save("Results\trained.xml");

I’ve created the folder Results and others files are written well into it (files for methods fopen(), imwrite()…). I don’t know why I can’t add the folder when it comes to this save method of svm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:32:38+00:00Added an answer on May 31, 2026 at 1:32 am

    If you use backslash “\”, you have to put “\\” instead (or you can use a frontslash “/”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.