Recognise known object - findHomography and perspective Transform

asked 2013-08-08 19:48:44 -0500

swamynathan gravatar image

updated 2013-08-08 20:22:30 -0500

I'm trying to detect known object in real time using feature2d there is no proper trapezoid formed at output if i draw border using line or rectangle - All I get is random lines(mostly dots) changing irrespective of the presence of object inside camera frame.

The complete code is here

Now I changed detector, descriptor and matcher from above to

    FeatureDetector detector = FeatureDetector.create(FeatureDetector.FAST);
    DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
    DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);

I now get good-matches depending on condition

 for (int i = 0; i < descriptorRef.rows(); i++) {
        if (matchesList.get(i).distance <= (3 * min_dist)) {
                good_matches.addLast(matchesList.get(i));
            }
    }

THE logcat now is

Keypoints Size: 1x676 
KeypointsRef Size : 1x139
descriptor Size: 32x629
descriptorRef Size : 32x32
Matches Size: 1x32
matchesList Size: 32
LIST D MATCH -- Max dist : 447.1934814453125 -- Min dist : 100.0
good matches size: 5
gm from good_matches Size: 1x5
obj Size: 1x5
scene Size: 1x5
Calib3d.findHomography  hg Size: 3x3

Frame - 1

hg : [-1.946750073879795, -2.153719667711051, 161.7932939049003;
      -2.245372221173412, -2.194859343368184, 175.7583814286593;
      -0.01283591450941816, -0.01266823891952267, 0.9999999999999999]
obj_corners : [0, 0; 153, 0; 153, 94; 0, 94]
scene_corners : [161.79329, 175.75838; 141.15591, 174.06831; 157.10199, 173.61986; 213.06747, 160.14717]

Frame-2

hg : [-1.934167716139827, -4.236308808871488, 249.7027233816234;
      -0.8409584670694304, -1.643347407920087, 101.4526716763755;
      -0.007981402185299564, -0.01677063017280203, 1]
obj_corners : [0, 0; 153, 0; 153, 94; 0, 94]
scene_corners : [249.70273, 101.45267; 209.01646, 123.05411; 247.24049, 101.07324; 257.63394, 91.981918]

Frame-3

hg : [18.44625165513222, -30.49302758685548, 245.9935488915967;
       8.983047514459511, -15.26849377435921, 134.9835860140666;
       0.07275391289238894, -0.1212195797795232, 1]
obj_corners : [0, 0; 153, 0; 153, 94; 0, 94]
scene_corners : [245.99355, 134.98358; 252.92078, 124.42062; 274.09152, 100.6524; 252.08675, 125.08897]

Frame-4

hg : [2523.743444745383, -3436.790363876738, -6320.163263697045;
      1152.68745032164, -1181.519781694952, -18248.99783312392;
      10.26100642365376, -14.53251070681075, 1]
obj_corners : [0, 0; 153, 0; 153, 94; 0, 94]
scene_corners : [-6320.1631, -18248.998; 241.77501, 100.64852; 277.01508, 229.64558; 241.293, 94.730072]

the "obj_corners is equal to the reference image dimensions(153*94)"

but the "scene_corners is either negative or random and mostly all points are almost at the same location".

the findHomography hg value is sometimes negative

and the perspectiveTransform scene_corners is either negative or random and mostly all points are almost at the same location.

Is the problem with output of findHomography or perspectiveTransform?

edit retag flag offensive close merge delete