mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
lot's of changes; nonfree & photo modules added; SIFT & SURF -> nonfree module; Inpainting -> photo; refactored features2d (ORB is still failing tests), optimized brute-force matcher and made it non-template.
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
|
||||
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
|
||||
SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
|
||||
opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
|
||||
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
|
||||
|
||||
ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
#include "opencv2/legacy/compat.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@@ -214,6 +217,7 @@ int main(int argc, char** argv)
|
||||
const char* object_filename = argc == 3 ? argv[1] : "box.png";
|
||||
const char* scene_filename = argc == 3 ? argv[2] : "box_in_scene.png";
|
||||
|
||||
cv::initModule_nonfree();
|
||||
help();
|
||||
|
||||
IplImage* object = cvLoadImage( object_filename, CV_LOAD_IMAGE_GRAYSCALE );
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -123,7 +125,7 @@ void testCalonderClassifier( const string& classifierFilename, const string& img
|
||||
Mat descriptors2; de.compute( img2, keypoints2, descriptors2 );
|
||||
|
||||
// Match descriptors
|
||||
BruteForceMatcher<L1<float> > matcher;
|
||||
BFMatcher matcher(NORM_L1);
|
||||
vector<DMatch> matches;
|
||||
matcher.match( descriptors1, descriptors2, matches );
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
+63
-111
@@ -1,134 +1,86 @@
|
||||
/* This sample code was originally provided by Liu Liu
|
||||
* Copyright� 2009, Liu Liu All rights reserved.
|
||||
* Copyright (C) 2009, Liu Liu All rights reserved.
|
||||
*/
|
||||
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
void help()
|
||||
{
|
||||
printf("\nThis program demonstrates the Maximal Extremal Region interest point detector.\n"
|
||||
"It finds the most stable (in size) dark and white regions as a threshold is increased.\n"
|
||||
"\nCall:\n"
|
||||
"./mser_sample <path_and_image_filename, Default is 'puzzle.png'>\n\n");
|
||||
cout << "\nThis program demonstrates the Maximal Extremal Region interest point detector.\n"
|
||||
"It finds the most stable (in size) dark and white regions as a threshold is increased.\n"
|
||||
"\nCall:\n"
|
||||
"./mser_sample <path_and_image_filename, Default is 'puzzle.png'>\n\n";
|
||||
}
|
||||
|
||||
static CvScalar colors[] =
|
||||
static const Vec3b bcolors[] =
|
||||
{
|
||||
{{0,0,255}},
|
||||
{{0,128,255}},
|
||||
{{0,255,255}},
|
||||
{{0,255,0}},
|
||||
{{255,128,0}},
|
||||
{{255,255,0}},
|
||||
{{255,0,0}},
|
||||
{{255,0,255}},
|
||||
{{255,255,255}},
|
||||
{{196,255,255}},
|
||||
{{255,255,196}}
|
||||
Vec3b(0,0,255),
|
||||
Vec3b(0,128,255),
|
||||
Vec3b(0,255,255),
|
||||
Vec3b(0,255,0),
|
||||
Vec3b(255,128,0),
|
||||
Vec3b(255,255,0),
|
||||
Vec3b(255,0,0),
|
||||
Vec3b(255,0,255),
|
||||
Vec3b(255,255,255)
|
||||
};
|
||||
|
||||
static uchar bcolors[][3] =
|
||||
{
|
||||
{0,0,255},
|
||||
{0,128,255},
|
||||
{0,255,255},
|
||||
{0,255,0},
|
||||
{255,128,0},
|
||||
{255,255,0},
|
||||
{255,0,0},
|
||||
{255,0,255},
|
||||
{255,255,255}
|
||||
};
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
char path[1024];
|
||||
IplImage* img;
|
||||
string path;
|
||||
Mat img0, img, yuv, gray, ellipses;
|
||||
help();
|
||||
if (argc!=2)
|
||||
|
||||
img0 = imread( argc != 2 ? "puzzle.png" : argv[1], 1 );
|
||||
if( img0.empty() )
|
||||
{
|
||||
if( argc != 2 )
|
||||
cout << "\nUsage: mser_sample <path_to_image>\n";
|
||||
else
|
||||
cout << "Unable to load image " << argv[1] << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cvtColor(img0, yuv, COLOR_BGR2YCrCb);
|
||||
cvtColor(img0, gray, COLOR_BGR2GRAY);
|
||||
cvtColor(gray, img, COLOR_GRAY2BGR);
|
||||
img.copyTo(ellipses);
|
||||
|
||||
vector<vector<Point> > contours;
|
||||
double t = (double)getTickCount();
|
||||
MSER()(yuv, contours);
|
||||
t = (double)getTickCount() - t;
|
||||
printf( "MSER extracted %d contours in %g ms.\n", (int)contours.size(),
|
||||
t*1000./getTickFrequency() );
|
||||
|
||||
// draw mser's with different colors
|
||||
for( int i = (int)contours.size()-1; i >= 0; i-- )
|
||||
{
|
||||
strcpy(path,"puzzle.png");
|
||||
img = cvLoadImage( path, CV_LOAD_IMAGE_GRAYSCALE );
|
||||
if (!img)
|
||||
const vector<Point>& r = contours[i];
|
||||
for ( int j = 0; j < (int)r.size(); j++ )
|
||||
{
|
||||
printf("\nUsage: mser_sample <path_to_image>\n");
|
||||
return 0;
|
||||
Point pt = r[j];
|
||||
img.at<Vec3b>(r[j]) = bcolors[i%9];
|
||||
}
|
||||
|
||||
// find ellipse (it seems cvfitellipse2 have error or sth?)
|
||||
RotatedRect box = fitEllipse( r );
|
||||
|
||||
box.angle=(float)CV_PI/2-box.angle;
|
||||
ellipse( ellipses, box, Scalar(196,255,255), 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(path,argv[1]);
|
||||
img = cvLoadImage( path, CV_LOAD_IMAGE_GRAYSCALE );
|
||||
}
|
||||
|
||||
if (!img)
|
||||
{
|
||||
printf("Unable to load image %s\n",path);
|
||||
return 0;
|
||||
}
|
||||
IplImage* rsp = cvLoadImage( path, CV_LOAD_IMAGE_COLOR );
|
||||
IplImage* ellipses = cvCloneImage(rsp);
|
||||
cvCvtColor(img,ellipses,CV_GRAY2BGR);
|
||||
CvSeq* contours;
|
||||
CvMemStorage* storage= cvCreateMemStorage();
|
||||
IplImage* hsv = cvCreateImage( cvGetSize( rsp ), IPL_DEPTH_8U, 3 );
|
||||
cvCvtColor( rsp, hsv, CV_BGR2YCrCb );
|
||||
CvMSERParams params = cvMSERParams();//cvMSERParams( 5, 60, cvRound(.2*img->width*img->height), .25, .2 );
|
||||
|
||||
double t = (double)cvGetTickCount();
|
||||
cvExtractMSER( hsv, NULL, &contours, storage, params );
|
||||
t = cvGetTickCount() - t;
|
||||
printf( "MSER extracted %d contours in %g ms.\n", contours->total, t/((double)cvGetTickFrequency()*1000.) );
|
||||
uchar* rsptr = (uchar*)rsp->imageData;
|
||||
// draw mser with different color
|
||||
for ( int i = contours->total-1; i >= 0; i-- )
|
||||
{
|
||||
CvSeq* r = *(CvSeq**)cvGetSeqElem( contours, i );
|
||||
for ( int j = 0; j < r->total; j++ )
|
||||
{
|
||||
CvPoint* pt = CV_GET_SEQ_ELEM( CvPoint, r, j );
|
||||
rsptr[pt->x*3+pt->y*rsp->widthStep] = bcolors[i%9][2];
|
||||
rsptr[pt->x*3+1+pt->y*rsp->widthStep] = bcolors[i%9][1];
|
||||
rsptr[pt->x*3+2+pt->y*rsp->widthStep] = bcolors[i%9][0];
|
||||
}
|
||||
}
|
||||
// find ellipse ( it seems cvfitellipse2 have error or sth?
|
||||
for ( int i = 0; i < contours->total; i++ )
|
||||
{
|
||||
CvContour* r = *(CvContour**)cvGetSeqElem( contours, i );
|
||||
CvBox2D box = cvFitEllipse2( r );
|
||||
box.angle=(float)CV_PI/2-box.angle;
|
||||
|
||||
if ( r->color > 0 )
|
||||
cvEllipseBox( ellipses, box, colors[9], 2 );
|
||||
else
|
||||
cvEllipseBox( ellipses, box, colors[2], 2 );
|
||||
|
||||
}
|
||||
|
||||
cvSaveImage( "rsp.png", rsp );
|
||||
|
||||
cvNamedWindow( "original", 0 );
|
||||
cvShowImage( "original", img );
|
||||
|
||||
cvNamedWindow( "response", 0 );
|
||||
cvShowImage( "response", rsp );
|
||||
|
||||
cvNamedWindow( "ellipses", 0 );
|
||||
cvShowImage( "ellipses", ellipses );
|
||||
|
||||
cvWaitKey(0);
|
||||
|
||||
cvDestroyWindow( "original" );
|
||||
cvDestroyWindow( "response" );
|
||||
cvDestroyWindow( "ellipses" );
|
||||
cvReleaseImage(&rsp);
|
||||
cvReleaseImage(&img);
|
||||
cvReleaseImage(&ellipses);
|
||||
|
||||
|
||||
imshow( "original", img0 );
|
||||
imshow( "response", img );
|
||||
imshow( "ellipses", ellipses );
|
||||
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
#include "opencv2/legacy/compat.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
@@ -25,8 +28,8 @@ void help()
|
||||
|
||||
using namespace cv;
|
||||
|
||||
IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2,
|
||||
const vector<KeyPoint>& features2, const vector<int>& desc_idx);
|
||||
Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
|
||||
const vector<KeyPoint>& features2, const vector<int>& desc_idx);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@@ -45,8 +48,8 @@ int main(int argc, char** argv)
|
||||
std::string img2_name = path_name + "/" + std::string(argv[3]);
|
||||
|
||||
printf("Reading the images...\n");
|
||||
IplImage* img1 = cvLoadImage(img1_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
IplImage* img2 = cvLoadImage(img2_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img1 = imread(img1_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img2 = imread(img2_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
// extract keypoints from the first image
|
||||
SURF surf_extractor(5.0e3);
|
||||
@@ -61,7 +64,9 @@ int main(int argc, char** argv)
|
||||
// create descriptors
|
||||
OneWayDescriptorBase descriptors(patch_size, pose_count, OneWayDescriptorBase::GetPCAFilename(), path_name,
|
||||
images_list);
|
||||
descriptors.CreateDescriptorsFromImage(img1, keypoints1);
|
||||
IplImage img1_c = img1;
|
||||
IplImage img2_c = img2;
|
||||
descriptors.CreateDescriptorsFromImage(&img1_c, keypoints1);
|
||||
printf("done\n");
|
||||
|
||||
// extract keypoints from the second image
|
||||
@@ -77,43 +82,37 @@ int main(int argc, char** argv)
|
||||
{
|
||||
int pose_idx = 0;
|
||||
float distance = 0;
|
||||
descriptors.FindDescriptor(img2, keypoints2[i].pt, desc_idx[i], pose_idx, distance);
|
||||
descriptors.FindDescriptor(&img2_c, keypoints2[i].pt, desc_idx[i], pose_idx, distance);
|
||||
}
|
||||
printf("done\n");
|
||||
|
||||
IplImage* img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, desc_idx);
|
||||
Mat img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, desc_idx);
|
||||
|
||||
cvNamedWindow("correspondences", 1);
|
||||
cvShowImage("correspondences", img_corr);
|
||||
cvWaitKey(0);
|
||||
|
||||
cvReleaseImage(&img1);
|
||||
cvReleaseImage(&img2);
|
||||
cvReleaseImage(&img_corr);
|
||||
imshow("correspondences", img_corr);
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2,
|
||||
const vector<KeyPoint>& features2, const vector<int>& desc_idx)
|
||||
Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
|
||||
const vector<KeyPoint>& features2, const vector<int>& desc_idx)
|
||||
{
|
||||
IplImage* img_corr = cvCreateImage(cvSize(img1->width + img2->width, MAX(img1->height, img2->height)),
|
||||
IPL_DEPTH_8U, 3);
|
||||
cvSetImageROI(img_corr, cvRect(0, 0, img1->width, img1->height));
|
||||
cvCvtColor(img1, img_corr, CV_GRAY2RGB);
|
||||
cvSetImageROI(img_corr, cvRect(img1->width, 0, img2->width, img2->height));
|
||||
cvCvtColor(img2, img_corr, CV_GRAY2RGB);
|
||||
cvResetImageROI(img_corr);
|
||||
|
||||
Mat part, img_corr(Size(img1.cols + img2.cols, MAX(img1.rows, img2.rows)), CV_8UC3);
|
||||
img_corr = Scalar::all(0);
|
||||
part = img_corr(Rect(0, 0, img1.cols, img1.rows));
|
||||
cvtColor(img1, part, COLOR_GRAY2RGB);
|
||||
part = img_corr(Rect(img1.cols, 0, img2.cols, img2.rows));
|
||||
cvtColor(img1, part, COLOR_GRAY2RGB);
|
||||
|
||||
for (size_t i = 0; i < features1.size(); i++)
|
||||
{
|
||||
cvCircle(img_corr, features1[i].pt, 3, CV_RGB(255, 0, 0));
|
||||
circle(img_corr, features1[i].pt, 3, CV_RGB(255, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < features2.size(); i++)
|
||||
{
|
||||
CvPoint pt = cvPoint((int)features2[i].pt.x + img1->width, (int)features2[i].pt.y);
|
||||
cvCircle(img_corr, pt, 3, CV_RGB(255, 0, 0));
|
||||
cvLine(img_corr, features1[desc_idx[i]].pt, pt, CV_RGB(0, 255, 0));
|
||||
Point pt((int)features2[i].pt.x + img1.cols, (int)features2[i].pt.y);
|
||||
circle(img_corr, pt, 3, Scalar(0, 0, 255));
|
||||
line(img_corr, features1[desc_idx[i]].pt, pt, Scalar(0, 255, 0));
|
||||
}
|
||||
|
||||
|
||||
return img_corr;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
|
||||
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
|
||||
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
|
||||
opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
|
||||
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
|
||||
|
||||
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ int main(int argc, const char ** argv)
|
||||
|
||||
//Do matching using features2d
|
||||
cout << "matching with BruteForceMatcher<Hamming>" << endl;
|
||||
BruteForceMatcher<Hamming> matcher_popcount;
|
||||
BFMatcher matcher_popcount(NORM_HAMMING);
|
||||
vector<DMatch> matches_popcount;
|
||||
double pop_time = match(kpts_1, kpts_2, matcher_popcount, desc_1, desc_2, matches_popcount);
|
||||
cout << "done BruteForceMatcher<Hamming> matching. took " << pop_time << " seconds" << endl;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <cstdio>
|
||||
@@ -879,7 +880,7 @@ public:
|
||||
{
|
||||
string classifierFile = data_path + "/features2d/calonder_classifier.rtc";
|
||||
defaultDescMatcher = new VectorDescriptorMatch( new CalonderDescriptorExtractor<float>( classifierFile ),
|
||||
new BruteForceMatcher<L2<float> > );
|
||||
new BFMatcher(NORM_L2) );
|
||||
specificDescMatcher = defaultDescMatcher;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@@ -14,8 +15,8 @@ void help()
|
||||
printf("For example: ./generic_descriptor_match ../c/scene_l.bmp ../c/scene_r.bmp FERN fern_params.xml\n");
|
||||
}
|
||||
|
||||
IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2,
|
||||
const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx);
|
||||
Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
|
||||
const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@@ -38,8 +39,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
//printf("Reading the images...\n");
|
||||
IplImage* img1 = cvLoadImage(img1_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
IplImage* img2 = cvLoadImage(img2_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img1 = imread(img1_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img2 = imread(img2_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
// extract keypoints from the first image
|
||||
SURF surf_extractor(5.0e3);
|
||||
@@ -60,38 +61,32 @@ int main(int argc, char** argv)
|
||||
descriptorMatcher->match( img2, keypoints2, img1, keypoints1, matches2to1 );
|
||||
printf("Done\n");
|
||||
|
||||
IplImage* img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, matches2to1);
|
||||
Mat img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, matches2to1);
|
||||
|
||||
cvNamedWindow("correspondences", 1);
|
||||
cvShowImage("correspondences", img_corr);
|
||||
cvWaitKey(0);
|
||||
|
||||
cvReleaseImage(&img1);
|
||||
cvReleaseImage(&img2);
|
||||
cvReleaseImage(&img_corr);
|
||||
imshow("correspondences", img_corr);
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
IplImage* DrawCorrespondences(IplImage* img1, const vector<KeyPoint>& features1, IplImage* img2,
|
||||
const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx)
|
||||
Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
|
||||
const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx)
|
||||
{
|
||||
IplImage* img_corr = cvCreateImage(cvSize(img1->width + img2->width, MAX(img1->height, img2->height)),
|
||||
IPL_DEPTH_8U, 3);
|
||||
cvSetImageROI(img_corr, cvRect(0, 0, img1->width, img1->height));
|
||||
cvCvtColor(img1, img_corr, CV_GRAY2RGB);
|
||||
cvSetImageROI(img_corr, cvRect(img1->width, 0, img2->width, img2->height));
|
||||
cvCvtColor(img2, img_corr, CV_GRAY2RGB);
|
||||
cvResetImageROI(img_corr);
|
||||
Mat part, img_corr(Size(img1.cols + img2.cols, MAX(img1.rows, img2.rows)), CV_8UC3);
|
||||
img_corr = Scalar::all(0);
|
||||
part = img_corr(Rect(0, 0, img1.cols, img1.rows));
|
||||
cvtColor(img1, part, COLOR_GRAY2RGB);
|
||||
part = img_corr(Rect(img1.cols, 0, img2.cols, img2.rows));
|
||||
cvtColor(img1, part, COLOR_GRAY2RGB);
|
||||
|
||||
for (size_t i = 0; i < features1.size(); i++)
|
||||
{
|
||||
cvCircle(img_corr, features1[i].pt, 3, CV_RGB(255, 0, 0));
|
||||
circle(img_corr, features1[i].pt, 3, CV_RGB(255, 0, 0));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < features2.size(); i++)
|
||||
{
|
||||
CvPoint pt = cvPoint(cvRound(features2[i].pt.x + img1->width), cvRound(features2[i].pt.y));
|
||||
cvCircle(img_corr, pt, 3, CV_RGB(255, 0, 0));
|
||||
cvLine(img_corr, features1[desc_idx[i].trainIdx].pt, pt, CV_RGB(0, 255, 0));
|
||||
Point pt(cvRound(features2[i].pt.x + img1.cols), cvRound(features2[i].pt.y));
|
||||
circle(img_corr, pt, 3, Scalar(0, 0, 255));
|
||||
line(img_corr, features1[desc_idx[i].trainIdx].pt, pt, Scalar(0, 255, 0));
|
||||
}
|
||||
|
||||
return img_corr;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/photo/photo.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
@@ -42,7 +43,7 @@ int main(int argc, char** argv)
|
||||
extractor.compute(img2, keypoints2, descriptors2);
|
||||
|
||||
// matching descriptors
|
||||
BruteForceMatcher<L2<float> > matcher;
|
||||
BFMatcher matcher(NORM_L2);
|
||||
vector<DMatch> matches;
|
||||
matcher.match(descriptors1, descriptors2, matches);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ int main(int ac, char ** av)
|
||||
|
||||
vector<DMatch> matches;
|
||||
|
||||
BruteForceMatcher<Hamming> desc_matcher;
|
||||
BFMatcher desc_matcher(NORM_HAMMING);
|
||||
|
||||
vector<Point2f> train_pts, query_pts;
|
||||
vector<KeyPoint> train_kpts, query_kpts;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
|
||||
opencv_ml opencv_video opencv_objdetect opencv_features2d
|
||||
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
|
||||
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu
|
||||
opencv_nonfree)
|
||||
|
||||
ocv_check_dependencies(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/video/video.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "performance.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -352,7 +353,7 @@ TEST(BruteForceMatcher)
|
||||
|
||||
int desc_len = 64;
|
||||
|
||||
BruteForceMatcher< L2<float> > matcher;
|
||||
BFMatcher matcher(NORM_L2);
|
||||
|
||||
Mat query;
|
||||
gen(query, 3000, desc_len, CV_32F, 0, 1);
|
||||
|
||||
Reference in New Issue
Block a user