fixes
This commit is contained in:
parent
450ea3131f
commit
07778e1760
@ -15,7 +15,7 @@ using namespace cv;
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
cv::CommandLineParser cmd(argc, argv,
|
||||
CommandLineParser cmd(argc, argv,
|
||||
"{ c camera | false | use camera }"
|
||||
"{ f file | 768x576.avi | input video file }"
|
||||
"{ t type | mog | method's type (mog, mog2) }"
|
||||
@ -58,8 +58,8 @@ int main(int argc, const char** argv)
|
||||
cap >> frame;
|
||||
fgimg.create(frame.size(), frame.type());
|
||||
|
||||
Ptr<cv::BackgroundSubtractorMOG> mog = createBackgroundSubtractorMOG();
|
||||
cv::Ptr<cv::BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
|
||||
Ptr<BackgroundSubtractorMOG> mog = createBackgroundSubtractorMOG();
|
||||
Ptr<BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
|
||||
|
||||
switch (m)
|
||||
{
|
||||
@ -80,7 +80,7 @@ int main(int argc, const char** argv)
|
||||
if (frame.empty())
|
||||
break;
|
||||
|
||||
int64 start = cv::getTickCount();
|
||||
int64 start = getTickCount();
|
||||
|
||||
//update the model
|
||||
switch (m)
|
||||
@ -94,7 +94,7 @@ int main(int argc, const char** argv)
|
||||
break;
|
||||
}
|
||||
|
||||
double fps = cv::getTickFrequency() / (cv::getTickCount() - start);
|
||||
double fps = getTickFrequency() / (getTickCount() - start);
|
||||
std::cout << "FPS : " << fps << std::endl;
|
||||
std::cout << fgimg.size() << std::endl;
|
||||
fgimg.setTo(Scalar::all(0));
|
||||
@ -113,8 +113,8 @@ int main(int argc, const char** argv)
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
ocl::setUseOpenCL(!cv::ocl::useOpenCL());
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL" : "CPU") << " mode\n";
|
||||
ocl::setUseOpenCL(!ocl::useOpenCL());
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL enabled" : "CPU") << " mode\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char** argv)
|
||||
else if(key == 'm')
|
||||
{
|
||||
ocl::setUseOpenCL(!cv::ocl::useOpenCL());
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL" : "CPU") << " mode\n";
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL enabled" : "CPU") << " mode\n";
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -269,7 +269,7 @@ void App::handleKey(char key)
|
||||
case 'm':
|
||||
case 'M':
|
||||
ocl::setUseOpenCL(!cv::ocl::useOpenCL());
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL" : "CPU") << " mode\n";
|
||||
cout << "Switched to " << (ocl::useOpenCL() ? "OpenCL enabled" : "CPU") << " mode\n";
|
||||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
|
@ -1,104 +0,0 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "opencv2/core/ocl.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
static void help()
|
||||
{
|
||||
|
||||
printf("\nShow off image morphology: erosion, dialation, open and close\n"
|
||||
"Call:\n morphology2 [image]\n"
|
||||
"This program also shows use of rect, elipse and cross kernels\n\n");
|
||||
printf( "Hot keys: \n"
|
||||
"\tESC - quit the program\n"
|
||||
"\tr - use rectangle structuring element\n"
|
||||
"\te - use elliptic structuring element\n"
|
||||
"\tc - use cross-shaped structuring element\n"
|
||||
"\tSPACE - loop through all the options\n"
|
||||
"\tm - switch openCL mode support\n");
|
||||
}
|
||||
|
||||
UMat src, dst;
|
||||
|
||||
int element_shape = MORPH_RECT;
|
||||
|
||||
//the address of variable which receives trackbar position update
|
||||
int max_iters = 10;
|
||||
int open_close_pos = 0;
|
||||
int erode_dilate_pos = 0;
|
||||
|
||||
// callback function for open/close trackbar
|
||||
static void OpenClose(int, void*)
|
||||
{
|
||||
int n = open_close_pos - max_iters;
|
||||
int an = n > 0 ? n : -n;
|
||||
Mat element = getStructuringElement(element_shape, Size(an*2+1, an*2+1), Point(an, an) );
|
||||
if( n < 0 )
|
||||
morphologyEx(src, dst, MORPH_OPEN, element);
|
||||
else
|
||||
morphologyEx(src, dst, MORPH_CLOSE, element);
|
||||
imshow("Open/Close",dst);
|
||||
}
|
||||
|
||||
// callback function for erode/dilate trackbar
|
||||
static void ErodeDilate(int, void*)
|
||||
{
|
||||
int n = erode_dilate_pos - max_iters;
|
||||
int an = n > 0 ? n : -n;
|
||||
Mat element = getStructuringElement(element_shape, Size(an*2+1, an*2+1), Point(an, an) );
|
||||
if( n < 0 )
|
||||
erode(src, dst, element);
|
||||
else
|
||||
dilate(src, dst, element);
|
||||
imshow("Erode/Dilate",dst);
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
char* filename = argc == 2 ? argv[1] : (char*)"baboon.jpg";
|
||||
|
||||
imread(filename,1).copyTo(src);
|
||||
if( src.u == 0 )
|
||||
return -1;
|
||||
|
||||
help();
|
||||
|
||||
//create windows for output images
|
||||
namedWindow("Open/Close",1);
|
||||
namedWindow("Erode/Dilate",1);
|
||||
|
||||
open_close_pos = erode_dilate_pos = max_iters;
|
||||
createTrackbar("iterations", "Open/Close",&open_close_pos,max_iters*2+1,OpenClose);
|
||||
createTrackbar("iterations", "Erode/Dilate",&erode_dilate_pos,max_iters*2+1,ErodeDilate);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int c;
|
||||
|
||||
OpenClose(open_close_pos, 0);
|
||||
ErodeDilate(erode_dilate_pos, 0);
|
||||
c = waitKey(0);
|
||||
|
||||
if( (char)c == 27 )
|
||||
break;
|
||||
if( (char)c == 'e' )
|
||||
element_shape = MORPH_ELLIPSE;
|
||||
else if( (char)c == 'r' )
|
||||
element_shape = MORPH_RECT;
|
||||
else if( (char)c == 'c' )
|
||||
element_shape = MORPH_CROSS;
|
||||
else if( (char)c == ' ' )
|
||||
element_shape = (element_shape + 1) % 3;
|
||||
else if( (char)c == 'm' )
|
||||
{
|
||||
cv::ocl::setUseOpenCL(!cv::ocl::useOpenCL());
|
||||
printf("OpenCL is %s\n", ocl::useOpenCL() ? "enabled" : "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -140,7 +140,7 @@ static UMat drawSquaresBoth( const UMat& image,
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const char* keys =
|
||||
"{ i input | | specify input image }"
|
||||
"{ i input | pic1.png | specify input image }"
|
||||
"{ o output | squares_output.jpg | specify output save path}"
|
||||
"{ h help | false | print help message }"
|
||||
"{ m cpu_mode | false | run without OpenCL }";
|
||||
@ -172,6 +172,7 @@ int main(int argc, char** argv)
|
||||
if( image.empty() )
|
||||
{
|
||||
cout << "Couldn't load " << inputName << endl;
|
||||
cmd.printMessage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ static void workEnd()
|
||||
|
||||
static double getTime()
|
||||
{
|
||||
return work_end /((double)getTickFrequency() * 1000.);
|
||||
return work_end /((double)getTickFrequency() )* 1000.;
|
||||
}
|
||||
|
||||
template<class KPDetector>
|
||||
@ -136,11 +136,11 @@ static Mat drawGoodMatches(
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* keys =
|
||||
"{ h help | false | print help message }"
|
||||
"{ l left | | specify left image }"
|
||||
"{ r right | | specify right image }"
|
||||
"{ o output | SURF_output.jpg | specify output save path }"
|
||||
"{ m cpu_mode | false | run without OpenCL }";
|
||||
"{ h help | false | print help message }"
|
||||
"{ l left | box.png | specify left image }"
|
||||
"{ r right | box_in_scene.png | specify right image }"
|
||||
"{ o output | SURF_output.jpg | specify output save path }"
|
||||
"{ m cpu_mode | false | run without OpenCL }";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
if (cmd.has("help"))
|
||||
@ -160,11 +160,23 @@ int main(int argc, char* argv[])
|
||||
|
||||
std::string outpath = cmd.get<std::string>("o");
|
||||
|
||||
imread(cmd.get<std::string>("l"), IMREAD_GRAYSCALE).copyTo(img1);
|
||||
CV_Assert(!img1.empty());
|
||||
std::string leftName = cmd.get<std::string>("l");
|
||||
imread(leftName, IMREAD_GRAYSCALE).copyTo(img1);
|
||||
if(img1.empty())
|
||||
{
|
||||
std::cout << "Couldn't load " << leftName << std::endl;
|
||||
cmd.printMessage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
imread(cmd.get<std::string>("r"), IMREAD_GRAYSCALE).copyTo(img2);
|
||||
CV_Assert(!img2.empty());
|
||||
std::string rightName = cmd.get<std::string>("r");
|
||||
imread(rightName, IMREAD_GRAYSCALE).copyTo(img2);
|
||||
if(img2.empty())
|
||||
{
|
||||
std::cout << "Couldn't load " << rightName << std::endl;
|
||||
cmd.printMessage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
double surf_time = 0.;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user