[opencv] 182/251: some improvements on tutorials
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.
commit 89480801b85160d24ca9f89f2c848ea59f247843
Author: Suleyman TURKMEN <sturkmen at hotmail.com>
Date: Wed Jul 26 08:39:53 2017 +0300
some improvements on tutorials
---
modules/core/include/opencv2/core.hpp | 6 ++++
modules/imgproc/include/opencv2/imgproc.hpp | 15 ++++++++++
modules/objdetect/include/opencv2/objdetect.hpp | 4 +++
modules/photo/include/opencv2/photo.hpp | 6 ++++
.../shape/include/opencv2/shape/shape_distance.hpp | 3 ++
modules/video/include/opencv2/video/tracking.hpp | 30 +++++++++++---------
modules/videoio/include/opencv2/videoio.hpp | 6 ++--
samples/cpp/create_mask.cpp | 27 ++++++++++--------
samples/cpp/drawing.cpp | 32 +++++++++++----------
samples/cpp/edge.cpp | 8 ++----
samples/cpp/falsecolor.cpp | 8 ++++--
samples/cpp/grabcut.cpp | 11 ++------
samples/cpp/image_alignment.cpp | 33 +++++++++-------------
samples/cpp/image_sequence.cpp | 9 ++----
samples/cpp/inpaint.cpp | 9 ++----
samples/cpp/laplace.cpp | 9 ++----
samples/cpp/letter_recog.cpp | 14 ++++-----
samples/cpp/lkdemo.cpp | 13 +++------
samples/cpp/mask_tmpl.cpp | 8 ++----
samples/cpp/npr_demo.cpp | 2 +-
samples/cpp/polar_transforms.cpp | 7 ++---
samples/cpp/shape_example.cpp | 1 +
.../HighGUI/BasicLinearTransformsTrackbar.cpp | 13 ++++++---
.../ImgProc/BasicLinearTransforms.cpp | 9 ++++--
samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp | 9 ++++--
samples/cpp/tutorial_code/ImgProc/Threshold.cpp | 9 ++++--
.../changing_contrast_brightness_image.cpp | 11 ++++++--
.../tutorial_code/ImgTrans/HoughCircle_Demo.cpp | 14 ++++-----
.../cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp | 11 ++++++--
.../cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp | 9 ++++--
samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp | 6 ++--
samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp | 9 ++++--
.../tutorial_code/ImgTrans/copyMakeBorder_demo.cpp | 9 ++++--
.../cpp/tutorial_code/ImgTrans/filter2D_demo.cpp | 9 ++++--
.../tutorial_code/ImgTrans/imageSegmentation.cpp | 4 +--
.../ShapeDescriptors/findContours_demo.cpp | 10 +++++--
.../tutorial_code/calib3d/stereoBM/SBM_Sample.cpp | 9 +++---
.../cpp/tutorial_code/features2D/AKAZE_match.cpp | 5 +++-
.../features2D/AKAZE_tracking/planar_tracking.cpp | 24 ++++++++--------
.../ml/introduction_to_pca/introduction_to_pca.cpp | 10 +++++--
.../cpp/tutorial_code/xfeatures2D/LATCH_match.cpp | 6 +++-
41 files changed, 260 insertions(+), 187 deletions(-)
diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp
index b6cc6bc..31d325c 100644
--- a/modules/core/include/opencv2/core.hpp
+++ b/modules/core/include/opencv2/core.hpp
@@ -273,6 +273,9 @@ of p and len.
*/
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
+/** @example copyMakeBorder_demo.cpp
+An example using copyMakeBorder function
+ */
/** @brief Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the
@@ -471,6 +474,9 @@ The function can also be emulated with a matrix expression, for example:
*/
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
+/** @example AddingImagesTrackbar.cpp
+
+ */
/** @brief Calculates the weighted sum of two arrays.
The function addWeighted calculates the weighted sum of two arrays as follows:
diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp
index 5e42232..1c86adb 100644
--- a/modules/imgproc/include/opencv2/imgproc.hpp
+++ b/modules/imgproc/include/opencv2/imgproc.hpp
@@ -2795,6 +2795,9 @@ CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
//! @addtogroup imgproc_filter
//! @{
+/** @example Pyramids.cpp
+An example using pyrDown and pyrUp functions
+ */
/** @brief Blurs an image and downsamples it.
By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in
@@ -3669,6 +3672,9 @@ enum TemplateMatchModes {
TM_CCOEFF_NORMED = 5 //!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} }\f]
};
+/** @example MatchTemplate_Demo.cpp
+An example using Template Matching algorithm
+ */
/** @brief Compares a template against overlapped image regions.
The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against
@@ -4134,6 +4140,9 @@ enum ColormapTypes
COLORMAP_PARULA = 12 //!< 
};
+/** @example falsecolor.cpp
+An example using applyColorMap function
+*/
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@@ -4216,6 +4225,9 @@ CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
+/** @example Drawing_2.cpp
+An example using drawing functions
+ */
/** @brief Draws a circle.
The function circle draws a simple or filled circle with a given center and radius.
@@ -4339,6 +4351,9 @@ CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
const Scalar& color, int lineType = LINE_8, int shift = 0,
Point offset = Point() );
+/** @example Drawing_1.cpp
+An example using drawing functions
+ */
/** @brief Fills the area bounded by one or more polygons.
The function fillPoly fills an area bounded by several polygonal contours. The function can fill
diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp
index 432bee4..0747d67 100644
--- a/modules/objdetect/include/opencv2/objdetect.hpp
+++ b/modules/objdetect/include/opencv2/objdetect.hpp
@@ -215,6 +215,8 @@ public:
virtual Ptr<MaskGenerator> getMaskGenerator() = 0;
};
+/** @example facedetect.cpp
+*/
/** @brief Cascade classifier class for object detection.
*/
class CV_EXPORTS_W CascadeClassifier
@@ -348,6 +350,8 @@ struct DetectionROI
std::vector<double> confidences;
};
+/**@example peopledetect.cpp
+ */
struct CV_EXPORTS_W HOGDescriptor
{
public:
diff --git a/modules/photo/include/opencv2/photo.hpp b/modules/photo/include/opencv2/photo.hpp
index 431a632..6651ac8 100644
--- a/modules/photo/include/opencv2/photo.hpp
+++ b/modules/photo/include/opencv2/photo.hpp
@@ -730,6 +730,9 @@ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray co
//! @addtogroup photo_clone
//! @{
+/** @example cloning_demo.cpp
+An example using seamlessClone function
+*/
/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters,
deformations) or local changes concerned to a selection. Here we are interested in achieving local
changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless
@@ -833,6 +836,9 @@ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flag
CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
float sigma_r = 0.15f);
+/** @example npr_demo.cpp
+An example using non-photorealistic line drawing functions
+*/
/** @brief Pencil-like non-photorealistic line drawing
@param src Input 8-bit 3-channel image.
diff --git a/modules/shape/include/opencv2/shape/shape_distance.hpp b/modules/shape/include/opencv2/shape/shape_distance.hpp
index e4c3a87..3a778f0 100644
--- a/modules/shape/include/opencv2/shape/shape_distance.hpp
+++ b/modules/shape/include/opencv2/shape/shape_distance.hpp
@@ -53,6 +53,9 @@ namespace cv
//! @addtogroup shape
//! @{
+/** @example shape_example.cpp
+An example using shape distance algorithm
+*/
/** @brief Abstract base class for shape distance algorithms.
*/
class CV_EXPORTS_W ShapeDistanceExtractor : public Algorithm
diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp
index 946596f..d397ac7 100644
--- a/modules/video/include/opencv2/video/tracking.hpp
+++ b/modules/video/include/opencv2/video/tracking.hpp
@@ -78,7 +78,9 @@ See the OpenCV sample camshiftdemo.c that tracks colored objects.
*/
CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
TermCriteria criteria );
-
+/** @example camshiftdemo.cpp
+An example using the mean-shift tracking algorithm
+*/
/** @brief Finds an object on a back projection image.
@param probImage Back projection of the object histogram. See calcBackProject for details.
@@ -97,8 +99,6 @@ projection and remove the noise. For example, you can do this by retrieving conn
with findContours , throwing away contours with small area ( contourArea ), and rendering the
remaining contours with drawContours.
- at note
-- A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp
*/
CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria );
@@ -123,6 +123,9 @@ CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays py
int derivBorder = BORDER_CONSTANT,
bool tryReuseInputImage = true );
+/** @example lkdemo.cpp
+An example using the Lucas-Kanade optical flow algorithm
+ */
/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
pyramids.
@@ -258,6 +261,10 @@ enum
MOTION_HOMOGRAPHY = 3
};
+/** @example image_alignment.cpp
+An example using the image alignment ECC algorithm
+ */
+
/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .
@param templateImage single-channel template image; CV_8U or CV_32F array.
@@ -313,25 +320,20 @@ CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray input
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001),
InputArray inputMask = noArray());
+/** @example kalman.cpp
+An example using the standard Kalman filter
+*/
/** @brief Kalman filter class.
The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,
@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get
-an extended Kalman filter functionality. See the OpenCV sample kalman.cpp.
-
- at note
-
-- An example using the standard Kalman filter can be found at
- opencv_source_code/samples/cpp/kalman.cpp
+an extended Kalman filter functionality.
+ at note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
+with cvReleaseKalman(&kalmanFilter)
*/
class CV_EXPORTS_W KalmanFilter
{
public:
- /** @brief The constructors.
-
- @note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
- with cvReleaseKalman(&kalmanFilter)
- */
CV_WRAP KalmanFilter();
/** @overload
@param dynamParams Dimensionality of the state.
diff --git a/modules/videoio/include/opencv2/videoio.hpp b/modules/videoio/include/opencv2/videoio.hpp
index aa3f31a..96d8df6 100644
--- a/modules/videoio/include/opencv2/videoio.hpp
+++ b/modules/videoio/include/opencv2/videoio.hpp
@@ -808,12 +808,12 @@ protected:
class IVideoWriter;
+/** @example videowriter_basic.cpp
+An example using VideoCapture and VideoWriter class
+ */
/** @brief Video writer class.
The class provides C++ API for writing video files or image sequences.
-
-Here is how the class can be used:
- at include samples/cpp/videowriter_basic.cpp
*/
class CV_EXPORTS_W VideoWriter
{
diff --git a/samples/cpp/create_mask.cpp b/samples/cpp/create_mask.cpp
index 7d6a61c..c87d0fd 100644
--- a/samples/cpp/create_mask.cpp
+++ b/samples/cpp/create_mask.cpp
@@ -33,8 +33,6 @@ int flag1 = 0;
int minx,miny,maxx,maxy,lenx,leny;
-int channel;
-
void mouseHandler(int, int, int, int, void*);
void mouseHandler(int event, int x, int y, int, void*)
@@ -121,14 +119,22 @@ void mouseHandler(int event, int x, int y, int, void*)
}
}
+static void help()
+{
+ cout << "\nThis program demonstrates using mouse events"
+ "\nCall:\n"
+ "./create_mask <image_name>\n"
+ "\n"
+ "\tleft mouse button - set a point to create mask shape"
+ "\n"
+ "\tright mouse button - create mask from points\n"
+ "\tmiddle mouse button - reset\n" << endl;
+}
+
int main(int argc, char **argv)
{
- cv::CommandLineParser parser(argc, argv, "{help h | | show help message}{@input | | input image}");
- if (parser.has("help"))
- {
- parser.printMessage();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@input | ../data/lena.jpg | input image}");
+ help();
string input_image = parser.get<string>("@input");
if (input_image.empty())
{
@@ -143,8 +149,6 @@ int main(int argc, char **argv)
img0 = src;
- channel = img0.channels();
-
res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3);
//////////// source image ///////////////////
@@ -154,6 +158,5 @@ int main(int argc, char **argv)
imshow("Source", img0);
waitKey(0);
- img0.release();
- img1.release();
+ return 0;
}
diff --git a/samples/cpp/drawing.cpp b/samples/cpp/drawing.cpp
index 236bcbc..93f09fe 100644
--- a/samples/cpp/drawing.cpp
+++ b/samples/cpp/drawing.cpp
@@ -2,6 +2,7 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <stdio.h>
+
using namespace cv;
static void help()
@@ -16,14 +17,9 @@ static Scalar randomColor(RNG& rng)
return Scalar(icolor&255, (icolor>>8)&255, (icolor>>16)&255);
}
-int main(int argc, char** argv)
+int main()
{
- cv::CommandLineParser parser(argc, argv, "{help h||}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ help();
char wndname[] = "Drawing Demo";
const int NUMBER = 100;
const int DELAY = 5;
@@ -36,7 +32,7 @@ int main(int argc, char** argv)
imshow(wndname, image);
waitKey(DELAY);
- for (i = 0; i < NUMBER; i++)
+ for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -44,14 +40,19 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
- line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
+ int arrowed = rng.uniform(0, 6);
+
+ if( arrowed < 3 )
+ line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
+ else
+ arrowedLine(image, pt1, pt2, randomColor(rng), rng.uniform(1, 10), lineType);
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
return 0;
}
- for (i = 0; i < NUMBER; i++)
+ for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -59,8 +60,13 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
int thickness = rng.uniform(-3, 10);
+ int marker = rng.uniform(0, 10);
+ int marker_size = rng.uniform(30, 80);
- rectangle( image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType );
+ if (marker > 5)
+ rectangle(image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType);
+ else
+ drawMarker(image, pt1, randomColor(rng), marker, marker_size );
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
@@ -181,7 +187,3 @@ int main(int argc, char** argv)
waitKey();
return 0;
}
-
-#ifdef _EiC
-main(1,"drawing.c");
-#endif
diff --git a/samples/cpp/edge.cpp b/samples/cpp/edge.cpp
index 4fbef93..78bc4b6 100644
--- a/samples/cpp/edge.cpp
+++ b/samples/cpp/edge.cpp
@@ -53,15 +53,11 @@ const char* keys =
int main( int argc, const char** argv )
{
+ help();
CommandLineParser parser(argc, argv, keys);
- if (parser.has("help"))
- {
- help();
- return 0;
- }
string filename = parser.get<string>(0);
- image = imread(filename, 1);
+ image = imread(filename, IMREAD_COLOR);
if(image.empty())
{
printf("Cannot read image file: %s\n", filename.c_str());
diff --git a/samples/cpp/falsecolor.cpp b/samples/cpp/falsecolor.cpp
index a72711c..3e62434 100644
--- a/samples/cpp/falsecolor.cpp
+++ b/samples/cpp/falsecolor.cpp
@@ -125,11 +125,15 @@ static Mat DrawMyImage(int thickness,int nbShape)
return img;
}
-int main(void)
+int main(int argc, char** argv)
{
ParamColorMar p;
- Mat img= DrawMyImage(2,256);
+ Mat img;
+ if (argc > 1)
+ img = imread(argv[1], 0);
+ else
+ img = DrawMyImage(2,256);
p.img=img;
p.iColormap=0;
diff --git a/samples/cpp/grabcut.cpp b/samples/cpp/grabcut.cpp
index 54edbf6..c5b68fc 100644
--- a/samples/cpp/grabcut.cpp
+++ b/samples/cpp/grabcut.cpp
@@ -276,12 +276,9 @@ static void on_mouse( int event, int x, int y, int flags, void* param )
int main( int argc, char** argv )
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@input||}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@input| ../data/messi5.jpg |}");
+ help();
+
string filename = parser.get<string>("@input");
if( filename.empty() )
{
@@ -295,8 +292,6 @@ int main( int argc, char** argv )
return 1;
}
- help();
-
const string winName = "image";
namedWindow( winName, WINDOW_AUTOSIZE );
setMouseCallback( winName, on_mouse, 0 );
diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp
index c62a160..2f0aa50 100644
--- a/samples/cpp/image_alignment.cpp
+++ b/samples/cpp/image_alignment.cpp
@@ -51,7 +51,7 @@ const std::string keys =
"{e epsilon | 0.0001 | ECC's convergence epsilon }"
"{o outputWarp | outWarp.ecc | output warp (matrix) filename }"
"{m motionType | affine | type of motion (translation, euclidean, affine, homography) }"
- "{v verbose | 0 | display initial and final images }"
+ "{v verbose | 1 | display initial and final images }"
"{w warpedImfile | warpedECC.png | warped input image }"
"{h help | | print help message }"
;
@@ -165,10 +165,10 @@ static void draw_warped_roi(Mat& image, const int width, const int height, Mat&
GET_HOMO_VALUES(U, bottom_right.x, bottom_right.y);
// draw the warped perimeter
- line(image, top_left, top_right, Scalar(255,0,255));
- line(image, top_right, bottom_right, Scalar(255,0,255));
- line(image, bottom_right, bottom_left, Scalar(255,0,255));
- line(image, bottom_left, top_left, Scalar(255,0,255));
+ line(image, top_left, top_right, Scalar(255));
+ line(image, top_right, bottom_right, Scalar(255));
+ line(image, bottom_right, bottom_left, Scalar(255));
+ line(image, bottom_left, top_left, Scalar(255));
}
int main (const int argc, const char * argv[])
@@ -177,17 +177,9 @@ int main (const int argc, const char * argv[])
CommandLineParser parser(argc, argv, keys);
parser.about("ECC demo");
- if (argc < 2) {
- parser.printMessage();
- help();
- return 1;
- }
- if (parser.has("help"))
- {
- parser.printMessage();
- help();
- return 1;
- }
+ parser.printMessage();
+ help();
+
string imgFile = parser.get<string>(0);
string tempImgFile = parser.get<string>(1);
string inWarpFile = parser.get<string>(2);
@@ -239,10 +231,10 @@ int main (const int argc, const char * argv[])
}
}
- else{ //apply random waro to input image
+ else{ //apply random warp to input image
resize(inputImage, target_image, Size(216, 216));
Mat warpGround;
- cv::RNG rng;
+ RNG rng(getTickCount());
double angle;
switch (mode_temp) {
case MOTION_TRANSLATION:
@@ -299,7 +291,7 @@ int main (const int argc, const char * argv[])
}
else {
- printf("\n ->Perfomarnce Warning: Identity warp ideally assumes images of "
+ printf("\n ->Performance Warning: Identity warp ideally assumes images of "
"similar size. If the deformation is strong, the identity warp may not "
"be a good initialization. \n");
@@ -363,7 +355,8 @@ int main (const int argc, const char * argv[])
namedWindow ("warped image", WINDOW_AUTOSIZE);
namedWindow ("error (black: no error)", WINDOW_AUTOSIZE);
- moveWindow ("template", 350, 350);
+ moveWindow ("image", 20, 300);
+ moveWindow ("template", 300, 300);
moveWindow ("warped image", 600, 300);
moveWindow ("error (black: no error)", 900, 300);
diff --git a/samples/cpp/image_sequence.cpp b/samples/cpp/image_sequence.cpp
index 6a84fab..ac99f78 100644
--- a/samples/cpp/image_sequence.cpp
+++ b/samples/cpp/image_sequence.cpp
@@ -18,17 +18,12 @@ static void help(char** argv)
int main(int argc, char** argv)
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@image||}");
- if (parser.has("help"))
- {
- help(argv);
- return 0;
- }
+ help(argv);
+ cv::CommandLineParser parser(argc, argv, "{@image| ../data/left%02d.jpg |}");
string first_file = parser.get<string>("@image");
if(first_file.empty())
{
- help(argv);
return 1;
}
diff --git a/samples/cpp/inpaint.cpp b/samples/cpp/inpaint.cpp
index 86e6e37..61c4c45 100644
--- a/samples/cpp/inpaint.cpp
+++ b/samples/cpp/inpaint.cpp
@@ -47,12 +47,9 @@ static void onMouse( int event, int x, int y, int flags, void* )
int main( int argc, char** argv )
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@image|../data/fruits.jpg|}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@image|../data/fruits.jpg|}");
+ help();
+
string filename = parser.get<string>("@image");
Mat img0 = imread(filename, -1);
if(img0.empty())
diff --git a/samples/cpp/laplace.cpp b/samples/cpp/laplace.cpp
index 958fccb..d50029c 100644
--- a/samples/cpp/laplace.cpp
+++ b/samples/cpp/laplace.cpp
@@ -26,12 +26,9 @@ int smoothType = GAUSSIAN;
int main( int argc, char** argv )
{
VideoCapture cap;
- cv::CommandLineParser parser(argc, argv, "{help h | | }{ c | 0 | }{ p | | }");
- if ( parser.has("help") )
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{ c | 0 | }{ p | | }");
+ help();
+
if( parser.get<string>("c").size() == 1 && isdigit(parser.get<string>("c")[0]) )
cap.open(parser.get<int>("c"));
else
diff --git a/samples/cpp/letter_recog.cpp b/samples/cpp/letter_recog.cpp
index 0eb67d1..32ccf6b 100644
--- a/samples/cpp/letter_recog.cpp
+++ b/samples/cpp/letter_recog.cpp
@@ -521,7 +521,7 @@ int main( int argc, char *argv[] )
int method = 0;
cv::CommandLineParser parser(argc, argv, "{data|../data/letter-recognition.data|}{save||}{load||}{boost||}"
- "{mlp||}{knn knearest||}{nbayes||}{svm||}{help h||}");
+ "{mlp||}{knn knearest||}{nbayes||}{svm||}");
data_filename = parser.get<string>("data");
if (parser.has("save"))
filename_to_save = parser.get<string>("save");
@@ -537,11 +537,9 @@ int main( int argc, char *argv[] )
method = 4;
else if (parser.has("svm"))
method = 5;
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+
+ help();
+
if( (method == 0 ?
build_rtrees_classifier( data_filename, filename_to_save, filename_to_load ) :
method == 1 ?
@@ -555,8 +553,6 @@ int main( int argc, char *argv[] )
method == 5 ?
build_svm_classifier( data_filename, filename_to_save, filename_to_load ):
-1) < 0)
- {
- help();
- }
+
return 0;
}
diff --git a/samples/cpp/lkdemo.cpp b/samples/cpp/lkdemo.cpp
index 5e57aa8..f8ba732 100644
--- a/samples/cpp/lkdemo.cpp
+++ b/samples/cpp/lkdemo.cpp
@@ -45,16 +45,11 @@ int main( int argc, char** argv )
bool needToInit = false;
bool nightMode = false;
- cv::CommandLineParser parser(argc, argv, "{@input||}{help h||}");
+ help();
+ cv::CommandLineParser parser(argc, argv, "{@input|0|}");
string input = parser.get<string>("@input");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
- if( input.empty() )
- cap.open(0);
- else if( input.size() == 1 && isdigit(input[0]) )
+
+ if( input.size() == 1 && isdigit(input[0]) )
cap.open(input[0] - '0');
else
cap.open(input);
diff --git a/samples/cpp/mask_tmpl.cpp b/samples/cpp/mask_tmpl.cpp
index 6617783..b20c3ee 100644
--- a/samples/cpp/mask_tmpl.cpp
+++ b/samples/cpp/mask_tmpl.cpp
@@ -19,16 +19,12 @@ static void help()
int main( int argc, const char** argv )
{
+ help();
cv::CommandLineParser parser(argc, argv,
- "{help h||}"
"{ i | ../data/lena_tmpl.jpg | }"
"{ t | ../data/tmpl.png | }"
"{ m | ../data/mask.png | }");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+
string filename = parser.get<string>("i");
string tmplname = parser.get<string>("t");
string maskname = parser.get<string>("m");
diff --git a/samples/cpp/npr_demo.cpp b/samples/cpp/npr_demo.cpp
index 64a3e05..c343969 100644
--- a/samples/cpp/npr_demo.cpp
+++ b/samples/cpp/npr_demo.cpp
@@ -28,7 +28,7 @@ using namespace cv;
int main(int argc, char* argv[])
{
- cv::CommandLineParser parser(argc, argv, "{help h||show help message}{@image||input image}");
+ cv::CommandLineParser parser(argc, argv, "{help h||show help message}{@image|../data/lena.jpg|input image}");
if (parser.has("help"))
{
parser.printMessage();
diff --git a/samples/cpp/polar_transforms.cpp b/samples/cpp/polar_transforms.cpp
index adbc955..d860e27 100644
--- a/samples/cpp/polar_transforms.cpp
+++ b/samples/cpp/polar_transforms.cpp
@@ -53,14 +53,13 @@ int main( int argc, char** argv )
break;
Point2f center( (float)frame.cols / 2, (float)frame.rows / 2 );
- double radius = (double)frame.cols / 4;
- double M = (double)frame.cols / log(radius);
+ double M = 70;
logPolar(frame,log_polar_img, center, M, INTER_LINEAR + WARP_FILL_OUTLIERS);
- linearPolar(frame,lin_polar_img, center, radius, INTER_LINEAR + WARP_FILL_OUTLIERS);
+ linearPolar(frame,lin_polar_img, center, M, INTER_LINEAR + WARP_FILL_OUTLIERS);
logPolar(log_polar_img, recovered_log_polar, center, M, WARP_INVERSE_MAP + INTER_LINEAR);
- linearPolar(lin_polar_img, recovered_lin_polar_img, center, radius, WARP_INVERSE_MAP + INTER_LINEAR + WARP_FILL_OUTLIERS);
+ linearPolar(lin_polar_img, recovered_lin_polar_img, center, M, WARP_INVERSE_MAP + INTER_LINEAR + WARP_FILL_OUTLIERS);
imshow("Log-Polar", log_polar_img );
imshow("Linear-Polar", lin_polar_img );
diff --git a/samples/cpp/shape_example.cpp b/samples/cpp/shape_example.cpp
index cb6cfbe..120d947 100644
--- a/samples/cpp/shape_example.cpp
+++ b/samples/cpp/shape_example.cpp
@@ -115,6 +115,7 @@ int main(int argc, char** argv)
resize(iiIm, bestToShow, sz2Sh);
imshow("BEST MATCH", bestToShow);
moveWindow("BEST MATCH", sz2Sh.width+50,0);
+ waitKey();
return 0;
}
diff --git a/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp b/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
index 1834e35..563e35d 100644
--- a/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
+++ b/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
@@ -40,10 +40,15 @@ static void on_trackbar( int, void* )
* @function main
* @brief Main function
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
/// Read image given by user
- image = imread( argv[1] );
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ image = imread( imageName );
/// Initialize values
alpha = 1;
@@ -54,8 +59,8 @@ int main( int, char** argv )
namedWindow("New Image", 1);
/// Create Trackbars
- createTrackbar( "Contrast Trackbar", "New Image", &alpha, alpha_max, on_trackbar );
- createTrackbar( "Brightness Trackbar", "New Image", &beta, beta_max, on_trackbar );
+ createTrackbar( "Contrast", "New Image", &alpha, alpha_max, on_trackbar );
+ createTrackbar( "Brightness", "New Image", &beta, beta_max, on_trackbar );
/// Show some stuff
imshow("Original Image", image);
diff --git a/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp b/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
index 2535782..0f32554 100644
--- a/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
@@ -15,7 +15,7 @@ using namespace cv;
* @function main
* @brief Main function
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//! [basic-linear-transform-parameters]
double alpha = 1.0; /*< Simple contrast control */
@@ -24,7 +24,12 @@ int main( int, char** argv )
/// Read image given by user
//! [basic-linear-transform-load]
- Mat image = imread( argv[1] );
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ Mat image = imread( imageName );
//! [basic-linear-transform-load]
//! [basic-linear-transform-output]
Mat new_image = Mat::zeros( image.size(), image.type() );
diff --git a/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp b/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
index 7a8fb57..6f843f6 100644
--- a/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
@@ -29,10 +29,15 @@ void Morphology_Operations( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/baboon.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread(imageName, IMREAD_COLOR); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgProc/Threshold.cpp b/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
index d057ebc..c127b7d 100644
--- a/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
@@ -30,10 +30,15 @@ void Threshold_Demo( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//! [load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/stuff.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp
index 7fc28f0..7ee22a2 100644
--- a/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp
@@ -58,9 +58,16 @@ void on_gamma_correction_trackbar(int, void *)
}
}
-int main( int, char** argv )
+int main( int argc, char** argv )
{
- img_original = imread( argv[1] );
+
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+
+ img_original = imread( imageName );
img_corrected = Mat(img_original.rows, img_original.cols*2, img_original.type());
img_gamma_corrected = Mat(img_original.rows, img_original.cols*2, img_original.type());
diff --git a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
index 2911b9d..604b57f 100644
--- a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
@@ -21,7 +21,7 @@ namespace
const std::string usage = "Usage : tutorial_HoughCircle_Demo <path_to_input_image>\n";
// initial and max values of the parameters of interests.
- const int cannyThresholdInitialValue = 200;
+ const int cannyThresholdInitialValue = 100;
const int accumulatorThresholdInitialValue = 50;
const int maxAccumulatorThreshold = 200;
const int maxCannyThreshold = 255;
@@ -55,15 +55,13 @@ int main(int argc, char** argv)
{
Mat src, src_gray;
- if (argc < 2)
+ // Read the image
+ String imageName("../data/stuff.jpg"); // by default
+ if (argc > 1)
{
- std::cerr<<"No input image specified\n";
- std::cout<<usage;
- return -1;
+ imageName = argv[1];
}
-
- // Read the image
- src = imread( argv[1], IMREAD_COLOR );
+ src = imread( imageName, IMREAD_COLOR );
if( src.empty() )
{
diff --git a/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
index 5610cfe..213d07c 100644
--- a/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
@@ -35,10 +35,15 @@ void Probabilistic_Hough( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
- /// Read the image
- src = imread( argv[1], IMREAD_COLOR );
+ // Read the image
+ String imageName("../data/building.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR );
if( src.empty() )
{ help();
diff --git a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
index 6a41c3a..0f56c49 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![variables]
Mat src, src_gray, dst;
@@ -25,7 +25,12 @@ int main( int, char** argv )
//![variables]
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
index afe7024..4cc3bb8 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
@@ -23,10 +23,12 @@ void update_map( void );
/**
* @function main
*/
-int main( int, char** argv )
+int main(int argc, const char** argv)
{
/// Load the image
- src = imread( argv[1], IMREAD_COLOR );
+ CommandLineParser parser(argc, argv, "{@image |../data/chicky_512.png|input image name}");
+ std::string filename = parser.get<std::string>(0);
+ src = imread( filename, IMREAD_COLOR );
/// Create dst, map_x and map_y with the same size as src:
dst.create( src.size(), src.type() );
diff --git a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
index ad45452..d5a3776 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![variables]
Mat src, src_gray;
@@ -25,7 +25,12 @@ int main( int, char** argv )
//![variables]
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp b/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
index 3b9ad0d..ca78078 100644
--- a/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
@@ -21,10 +21,15 @@ RNG rng(12345);
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{
diff --git a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
index 81a6fc0..24aef46 100644
--- a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main ( int, char** argv )
+int main ( int argc, char** argv )
{
/// Declare variables
Mat src, dst;
@@ -26,7 +26,12 @@ int main ( int, char** argv )
const char* window_name = "filter2D Demo";
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
index 424a490..01783cc 100644
--- a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
@@ -10,11 +10,11 @@
using namespace std;
using namespace cv;
-int main(int, char** argv)
+int main()
{
//! [load_image]
// Load the image
- Mat src = imread(argv[1]);
+ Mat src = imread("../data/cards.png");
// Check if everything was fine
if (!src.data)
diff --git a/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp b/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
index b831441..233800e 100644
--- a/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
+++ b/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
@@ -23,10 +23,16 @@ void thresh_callback(int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
/// Load source image
- src = imread(argv[1], IMREAD_COLOR);
+ String imageName("../data/happyfish.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread(imageName, IMREAD_COLOR);
+
if (src.empty())
{
cerr << "No image supplied ..." << endl;
diff --git a/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp b/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
index d114a95..e024b21 100644
--- a/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
+++ b/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
@@ -19,14 +19,13 @@ void readme();
* @function main
* @brief Main function
*/
-int main( int argc, char** argv )
+int main()
{
- if( argc != 3 )
- { readme(); return -1; }
+ readme();
//-- 1. Read the images
- Mat imgLeft = imread( argv[1], IMREAD_GRAYSCALE );
- Mat imgRight = imread( argv[2], IMREAD_GRAYSCALE );
+ Mat imgLeft = imread( "../data/rubberwhale1.png", IMREAD_GRAYSCALE );
+ Mat imgRight = imread( "../data/rubberwhale2.png", IMREAD_GRAYSCALE );
//-- And create the image in which we will save our disparities
Mat imgDisparity16S = Mat( imgLeft.rows, imgLeft.cols, CV_16S );
Mat imgDisparity8U = Mat( imgLeft.rows, imgLeft.cols, CV_8UC1 );
diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
index 7018b70..f0e0ff1 100755
--- a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
+++ b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
@@ -63,7 +63,7 @@ int main(void)
Mat res;
drawMatches(img1, inliers1, img2, inliers2, good_matches, res);
- imwrite("res.png", res);
+ imwrite("akaze_result.png", res);
double inlier_ratio = inliers1.size() * 1.0 / matched1.size();
cout << "A-KAZE Matching Results" << endl;
@@ -75,5 +75,8 @@ int main(void)
cout << "# Inliers Ratio: \t" << inlier_ratio << endl;
cout << endl;
+ imshow("result", res);
+ waitKey();
+
return 0;
}
diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
index 6ccb831..e4673f8 100755
--- a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
+++ b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
@@ -120,27 +120,27 @@ Mat Tracker::process(const Mat frame, Stats& stats)
int main(int argc, char **argv)
{
- if(argc < 2) {
- cerr << "Usage: " << endl
- << "akaze_track input_path" << endl
- << " (input_path can be a camera id, like 0,1,2 or a video filename)" << endl;
- return 1;
- }
+ cerr << "Usage: " << endl
+ << "akaze_track input_path" << endl
+ << " (input_path can be a camera id, like 0,1,2 or a video filename)" << endl;
- std::string video_name = argv[1];
- std::stringstream ssFormat;
- ssFormat << atoi(argv[1]);
+ CommandLineParser parser(argc, argv, "{@input_path |0|input path can be a camera id, like 0,1,2 or a video filename}");
+ string input_path = parser.get<string>(0);
+ string video_name = input_path;
VideoCapture video_in;
- if (video_name.compare(ssFormat.str())==0) { //test str==str(num)
- video_in.open(atoi(argv[1]));
+
+ if ( ( isdigit(input_path[0]) && input_path.size() == 1 ) )
+ {
+ int camera_no = input_path[0] - '0';
+ video_in.open( camera_no );
}
else {
video_in.open(video_name);
}
if(!video_in.isOpened()) {
- cerr << "Couldn't open " << argv[1] << endl;
+ cerr << "Couldn't open " << video_name << endl;
return 1;
}
diff --git a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
index 97ac8e8..851b32c 100644
--- a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
+++ b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
@@ -94,12 +94,16 @@ double getOrientation(const vector<Point> &pts, Mat &img)
/**
* @function main
*/
-int main(int, char** argv)
+int main(int argc, char** argv)
{
//! [pre-process]
// Load image
-// Mat src = imread("pca_test1.jpg");
- Mat src = imread(argv[1]);
+ String imageName("../data/pca_test1.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ Mat src = imread( imageName );
// Check if image is loaded successfully
if(!src.data || src.empty())
diff --git a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
index 2fd0bb9..c118b76 100644
--- a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
+++ b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
@@ -81,7 +81,7 @@ int main(void)
Mat res;
drawMatches(img1, inliers1, img2, inliers2, good_matches, res);
- imwrite("../../samples/data/latch_res.png", res);
+ imwrite("latch_result.png", res);
double inlier_ratio = inliers1.size() * 1.0 / matched1.size();
@@ -93,6 +93,10 @@ int main(void)
cout << "# Inliers: \t" << inliers1.size() << endl;
cout << "# Inliers Ratio: \t" << inlier_ratio << endl;
cout << endl;
+
+ imshow("result", res);
+ waitKey();
+
return 0;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list