本文整理汇总了C++中Controller::displayFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::displayFunction方法的具体用法?C++ Controller::displayFunction怎么用?C++ Controller::displayFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::displayFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processImagePair
int processImagePair() {
namedWindow("Main", CV_WINDOW_KEEPRATIO); //resizable window;
Mat sceneRgbImage, sceneGrayImage;
sceneRgbImage = cv::imread(path + "/images/card_frame.jpg");
if (sceneRgbImage.empty()) {
std::cout << "Scene image cannot be read" << std::endl;
return 1;
}
cvtColor(sceneRgbImage, sceneGrayImage, CV_RGB2GRAY);
Controller *controller = Controller::getInstance();
if (!controller->isInitialized) {
controller->initialize(sceneRgbImage, path);
}
controller->isModeObjectDetection(true);
// call display function with frame data
bool shouldQuit = false;
do {
// display single window with one analyzer configuration
controller->displayFunction(sceneRgbImage, sceneGrayImage);
// Read the keyboard input:
int keyCode = cv::waitKey(5);
if (keyCode == 27 || keyCode == 'q') {
shouldQuit = true;
}
} while (!shouldQuit);
return 0;
}
示例2: processVideo
int processVideo() {
VideoCapture capture(1);
if (!capture.isOpened()) {
cerr << "Failed to open video stream\n" << endl;
return 1;
}
namedWindow("Main", CV_WINDOW_KEEPRATIO); //resizable window;
Mat rgbFrame, grayFrame;
capture.read(rgbFrame);
// Try to read the pattern:
cv::Mat patternImage, patternImageGray;
patternImage = cv::imread(path + "/images/card.jpg");
if (patternImage.empty()) {
std::cout << "Input image cannot be read" << std::endl;
return 2;
}
cvtColor(patternImage, patternImageGray, CV_RGB2GRAY);
Controller *controller = Controller::getInstance();
for (; ;) {
capture.read(rgbFrame);
if (rgbFrame.empty()) break;
if (!controller->isInitialized) {
controller->initialize(rgbFrame, path);
}
cvtColor(rgbFrame, grayFrame, CV_RGB2GRAY);
if (grayFrame.empty()) {
std::cout << "Cannot open video capture device" << std::endl;
}
// call display function with frame data
controller->displayFunction(rgbFrame, grayFrame);
imshow("Main", rgbFrame);
char key = (char) waitKey(5); //delay N millis, usually long enough to display and capture input
switch (key) {
case 'q':
controller->isModeObjectDetection(true);
cout << "Recognition started.." << endl;
break;
case 'w':
controller->isModeObjectDetection(false);
cout << "Recognition stopped!" << endl;
break;
case 'e':
controller->isModeTracking(true);
cout << "Tracking started.." << endl;
break;
case 'r':
controller->isModeTracking(false);
cout << "Tracking stopped!" << endl;
break;
case 's':
controller->createObjectPattern(patternImage, patternImageGray);
cout << "Image registered" << endl;
break;
case 'd':
controller->createObjectPattern(rgbFrame, grayFrame);
cout << "Frame registered" << endl;
break;
case 't':
cout << "Configure SURF as detector" << endl;
cout << "RESULT=" << controller->setDetector("SURF");
break;
case 'z':
cout << "Configure SURF as extractor" << endl;
cout << "RESULT=" << controller->setExtractor("SURF");
break;
case 'u':
cout << "Configure BF as matcher" << endl;
cout << "RESULT=" << controller->setMatcher("BF");
break;
case 27: //escape key
return 0;
default:
break;
}
}
}