Skip to content

Commit

Permalink
draw code
Browse files Browse the repository at this point in the history
  • Loading branch information
rj committed Mar 18, 2011
1 parent d7c65d1 commit 954c94e
Show file tree
Hide file tree
Showing 2 changed files with 417 additions and 21 deletions.
47 changes: 26 additions & 21 deletions jni/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ void warpPerspectiveRand( const Mat& src, Mat& dst, Mat& H, RNG& rng )

void validateKeypoints(const std::vector<KeyPoint>& keypoints, const vector<int>& keypointIndexes)
{
D("begin validateKeypoints\n");
//D("begin validateKeypoints\n");
for( size_t i = 0; i < keypointIndexes.size(); i++ )
{
int idx = keypointIndexes[i];
if( idx >= 0 ) {
if (idx > (keypoints.size() - 1)) {
D("we got an out of bounds thing. idx: %d, size: %zu\n", idx, keypoints.size());
//D("we got an out of bounds thing. idx: %d, size: %zu\n", idx, keypoints.size());
}
}
else
{
D("keypointIndexes has element < 0. TODO: process this case" );
//D("keypointIndexes has element < 0. TODO: process this case" );
//points2f[i] = Point2f(-1, -1);
}
}
D("validateKeypoints succeeded\n");
//D("validateKeypoints succeeded\n");
}

void convertKeypoints(const std::vector<KeyPoint>& keypoints, std::vector<Point2f>& points2f,
Expand Down Expand Up @@ -188,26 +188,31 @@ void doIteration( const Mat& img1, Mat& img2,

if( !H12.empty() ) // filter outliers
{
// vector<char> matchesMask( filteredMatches.size(), 0 );
// vector<Point2f> points1; KeyPoint::convert(keypoints1, points1, *queryIdxs);
// vector<Point2f> points2; KeyPoint::convert(keypoints2, points2, *trainIdxs);
// Mat points1t; perspectiveTransform(Mat(points1), points1t, H12);
// D("perspectiveTransform succeeded\n");
// for( size_t i1 = 0; i1 < points1.size(); i1++ )
// {
// if( norm(points2[i1] - points1t.at<Point2f>((int)i1,0)) < 4 ) // inlier
// matchesMask[i1] = 1;
// }
// D("inliers succeeded\n");
// // draw inliers
// drawMatches( img1, keypoints1, img2, keypoints2, filteredMatches, drawImg, CV_RGB(0, 255, 0), CV_RGB(0, 0, 255), matchesMask
// );
// D("drawMatches (inlier)\n");
vector<char> matchesMask( filteredMatches.size(), 0 );
vector<Point2f> points1; KeyPoint::convert(keypoints1, points1, *queryIdxs);
vector<Point2f> points2; KeyPoint::convert(keypoints2, points2, *trainIdxs);
Mat points1t; perspectiveTransform(Mat(points1), points1t, H12);
D("perspectiveTransform succeeded\n");
for( size_t i1 = 0; i1 < points1.size(); i1++ )
{
if( norm(points2[i1] - points1t.at<Point2f>((int)i1,0)) < 4 ) // inlier
matchesMask[i1] = 1;
}
D("inliers succeeded\n");
// draw inliers
drawMatches( img1, keypoints1, img2, keypoints2, filteredMatches, drawImg, CV_RGB(0, 255, 0), CV_RGB(0, 0, 255), matchesMask
);
D("drawMatches (inlier)\n");
//drawMatches( img1, keypoints1, img2, keypoints2, filteredMatches, drawImg );
//for (vector<KeyPoint>::const_iterator it = keypoints2.begin(); it != keypoints2.end(); ++it)
//{
// circle(drawImg, it->pt, 3, cvScalar(255, 0, 255, 0));
//}
//D("drawMatches (outlier)\n");
}
else
{
drawMatches( img1, keypoints1, img2, keypoints2, filteredMatches, drawImg );
D("drawMatches (outlier)\n");
D("drawMatches (nomatches)\n");
}
delete points1;
delete points2;
Expand Down
Loading

0 comments on commit 954c94e

Please sign in to comment.