Ask Your Question

mgautam's profile - activity

2017-09-03 17:03:10 -0600 received badge  Popular Question (source)
2013-10-17 07:57:03 -0600 asked a question OpenCV GUI Application Hangs

My OpenCV GUI application built in QT Creator 5.1 VSC2012 (64 bits) hangs at this contour line code - itc=contours.erase(itc). Here is the complete codeblock where this code line appears:

   vector<vector<Point> >::iterator itc= contours.begin();
   vector<RotatedRect> rects;
    //Remove patch that are no inside limits of aspect ratio and area.
    while (itc!=contours.end()) {
        //Create bounding rect of object
        RotatedRect mr= minAreaRect(Mat(*itc));
        if( !verifySizes(mr)){
            itc= contours.erase(itc);
            qDebug()<<"Hangs!!";
        }else{
            ++itc;
            rects.push_back(mr);
        }
    }
2013-09-28 22:37:05 -0600 asked a question How to train OCR to recognize characters?

I want too know how can I modify the following code to train OCR to recognize 26 characters instead of 20 characters and storing that information in OCR.xml file.

Extra characters that are now included are: A,E,I,O,U,Q.

Also what are TrainingDataF5, TrainingDataF10, TrainingDataF15 and TrainingDataF20? What is their use? Do they work on same character image size of 20x20?

#include <cv.h>
#include <highgui.h>
#include <cvaux.h>

#include "OCR.h"

#include <iostream>
#include <vector>

using namespace std;
using namespace cv;

const int numFilesChars[]={30, 30, 30, 30,30,30, 35, 40, 42, 41, 42, 33, 30, 31, 49, 44, 30, 24, 21, 20, 34, 9, 10, 3, 11, 3, 15, 4, 9, 12, 10, 21, 18, 8, 15, 7};

int main ( int argc, char** argv )
{
    cout << "OpenCV Training OCR Automatic Number Plate Recognition\n";
    cout << "\n";

    char* path;

    //Check if user specify image to process
    if(argc >= 1 )
    {
        path= argv[1];

    }else{
        cout << "Usage:\n" << argv[0] << " <path to chars folders files> \n";
        return 0;
    }        

    Mat classes;
    Mat trainingDataf5;
    Mat trainingDataf10;
    Mat trainingDataf15;
    Mat trainingDataf20;

    vector<int> trainingLabels;
    OCR ocr;

    for(int i=0; i< OCR::numCharacters; i++)
    {
        int numFiles=numFilesChars[i];
        for(int j=0; j< numFiles; j++){
            cout << "Character "<< OCR::strCharacters[i] << " file: " << j << "\n";
            stringstream ss(stringstream::in | stringstream::out);
            ss << path << OCR::strCharacters[i] << "/" << j << ".jpg";
            Mat img=imread(ss.str(), 0);
            Mat f5=ocr.features(img, 5);
            Mat f10=ocr.features(img, 10);
            Mat f15=ocr.features(img, 15);
            Mat f20=ocr.features(img, 20);

            trainingDataf5.push_back(f5);
            trainingDataf10.push_back(f10);
            trainingDataf15.push_back(f15);
            trainingDataf20.push_back(f20);
            trainingLabels.push_back(i);
        }
    }


    trainingDataf5.convertTo(trainingDataf5, CV_32FC1);
    trainingDataf10.convertTo(trainingDataf10, CV_32FC1);
    trainingDataf15.convertTo(trainingDataf15, CV_32FC1);
    trainingDataf20.convertTo(trainingDataf20, CV_32FC1);
    Mat(trainingLabels).copyTo(classes);

    FileStorage fs("OCR.xml", FileStorage::WRITE);
    fs << "TrainingDataF5" << trainingDataf5;
    fs << "TrainingDataF10" << trainingDataf10;
    fs << "TrainingDataF15" << trainingDataf15;
    fs << "TrainingDataF20" << trainingDataf20;
    fs << "classes" << classes;
    fs.release();

    return 0;
}
2013-03-27 08:08:06 -0600 asked a question Unable to build OpenCV project with CMake

I'm trying to build an opencv project using cmake , but using both the GUI utility and the command line tool , but keep having the same error popping up.

CMake Warning at cmake/modules/FindOpenCV.cmake:160 (message):
  Found OpenCV 2.4.3 Windows Super Pack but it has not binaries compatible
  with your configuration.
      You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
  Call Stack (most recent call first):
  CMakeLists.txt:48 (FIND_PACKAGE)

Please help.

2013-03-26 03:47:18 -0600 commented answer Should I download Intel IPP 7.1?

Thanks.for the help.

2013-03-25 17:57:36 -0600 asked a question Should I download Intel IPP 7.1?

I want to know whether I should download Intel IPP 7.1 as it is available for only 30 days?