Ask Your Question

Grigory Velmozhin's profile - activity

2014-06-28 04:51:36 -0600 received badge  Student (source)
2014-06-27 12:12:35 -0600 asked a question Different recognition results by SURF on CUDA and OpenCL

I use both three SURF algorithm implementation in the program. When I conducted the tests I noticed that the algorithm using OpenCL detect much smaller objects in the image than that on CUDA. What may be the reason? Anybody notice like that? Implementation of algorithms written by different people, can differ in the implementation of the algorithms? P.S. All parameters are the same sets of reference images too. I can provide code samples and processing results.

2014-05-19 05:55:56 -0600 asked a question Russian books or articles about Viola Jones & AdaBoost algorithm

I apologize for the issue is not explicitly linked OpenCV. For my thesis I need to complete mathematical description of these algorithms in the literature in Russian. If anyone met similar would be very grateful. I can also share a set of books and articles (~ 4GB) on the topic of computer vision.

2014-04-11 06:54:08 -0600 asked a question Manual selection of OpenCL adapter

In my configuration, I have a few (2-8) ATI adapters. From config specific DeviceId know which I need to connect to. How can I do it in code?

2013-07-24 04:22:11 -0600 commented answer Strange assert in surf_gpu.cpp

Thanks for the proof. Then maybe we should change the line 131 to const int min_margin = 11;

2013-07-24 02:35:33 -0600 commented answer Strange assert in surf_gpu.cpp

I solved the problem with the small image size. But why line 131 returns always 11? =)

2013-07-23 14:46:21 -0600 asked a question Strange assert in surf_gpu.cpp

I get very strange asserts in my code, changing the size of the input image.

        CV_Assert(img_rows - min_size >= 0);
        CV_Assert(img_cols - min_size >= 0);

       or

        CV_Assert(layer_rows - 2 * min_margin > 0);
        CV_Assert(layer_cols - 2 * min_margin > 0);

Line 125 surf_gpu.cpp opencv 2.4.5

I decided to read the code and came across a black magic

Code (line 131):

const int min_margin = ((calcSize((surf_.nOctaves - 1), 2) >> 1) >> (surf_.nOctaves - 1)) + 1;

gives always 11

proof:

image description

this is bug or not?

2013-04-24 06:01:53 -0600 commented answer Bug or not bug? knnMatch from BruteForceMatcher_GPU

Thank you for help! It work!

2013-04-23 08:29:34 -0600 commented answer Bug or not bug? knnMatch from BruteForceMatcher_GPU

