Features Matching: converting KeyPoint into CvPoint32f

1,049 views
Skip to first unread message

Ljupce

unread,
Dec 21, 2011, 9:07:20 AM12/21/11
to javacv
Hi,

I'm trying to adapt a code written using C++ API of OpenCV to an
Android phone. I matched features from two different frames which
gives me source KeyPoint destination KeyPoint and DMatch. In order to
be able to use cvFindHomography, I have to convert them into two
CvPoint32f objects. In my C++ version, I used the following code to do
that:

Mat VideoStabilizer::computeTransformationMatrix(vector<KeyPoint>&
src_key, vector<KeyPoint>& dst_key, vector<DMatch>& matches){

std::vector<Point2f> src;
std::vector<Point2f> dst;

for(int i=0; i < (int)matches.size(); i++)
{
src.push_back( src_key[ matches[i].queryIdx ].pt );
<--- this line
dst.push_back( dst_key[ matches[i].trainIdx ].pt );
<--- this line
}

Mat H = findHomography( src, dst, CV_RANSAC);
return H;
}

But with JavaCV I couldn't figure it out how the two marked line could
be expressed.

Could you help me with that?

Thanks a lot

Ljupce

ChrisP

unread,
Dec 21, 2011, 10:00:38 AM12/21/11
to javacv
I think something like this is done in ObjectFinder.java:

http://code.google.com/p/javacv/source/browse/trunk/javacv/src/name/audet/samuel/javacv/ObjectFinder.java?r=46#254

I don't know if this helps you but I think for using cvFindHomography
in JavaCV you need two cvMat objects at the end. I have done something
similar. Not sure however if this works correctly:

ArrayList<CvPoint2D32f> cornersA;
ArrayList<CvPoint2D32f> cornersB;

CvPoint2D32f p;
Iterator ica = cornersA.iterator();
int i = 0;

while(ica.hasNext()){
p = (CvPoint2D32f) ica.next();
pt1.put(i,p.x());
pt1.put(i+1,p.y());
i = i+2;
}

pt1 = CvMat.create(1, cornersA.size(), CV_32F, 2);
pt2 = CvMat.create(1, cornersA.size(), CV_32F, 2);

cvFindHomography(pt1,pt2,....

Ljupce

unread,
Dec 21, 2011, 10:33:03 AM12/21/11
to javacv
Thanks for your answer.

The features from my source and destination image are stored in two
KeyPoint object. How could I map the
the source features to the destination features using my DMatch
object?

Since using the C++ API the features were stored in vector<KeyPoint>,
I have some difficulties to understand what a KeyPoint object is,
is it a single keypoint or an array of keypoints?

Thanks

Ljupce

On 21 déc, 16:00, ChrisP <pausch...@googlemail.com> wrote:
> I think something like this is done in ObjectFinder.java:
>
> http://code.google.com/p/javacv/source/browse/trunk/javacv/src/name/a...

ChrisP

unread,
Dec 21, 2011, 10:57:17 AM12/21/11
to javacv
I remember wondering about DMatch etc. too. But I decided to rather
get inspired from the JavaCV examples than trying to stick too much to
the C++ program when implementing this in Java. But maybe somebody
else can help?

alessandro...@gmail.com

unread,
Dec 21, 2011, 11:02:25 AM12/21/11
to jav...@googlegroups.com
hi guys, i very need help with Iris and Pupil detection anyone can help
me?i have tried many ways but nothing...
thx at all

Samuel Audet

unread,
Dec 23, 2011, 8:05:27 AM12/23/11
to jav...@googlegroups.com

Samuel Audet

unread,
Dec 23, 2011, 8:09:30 AM12/23/11
to jav...@googlegroups.com
Oh, sorry about repeating your answer Chris, thanks for that!

As far as com.googlecode.javacpp.Pointer objects are concerned, they are
both pointers and arrays because any pointer in C/C++ can be accessed as
an array. So if you know that a KeyPoint object is actually an array,
you can access the elements with Pointer.position(), as shown in the
README.txt file. The same for DMatch or any other Pointer object for
that matter.

Samuel

Samuel Audet

unread,
Dec 23, 2011, 8:12:47 AM12/23/11
to jav...@googlegroups.com

Sorry, it does not look like anyone here has any experience with that :(

I guess something you could try would be to run cvHoughCircle() in the
region detected by an eye detector. That should return the iris and
pupil AFAIK, but I haven't tried it myself.

Samuel

alessandro...@gmail.com

unread,
Dec 23, 2011, 8:33:26 AM12/23/11
to jav...@googlegroups.com
thx for answere...i have already tried cvHoughCircle on eye ROI but is
not very precise :(


Il 23/12/11 14:12, Samuel Audet ha scritto:

Jeremy NICOLA

unread,
Dec 23, 2011, 8:33:33 AM12/23/11
to jav...@googlegroups.com
Hello,

I'm not sure if this is directly related to pupil detection but these guys (  http://code.google.com/p/experteyes/  ) seems to be doing good work on eye tracking.

Jeremy

2011/12/23 Samuel Audet <samuel...@gmail.com>

alessandro...@gmail.com

unread,
Dec 23, 2011, 8:41:52 AM12/23/11
to jav...@googlegroups.com
thx a lot...now i check the code :)

Il 23/12/11 14:33, Jeremy NICOLA ha scritto:

Harold Selvaggi

unread,
Dec 23, 2011, 1:48:18 PM12/23/11
to jav...@googlegroups.com
I think you can extract circular shapes (Hough transform) after you extract the saliency map of the image.
--
Saludos:
Harold.

Alessandro Trosino

unread,
Feb 8, 2012, 8:42:32 AM2/8/12
to javacv
Hei guys...any good news for iris/pupil detection? i very need

Thx a lot
Reply all
Reply to author
Forward
0 new messages