История изменений
Исправление LIKAN, (текущая версия) :
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat frame, gray;
VideoCapture capture;
int dev_id = 0; //Device number.
capture.open(dev_id);
if (!capture.isOpened()){
cerr << "Failed to open video device "
<< dev_id << " \n" << endl;
return 1;
}
while (frame.empty()){
capture >> frame;
}
int MAX_COUNT = 10;
TermCriteria termcrit(TermCriteria::COUNT + TermCriteria::EPS,
20, 0.3);
// We use two sets of points in order to swap
// pointers.
vector<Point2f> points;
Size subPixWinSize(10, 10), winSize(100, 100);
//Convert image to gray scale.
cvtColor(frame, gray, CV_RGB2GRAY);
//Feature detection is performed here...
goodFeaturesToTrack(gray, points, MAX_COUNT, 0.01, 10, Mat(), 3, 0, 0.04);
try{
cornerSubPix(gray, points, subPixWinSize, Size(-1, -1), termcrit);
}
catch (Exception &e){
cout << e.msg << endl;
}
cout << points.size()<<endl;
/*for (int i = 0; i < 2000; ++i)
circle(gray, points[i], 10, Scalar(255, 255, 255));*/
imshow("Camera check", gray);
char key = (char)waitKey(0);
return 0;
}
Исходная версия LIKAN, :
#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat frame, gray;
VideoCapture capture;
int dev_id = 0; //Device number.
capture.open(dev_id);
if (!capture.isOpened()){
cerr << "Failed to open video device "
<< dev_id << " \n" << endl;
return 1;
}
while (frame.empty()){
capture >> frame;
}
int MAX_COUNT = 10;
TermCriteria termcrit(TermCriteria::COUNT + TermCriteria::EPS,
20, 0.3);
// We use two sets of points in order to swap
// pointers.
vector<Point2f> points;
Size subPixWinSize(10, 10), winSize(100, 100);
//Convert image to gray scale.
cvtColor(frame, gray, CV_RGB2GRAY);
//Feature detection is performed here...
goodFeaturesToTrack(gray, points, MAX_COUNT, 0.01, 10, Mat(), 3, 0, 0.04);
try{
cornerSubPix(gray, points, subPixWinSize, Size(-1, -1), termcrit);
}
catch (Exception &e){
cout << e.msg << endl;
}
cout << points.size();
/*for (int i = 0; i < 2000; ++i)
circle(gray, points[i], 10, Scalar(255, 255, 255));*/
imshow("Camera check", gray);
char key = (char)waitKey(0);
return 0;
}