Thank you for answer! It`s cool! But this check did not work

H = findHomography( obj, scene, CV_RANSAC); perspectiveTransform( objs_corners, scene_corners, H); bool falseDetect = isSmallAngle(scene_corners); if(!falseDetect) { cout<<"DETECT "<<baseImagesNames[i]<<endl; }

My function gives a result for the corners of the result border:

9.68458 7.70105 6.36017 4.37667 (in degrees) if I set MIN_HESSIAN to 400 (241 matches) and 90 90 90 90 if I set MIN_HESSIAN to 1500 (25 matches) But on the CPU with MIN_HESSIAN 400, all works fine

2013-04-23 08:21:53 -0600 received badge  Scholar (source)
2013-04-23 08:21:46 -0600 received badge  Supporter (source)
2013-04-23 08:01:18 -0600 commented question Bug or not bug? knnMatch from BruteForceMatcher_GPU

Hmm.. I'll try it. How can I download descriptors from ORB_GPU? In my code I used surf.downloadDescriptors(descriptors_test_GPU, descriptors_test_CPU)

2013-04-23 06:45:26 -0600 received badge  Editor (source)
2013-04-23 06:44:07 -0600 asked a question Bug or not bug? knnMatch from BruteForceMatcher_GPU

There is a problem of the match decriptors on the GPU.

OpenCV 2.4.5, CUDA 5.0

I tried to transfer my SURF matcher from the CPU to the GPU and got such a strange result. I use knnMatch and findHomography + perspectiveTransform together with my function, which checks the corners of the bounding box for the result to more precision.

GPU part:

const int baseImagesSize = baseImages.size();
SURF_GPU surf(1500);
surf.extended = false; 

GpuMat keypoints_test_GPU, descriptors_test_GPU;
surf(frame, GpuMat(), keypoints_test_GPU, descriptors_test_GPU);
vector<float> descriptors_test_CPU;
surf.downloadDescriptors(descriptors_test_GPU, descriptors_test_CPU);
Mat descriptors_test_CPU_Mat(descriptors_test_CPU);
vector<Point2f> objs_corners(4);
BruteForceMatcher_GPU< L2<float> > matcher;

vector<KeyPoint> keypoints_test_CPU;
surf.downloadKeypoints(keypoints_test_GPU, keypoints_test_CPU);

for (int i = 0; i < baseImagesSize; ++i)
{
    //Get the corners from the object
    objs_corners[0] = cvPoint(0,0);
    objs_corners[1] = cvPoint( baseImages[i].cols, 0 );
    objs_corners[2] = cvPoint( baseImages[i].cols, baseImages[i].rows );
    objs_corners[3] = cvPoint( 0, baseImages[i].rows );

    //cout<<endl<<objs_corners[0]<<" "<<objs_corners[1]<<" "<<objs_corners[2]<<" "<<objs_corners[3]<<endl;
    GpuMat keypoints_tmp_GPU, descriptors_tmp_GPU;
    surf(baseImages[i], GpuMat(), keypoints_tmp_GPU, descriptors_tmp_GPU);
    GpuMat trainIdx, distance;

    vector< vector<DMatch> > matches;
    matcher.knnMatch(descriptors_test_GPU, descriptors_tmp_GPU, matches, 2);
    vector<KeyPoint> keypoints_tmp_CPU;

    surf.downloadKeypoints(keypoints_tmp_GPU, keypoints_tmp_CPU);
    std::vector<DMatch > good_matches;

    for(int k = 0; k < min(descriptors_test_CPU_Mat.rows-1,(int) matches.size()); k++) //THIS LOOP IS SENSITIVE TO SEGFAULTS
    {
        if((matches[k][0].distance < 0.6*(matches[k][1].distance)) && ((int) matches[k].size()<=2 && (int) matches[k].size()>0))
        {
            good_matches.push_back(matches[k][0]);
        }
    }

    vector<Point2f> obj;
    vector<Point2f> scene;
    vector<Point2f> scene_corners(4);
    Mat H;
    Mat img (baseImages[i]), img_matches, frame_cpu (frame);
    std::ostringstream o_stream;
    o_stream<<"Logo_save/"<<baseImagesNames[i];
    try
    {
        drawMatches( img, keypoints_tmp_CPU, frame_cpu, keypoints_test_CPU, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
        imwrite(o_stream.str(),img_matches);
    }
    catch(...)
    {
        cout<<"Error in drawMatches name: "<< baseImagesNames[i]<<endl;
    }

    if (good_matches.size() >= 4)
    {
        for( int k = 0; k < good_matches.size(); k++ )
        {
            //Get the keypoints from the good matches
            obj.push_back( (keypoints_tmp_CPU)[ good_matches[k].queryIdx ].pt );
            scene.push_back( keypoints_test_CPU[ good_matches[k].trainIdx ].pt );
        }

        cout<<good_matches.size()<<" "<<baseImagesNames[i]<<endl;
        H = findHomography( obj, scene, CV_RANSAC);
        perspectiveTransform( objs_corners, scene_corners, H);
        bool falseDetect = isSmallAngle(scene_corners);
        //cout<< falseDetect<< endl;
        if(!falseDetect)
        {
            cout<<"DETECT "<<baseImagesNames[i]<<endl;
        }


    }

    matcher.clear();
}

Bad result on GPU (MIN_HESSIAN==1500): surf(1500)

Bad result on GPU (MIN_HESSIAN==400): surf(400)

CPU part:

SurfFeatureDetector detector( MIN_HESSIAN );//MIN_HESSIAN==400
const int baseImagesSize = baseImages.size();
vector< vector<KeyPoint> > kp_objects(baseImagesSize);

//Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
vector<Mat> des_objects(baseImagesSize);
FlannBasedMatcher matcher;
//namedWindow("SURF feature detector");
vector< vector<Point2f> > objs_corners(baseImagesSize,vector<Point2f>(4));

for (int i = 0; i < baseImagesSize; ++i)
{
    detector.detect(baseImages[i], kp_objects[i]);
    extractor.compute(baseImages[i], kp_objects[i], des_objects[i]);

    //Get the corners from the object
    (objs_corners[i])[0] = cvPoint(0,0);
    (objs_corners[i])[1] = cvPoint( baseImages[i].cols, 0 );
    (objs_corners[i])[2] = cvPoint( baseImages[i].cols, baseImages[i].rows );
    (objs_corners[i])[3] = cvPoint( 0, baseImages[i].rows );
}

Mat des_image;
std::vector<KeyPoint> kp_image;
Mat image;
cvtColor(frame, image, CV_RGB2GRAY);
detector.detect( image, kp_image );
extractor.compute( image, kp_image, des_image );

for (int i = 0; i < baseImagesSize; ++i)
{
    Mat img_matches;
    std ...
(more)
2013-04-04 03:31:00 -0600 asked a question Create Haar classifier using CUDA

Hi! I have a video card Tesla k20c, can I quickly get a cascade using GPU computing?