Ask Your Question

XCoder's profile - activity

2013-01-18 14:47:11 -0600 received badge  Nice Answer (source)
2012-08-23 06:30:30 -0600 commented answer Is there cvSetImageROI function in OpenCV on Android?

I have never tried gray scaling only ROI. Not really sure how it's done, but I've merged matrices together. You can extract your ROI's and do whatever you want with them, and then put them back together.

2012-08-17 03:09:12 -0600 answered a question Is there cvSetImageROI function in OpenCV on Android?

I Have yet to use OpenCV on android. And I'm not sure if it has a built in function. Anyway, I think this should work:

Mat normalImage;
Rect roi = new Rect(x, y, width, height);
Mat cropped = new Mat(normalImage, roi);

And if you want it as function then this might work:

private Mat croppMat(Mat normalImage, Rect roi)
    Mat cropped = new Mat(normalImage, roi);
    return cropped;

The usage of function I guess would be something like this:

myROIMat = croppMat(uncroppedImage, new Rect(x,y,width,height));
2012-08-09 03:09:38 -0600 commented question OpenCV with Qt support namedWindow crash

Try rolling back a version if you are using 2.4.2. The compiling part, at least for me, is always a very tricky thing to do.

2012-07-25 05:31:39 -0600 received badge  Citizen Patrol (source)
2012-07-25 05:31:34 -0600 received badge  Critic (source)
2012-07-24 06:44:14 -0600 received badge  Nice Answer (source)
2012-07-23 11:29:04 -0600 commented answer OpenCV & OpenCVSharp Setup/Installation

Just from experience, I couldn't compile a working OpenCV with VC++. I had the same thing about not supporting solution folders, I read that it was supported only in VS, so without changing anything compiled with VS and wola, I had a working version of openCV with TBB, Qt and CUDA. I'm actually really surprised now, when you said you were successful compiling with VC++. This compilation part always has been tricky :)

2012-07-23 07:37:46 -0600 commented answer OpenCV with Qt support namedWindow crash

Indeed I noticed, that your CUDA might not be properly configured, checked the attached text document in the rar file called "differences*.txt". In your file these parts probably are incorrect: //Path to a file. CUDASDKROOT_DIR:PATH=C:/NVIDIA/CUDA

//Specify 'virtual' PTX architectures to build PTX intermediate // code for CUDAARCHPTX:STRING=

It should be something like this //Specify 'virtual' PTX architectures to build PTX intermediate // code for CUDAARCHPTX:STRING=2.0

//Path to a file. CUDASDKROOT_DIR:PATH=C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/C

+What CUDA version are you using?

2012-07-23 04:48:05 -0600 answered a question Making a window full screen keeping aspect ratio

I'm not sure if this will work and I don't have Qt compiled at this moment but try something like this:


Without Qt, when I maximized the window, the image kept it's size and aspect ratio.

Check these two documentation about windows:

2012-07-23 04:19:59 -0600 answered a question OpenCV & OpenCVSharp Setup/Installation

Additionally when I first open OpenCV in VC++, I get a warning saying it doesn't support solution folder. Not sure if that makes a difference here.

First of all to compile OpenCV you have to use Full Visual Studio you can download it and use it for free for 90 days, that's enough to compile it and then you can use the compiled opencv in VC++ as well.

Have you added opencv build/install/bin and build/install/lib to your system environment path?

2012-07-23 04:14:37 -0600 commented question Bilinear sampling from a GpuMat

"Alternatively, I could rotate/scale the whole image and then crop an axis-aligned patch, but this seems less efficient." - This exactly what I'm doing in my project, it might not be the most efficient way to do it, but it takes less than 2 millisecond to execute on my computer while image being 640x480.

2012-07-23 04:02:51 -0600 answered a question How do FREAK\SIFT\SURF verify that two images are the same

