Commit f7339512 authored by Suleyman TURKMEN's avatar Suleyman TURKMEN Committed by sturkmen72

Update Samples

parent 9ef53737
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/core/utils/trace.hpp> #include <opencv2/core/utils/trace.hpp>
using namespace cv; using namespace cv;
......
...@@ -56,11 +56,6 @@ static void updateBrightnessContrast( int /*arg*/, void* ) ...@@ -56,11 +56,6 @@ static void updateBrightnessContrast( int /*arg*/, void* )
Scalar::all(0), -1, 8, 0 ); Scalar::all(0), -1, 8, 0 );
imshow("histogram", histImage); imshow("histogram", histImage);
} }
static void help()
{
std::cout << "\nThis program demonstrates the use of calcHist() -- histogram creation.\n"
<< "Usage: \n" << "demhist [image_name -- Defaults to baboon.jpg]" << std::endl;
}
const char* keys = const char* keys =
{ {
...@@ -70,9 +65,10 @@ const char* keys = ...@@ -70,9 +65,10 @@ const char* keys =
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
parser.about("\nThis program demonstrates the use of calcHist() -- histogram creation.\n");
if (parser.has("help")) if (parser.has("help"))
{ {
help(); parser.printMessage();
return 0; return 0;
} }
string inputImage = parser.get<string>(0); string inputImage = parser.get<string>(0);
......
...@@ -9,12 +9,11 @@ ...@@ -9,12 +9,11 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
static void help() static void help(const char ** argv)
{ {
printf("\nThis program demonstrated the use of the discrete Fourier transform (dft)\n" printf("\nThis program demonstrated the use of the discrete Fourier transform (dft)\n"
"The dft of an image is taken and it's power spectrum is displayed.\n" "The dft of an image is taken and it's power spectrum is displayed.\n"
"Usage:\n" "Usage:\n %s [image_name -- default lena.jpg]\n",argv[0]);
"./dft [image_name -- default lena.jpg]\n");
} }
const char* keys = const char* keys =
...@@ -24,18 +23,18 @@ const char* keys = ...@@ -24,18 +23,18 @@ const char* keys =
int main(int argc, const char ** argv) int main(int argc, const char ** argv)
{ {
help(); help(argv);
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
if (parser.has("help")) if (parser.has("help"))
{ {
help(); help(argv);
return 0; return 0;
} }
string filename = parser.get<string>(0); string filename = parser.get<string>(0);
Mat img = imread(samples::findFile(filename), IMREAD_GRAYSCALE); Mat img = imread(samples::findFile(filename), IMREAD_GRAYSCALE);
if( img.empty() ) if( img.empty() )
{ {
help(); help(argv);
printf("Cannot read image file: %s\n", filename.c_str()); printf("Cannot read image file: %s\n", filename.c_str());
return -1; return -1;
} }
......
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
......
...@@ -14,15 +14,16 @@ struct ParamColorMap { ...@@ -14,15 +14,16 @@ struct ParamColorMap {
}; };
String winName="False color"; String winName="False color";
static const String ColorMaps[] = { "Autumn", "Bone", "Jet", "Winter", "Rainbow", "Ocean", "Summer", static const String ColorMaps[] = { "Autumn", "Bone", "Jet", "Winter", "Rainbow", "Ocean", "Summer", "Spring",
"Spring", "Cool", "HSV", "Pink", "Hot", "Parula", "User defined (random)"}; "Cool", "HSV", "Pink", "Hot", "Parula", "Magma", "Inferno", "Plasma", "Viridis",
"Cividis", "Twilight", "Twilight Shifted", "Turbo", "User defined (random)" };
static void TrackColorMap(int x, void *r) static void TrackColorMap(int x, void *r)
{ {
ParamColorMap *p = (ParamColorMap*)r; ParamColorMap *p = (ParamColorMap*)r;
Mat dst; Mat dst;
p->iColormap= x; p->iColormap= x;
if (x == COLORMAP_PARULA + 1) if (x == COLORMAP_TURBO + 1)
{ {
Mat lutRND(256, 1, CV_8UC3); Mat lutRND(256, 1, CV_8UC3);
randu(lutRND, Scalar(0, 0, 0), Scalar(255, 255, 255)); randu(lutRND, Scalar(0, 0, 0), Scalar(255, 255, 255));
...@@ -98,7 +99,7 @@ int main(int argc, char** argv) ...@@ -98,7 +99,7 @@ int main(int argc, char** argv)
namedWindow(winName); namedWindow(winName);
createTrackbar("colormap", winName,&p.iColormap,1,TrackColorMap,(void*)&p); createTrackbar("colormap", winName,&p.iColormap,1,TrackColorMap,(void*)&p);
setTrackbarMin("colormap", winName, COLORMAP_AUTUMN); setTrackbarMin("colormap", winName, COLORMAP_AUTUMN);
setTrackbarMax("colormap", winName, COLORMAP_PARULA+1); setTrackbarMax("colormap", winName, COLORMAP_TURBO+1);
setTrackbarPos("colormap", winName, -1); setTrackbarPos("colormap", winName, -1);
TrackColorMap(0, (void*)&p); TrackColorMap(0, (void*)&p);
......
...@@ -8,13 +8,12 @@ ...@@ -8,13 +8,12 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
static void help() static void help( char** argv )
{ {
cout << "\nCool inpainging demo. Inpainting repairs damage to images by floodfilling the damage \n" cout << "\nCool inpainging demo. Inpainting repairs damage to images by floodfilling the damage \n"
<< "with surrounding image areas.\n" << "with surrounding image areas.\n"
"Using OpenCV version %s\n" << CV_VERSION << "\n" "Using OpenCV version %s\n" << CV_VERSION << "\n"
"Usage:\n" "Usage:\n" << argv[0] <<" [image_name -- Default fruits.jpg]\n" << endl;
"./inpaint [image_name -- Default fruits.jpg]\n" << endl;
cout << "Hot keys: \n" cout << "Hot keys: \n"
"\tESC - quit the program\n" "\tESC - quit the program\n"
...@@ -48,7 +47,7 @@ static void onMouse( int event, int x, int y, int flags, void* ) ...@@ -48,7 +47,7 @@ static void onMouse( int event, int x, int y, int flags, void* )
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
cv::CommandLineParser parser(argc, argv, "{@image|fruits.jpg|}"); cv::CommandLineParser parser(argc, argv, "{@image|fruits.jpg|}");
help(); help(argv);
string filename = samples::findFile(parser.get<string>("@image")); string filename = samples::findFile(parser.get<string>("@image"));
Mat img0 = imread(filename, IMREAD_COLOR); Mat img0 = imread(filename, IMREAD_COLOR);
......
...@@ -31,9 +31,9 @@ public: ...@@ -31,9 +31,9 @@ public:
// groupThreshold (set groupThreshold to 0 to turn off the grouping completely). // groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
vector<Rect> found; vector<Rect> found;
if (m == Default) if (m == Default)
hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2, false); hog.detectMultiScale(img, found, 0, Size(8,8), Size(), 1.05, 2, false);
else if (m == Daimler) else if (m == Daimler)
hog_d.detectMultiScale(img, found, 0.5, Size(8,8), Size(32,32), 1.05, 2, true); hog_d.detectMultiScale(img, found, 0, Size(8,8), Size(), 1.05, 2, true);
return found; return found;
} }
void adjustRect(Rect & r) const void adjustRect(Rect & r) const
...@@ -54,7 +54,7 @@ static const string keys = "{ help h | | print help message }" ...@@ -54,7 +54,7 @@ static const string keys = "{ help h | | print help message }"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
parser.about("This sample demonstrates the use ot the HoG descriptor."); parser.about("This sample demonstrates the use of the HoG descriptor.");
if (parser.has("help")) if (parser.has("help"))
{ {
parser.printMessage(); parser.printMessage();
...@@ -114,7 +114,7 @@ int main(int argc, char** argv) ...@@ -114,7 +114,7 @@ int main(int argc, char** argv)
imshow("People detector", frame); imshow("People detector", frame);
// interact with user // interact with user
const char key = (char)waitKey(30); const char key = (char)waitKey(1);
if (key == 27 || key == 'q') // ESC if (key == 27 || key == 'q') // ESC
{ {
cout << "Exit requested" << endl; cout << "Exit requested" << endl;
......
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
using namespace cv; using namespace cv;
static void help( void )
{
printf("\nThis program illustrates Linear-Polar and Log-Polar image transforms\n"
"Usage :\n"
"./polar_transforms [[camera number -- Default 0],[path_to_filename]]\n\n");
}
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
VideoCapture capture; VideoCapture capture;
Mat log_polar_img, lin_polar_img, recovered_log_polar, recovered_lin_polar_img; Mat log_polar_img, lin_polar_img, recovered_log_polar, recovered_lin_polar_img;
help(); CommandLineParser parser(argc, argv, "{@input|0| camera device number or video file path}");
parser.about("\nThis program illustrates usage of Linear-Polar and Log-Polar image transforms\n");
CommandLineParser parser(argc, argv, "{@input|0|}"); parser.printMessage();
std::string arg = parser.get<std::string>("@input"); std::string arg = parser.get<std::string>("@input");
if( arg.size() == 1 && isdigit(arg[0]) ) if( arg.size() == 1 && isdigit(arg[0]) )
...@@ -28,9 +22,7 @@ int main( int argc, char** argv ) ...@@ -28,9 +22,7 @@ int main( int argc, char** argv )
if( !capture.isOpened() ) if( !capture.isOpened() )
{ {
const char* name = argv[0];
fprintf(stderr,"Could not initialize capturing...\n"); fprintf(stderr,"Could not initialize capturing...\n");
fprintf(stderr,"Usage: %s <CAMERA_NUMBER> , or \n %s <VIDEO_FILE>\n", name, name);
return -1; return -1;
} }
...@@ -102,15 +94,6 @@ int main( int argc, char** argv ) ...@@ -102,15 +94,6 @@ int main( int argc, char** argv )
drawMarker(src, Point(x, y), Scalar(0, 255, 0)); drawMarker(src, Point(x, y), Scalar(0, 255, 0));
drawMarker(dst, Point(rho, phi), Scalar(0, 255, 0)); drawMarker(dst, Point(rho, phi), Scalar(0, 255, 0));
#if 0 //C version
CvMat src = frame;
CvMat dst = lin_polar_img;
CvMat inverse = recovered_lin_polar_img;
cvLinearPolar(&src, &dst, center, maxRadius, flags);
cvLinearPolar(&dst, &inverse, center, maxRadius,flags + WARP_INVERSE_MAP);
#endif
imshow("Src frame", src); imshow("Src frame", src);
imshow("Log-Polar", log_polar_img); imshow("Log-Polar", log_polar_img);
imshow("Linear-Polar", lin_polar_img); imshow("Linear-Polar", lin_polar_img);
......
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <string> #include <string>
#include <iostream> #include <iostream>
......
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
static void help() static void help(const char** argv)
{ {
cout << "\nThis program demonstrates the smile detector.\n" cout << "\nThis program demonstrates the smile detector.\n"
"Usage:\n" "Usage:\n" <<
"./smiledetect [--cascade=<cascade_path> this is the frontal face classifier]\n" argv[0] << " [--cascade=<cascade_path> this is the frontal face classifier]\n"
" [--smile-cascade=[<smile_cascade_path>]]\n" " [--smile-cascade=[<smile_cascade_path>]]\n"
" [--scale=<image scale greater or equal to 1, try 2.0 for example. The larger the faster the processing>]\n" " [--scale=<image scale greater or equal to 1, try 2.0 for example. The larger the faster the processing>]\n"
" [--try-flip]\n" " [--try-flip]\n"
" [video_filename|camera_index]\n\n" " [video_filename|camera_index]\n\n"
"Example:\n" "Example:\n" <<
"./smiledetect --cascade=\"data/haarcascades/haarcascade_frontalface_alt.xml\" --smile-cascade=\"data/haarcascades/haarcascade_smile.xml\" --scale=2.0\n\n" argv[0] << " --cascade=\"data/haarcascades/haarcascade_frontalface_alt.xml\" --smile-cascade=\"data/haarcascades/haarcascade_smile.xml\" --scale=2.0\n\n"
"During execution:\n\tHit any key to quit.\n" "During execution:\n\tHit any key to quit.\n"
"\tUsing OpenCV version " << CV_VERSION << "\n" << endl; "\tUsing OpenCV version " << CV_VERSION << "\n" << endl;
} }
...@@ -35,7 +36,7 @@ int main( int argc, const char** argv ) ...@@ -35,7 +36,7 @@ int main( int argc, const char** argv )
string inputName; string inputName;
bool tryflip; bool tryflip;
help(); help(argv);
CascadeClassifier cascade, nestedCascade; CascadeClassifier cascade, nestedCascade;
double scale; double scale;
...@@ -46,7 +47,7 @@ int main( int argc, const char** argv ) ...@@ -46,7 +47,7 @@ int main( int argc, const char** argv )
"{try-flip||}{@input||}"); "{try-flip||}{@input||}");
if (parser.has("help")) if (parser.has("help"))
{ {
help(); help(argv);
return 0; return 0;
} }
cascadeName = samples::findFile(parser.get<string>("cascade")); cascadeName = samples::findFile(parser.get<string>("cascade"));
...@@ -56,7 +57,7 @@ int main( int argc, const char** argv ) ...@@ -56,7 +57,7 @@ int main( int argc, const char** argv )
scale = parser.get<int>("scale"); scale = parser.get<int>("scale");
if (!parser.check()) if (!parser.check())
{ {
help(); help(argv);
return 1; return 1;
} }
if (scale < 1) if (scale < 1)
...@@ -64,13 +65,13 @@ int main( int argc, const char** argv ) ...@@ -64,13 +65,13 @@ int main( int argc, const char** argv )
if( !cascade.load( cascadeName ) ) if( !cascade.load( cascadeName ) )
{ {
cerr << "ERROR: Could not load face cascade" << endl; cerr << "ERROR: Could not load face cascade" << endl;
help(); help(argv);
return -1; return -1;
} }
if( !nestedCascade.load( nestedCascadeName ) ) if( !nestedCascade.load( nestedCascadeName ) )
{ {
cerr << "ERROR: Could not load smile cascade" << endl; cerr << "ERROR: Could not load smile cascade" << endl;
help(); help(argv);
return -1; return -1;
} }
if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) ) if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) )
...@@ -108,7 +109,7 @@ int main( int argc, const char** argv ) ...@@ -108,7 +109,7 @@ int main( int argc, const char** argv )
else else
{ {
cerr << "ERROR: Could not initiate capture" << endl; cerr << "ERROR: Could not initiate capture" << endl;
help(); help(argv);
return -1; return -1;
} }
......
...@@ -138,8 +138,8 @@ static void drawSquares( Mat& image, const vector<vector<Point> >& squares ) ...@@ -138,8 +138,8 @@ static void drawSquares( Mat& image, const vector<vector<Point> >& squares )
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
static const char* names[] = { "data/pic1.png", "data/pic2.png", "data/pic3.png", static const char* names[] = { "pic1.png", "pic2.png", "pic3.png",
"data/pic4.png", "data/pic5.png", "data/pic6.png", 0 }; "pic4.png", "pic5.png", "pic6.png", 0 };
help(argv[0]); help(argv[0]);
if( argc > 1) if( argc > 1)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/ml.hpp" #include "opencv2/ml.hpp"
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
#include <time.h> #include <time.h>
......
/** /**
* @file LinearBlend.cpp * @file AddingImagesTrackbar.cpp
* @brief Simple linear blender ( dst = alpha*src1 + beta*src2 ) * @brief Simple linear blender ( dst = alpha*src1 + beta*src2 )
* @author OpenCV team * @author OpenCV team
*/ */
...@@ -44,8 +44,8 @@ int main( void ) ...@@ -44,8 +44,8 @@ int main( void )
{ {
//![load] //![load]
/// Read images ( both have to be of the same size and type ) /// Read images ( both have to be of the same size and type )
src1 = imread("../data/LinuxLogo.jpg"); src1 = imread( samples::findFile("LinuxLogo.jpg") );
src2 = imread("../data/WindowsLogo.jpg"); src2 = imread( samples::findFile("WindowsLogo.jpg") );
//![load] //![load]
if( src1.empty() ) { cout << "Error loading src1 \n"; return -1; } if( src1.empty() ) { cout << "Error loading src1 \n"; return -1; }
......
/** /**
* @file LinearTransforms.cpp * @file BasicLinearTransformsTrackbar.cpp
* @brief Simple program to change contrast and brightness * @brief Simple program to change contrast and brightness
* @date Mon, June 6, 2011 * @date Mon, June 6, 2011
* @author OpenCV team * @author OpenCV team
...@@ -44,12 +44,12 @@ static void on_trackbar( int, void* ) ...@@ -44,12 +44,12 @@ static void on_trackbar( int, void* )
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Read image given by user /// Read image given by user
String imageName("../data/lena.jpg"); // by default String imageName("lena.jpg"); // by default
if (argc > 1) if (argc > 1)
{ {
imageName = argv[1]; imageName = argv[1];
} }
image = imread( imageName ); image = imread( samples::findFile( imageName ) );
/// Initialize values /// Initialize values
alpha = 1; alpha = 1;
......
...@@ -18,8 +18,8 @@ using namespace std; ...@@ -18,8 +18,8 @@ using namespace std;
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//! [Load image] //! [Load image]
CommandLineParser parser( argc, argv, "{@input | ../data/lena.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -34,7 +34,7 @@ int main( int argc, char** argv ) ...@@ -34,7 +34,7 @@ int main( int argc, char** argv )
if (argc < 3) if (argc < 3)
{ {
cout << "Not enough parameters" << endl; cout << "Not enough parameters" << endl;
cout << "Usage:\n./MatchTemplate_Demo <image_name> <template_name> [<mask_name>]" << endl; cout << "Usage:\n" << argv[0] << " <image_name> <template_name> [<mask_name>]" << endl;
return -1; return -1;
} }
...@@ -51,7 +51,7 @@ int main( int argc, char** argv ) ...@@ -51,7 +51,7 @@ int main( int argc, char** argv )
if(img.empty() || templ.empty() || (use_mask && mask.empty())) if(img.empty() || templ.empty() || (use_mask && mask.empty()))
{ {
cout << "Can't read one of the images" << endl; cout << "Can't read one of the images" << endl;
return -1; return EXIT_FAILURE;
} }
//! [load_image] //! [load_image]
...@@ -71,7 +71,7 @@ int main( int argc, char** argv ) ...@@ -71,7 +71,7 @@ int main( int argc, char** argv )
//! [wait_key] //! [wait_key]
waitKey(0); waitKey(0);
return 0; return EXIT_SUCCESS;
//! [wait_key] //! [wait_key]
} }
......
...@@ -18,11 +18,11 @@ using namespace cv; ...@@ -18,11 +18,11 @@ using namespace cv;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
//! [Load image] //! [Load image]
CommandLineParser parser( argc, argv, "{@input | ../data/lena.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR );
if( src.empty() ) if( src.empty() )
{ {
return -1; return EXIT_FAILURE;
} }
//! [Load image] //! [Load image]
...@@ -85,5 +85,5 @@ int main(int argc, char** argv) ...@@ -85,5 +85,5 @@ int main(int argc, char** argv)
waitKey(); waitKey();
//! [Display] //! [Display]
return 0; return EXIT_SUCCESS;
} }
...@@ -22,8 +22,8 @@ int main( int argc, char** argv ) ...@@ -22,8 +22,8 @@ int main( int argc, char** argv )
{ {
/// Read image given by user /// Read image given by user
//! [basic-linear-transform-load] //! [basic-linear-transform-load]
CommandLineParser parser( argc, argv, "{@input | ../data/lena.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
Mat image = imread( parser.get<String>( "@input" ) ); Mat image = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( image.empty() ) if( image.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
...@@ -67,7 +67,7 @@ int main( int argc, char** argv ) ...@@ -67,7 +67,7 @@ int main( int argc, char** argv )
imshow("Original Image", image); imshow("Original Image", image);
imshow("New Image", new_image); imshow("New Image", new_image);
/// Wait until user press some key /// Wait until the user press a key
waitKey(); waitKey();
//! [basic-linear-transform-display] //! [basic-linear-transform-display]
return 0; return 0;
......
...@@ -31,8 +31,8 @@ void Dilation( int, void* ); ...@@ -31,8 +31,8 @@ void Dilation( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load an image /// Load an image
CommandLineParser parser( argc, argv, "{@input | ../data/LinuxLogo.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | LinuxLogo.jpg | input image}" );
src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -33,13 +33,13 @@ void Morphology_Operations( int, void* ); ...@@ -33,13 +33,13 @@ void Morphology_Operations( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//![load] //![load]
CommandLineParser parser( argc, argv, "{@input | ../data/baboon.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | baboon.jpg | input image}" );
src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR );
if (src.empty()) if (src.empty())
{ {
std::cout << "Could not open or find the image!\n" << std::endl; std::cout << "Could not open or find the image!\n" << std::endl;
std::cout << "Usage: " << argv[0] << " <Input image>" << std::endl; std::cout << "Usage: " << argv[0] << " <Input image>" << std::endl;
return -1; return EXIT_FAILURE;
} }
//![load] //![load]
......
...@@ -27,16 +27,16 @@ int main( int argc, char** argv ) ...@@ -27,16 +27,16 @@ int main( int argc, char** argv )
" * [ESC] -> Close program \n" << endl; " * [ESC] -> Close program \n" << endl;
//![load] //![load]
const char* filename = argc >=2 ? argv[1] : "../data/chicky_512.png"; const char* filename = argc >=2 ? argv[1] : "chicky_512.png";
// Loads an image // Loads an image
Mat src = imread( filename ); Mat src = imread( samples::findFile( filename ) );
// Check if image is loaded fine // Check if image is loaded fine
if(src.empty()){ if(src.empty()){
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default ../data/chicky_512.png] \n"); printf(" Program Arguments: [image_name -- default chicky_512.png] \n");
return -1; return EXIT_FAILURE;
} }
//![load] //![load]
...@@ -65,5 +65,5 @@ int main( int argc, char** argv ) ...@@ -65,5 +65,5 @@ int main( int argc, char** argv )
} }
//![loop] //![loop]
return 0; return EXIT_SUCCESS;
} }
...@@ -33,14 +33,14 @@ int main( int argc, char ** argv ) ...@@ -33,14 +33,14 @@ int main( int argc, char ** argv )
namedWindow( window_name, WINDOW_AUTOSIZE ); namedWindow( window_name, WINDOW_AUTOSIZE );
/// Load the source image /// Load the source image
const char* filename = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* filename = argc >=2 ? argv[1] : "lena.jpg";
src = imread( filename, IMREAD_COLOR ); src = imread( samples::findFile( filename ), IMREAD_COLOR );
if(src.empty()) if (src.empty())
{ {
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Usage: ./Smoothing [image_name -- default ../data/lena.jpg] \n"); printf(" Usage:\n %s [image_name-- default lena.jpg] \n", argv[0]);
return -1; return EXIT_FAILURE;
} }
if( display_caption( "Original Image" ) != 0 ) if( display_caption( "Original Image" ) != 0 )
......
...@@ -49,16 +49,16 @@ static void Threshold_Demo( int, void* ) ...@@ -49,16 +49,16 @@ static void Threshold_Demo( int, void* )
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//! [load] //! [load]
String imageName("../data/stuff.jpg"); // by default String imageName("stuff.jpg"); // by default
if (argc > 1) if (argc > 1)
{ {
imageName = argv[1]; imageName = argv[1];
} }
src = imread( imageName, IMREAD_COLOR ); // Load an image src = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Load an image
if (src.empty()) if (src.empty())
{ {
cout << "Cannot read image: " << imageName << std::endl; cout << "Cannot read the image: " << imageName << std::endl;
return -1; return -1;
} }
...@@ -72,16 +72,16 @@ int main( int argc, char** argv ) ...@@ -72,16 +72,16 @@ int main( int argc, char** argv )
//! [trackbar] //! [trackbar]
createTrackbar( trackbar_type, createTrackbar( trackbar_type,
window_name, &threshold_type, window_name, &threshold_type,
max_type, Threshold_Demo ); // Create Trackbar to choose type of Threshold max_type, Threshold_Demo ); // Create a Trackbar to choose type of Threshold
createTrackbar( trackbar_value, createTrackbar( trackbar_value,
window_name, &threshold_value, window_name, &threshold_value,
max_value, Threshold_Demo ); // Create Trackbar to choose Threshold value max_value, Threshold_Demo ); // Create a Trackbar to choose Threshold value
//! [trackbar] //! [trackbar]
Threshold_Demo( 0, 0 ); // Call the function to initialize Threshold_Demo( 0, 0 ); // Call the function to initialize
/// Wait until user finishes program /// Wait until the user finishes the program
waitKey(); waitKey();
return 0; return 0;
} }
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
using namespace cv; using namespace cv;
......
...@@ -64,8 +64,8 @@ void on_gamma_correction_trackbar(int, void *) ...@@ -64,8 +64,8 @@ void on_gamma_correction_trackbar(int, void *)
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
CommandLineParser parser( argc, argv, "{@input | ../data/lena.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
img_original = imread( parser.get<String>( "@input" ) ); img_original = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( img_original.empty() ) if( img_original.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -17,8 +17,8 @@ using namespace cv; ...@@ -17,8 +17,8 @@ using namespace cv;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
//! [load_image] //! [load_image]
CommandLineParser parser(argc, argv, "{@input | ../data/notes.png | input image}"); CommandLineParser parser(argc, argv, "{@input | notes.png | input image}");
Mat src = imread(parser.get<String>("@input"), IMREAD_COLOR); Mat src = imread( samples::findFile( parser.get<String>("@input") ), IMREAD_COLOR);
if (src.empty()) if (src.empty())
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -58,8 +58,8 @@ static void CannyThreshold(int, void*) ...@@ -58,8 +58,8 @@ static void CannyThreshold(int, void*)
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//![load] //![load]
CommandLineParser parser( argc, argv, "{@input | ../data/fruits.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | fruits.jpg | input image}" );
src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); // Load an image src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR ); // Load an image
if( src.empty() ) if( src.empty() )
{ {
......
...@@ -18,8 +18,8 @@ using namespace std; ...@@ -18,8 +18,8 @@ using namespace std;
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//! [Load the image] //! [Load the image]
CommandLineParser parser( argc, argv, "{@input | ../data/lena.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -18,7 +18,6 @@ namespace ...@@ -18,7 +18,6 @@ namespace
const std::string windowName = "Hough Circle Detection Demo"; const std::string windowName = "Hough Circle Detection Demo";
const std::string cannyThresholdTrackbarName = "Canny threshold"; const std::string cannyThresholdTrackbarName = "Canny threshold";
const std::string accumulatorThresholdTrackbarName = "Accumulator Threshold"; const std::string accumulatorThresholdTrackbarName = "Accumulator Threshold";
const std::string usage = "Usage : tutorial_HoughCircle_Demo <path_to_input_image>\n";
// initial and max values of the parameters of interests. // initial and max values of the parameters of interests.
const int cannyThresholdInitialValue = 100; const int cannyThresholdInitialValue = 100;
...@@ -56,17 +55,17 @@ int main(int argc, char** argv) ...@@ -56,17 +55,17 @@ int main(int argc, char** argv)
Mat src, src_gray; Mat src, src_gray;
// Read the image // Read the image
String imageName("../data/stuff.jpg"); // by default String imageName("stuff.jpg"); // by default
if (argc > 1) if (argc > 1)
{ {
imageName = argv[1]; imageName = argv[1];
} }
src = imread( imageName, IMREAD_COLOR ); src = imread( samples::findFile( imageName ), IMREAD_COLOR );
if( src.empty() ) if( src.empty() )
{ {
std::cerr<<"Invalid input image\n"; std::cerr << "Invalid input image\n";
std::cout<<usage; std::cout << "Usage : " << argv[0] << " <path_to_input_image>\n";;
return -1; return -1;
} }
......
...@@ -38,12 +38,12 @@ void Probabilistic_Hough( int, void* ); ...@@ -38,12 +38,12 @@ void Probabilistic_Hough( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
// Read the image // Read the image
String imageName("../data/building.jpg"); // by default String imageName("building.jpg"); // by default
if (argc > 1) if (argc > 1)
{ {
imageName = argv[1]; imageName = argv[1];
} }
src = imread( imageName, IMREAD_COLOR ); src = imread( samples::findFile( imageName ), IMREAD_COLOR );
if( src.empty() ) if( src.empty() )
{ help(); { help();
......
...@@ -26,14 +26,14 @@ int main( int argc, char** argv ) ...@@ -26,14 +26,14 @@ int main( int argc, char** argv )
//![variables] //![variables]
//![load] //![load]
const char* imageName = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* imageName = argc >=2 ? argv[1] : "lena.jpg";
src = imread( imageName, IMREAD_COLOR ); // Load an image src = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Load an image
// Check if image is loaded fine // Check if image is loaded fine
if(src.empty()){ if(src.empty()){
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default ../data/lena.jpg] \n"); printf(" Program Arguments: [image_name -- default lena.jpg] \n");
return -1; return -1;
} }
//![load] //![load]
......
...@@ -19,11 +19,11 @@ void update_map( int &ind, Mat &map_x, Mat &map_y ); ...@@ -19,11 +19,11 @@ void update_map( int &ind, Mat &map_x, Mat &map_y );
*/ */
int main(int argc, const char** argv) int main(int argc, const char** argv)
{ {
CommandLineParser parser(argc, argv, "{@image |../data/chicky_512.png|input image name}"); CommandLineParser parser(argc, argv, "{@image |chicky_512.png|input image name}");
std::string filename = parser.get<std::string>(0); std::string filename = parser.get<std::string>(0);
//! [Load] //! [Load]
/// Load the image /// Load the image
Mat src = imread( filename, IMREAD_COLOR ); Mat src = imread( samples::findFile( filename ), IMREAD_COLOR );
if (src.empty()) if (src.empty())
{ {
std::cout << "Cannot read image: " << filename << std::endl; std::cout << "Cannot read image: " << filename << std::endl;
......
...@@ -19,10 +19,10 @@ using namespace std; ...@@ -19,10 +19,10 @@ using namespace std;
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
cv::CommandLineParser parser(argc, argv, cv::CommandLineParser parser(argc, argv,
"{@input |../data/lena.jpg|input image}" "{@input |lena.jpg|input image}"
"{ksize k|1|ksize (hit 'K' to increase its value)}" "{ksize k|1|ksize (hit 'K' to increase its value at run time)}"
"{scale s|1|scale (hit 'S' to increase its value)}" "{scale s|1|scale (hit 'S' to increase its value at run time)}"
"{delta d|0|delta (hit 'D' to increase its value)}" "{delta d|0|delta (hit 'D' to increase its value at run time)}"
"{help h|false|show help message}"); "{help h|false|show help message}");
cout << "The sample uses Sobel or Scharr OpenCV functions for edge detection\n\n"; cout << "The sample uses Sobel or Scharr OpenCV functions for edge detection\n\n";
...@@ -43,13 +43,13 @@ int main( int argc, char** argv ) ...@@ -43,13 +43,13 @@ int main( int argc, char** argv )
//![load] //![load]
String imageName = parser.get<String>("@input"); String imageName = parser.get<String>("@input");
// As usual we load our source image (src) // As usual we load our source image (src)
image = imread( imageName, IMREAD_COLOR ); // Load an image image = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Load an image
// Check if image is loaded fine // Check if image is loaded fine
if( image.empty() ) if( image.empty() )
{ {
printf("Error opening image: %s\n", imageName.c_str()); printf("Error opening image: %s\n", imageName.c_str());
return 1; return EXIT_FAILURE;
} }
//![load] //![load]
...@@ -95,7 +95,7 @@ int main( int argc, char** argv ) ...@@ -95,7 +95,7 @@ int main( int argc, char** argv )
if(key == 27) if(key == 27)
{ {
return 0; return EXIT_SUCCESS;
} }
if (key == 'k' || key == 'K') if (key == 'k' || key == 'K')
...@@ -120,5 +120,5 @@ int main( int argc, char** argv ) ...@@ -120,5 +120,5 @@ int main( int argc, char** argv )
delta = 0; delta = 0;
} }
} }
return 0; return EXIT_SUCCESS;
} }
...@@ -25,15 +25,15 @@ RNG rng(12345); ...@@ -25,15 +25,15 @@ RNG rng(12345);
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//![load] //![load]
const char* imageName = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* imageName = argc >=2 ? argv[1] : "lena.jpg";
// Loads an image // Loads an image
src = imread( imageName, IMREAD_COLOR ); // Load an image src = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Load an image
// Check if image is loaded fine // Check if image is loaded fine
if( src.empty()) { if( src.empty()) {
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default ../data/lena.jpg] \n"); printf(" Program Arguments: [image_name -- default lena.jpg] \n");
return -1; return -1;
} }
//![load] //![load]
......
...@@ -26,16 +26,16 @@ int main ( int argc, char** argv ) ...@@ -26,16 +26,16 @@ int main ( int argc, char** argv )
const char* window_name = "filter2D Demo"; const char* window_name = "filter2D Demo";
//![load] //![load]
const char* imageName = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* imageName = argc >=2 ? argv[1] : "lena.jpg";
// Loads an image // Loads an image
src = imread( imageName, IMREAD_COLOR ); // Load an image src = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Load an image
if( src.empty() ) if( src.empty() )
{ {
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default ../data/lena.jpg] \n"); printf(" Program Arguments: [image_name -- default lena.jpg] \n");
return -1; return EXIT_FAILURE;
} }
//![load] //![load]
...@@ -70,5 +70,5 @@ int main ( int argc, char** argv ) ...@@ -70,5 +70,5 @@ int main ( int argc, char** argv )
ind++; ind++;
} }
return 0; return EXIT_SUCCESS;
} }
...@@ -12,16 +12,16 @@ using namespace std; ...@@ -12,16 +12,16 @@ using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
//![load] //![load]
const char* filename = argc >=2 ? argv[1] : "../data/smarties.png"; const char* filename = argc >=2 ? argv[1] : "smarties.png";
// Loads an image // Loads an image
Mat src = imread( filename, IMREAD_COLOR ); Mat src = imread( samples::findFile( filename ), IMREAD_COLOR );
// Check if image is loaded fine // Check if image is loaded fine
if(src.empty()){ if(src.empty()){
printf(" Error opening image\n"); printf(" Error opening image\n");
printf(" Program Arguments: [image_name -- default %s] \n", filename); printf(" Program Arguments: [image_name -- default %s] \n", filename);
return -1; return EXIT_FAILURE;
} }
//![load] //![load]
...@@ -61,5 +61,5 @@ int main(int argc, char** argv) ...@@ -61,5 +61,5 @@ int main(int argc, char** argv)
waitKey(); waitKey();
//![display] //![display]
return 0; return EXIT_SUCCESS;
} }
/** /**
* @file houghclines.cpp * @file houghlines.cpp
* @brief This program demonstrates line finding with the Hough transform * @brief This program demonstrates line finding with the Hough transform
*/ */
...@@ -16,11 +16,11 @@ int main(int argc, char** argv) ...@@ -16,11 +16,11 @@ int main(int argc, char** argv)
Mat dst, cdst, cdstP; Mat dst, cdst, cdstP;
//![load] //![load]
const char* default_file = "../data/sudoku.png"; const char* default_file = "sudoku.png";
const char* filename = argc >=2 ? argv[1] : default_file; const char* filename = argc >=2 ? argv[1] : default_file;
// Loads an image // Loads an image
Mat src = imread( filename, IMREAD_GRAYSCALE ); Mat src = imread( samples::findFile( filename ), IMREAD_GRAYSCALE );
// Check if image is loaded fine // Check if image is loaded fine
if(src.empty()){ if(src.empty()){
......
...@@ -15,8 +15,8 @@ int main(int argc, char *argv[]) ...@@ -15,8 +15,8 @@ int main(int argc, char *argv[])
{ {
//! [load_image] //! [load_image]
// Load the image // Load the image
CommandLineParser parser( argc, argv, "{@input | ../data/cards.png | input image}" ); CommandLineParser parser( argc, argv, "{@input | cards.png | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -25,8 +25,8 @@ void thresh_callback(int, void* ); ...@@ -25,8 +25,8 @@ void thresh_callback(int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image /// Load source image
CommandLineParser parser( argc, argv, "{@input | ../data/HappyFish.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | HappyFish.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -26,8 +26,8 @@ int main( int argc, char** argv ) ...@@ -26,8 +26,8 @@ int main( int argc, char** argv )
{ {
//! [setup] //! [setup]
/// Load source image /// Load source image
CommandLineParser parser( argc, argv, "{@input | ../data/stuff.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | stuff.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -25,8 +25,8 @@ void thresh_callback(int, void* ); ...@@ -25,8 +25,8 @@ void thresh_callback(int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/stuff.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | stuff.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -25,8 +25,8 @@ void thresh_callback(int, void* ); ...@@ -25,8 +25,8 @@ void thresh_callback(int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/stuff.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | stuff.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -26,8 +26,8 @@ void thresh_callback(int, void* ); ...@@ -26,8 +26,8 @@ void thresh_callback(int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image /// Load source image
CommandLineParser parser( argc, argv, "{@input | ../data/stuff.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | stuff.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ) ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
......
...@@ -38,8 +38,8 @@ void myHarris_function( int, void* ); ...@@ -38,8 +38,8 @@ void myHarris_function( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/building.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | building.jpg | input image}" );
src = imread( parser.get<String>( "@input" ) ); src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if ( src.empty() ) if ( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -28,8 +28,8 @@ void cornerHarris_demo( int, void* ); ...@@ -28,8 +28,8 @@ void cornerHarris_demo( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/building.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | building.jpg | input image}" );
src = imread( parser.get<String>( "@input" ) ); src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if ( src.empty() ) if ( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -29,8 +29,8 @@ void goodFeaturesToTrack_Demo( int, void* ); ...@@ -29,8 +29,8 @@ void goodFeaturesToTrack_Demo( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/pic3.png | input image}" ); CommandLineParser parser( argc, argv, "{@input | pic3.png | input image}" );
src = imread( parser.get<String>( "@input" ) ); src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -30,8 +30,8 @@ void goodFeaturesToTrack_Demo( int, void* ); ...@@ -30,8 +30,8 @@ void goodFeaturesToTrack_Demo( int, void* );
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
/// Load source image and convert it to gray /// Load source image and convert it to gray
CommandLineParser parser( argc, argv, "{@input | ../data/pic3.png | input image}" ); CommandLineParser parser( argc, argv, "{@input | pic3.png | input image}" );
src = imread( parser.get<String>( "@input" ) ); src = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( src.empty() ) if( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -36,12 +36,12 @@ int main( void ) ...@@ -36,12 +36,12 @@ int main( void )
//![load] //![load]
/// Read images ( both have to be of the same size and type ) /// Read images ( both have to be of the same size and type )
src1 = imread( "../data/LinuxLogo.jpg" ); src1 = imread( samples::findFile("LinuxLogo.jpg") );
src2 = imread( "../data/WindowsLogo.jpg" ); src2 = imread( samples::findFile("WindowsLogo.jpg") );
//![load] //![load]
if( src1.empty() ) { cout << "Error loading src1" << endl; return -1; } if( src1.empty() ) { cout << "Error loading src1" << endl; return EXIT_FAILURE; }
if( src2.empty() ) { cout << "Error loading src2" << endl; return -1; } if( src2.empty() ) { cout << "Error loading src2" << endl; return EXIT_FAILURE; }
//![blend_images] //![blend_images]
beta = ( 1.0 - alpha ); beta = ( 1.0 - alpha );
......
...@@ -8,25 +8,25 @@ ...@@ -8,25 +8,25 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
static void help(void) static void help(char ** argv)
{ {
cout << endl cout << endl
<< "This program demonstrated the use of the discrete Fourier transform (DFT). " << endl << "This program demonstrated the use of the discrete Fourier transform (DFT). " << endl
<< "The dft of an image is taken and it's power spectrum is displayed." << endl << "The dft of an image is taken and it's power spectrum is displayed." << endl << endl
<< "Usage:" << endl << "Usage:" << endl
<< "./discrete_fourier_transform [image_name -- default ../data/lena.jpg]" << endl; << argv[0] << " [image_name -- default lena.jpg]" << endl << endl;
} }
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
help(); help(argv);
const char* filename = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* filename = argc >=2 ? argv[1] : "lena.jpg";
Mat I = imread(filename, IMREAD_GRAYSCALE); Mat I = imread( samples::findFile( filename ), IMREAD_GRAYSCALE);
if( I.empty()){ if( I.empty()){
cout << "Error opening image" << endl; cout << "Error opening image" << endl;
return -1; return EXIT_FAILURE;
} }
//! [expand] //! [expand]
...@@ -91,5 +91,5 @@ int main(int argc, char ** argv) ...@@ -91,5 +91,5 @@ int main(int argc, char ** argv)
imshow("spectrum magnitude", magI); imshow("spectrum magnitude", magI);
waitKey(); waitKey();
return 0; return EXIT_SUCCESS;
} }
...@@ -12,7 +12,7 @@ static void help(char* progName) ...@@ -12,7 +12,7 @@ static void help(char* progName)
<< "This program shows how to filter images with mask: the write it yourself and the" << "This program shows how to filter images with mask: the write it yourself and the"
<< "filter2d way. " << endl << "filter2d way. " << endl
<< "Usage:" << endl << "Usage:" << endl
<< progName << " [image_path -- default ../data/lena.jpg] [G -- grayscale] " << endl << endl; << progName << " [image_path -- default lena.jpg] [G -- grayscale] " << endl << endl;
} }
...@@ -21,19 +21,19 @@ void Sharpen(const Mat& myImage,Mat& Result); ...@@ -21,19 +21,19 @@ void Sharpen(const Mat& myImage,Mat& Result);
int main( int argc, char* argv[]) int main( int argc, char* argv[])
{ {
help(argv[0]); help(argv[0]);
const char* filename = argc >=2 ? argv[1] : "../data/lena.jpg"; const char* filename = argc >=2 ? argv[1] : "lena.jpg";
Mat src, dst0, dst1; Mat src, dst0, dst1;
if (argc >= 3 && !strcmp("G", argv[2])) if (argc >= 3 && !strcmp("G", argv[2]))
src = imread( filename, IMREAD_GRAYSCALE); src = imread( samples::findFile( filename ), IMREAD_GRAYSCALE);
else else
src = imread( filename, IMREAD_COLOR); src = imread( samples::findFile( filename ), IMREAD_COLOR);
if (src.empty()) if (src.empty())
{ {
cerr << "Can't open image [" << filename << "]" << endl; cerr << "Can't open image [" << filename << "]" << endl;
return -1; return EXIT_FAILURE;
} }
namedWindow("Input", WINDOW_AUTOSIZE); namedWindow("Input", WINDOW_AUTOSIZE);
...@@ -67,7 +67,7 @@ int main( int argc, char* argv[]) ...@@ -67,7 +67,7 @@ int main( int argc, char* argv[])
imshow( "Output", dst1 ); imshow( "Output", dst1 );
waitKey(); waitKey();
return 0; return EXIT_SUCCESS;
} }
//! [basic_method] //! [basic_method]
void Sharpen(const Mat& myImage,Mat& Result) void Sharpen(const Mat& myImage,Mat& Result)
......
...@@ -13,14 +13,14 @@ int main(int argc, char* argv[]) ...@@ -13,14 +13,14 @@ int main(int argc, char* argv[])
{ {
//! [load] //! [load]
CommandLineParser parser(argc, argv, CommandLineParser parser(argc, argv,
"{@img1 | ../data/graf1.png | input image 1}" "{@img1 | graf1.png | input image 1}"
"{@img2 | ../data/graf3.png | input image 2}" "{@img2 | graf3.png | input image 2}"
"{@homography | ../data/H1to3p.xml | homography matrix}"); "{@homography | H1to3p.xml | homography matrix}");
Mat img1 = imread(parser.get<String>("@img1"), IMREAD_GRAYSCALE); Mat img1 = imread( samples::findFile( parser.get<String>("@img1") ), IMREAD_GRAYSCALE);
Mat img2 = imread(parser.get<String>("@img2"), IMREAD_GRAYSCALE); Mat img2 = imread( samples::findFile( parser.get<String>("@img2") ), IMREAD_GRAYSCALE);
Mat homography; Mat homography;
FileStorage fs(parser.get<String>("@homography"), FileStorage::READ); FileStorage fs( samples::findFile( parser.get<String>("@homography") ), FileStorage::READ);
fs.getFirstTopLevelNode() >> homography; fs.getFirstTopLevelNode() >> homography;
//! [load] //! [load]
......
...@@ -52,8 +52,8 @@ void computeC2MC1(const Mat &R1, const Mat &tvec1, const Mat &R2, const Mat &tve ...@@ -52,8 +52,8 @@ void computeC2MC1(const Mat &R1, const Mat &tvec1, const Mat &R2, const Mat &tve
void decomposeHomography(const string &img1Path, const string &img2Path, const Size &patternSize, void decomposeHomography(const string &img1Path, const string &img2Path, const Size &patternSize,
const float squareSize, const string &intrinsicsPath) const float squareSize, const string &intrinsicsPath)
{ {
Mat img1 = imread(img1Path); Mat img1 = imread( samples::findFile( img1Path) );
Mat img2 = imread(img2Path); Mat img2 = imread( samples::findFile( img2Path) );
vector<Point2f> corners1, corners2; vector<Point2f> corners1, corners2;
bool found1 = findChessboardCorners(img1, patternSize, corners1); bool found1 = findChessboardCorners(img1, patternSize, corners1);
...@@ -69,7 +69,7 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S ...@@ -69,7 +69,7 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S
vector<Point3f> objectPoints; vector<Point3f> objectPoints;
calcChessboardCorners(patternSize, squareSize, objectPoints); calcChessboardCorners(patternSize, squareSize, objectPoints);
FileStorage fs(intrinsicsPath, FileStorage::READ); FileStorage fs( samples::findFile( intrinsicsPath ), FileStorage::READ);
Mat cameraMatrix, distCoeffs; Mat cameraMatrix, distCoeffs;
fs["camera_matrix"] >> cameraMatrix; fs["camera_matrix"] >> cameraMatrix;
fs["distortion_coefficients"] >> distCoeffs; fs["distortion_coefficients"] >> distCoeffs;
...@@ -154,9 +154,9 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S ...@@ -154,9 +154,9 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S
const char* params const char* params
= "{ help h | | print usage }" = "{ help h | | print usage }"
"{ image1 | ../data/left02.jpg | path to the source chessboard image }" "{ image1 | left02.jpg | path to the source chessboard image }"
"{ image2 | ../data/left01.jpg | path to the desired chessboard image }" "{ image2 | left01.jpg | path to the desired chessboard image }"
"{ intrinsics | ../data/left_intrinsics.yml | path to camera intrinsics }" "{ intrinsics | left_intrinsics.yml | path to camera intrinsics }"
"{ width bw | 9 | chessboard width }" "{ width bw | 9 | chessboard width }"
"{ height bh | 6 | chessboard height }" "{ height bh | 6 | chessboard height }"
"{ square_size | 0.025 | chessboard square size }"; "{ square_size | 0.025 | chessboard square size }";
......
...@@ -65,8 +65,8 @@ void computeC2MC1(const Mat &R1, const Mat &tvec1, const Mat &R2, const Mat &tve ...@@ -65,8 +65,8 @@ void computeC2MC1(const Mat &R1, const Mat &tvec1, const Mat &R2, const Mat &tve
void homographyFromCameraDisplacement(const string &img1Path, const string &img2Path, const Size &patternSize, void homographyFromCameraDisplacement(const string &img1Path, const string &img2Path, const Size &patternSize,
const float squareSize, const string &intrinsicsPath) const float squareSize, const string &intrinsicsPath)
{ {
Mat img1 = imread(img1Path); Mat img1 = imread( samples::findFile( img1Path ) );
Mat img2 = imread(img2Path); Mat img2 = imread( samples::findFile( img2Path ) );
//! [compute-poses] //! [compute-poses]
vector<Point2f> corners1, corners2; vector<Point2f> corners1, corners2;
...@@ -82,7 +82,7 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2 ...@@ -82,7 +82,7 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2
vector<Point3f> objectPoints; vector<Point3f> objectPoints;
calcChessboardCorners(patternSize, squareSize, objectPoints); calcChessboardCorners(patternSize, squareSize, objectPoints);
FileStorage fs(intrinsicsPath, FileStorage::READ); FileStorage fs( samples::findFile( intrinsicsPath ), FileStorage::READ);
Mat cameraMatrix, distCoeffs; Mat cameraMatrix, distCoeffs;
fs["camera_matrix"] >> cameraMatrix; fs["camera_matrix"] >> cameraMatrix;
fs["distortion_coefficients"] >> distCoeffs; fs["distortion_coefficients"] >> distCoeffs;
...@@ -170,9 +170,9 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2 ...@@ -170,9 +170,9 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2
const char* params const char* params
= "{ help h | | print usage }" = "{ help h | | print usage }"
"{ image1 | ../data/left02.jpg | path to the source chessboard image }" "{ image1 | left02.jpg | path to the source chessboard image }"
"{ image2 | ../data/left01.jpg | path to the desired chessboard image }" "{ image2 | left01.jpg | path to the desired chessboard image }"
"{ intrinsics | ../data/left_intrinsics.yml | path to camera intrinsics }" "{ intrinsics | left_intrinsics.yml | path to camera intrinsics }"
"{ width bw | 9 | chessboard width }" "{ width bw | 9 | chessboard width }"
"{ height bh | 6 | chessboard height }" "{ height bh | 6 | chessboard height }"
"{ square_size | 0.025 | chessboard square size }"; "{ square_size | 0.025 | chessboard square size }";
......
...@@ -10,8 +10,8 @@ namespace ...@@ -10,8 +10,8 @@ namespace
{ {
void basicPanoramaStitching(const string &img1Path, const string &img2Path) void basicPanoramaStitching(const string &img1Path, const string &img2Path)
{ {
Mat img1 = imread(img1Path); Mat img1 = imread( samples::findFile( img1Path ) );
Mat img2 = imread(img2Path); Mat img2 = imread( samples::findFile( img2Path ) );
//! [camera-pose-from-Blender-at-location-1] //! [camera-pose-from-Blender-at-location-1]
Mat c1Mo = (Mat_<double>(4,4) << 0.9659258723258972, 0.2588190734386444, 0.0, 1.5529145002365112, Mat c1Mo = (Mat_<double>(4,4) << 0.9659258723258972, 0.2588190734386444, 0.0, 1.5529145002365112,
...@@ -68,8 +68,8 @@ void basicPanoramaStitching(const string &img1Path, const string &img2Path) ...@@ -68,8 +68,8 @@ void basicPanoramaStitching(const string &img1Path, const string &img2Path)
const char* params const char* params
= "{ help h | | print usage }" = "{ help h | | print usage }"
"{ image1 | ../data/Blender_Suzanne1.jpg | path to the first Blender image }" "{ image1 | Blender_Suzanne1.jpg | path to the first Blender image }"
"{ image2 | ../data/Blender_Suzanne2.jpg | path to the second Blender image }"; "{ image2 | Blender_Suzanne2.jpg | path to the second Blender image }";
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
......
...@@ -19,8 +19,8 @@ Scalar randomColor( RNG& rng ) ...@@ -19,8 +19,8 @@ Scalar randomColor( RNG& rng )
void perspectiveCorrection(const string &img1Path, const string &img2Path, const Size &patternSize, RNG &rng) void perspectiveCorrection(const string &img1Path, const string &img2Path, const Size &patternSize, RNG &rng)
{ {
Mat img1 = imread(img1Path); Mat img1 = imread( samples::findFile(img1Path) );
Mat img2 = imread(img2Path); Mat img2 = imread( samples::findFile(img2Path) );
//! [find-corners] //! [find-corners]
vector<Point2f> corners1, corners2; vector<Point2f> corners1, corners2;
...@@ -68,8 +68,8 @@ void perspectiveCorrection(const string &img1Path, const string &img2Path, const ...@@ -68,8 +68,8 @@ void perspectiveCorrection(const string &img1Path, const string &img2Path, const
const char* params const char* params
= "{ help h | | print usage }" = "{ help h | | print usage }"
"{ image1 | ../data/left02.jpg | path to the source chessboard image }" "{ image1 | left02.jpg | path to the source chessboard image }"
"{ image2 | ../data/left01.jpg | path to the desired chessboard image }" "{ image2 | left01.jpg | path to the desired chessboard image }"
"{ width bw | 9 | chessboard width }" "{ width bw | 9 | chessboard width }"
"{ height bh | 6 | chessboard height }"; "{ height bh | 6 | chessboard height }";
} }
......
...@@ -42,7 +42,7 @@ void calcChessboardCorners(Size boardSize, float squareSize, vector<Point3f>& co ...@@ -42,7 +42,7 @@ void calcChessboardCorners(Size boardSize, float squareSize, vector<Point3f>& co
void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intrinsicsPath, const Size &patternSize, void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intrinsicsPath, const Size &patternSize,
const float squareSize) const float squareSize)
{ {
Mat img = imread(imgPath); Mat img = imread( samples::findFile( imgPath) );
Mat img_corners = img.clone(), img_pose = img.clone(); Mat img_corners = img.clone(), img_pose = img.clone();
//! [find-chessboard-corners] //! [find-chessboard-corners]
...@@ -69,7 +69,7 @@ void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intri ...@@ -69,7 +69,7 @@ void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intri
//! [compute-object-points] //! [compute-object-points]
//! [load-intrinsics] //! [load-intrinsics]
FileStorage fs(intrinsicsPath, FileStorage::READ); FileStorage fs( samples::findFile( intrinsicsPath ), FileStorage::READ);
Mat cameraMatrix, distCoeffs; Mat cameraMatrix, distCoeffs;
fs["camera_matrix"] >> cameraMatrix; fs["camera_matrix"] >> cameraMatrix;
fs["distortion_coefficients"] >> distCoeffs; fs["distortion_coefficients"] >> distCoeffs;
...@@ -126,8 +126,8 @@ void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intri ...@@ -126,8 +126,8 @@ void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intri
const char* params const char* params
= "{ help h | | print usage }" = "{ help h | | print usage }"
"{ image | ../data/left04.jpg | path to a chessboard image }" "{ image | left04.jpg | path to a chessboard image }"
"{ intrinsics | ../data/left_intrinsics.yml | path to camera intrinsics }" "{ intrinsics | left_intrinsics.yml | path to camera intrinsics }"
"{ width bw | 9 | chessboard width }" "{ width bw | 9 | chessboard width }"
"{ height bh | 6 | chessboard height }" "{ height bh | 6 | chessboard height }"
"{ square_size | 0.025 | chessboard square size }"; "{ square_size | 0.025 | chessboard square size }";
......
...@@ -12,14 +12,14 @@ using std::endl; ...@@ -12,14 +12,14 @@ using std::endl;
const char* keys = const char* keys =
"{ help h | | Print help message. }" "{ help h | | Print help message. }"
"{ input1 | ../data/box.png | Path to input image 1. }" "{ input1 | box.png | Path to input image 1. }"
"{ input2 | ../data/box_in_scene.png | Path to input image 2. }"; "{ input2 | box_in_scene.png | Path to input image 2. }";
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
CommandLineParser parser( argc, argv, keys ); CommandLineParser parser( argc, argv, keys );
Mat img1 = imread( parser.get<String>("input1"), IMREAD_GRAYSCALE ); Mat img1 = imread( samples::findFile( parser.get<String>("input1") ), IMREAD_GRAYSCALE );
Mat img2 = imread( parser.get<String>("input2"), IMREAD_GRAYSCALE ); Mat img2 = imread( samples::findFile( parser.get<String>("input2") ), IMREAD_GRAYSCALE );
if ( img1.empty() || img2.empty() ) if ( img1.empty() || img2.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -12,8 +12,8 @@ using std::endl; ...@@ -12,8 +12,8 @@ using std::endl;
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
CommandLineParser parser( argc, argv, "{@input | ../data/box.png | input image}" ); CommandLineParser parser( argc, argv, "{@input | box.png | input image}" );
Mat src = imread( parser.get<String>( "@input" ), IMREAD_GRAYSCALE ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_GRAYSCALE );
if ( src.empty() ) if ( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -12,14 +12,14 @@ using std::endl; ...@@ -12,14 +12,14 @@ using std::endl;
const char* keys = const char* keys =
"{ help h | | Print help message. }" "{ help h | | Print help message. }"
"{ input1 | ../data/box.png | Path to input image 1. }" "{ input1 | box.png | Path to input image 1. }"
"{ input2 | ../data/box_in_scene.png | Path to input image 2. }"; "{ input2 | box_in_scene.png | Path to input image 2. }";
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
CommandLineParser parser( argc, argv, keys ); CommandLineParser parser( argc, argv, keys );
Mat img1 = imread( parser.get<String>("input1"), IMREAD_GRAYSCALE ); Mat img1 = imread( samples::findFile( parser.get<String>("input1") ), IMREAD_GRAYSCALE );
Mat img2 = imread( parser.get<String>("input2"), IMREAD_GRAYSCALE ); Mat img2 = imread( samples::findFile( parser.get<String>("input2") ), IMREAD_GRAYSCALE );
if ( img1.empty() || img2.empty() ) if ( img1.empty() || img2.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -14,14 +14,14 @@ using std::endl; ...@@ -14,14 +14,14 @@ using std::endl;
const char* keys = const char* keys =
"{ help h | | Print help message. }" "{ help h | | Print help message. }"
"{ input1 | ../data/box.png | Path to input image 1. }" "{ input1 | box.png | Path to input image 1. }"
"{ input2 | ../data/box_in_scene.png | Path to input image 2. }"; "{ input2 | box_in_scene.png | Path to input image 2. }";
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
CommandLineParser parser( argc, argv, keys ); CommandLineParser parser( argc, argv, keys );
Mat img_object = imread( parser.get<String>("input1"), IMREAD_GRAYSCALE ); Mat img_object = imread( samples::findFile( parser.get<String>("input1") ), IMREAD_GRAYSCALE );
Mat img_scene = imread( parser.get<String>("input2"), IMREAD_GRAYSCALE ); Mat img_scene = imread( samples::findFile( parser.get<String>("input2") ), IMREAD_GRAYSCALE );
if ( img_object.empty() || img_scene.empty() ) if ( img_object.empty() || img_scene.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
......
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <iostream> #include <iostream>
#include <string>
//! [includes] //! [includes]
//! [namespace] //! [namespace]
using namespace cv; using namespace cv;
using namespace std;
//! [namespace] //! [namespace]
using namespace std;
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
//! [load] //! [load]
String imageName( "../data/HappyFish.jpg" ); // by default String imageName( "HappyFish.jpg" ); // by default
if( argc > 1) if( argc > 1)
{ {
imageName = argv[1]; imageName = argv[1];
...@@ -28,7 +27,7 @@ int main( int argc, char** argv ) ...@@ -28,7 +27,7 @@ int main( int argc, char** argv )
//! [mat] //! [mat]
//! [imread] //! [imread]
image = imread( imageName, IMREAD_COLOR ); // Read the file image = imread( samples::findFile( imageName ), IMREAD_COLOR ); // Read the file
//! [imread] //! [imread]
if( image.empty() ) // Check for invalid input if( image.empty() ) // Check for invalid input
......
...@@ -10,7 +10,7 @@ int main( int argc, char** argv ) ...@@ -10,7 +10,7 @@ int main( int argc, char** argv )
{ {
if( argc != 2) if( argc != 2)
{ {
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl; cout <<" Usage: " << argv[0] << " ImageToLoadAndDisplay" << endl;
return -1; return -1;
} }
......
...@@ -96,11 +96,11 @@ int main(int argc, char** argv) ...@@ -96,11 +96,11 @@ int main(int argc, char** argv)
{ {
//! [pre-process] //! [pre-process]
// Load image // Load image
CommandLineParser parser(argc, argv, "{@input | ../data/pca_test1.jpg | input image}"); CommandLineParser parser(argc, argv, "{@input | pca_test1.jpg | input image}");
parser.about( "This program demonstrates how to use OpenCV PCA to extract the orientation of an object.\n" ); parser.about( "This program demonstrates how to use OpenCV PCA to extract the orientation of an object.\n" );
parser.printMessage(); parser.printMessage();
Mat src = imread(parser.get<String>("@input")); Mat src = imread( samples::findFile( parser.get<String>("@input") ) );
// Check if image is loaded successfully // Check if image is loaded successfully
if(src.empty()) if(src.empty())
...@@ -142,5 +142,5 @@ int main(int argc, char** argv) ...@@ -142,5 +142,5 @@ int main(int argc, char** argv)
imshow("output", src); imshow("output", src);
waitKey(); waitKey();
return 0; return EXIT_SUCCESS;
} }
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
...@@ -19,16 +19,16 @@ int main( int argc, const char** argv ) ...@@ -19,16 +19,16 @@ int main( int argc, const char** argv )
{ {
CommandLineParser parser(argc, argv, CommandLineParser parser(argc, argv,
"{help h||}" "{help h||}"
"{face_cascade|../../data/haarcascades/haarcascade_frontalface_alt.xml|Path to face cascade.}" "{face_cascade|data/haarcascades/haarcascade_frontalface_alt.xml|Path to face cascade.}"
"{eyes_cascade|../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|Path to eyes cascade.}" "{eyes_cascade|data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|Path to eyes cascade.}"
"{camera|0|Camera device number.}"); "{camera|0|Camera device number.}");
parser.about( "\nThis program demonstrates using the cv::CascadeClassifier class to detect objects (Face + eyes) in a video stream.\n" parser.about( "\nThis program demonstrates using the cv::CascadeClassifier class to detect objects (Face + eyes) in a video stream.\n"
"You can use Haar or LBP features.\n\n" ); "You can use Haar or LBP features.\n\n" );
parser.printMessage(); parser.printMessage();
String face_cascade_name = parser.get<String>("face_cascade"); String face_cascade_name = samples::findFile( parser.get<String>("face_cascade") );
String eyes_cascade_name = parser.get<String>("eyes_cascade"); String eyes_cascade_name = samples::findFile( parser.get<String>("eyes_cascade") );
//-- 1. Load the cascades //-- 1. Load the cascades
if( !face_cascade.load( face_cascade_name ) ) if( !face_cascade.load( face_cascade_name ) )
......
...@@ -26,18 +26,18 @@ using namespace cv; ...@@ -26,18 +26,18 @@ using namespace cv;
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
CommandLineParser parser( argc, argv, "{@input | ../data/HappyFish.jpg | input image}" ); CommandLineParser parser( argc, argv, "{@input | HappyFish.jpg | input image}" );
Mat src = imread( parser.get<String>( "@input" ), IMREAD_COLOR ); Mat src = imread( samples::findFile( parser.get<String>( "@input" ) ), IMREAD_COLOR );
if ( src.empty() ) if ( src.empty() )
{ {
cout << "Could not open or find the image!\n" << endl; cout << "Could not open or find the image!\n" << endl;
cout << "Usage: " << argv[0] << " <Input image>" << endl; cout << "Usage: " << argv[0] << " <Input image>" << endl;
return -1; return EXIT_FAILURE;
} }
Mat gray = Mat( src.size(), CV_8UC1 );
Mat color_boost = Mat( src.size(), CV_8UC3 );
Mat gray, color_boost;
decolor( src, gray, color_boost ); decolor( src, gray, color_boost );
imshow( "Source Image", src );
imshow( "grayscale", gray ); imshow( "grayscale", gray );
imshow( "color_boost", color_boost ); imshow( "color_boost", color_boost );
waitKey(0); waitKey(0);
......
...@@ -25,8 +25,8 @@ using namespace cv; ...@@ -25,8 +25,8 @@ using namespace cv;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int num,type; int num,type;
CommandLineParser parser(argc, argv, "{@input | ../data/lena.jpg | input image}"); CommandLineParser parser(argc, argv, "{@input | lena.jpg | input image}");
Mat src = imread(parser.get<String>("@input"), IMREAD_COLOR); Mat src = imread( samples::findFile( parser.get<String>("@input") ), IMREAD_COLOR);
if(src.empty()) if(src.empty())
{ {
......
...@@ -17,7 +17,7 @@ using namespace std; ...@@ -17,7 +17,7 @@ using namespace std;
const char* params const char* params
= "{ help h | | Print usage }" = "{ help h | | Print usage }"
"{ input | ../data/vtest.avi | Path to a video or a sequence of image }" "{ input | vtest.avi | Path to a video or a sequence of image }"
"{ algo | MOG2 | Background subtraction method (KNN, MOG2) }"; "{ algo | MOG2 | Background subtraction method (KNN, MOG2) }";
int main(int argc, char* argv[]) int main(int argc, char* argv[])
...@@ -41,7 +41,7 @@ int main(int argc, char* argv[]) ...@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
//! [create] //! [create]
//! [capture] //! [capture]
VideoCapture capture(parser.get<String>("input")); VideoCapture capture( samples::findFile( parser.get<String>("input") ) );
if (!capture.isOpened()){ if (!capture.isOpened()){
//error in opening the video input //error in opening the video input
cerr << "Unable to open: " << parser.get<String>("input") << endl; cerr << "Unable to open: " << parser.get<String>("input") << endl;
......
...@@ -16,7 +16,7 @@ int main(int argc, char **argv) ...@@ -16,7 +16,7 @@ int main(int argc, char **argv)
" https://www.bogotobogo.com/python/OpenCV_Python/images/mean_shift_tracking/slow_traffic_small.mp4"; " https://www.bogotobogo.com/python/OpenCV_Python/images/mean_shift_tracking/slow_traffic_small.mp4";
const string keys = const string keys =
"{ h help | | print this help message }" "{ h help | | print this help message }"
"{ @image |<none>| path to image file }"; "{ @image | vtest.avi | path to image file }";
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
parser.about(about); parser.about(about);
if (parser.has("help")) if (parser.has("help"))
...@@ -24,7 +24,7 @@ int main(int argc, char **argv) ...@@ -24,7 +24,7 @@ int main(int argc, char **argv)
parser.printMessage(); parser.printMessage();
return 0; return 0;
} }
string filename = parser.get<string>("@image"); string filename = samples::findFile(parser.get<string>("@image"));
if (!parser.check()) if (!parser.check())
{ {
parser.printErrors(); parser.printErrors();
......
...@@ -24,14 +24,14 @@ const float nn_match_ratio = 0.8f; // Nearest neighbor matching ratio ...@@ -24,14 +24,14 @@ const float nn_match_ratio = 0.8f; // Nearest neighbor matching ratio
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
CommandLineParser parser(argc, argv, CommandLineParser parser(argc, argv,
"{@img1 | ../data/graf1.png | input image 1}" "{@img1 | graf1.png | input image 1}"
"{@img2 | ../data/graf3.png | input image 2}" "{@img2 | graf3.png | input image 2}"
"{@homography | ../data/H1to3p.xml | homography matrix}"); "{@homography | H1to3p.xml | homography matrix}");
Mat img1 = imread(parser.get<String>("@img1"), IMREAD_GRAYSCALE); Mat img1 = imread( samples::findFile( parser.get<String>("@img1") ), IMREAD_GRAYSCALE);
Mat img2 = imread(parser.get<String>("@img2"), IMREAD_GRAYSCALE); Mat img2 = imread( samples::findFile( parser.get<String>("@img2") ), IMREAD_GRAYSCALE);
Mat homography; Mat homography;
FileStorage fs(parser.get<String>("@homography"), FileStorage::READ); FileStorage fs( samples::findFile( parser.get<String>("@homography") ), FileStorage::READ);
fs.getFirstTopLevelNode() >> homography; fs.getFirstTopLevelNode() >> homography;
vector<KeyPoint> kpts1, kpts2; vector<KeyPoint> kpts1, kpts2;
......
...@@ -20,7 +20,7 @@ static void help(char** argv) ...@@ -20,7 +20,7 @@ static void help(char** argv)
cout << "\nThis is a demo program shows how perspective transformation applied on an image, \n" cout << "\nThis is a demo program shows how perspective transformation applied on an image, \n"
"Using OpenCV version " << CV_VERSION << endl; "Using OpenCV version " << CV_VERSION << endl;
cout << "\nUsage:\n" << argv[0] << " [image_name -- Default data/right.jpg]\n" << endl; cout << "\nUsage:\n" << argv[0] << " [image_name -- Default right.jpg]\n" << endl;
cout << "\nHot keys: \n" cout << "\nHot keys: \n"
"\tESC, q - quit the program\n" "\tESC, q - quit the program\n"
...@@ -45,7 +45,7 @@ bool validation_needed = true; ...@@ -45,7 +45,7 @@ bool validation_needed = true;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
help(argv); help(argv);
CommandLineParser parser(argc, argv, "{@input| data/right.jpg |}"); CommandLineParser parser(argc, argv, "{@input| right.jpg |}");
string filename = samples::findFile(parser.get<string>("@input")); string filename = samples::findFile(parser.get<string>("@input"));
Mat original_image = imread( filename ); Mat original_image = imread( filename );
...@@ -81,7 +81,7 @@ int main(int argc, char** argv) ...@@ -81,7 +81,7 @@ int main(int argc, char** argv)
{ {
line(image, roi_corners[i-1], roi_corners[(i)], Scalar(0, 0, 255), 2); line(image, roi_corners[i-1], roi_corners[(i)], Scalar(0, 0, 255), 2);
circle(image, roi_corners[i], 5, Scalar(0, 255, 0), 3); circle(image, roi_corners[i], 5, Scalar(0, 255, 0), 3);
putText(image, labels[i].c_str(), roi_corners[i], QT_FONT_NORMAL, 0.8, Scalar(255, 0, 0), 2); putText(image, labels[i].c_str(), roi_corners[i], FONT_HERSHEY_SIMPLEX, 0.8, Scalar(255, 0, 0), 2);
} }
} }
imshow( windowTitle, image ); imshow( windowTitle, image );
...@@ -94,7 +94,7 @@ int main(int argc, char** argv) ...@@ -94,7 +94,7 @@ int main(int argc, char** argv)
{ {
line(image, roi_corners[i], roi_corners[(i + 1) % 4], Scalar(0, 0, 255), 2); line(image, roi_corners[i], roi_corners[(i + 1) % 4], Scalar(0, 0, 255), 2);
circle(image, roi_corners[i], 5, Scalar(0, 255, 0), 3); circle(image, roi_corners[i], 5, Scalar(0, 255, 0), 3);
putText(image, labels[i].c_str(), roi_corners[i], QT_FONT_NORMAL, 0.8, Scalar(255, 0, 0), 2); putText(image, labels[i].c_str(), roi_corners[i], FONT_HERSHEY_SIMPLEX, 0.8, Scalar(255, 0, 0), 2);
} }
imshow( windowTitle, image ); imshow( windowTitle, image );
......
...@@ -9,11 +9,10 @@ ...@@ -9,11 +9,10 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
static void help() static void help(char** argv)
{ {
cout << "\nThis program demonstrates the famous watershed segmentation algorithm in OpenCV: watershed()\n" cout << "\nThis program demonstrates the famous watershed segmentation algorithm in OpenCV: watershed()\n"
"Usage:\n" "Usage:\n" << argv[0] <<" [image_name -- default is fruits.jpg]\n" << endl;
"./watershed [image_name -- default is fruits.jpg]\n" << endl;
cout << "Hot keys: \n" cout << "Hot keys: \n"
...@@ -51,7 +50,7 @@ int main( int argc, char** argv ) ...@@ -51,7 +50,7 @@ int main( int argc, char** argv )
cv::CommandLineParser parser(argc, argv, "{help h | | }{ @input | fruits.jpg | }"); cv::CommandLineParser parser(argc, argv, "{help h | | }{ @input | fruits.jpg | }");
if (parser.has("help")) if (parser.has("help"))
{ {
help(); help(argv);
return 0; return 0;
} }
string filename = samples::findFile(parser.get<string>("@input")); string filename = samples::findFile(parser.get<string>("@input"));
...@@ -59,10 +58,11 @@ int main( int argc, char** argv ) ...@@ -59,10 +58,11 @@ int main( int argc, char** argv )
if( img0.empty() ) if( img0.empty() )
{ {
cout << "Couldn't open image " << filename << ". Usage: watershed <image_name>\n"; cout << "Couldn't open image ";
help(argv);
return 0; return 0;
} }
help(); help(argv);
namedWindow( "image", 1 ); namedWindow( "image", 1 );
img0.copyTo(img); img0.copyTo(img);
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <opencv2/core/ocl.hpp> #include <opencv2/core/ocl.hpp>
#include <opencv2/core/utility.hpp> #include <opencv2/core/utility.hpp>
#include "opencv2/imgcodecs.hpp" #include "opencv2/imgcodecs.hpp"
#include <opencv2/video.hpp>
#include <opencv2/videoio.hpp> #include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <opencv2/objdetect.hpp> #include <opencv2/objdetect.hpp>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment