warningx fixed under vs2008
This commit is contained in:
parent
0545e780f8
commit
998fab0ef5
@ -1155,7 +1155,7 @@ ChamferMatcher::Matches* ChamferMatcher::Matching::matchTemplates(Mat& dist_img,
|
|||||||
* @param edge_img Edge image
|
* @param edge_img Edge image
|
||||||
* @return a match object
|
* @return a match object
|
||||||
*/
|
*/
|
||||||
ChamferMatcher::Matches* ChamferMatcher::Matching::matchEdgeImage(Mat& edge_img, const ImageRange& range, float orientation_weight, int max_matches, float min_match_distance)
|
ChamferMatcher::Matches* ChamferMatcher::Matching::matchEdgeImage(Mat& edge_img, const ImageRange& range, float orientation_weight, int /*max_matches*/, float /*min_match_distance*/)
|
||||||
{
|
{
|
||||||
CV_Assert(edge_img.channels()==1);
|
CV_Assert(edge_img.channels()==1);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void matches2points(const vector<DMatch>& matches, const vector<KeyPoint>& kpts_
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double match(const vector<KeyPoint>& kpts_train, const vector<KeyPoint>& kpts_query, DescriptorMatcher& matcher,
|
double match(const vector<KeyPoint>& /*kpts_train*/, const vector<KeyPoint>& /*kpts_query*/, DescriptorMatcher& matcher,
|
||||||
const Mat& train, const Mat& query, vector<DMatch>& matches)
|
const Mat& train, const Mat& query, vector<DMatch>& matches)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ int main(int ac, char ** av)
|
|||||||
cout << "matching with BruteForceMatcher<HammingLUT>" << endl;
|
cout << "matching with BruteForceMatcher<HammingLUT>" << endl;
|
||||||
BruteForceMatcher<HammingLUT> matcher;
|
BruteForceMatcher<HammingLUT> matcher;
|
||||||
vector<DMatch> matches_lut;
|
vector<DMatch> matches_lut;
|
||||||
float lut_time = match(kpts_1, kpts_2, matcher, desc_1, desc_2, matches_lut);
|
float lut_time = (float)match(kpts_1, kpts_2, matcher, desc_1, desc_2, matches_lut);
|
||||||
cout << "done BruteForceMatcher<HammingLUT> matching. took " << lut_time << " seconds" << endl;
|
cout << "done BruteForceMatcher<HammingLUT> matching. took " << lut_time << " seconds" << endl;
|
||||||
|
|
||||||
cout << "matching with BruteForceMatcher<Hamming>" << endl;
|
cout << "matching with BruteForceMatcher<Hamming>" << endl;
|
||||||
|
@ -59,7 +59,7 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
// Define trackbar callback functon. This function find contours,
|
// Define trackbar callback functon. This function find contours,
|
||||||
// draw it and approximate it by ellipses.
|
// draw it and approximate it by ellipses.
|
||||||
void processImage(int h, void*)
|
void processImage(int /*h*/, void*)
|
||||||
{
|
{
|
||||||
vector<vector<Point> > contours;
|
vector<vector<Point> > contours;
|
||||||
Mat bimage = image >= sliderPos;
|
Mat bimage = image >= sliderPos;
|
||||||
|
@ -14,7 +14,7 @@ void help()
|
|||||||
"./kmeans\n" << endl;
|
"./kmeans\n" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int /*argc*/, char** /*argv*/ )
|
||||||
{
|
{
|
||||||
const int MAX_CLUSTERS = 5;
|
const int MAX_CLUSTERS = 5;
|
||||||
Scalar colorTab[] =
|
Scalar colorTab[] =
|
||||||
|
@ -26,7 +26,7 @@ void help()
|
|||||||
Point2f pt;
|
Point2f pt;
|
||||||
bool addRemovePt = false;
|
bool addRemovePt = false;
|
||||||
|
|
||||||
void onMouse( int event, int x, int y, int flags, void* param )
|
void onMouse( int event, int x, int y, int /*flags*/, void* /*param*/ )
|
||||||
{
|
{
|
||||||
if( event == CV_EVENT_LBUTTONDOWN )
|
if( event == CV_EVENT_LBUTTONDOWN )
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ void help()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int /*argc*/, char** /*argv*/ )
|
||||||
{
|
{
|
||||||
Mat img(500, 500, CV_8UC3);
|
Mat img(500, 500, CV_8UC3);
|
||||||
RNG& rng = theRNG();
|
RNG& rng = theRNG();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* starter_video.cpp
|
* starter_video.cpp
|
||||||
*
|
*
|
||||||
* Created on: Nov 23, 2010
|
* Created on: Nov 23, 2010
|
||||||
* Author: Ethan Rublee
|
* Author: Ethan Rublee
|
||||||
*
|
*
|
||||||
* A starter sample for using opencv, get a video stream and display the images
|
* A starter sample for using opencv, get a video stream and display the images
|
||||||
* easy as CV_PI right?
|
* easy as CV_PI right?
|
||||||
*/
|
*/
|
||||||
#include <opencv2/highgui/highgui.hpp>
|
#include <opencv2/highgui/highgui.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -16,55 +16,55 @@ using namespace std;
|
|||||||
|
|
||||||
//hide the local functions in an anon namespace
|
//hide the local functions in an anon namespace
|
||||||
namespace {
|
namespace {
|
||||||
void help(char** av) {
|
void help(char** av) {
|
||||||
cout << "\nThis program justs gets you started reading images from video\n"
|
cout << "\nThis program justs gets you started reading images from video\n"
|
||||||
"Usage:\n./" << av[0] << " <video device number>\n"
|
"Usage:\n./" << av[0] << " <video device number>\n"
|
||||||
<< "\tThis is a starter sample, to get you up and going in a copy pasta fashion\n"
|
<< "\tThis is a starter sample, to get you up and going in a copy pasta fashion\n"
|
||||||
<< "\tThe program captures frames from a camera connected to your computer.\n"
|
<< "\tThe program captures frames from a camera connected to your computer.\n"
|
||||||
<< "\tTo find the video device number, try ls /dev/video* \n"
|
<< "\tTo find the video device number, try ls /dev/video* \n"
|
||||||
<< "\tYou may also pass a video file, like my_vide.avi instead of a device number"
|
<< "\tYou may also pass a video file, like my_vide.avi instead of a device number"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process(VideoCapture& capture) {
|
int process(VideoCapture& capture) {
|
||||||
string window_name = "video | q or esc to quit";
|
string window_name = "video | q or esc to quit";
|
||||||
cout << "press q or esc to quit" << endl;
|
cout << "press q or esc to quit" << endl;
|
||||||
namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
|
namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
|
||||||
Mat frame;
|
Mat frame;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
capture >> frame;
|
capture >> frame;
|
||||||
if (frame.empty())
|
if (frame.empty())
|
||||||
continue;
|
continue;
|
||||||
imshow(window_name, frame);
|
imshow(window_name, frame);
|
||||||
char key = (char)waitKey(5); //delay N millis, usually long enough to display and capture input
|
char key = (char)waitKey(5); //delay N millis, usually long enough to display and capture input
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'q':
|
case 'q':
|
||||||
case 'Q':
|
case 'Q':
|
||||||
case 27: //escape key
|
case 27: //escape key
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int ac, char** av) {
|
int main(int ac, char** av) {
|
||||||
|
|
||||||
if (ac != 2) {
|
if (ac != 2) {
|
||||||
help(av);
|
help(av);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::string arg = av[1];
|
std::string arg = av[1];
|
||||||
VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file
|
VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file
|
||||||
if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
|
if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
|
||||||
capture.open(atoi(arg.c_str()));
|
capture.open(atoi(arg.c_str()));
|
||||||
if (!capture.isOpened()) {
|
if (!capture.isOpened()) {
|
||||||
cerr << "Failed to open a video device or video file!\n" << endl;
|
cerr << "Failed to open a video device or video file!\n" << endl;
|
||||||
help(av);
|
help(av);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return process(capture);
|
return process(capture);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* video_homography.cpp
|
* video_homography.cpp
|
||||||
*
|
*
|
||||||
* Created on: Oct 18, 2010
|
* Created on: Oct 18, 2010
|
||||||
* Author: erublee
|
* Author: erublee
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <opencv2/calib3d/calib3d.hpp>
|
#include <opencv2/calib3d/calib3d.hpp>
|
||||||
#include <opencv2/highgui/highgui.hpp>
|
#include <opencv2/highgui/highgui.hpp>
|
||||||
@ -18,8 +18,8 @@ using namespace cv;
|
|||||||
|
|
||||||
void help(char **av)
|
void help(char **av)
|
||||||
{
|
{
|
||||||
cout << "\nThis program demonstrated the use of features2d with the Fast corner detector and brief descriptors\n"
|
cout << "\nThis program demonstrated the use of features2d with the Fast corner detector and brief descriptors\n"
|
||||||
<< "to track planar objects by computing their homography from the key (training) image to the query (test) image\n\n" << endl;
|
<< "to track planar objects by computing their homography from the key (training) image to the query (test) image\n\n" << endl;
|
||||||
cout << "usage: " << av[0] << " <video device number>\n" << endl;
|
cout << "usage: " << av[0] << " <video device number>\n" << endl;
|
||||||
cout << "The following keys do stuff:" << endl;
|
cout << "The following keys do stuff:" << endl;
|
||||||
cout << " t : grabs a reference frame to match against" << endl;
|
cout << " t : grabs a reference frame to match against" << endl;
|
||||||
@ -29,206 +29,206 @@ void help(char **av)
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query,
|
void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query,
|
||||||
std::vector<cv::DMatch>& matches, Mat& img, const vector<unsigned char>& mask = vector<
|
std::vector<cv::DMatch>& matches, Mat& img, const vector<unsigned char>& mask = vector<
|
||||||
unsigned char> ())
|
unsigned char> ())
|
||||||
{
|
|
||||||
for (int i = 0; i < (int)matches.size(); i++)
|
|
||||||
{
|
|
||||||
if (mask.empty() || mask[i])
|
|
||||||
{
|
{
|
||||||
Point2f pt_new = query[matches[i].queryIdx].pt;
|
for (int i = 0; i < (int)matches.size(); i++)
|
||||||
Point2f pt_old = train[matches[i].trainIdx].pt;
|
{
|
||||||
Point2f dist = pt_new - pt_old;
|
if (mask.empty() || mask[i])
|
||||||
|
{
|
||||||
|
Point2f pt_new = query[matches[i].queryIdx].pt;
|
||||||
|
Point2f pt_old = train[matches[i].trainIdx].pt;
|
||||||
|
Point2f dist = pt_new - pt_old;
|
||||||
|
|
||||||
cv::line(img, pt_new, pt_old, Scalar(125, 255, 125), 1);
|
cv::line(img, pt_new, pt_old, Scalar(125, 255, 125), 1);
|
||||||
cv::circle(img, pt_new, 2, Scalar(255, 0, 125), 1);
|
cv::circle(img, pt_new, 2, Scalar(255, 0, 125), 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Takes a descriptor and turns it into an xy point
|
||||||
|
void keypoints2points(const vector<KeyPoint>& in, vector<Point2f>& out)
|
||||||
|
{
|
||||||
|
out.clear();
|
||||||
|
out.reserve(in.size());
|
||||||
|
for (size_t i = 0; i < in.size(); ++i)
|
||||||
|
{
|
||||||
|
out.push_back(in[i].pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Takes an xy point and appends that to a keypoint structure
|
||||||
|
void points2keypoints(const vector<Point2f>& in, vector<KeyPoint>& out)
|
||||||
|
{
|
||||||
|
out.clear();
|
||||||
|
out.reserve(in.size());
|
||||||
|
for (size_t i = 0; i < in.size(); ++i)
|
||||||
|
{
|
||||||
|
out.push_back(KeyPoint(in[i], 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Uses computed homography H to warp original input points to new planar position
|
||||||
|
void warpKeypoints(const Mat& H, const vector<KeyPoint>& in, vector<KeyPoint>& out)
|
||||||
|
{
|
||||||
|
vector<Point2f> pts;
|
||||||
|
keypoints2points(in, pts);
|
||||||
|
vector<Point2f> pts_w(pts.size());
|
||||||
|
Mat m_pts_w(pts_w);
|
||||||
|
perspectiveTransform(Mat(pts), m_pts_w, H);
|
||||||
|
points2keypoints(pts_w, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Converts matching indices to xy points
|
||||||
|
void matches2points(const vector<KeyPoint>& train, const vector<KeyPoint>& query,
|
||||||
|
const std::vector<cv::DMatch>& matches, std::vector<cv::Point2f>& pts_train,
|
||||||
|
std::vector<Point2f>& pts_query)
|
||||||
|
{
|
||||||
|
|
||||||
|
pts_train.clear();
|
||||||
|
pts_query.clear();
|
||||||
|
pts_train.reserve(matches.size());
|
||||||
|
pts_query.reserve(matches.size());
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
for (; i < matches.size(); i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
const DMatch & dmatch = matches[i];
|
||||||
|
|
||||||
|
pts_query.push_back(query[dmatch.queryIdx].pt);
|
||||||
|
pts_train.push_back(train[dmatch.trainIdx].pt);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Takes a descriptor and turns it into an xy point
|
void resetH(Mat&H)
|
||||||
void keypoints2points(const vector<KeyPoint>& in, vector<Point2f>& out)
|
{
|
||||||
{
|
H = Mat::eye(3, 3, CV_32FC1);
|
||||||
out.clear();
|
}
|
||||||
out.reserve(in.size());
|
|
||||||
for (size_t i = 0; i < in.size(); ++i)
|
|
||||||
{
|
|
||||||
out.push_back(in[i].pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Takes an xy point and appends that to a keypoint structure
|
|
||||||
void points2keypoints(const vector<Point2f>& in, vector<KeyPoint>& out)
|
|
||||||
{
|
|
||||||
out.clear();
|
|
||||||
out.reserve(in.size());
|
|
||||||
for (size_t i = 0; i < in.size(); ++i)
|
|
||||||
{
|
|
||||||
out.push_back(KeyPoint(in[i], 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Uses computed homography H to warp original input points to new planar position
|
|
||||||
void warpKeypoints(const Mat& H, const vector<KeyPoint>& in, vector<KeyPoint>& out)
|
|
||||||
{
|
|
||||||
vector<Point2f> pts;
|
|
||||||
keypoints2points(in, pts);
|
|
||||||
vector<Point2f> pts_w(pts.size());
|
|
||||||
Mat m_pts_w(pts_w);
|
|
||||||
perspectiveTransform(Mat(pts), m_pts_w, H);
|
|
||||||
points2keypoints(pts_w, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Converts matching indices to xy points
|
|
||||||
void matches2points(const vector<KeyPoint>& train, const vector<KeyPoint>& query,
|
|
||||||
const std::vector<cv::DMatch>& matches, std::vector<cv::Point2f>& pts_train,
|
|
||||||
std::vector<Point2f>& pts_query)
|
|
||||||
{
|
|
||||||
|
|
||||||
pts_train.clear();
|
|
||||||
pts_query.clear();
|
|
||||||
pts_train.reserve(matches.size());
|
|
||||||
pts_query.reserve(matches.size());
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
for (; i < matches.size(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
const DMatch & dmatch = matches[i];
|
|
||||||
|
|
||||||
pts_query.push_back(query[dmatch.queryIdx].pt);
|
|
||||||
pts_train.push_back(train[dmatch.trainIdx].pt);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetH(Mat&H)
|
|
||||||
{
|
|
||||||
H = Mat::eye(3, 3, CV_32FC1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int ac, char ** av)
|
int main(int ac, char ** av)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ac != 2)
|
if (ac != 2)
|
||||||
{
|
|
||||||
help(av);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
BriefDescriptorExtractor brief(32);
|
|
||||||
|
|
||||||
VideoCapture capture;
|
|
||||||
capture.open(atoi(av[1]));
|
|
||||||
if (!capture.isOpened())
|
|
||||||
{
|
|
||||||
help(av);
|
|
||||||
cout << "capture device " << atoi(av[1]) << " failed to open!" << endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "following keys do stuff:" << endl;
|
|
||||||
cout << "t : grabs a reference frame to match against" << endl;
|
|
||||||
cout << "l : makes the reference frame new every frame" << endl;
|
|
||||||
cout << "q or escape: quit" << endl;
|
|
||||||
|
|
||||||
Mat frame;
|
|
||||||
|
|
||||||
vector<DMatch> matches;
|
|
||||||
|
|
||||||
BruteForceMatcher<Hamming> desc_matcher;
|
|
||||||
|
|
||||||
vector<Point2f> train_pts, query_pts;
|
|
||||||
vector<KeyPoint> train_kpts, query_kpts;
|
|
||||||
vector<unsigned char> match_mask;
|
|
||||||
|
|
||||||
Mat gray;
|
|
||||||
|
|
||||||
bool ref_live = true;
|
|
||||||
|
|
||||||
Mat train_desc, query_desc;
|
|
||||||
const int DESIRED_FTRS = 500;
|
|
||||||
GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4);
|
|
||||||
|
|
||||||
Mat H_prev = Mat::eye(3, 3, CV_32FC1);
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
capture >> frame;
|
|
||||||
if (frame.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cvtColor(frame, gray, CV_RGB2GRAY);
|
|
||||||
|
|
||||||
detector.detect(gray, query_kpts); //Find interest points
|
|
||||||
|
|
||||||
brief.compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location
|
|
||||||
|
|
||||||
if (!train_kpts.empty())
|
|
||||||
{
|
{
|
||||||
|
help(av);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
vector<KeyPoint> test_kpts;
|
BriefDescriptorExtractor brief(32);
|
||||||
warpKeypoints(H_prev.inv(), query_kpts, test_kpts);
|
|
||||||
|
|
||||||
Mat mask = windowedMatchingMask(test_kpts, train_kpts, 25, 25);
|
VideoCapture capture;
|
||||||
desc_matcher.match(query_desc, train_desc, matches, mask);
|
capture.open(atoi(av[1]));
|
||||||
drawKeypoints(frame, test_kpts, frame, Scalar(255, 0, 0), DrawMatchesFlags::DRAW_OVER_OUTIMG);
|
if (!capture.isOpened())
|
||||||
|
{
|
||||||
|
help(av);
|
||||||
|
cout << "capture device " << atoi(av[1]) << " failed to open!" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
matches2points(train_kpts, query_kpts, matches, train_pts, query_pts);
|
cout << "following keys do stuff:" << endl;
|
||||||
|
cout << "t : grabs a reference frame to match against" << endl;
|
||||||
|
cout << "l : makes the reference frame new every frame" << endl;
|
||||||
|
cout << "q or escape: quit" << endl;
|
||||||
|
|
||||||
if (matches.size() > 5)
|
Mat frame;
|
||||||
{
|
|
||||||
Mat H = findHomography(Mat(train_pts), Mat(query_pts), match_mask, RANSAC, 4);
|
vector<DMatch> matches;
|
||||||
if (countNonZero(Mat(match_mask)) > 15)
|
|
||||||
|
BruteForceMatcher<Hamming> desc_matcher;
|
||||||
|
|
||||||
|
vector<Point2f> train_pts, query_pts;
|
||||||
|
vector<KeyPoint> train_kpts, query_kpts;
|
||||||
|
vector<unsigned char> match_mask;
|
||||||
|
|
||||||
|
Mat gray;
|
||||||
|
|
||||||
|
bool ref_live = true;
|
||||||
|
|
||||||
|
Mat train_desc, query_desc;
|
||||||
|
const int DESIRED_FTRS = 500;
|
||||||
|
GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4);
|
||||||
|
|
||||||
|
Mat H_prev = Mat::eye(3, 3, CV_32FC1);
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
capture >> frame;
|
||||||
|
if (frame.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cvtColor(frame, gray, CV_RGB2GRAY);
|
||||||
|
|
||||||
|
detector.detect(gray, query_kpts); //Find interest points
|
||||||
|
|
||||||
|
brief.compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location
|
||||||
|
|
||||||
|
if (!train_kpts.empty())
|
||||||
{
|
{
|
||||||
H_prev = H;
|
|
||||||
|
vector<KeyPoint> test_kpts;
|
||||||
|
warpKeypoints(H_prev.inv(), query_kpts, test_kpts);
|
||||||
|
|
||||||
|
Mat mask = windowedMatchingMask(test_kpts, train_kpts, 25, 25);
|
||||||
|
desc_matcher.match(query_desc, train_desc, matches, mask);
|
||||||
|
drawKeypoints(frame, test_kpts, frame, Scalar(255, 0, 0), DrawMatchesFlags::DRAW_OVER_OUTIMG);
|
||||||
|
|
||||||
|
matches2points(train_kpts, query_kpts, matches, train_pts, query_pts);
|
||||||
|
|
||||||
|
if (matches.size() > 5)
|
||||||
|
{
|
||||||
|
Mat H = findHomography(Mat(train_pts), Mat(query_pts), match_mask, RANSAC, 4);
|
||||||
|
if (countNonZero(Mat(match_mask)) > 15)
|
||||||
|
{
|
||||||
|
H_prev = H;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resetH(H_prev);
|
||||||
|
drawMatchesRelative(train_kpts, query_kpts, matches, frame, match_mask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resetH(H_prev);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
resetH(H_prev);
|
{
|
||||||
drawMatchesRelative(train_kpts, query_kpts, matches, frame, match_mask);
|
H_prev = Mat::eye(3, 3, CV_32FC1);
|
||||||
}
|
Mat out;
|
||||||
else
|
drawKeypoints(gray, query_kpts, out);
|
||||||
resetH(H_prev);
|
frame = out;
|
||||||
|
}
|
||||||
|
|
||||||
|
imshow("frame", frame);
|
||||||
|
|
||||||
|
if (ref_live)
|
||||||
|
{
|
||||||
|
train_kpts = query_kpts;
|
||||||
|
query_desc.copyTo(train_desc);
|
||||||
|
}
|
||||||
|
char key = (char)waitKey(2);
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case 'l':
|
||||||
|
ref_live = true;
|
||||||
|
resetH(H_prev);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
ref_live = false;
|
||||||
|
train_kpts = query_kpts;
|
||||||
|
query_desc.copyTo(train_desc);
|
||||||
|
resetH(H_prev);
|
||||||
|
break;
|
||||||
|
case 27:
|
||||||
|
case 'q':
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
return 0;
|
||||||
{
|
|
||||||
H_prev = Mat::eye(3, 3, CV_32FC1);
|
|
||||||
Mat out;
|
|
||||||
drawKeypoints(gray, query_kpts, out);
|
|
||||||
frame = out;
|
|
||||||
}
|
|
||||||
|
|
||||||
imshow("frame", frame);
|
|
||||||
|
|
||||||
if (ref_live)
|
|
||||||
{
|
|
||||||
train_kpts = query_kpts;
|
|
||||||
query_desc.copyTo(train_desc);
|
|
||||||
}
|
|
||||||
char key = waitKey(2);
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case 'l':
|
|
||||||
ref_live = true;
|
|
||||||
resetH(H_prev);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
ref_live = false;
|
|
||||||
train_kpts = query_kpts;
|
|
||||||
query_desc.copyTo(train_desc);
|
|
||||||
resetH(H_prev);
|
|
||||||
break;
|
|
||||||
case 27:
|
|
||||||
case 'q':
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
|
|||||||
Size pattern_size = expected.size();
|
Size pattern_size = expected.size();
|
||||||
|
|
||||||
vector<Point2f> v;
|
vector<Point2f> v;
|
||||||
bool result;
|
bool result = false;
|
||||||
switch( pattern )
|
switch( pattern )
|
||||||
{
|
{
|
||||||
case CHESSBOARD:
|
case CHESSBOARD:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user