Well, it isn't the best approach using those algorithms as face recognition. To some extent those algorithms could be used for face recognition, however I would predict them to be super slow and might sometimes give false positive matches or no matches at all, it would be better to use something like eigen faces or fisher faces, algorithms which are designed to do just that.

That's only for recognizing, but before face recognition you have to find the face in the image, for that you have to use something like cascade classifiers, in opencv you have already some Haar classifiers inside for detecting faces. Basically first step for you would be to detect faces.

Here are couple links to get you started with recognition:

When I made my face recognition application, the biggest help to understand and program it came from the first link, even though it's in old openCV.

2012-07-23 03:54:01 -0600 answered a question OpenCV with Qt support namedWindow crash

Well I'm not exactly sure what causes your problem, I compared my CmakeCache with yours, and it looks like you have compiled a lot of plugins inside Qt. This experiment might take a half a day :), but maybe try recompiling Qt with the configuration like in the installation documentation:

configure.exe -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools
              -no-qt3support -no-multimedia -no-ltcg

Check if your environment variable called QTDIR, and environment path pointing something similar to this:


Another thing I saw, your CUDA might not be working. By the way, what compiler were you using to compile OpenCV?

It might help you to compare those cmake files yourself, download notepad++ and install compare plugin, and here are my and your CMakeCache files and text document pointing out differences worth taking a deeper look into: cmakecaches.rar

Maybe try, to follow the instruction videos again in the installation documentation, maybe you missed something, anyway GOOD LUCK.

2012-07-20 10:37:54 -0600 received badge  Nice Answer (source)
2012-07-19 09:11:47 -0600 answered a question Paper form recognition

It's a pretty difficult task for a newbie and probably for experienced developer too. For text, I would suggest you to look into OCR (Optical Character Recognition). And maybe if you could provide a sample form, we would be able to suggest something further. One thing for sure if you want to recognize text take a look into OCR, here is a basic tutorial Be aware he is using old OpenCV version, but for understanding it's a good article.

For check boxes, if a user draws cross in it, you can use template matching.

Maybe it's even easier to find already made solution to scan documents and convert them to digital file. If you're up for challenge I encourage trying to accomplish this task by yourself

2012-07-16 09:31:00 -0600 commented question OpenCV with Qt support namedWindow crash

Can you please post whole CMAKE configuration? I compiled the openCV with Qt like two weeks ago, I remember I had some kind of problems too, not exactly like yours, but I fixed it by rolling back a version and changed something in cmake configuration, I should still have it I'll take a look.

2012-07-16 09:27:10 -0600 received badge  Autobiographer
2012-07-16 08:50:50 -0600 answered a question Need a working tutorial for installing opencv4android in windows 7 64bit

Did you check this one out, it should work regardless of what OS you have or even architecture:

2012-07-16 07:14:04 -0600 answered a question Could Opencv2.4.2 registrate images?

Well I'm not sure I understood exactly what you're up to. But this is how I find the homography of detected keypoints. It's more or less based on this OpenCV tutorial:

Only in my code I'm using Flann matcher instead of brute force, but you can use brute force as well if you wish, then, if you are using opencv I think 2.4 and up you have to change "BruteForceMatcher" to "BFMatcher" in your case it might be "BFMatcher matcher(HAMMING)" I'm not sure about the hamming part I know exactly that this works BFMatcher matcher(NORM_L1);

//-- Step 3: Matching descriptor vectors using FLANN matcher
  FlannBasedMatcher matcher;  
  std::vector< vector<DMatch>  > matches;
  matcher.knnMatch( descriptors_object, descriptors_scene, matches, 2 );    
  vector< DMatch > good_matches;

  for (size_t i = 0; i < matches.size(); ++i)
      if (matches[i].size() < 2)

      const DMatch &m1 = matches[i][0];
      const DMatch &m2 = matches[i][1];

      if(m1.distance <= nndrRatio * m2.distance)        

  //If there are at least 7 good matches, then object has been found
  if( (good_matches.size() >=7))
    cout << "OBJECT FOUND!" << endl;

    std::vector<Point2f> obj;
    std::vector<Point2f> scene;

    for( unsigned int i = 0; i < good_matches.size(); i++ )
        //-- Get the keypoints from the good matches
        obj.push_back( keypointsO[ good_matches[i].queryIdx ].pt );
        scene.push_back( keypointsS[ good_matches[i].trainIdx ].pt );

    Mat H = findHomography( obj, scene, CV_RANSAC );

    //-- Get the corners from the image_1 ( the object to be "detected" )
    std::vector<Point2f> obj_corners(4);
    obj_corners[0] = cvPoint(0,0); obj_corners[1] = cvPoint( objectP.cols, 0 );
    obj_corners[2] = cvPoint( objectP.cols, objectP.rows ); obj_corners[3] = cvPoint( 0, objectP.rows );
    std::vector<Point2f> scene_corners(4);

    perspectiveTransform( obj_corners, scene_corners, H);

    //-- Draw lines between the corners (the mapped object in the scene - image_2 ) 
    line( outImg, scene_corners[0] , scene_corners[1], color, 2 ); //TOP line
    line( outImg, scene_corners[1] , scene_corners[2], color, 2 );
    line( outImg, scene_corners[2] , scene_corners[3], color, 2 );
    line( outImg, scene_corners[3] , scene_corners[0] , color, 2 ); 
  cout << "OBJECT NOT FOUND" << endl;
2012-07-16 06:04:15 -0600 commented question Could Opencv2.4.2 registrate images?

What do you mean? You want to know how to extract the good matches and draw boundary around them? In simpler words, determine, whether the object was found in the scene or not?

2012-07-16 05:35:53 -0600 commented question 3rd party and static libs : error LNK2019 with MSVC 2010 32 bits

Well, why would you uncheck those two? I'm not sure, but I think the lib files are generated only when BUILD_ WITH STATIC CRT is checked. Were you able to compile before unchecking those two?

2012-07-15 09:24:14 -0600 received badge  Supporter (source)
2012-07-13 10:51:57 -0600 received badge  Nice Answer (source)
2012-07-13 10:37:15 -0600 received badge  Teacher (source)
2012-07-13 09:55:02 -0600 edited answer How to read directory with images by VideoCapture?

I had a similar need as you did, I solved the problem with boost filesystem library.

For file scanning with boost, it would look something like this:

int scanFiles( const path & directory, string filterFileType)
    int fileCount=0;
    if( exists( directory ) )
        directory_iterator end ;
        for( directory_iterator iter(directory) ; iter != end ; ++iter )
            if ( (is_regular_file( *iter ) && iter->path().extension().string() == filterFileType))
            cout << iter->path().filename().string() << endl ; //this is the one of scanned file names
    return fileCount;

Basically what that function does (at least in my app), returns the count of files with a specified extension. So scanFiles("labels", "png"); will return me the number of png files in directory labels.

While scanning you can return or update global Mat variable and use it to do your stuff.

But I don't think that OpenCV can scan through files natively.

2012-07-13 09:37:15 -0600 edited answer How to write Keypoints into document of txt

I would recommend using YML rather than txt, because with YML it will be much easier to access data afterwards.

To write in yml file your keypoints and descriptors use this:

 fileString = "keypoints.yml";
 cv::FileStorage fs(fileString, cv::FileStorage::WRITE);

 write(fs,"keyPointsSURF", keypointsSURF);              
 write(fs,"descriptorsSURF", descriptorsSURF);  

It's very simnple to access the data:"keypoints.yml", FileStorage::READ);
            read(fs["descriptorsSURF"], descriptorsSURF); 
            read(fs["keyPointsSURF"], keypointsSURF);   

The "read" command can be swapped with this too, I personally prefer the "read" method:

fs["descriptorsSURF"] >> descriptorsSURF;
fs["keyPointsSURF"] >> keypointsSURF;