From f83a76cdebee199cd921fa7749ead1c52e78f2eb Mon Sep 17 00:00:00 2001 From: Brian Park Date: Tue, 21 Oct 2014 22:47:49 -0700 Subject: [PATCH 1/3] add input paramter checking that verifies the existance of the input files to stero_match example --- samples/cpp/stereo_match.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/samples/cpp/stereo_match.cpp b/samples/cpp/stereo_match.cpp index f5f77cf3d..ad4670f73 100644 --- a/samples/cpp/stereo_match.cpp +++ b/samples/cpp/stereo_match.cpp @@ -14,6 +14,7 @@ #include "opencv2/core/utility.hpp" #include +#include using namespace cv; @@ -143,6 +144,19 @@ int main(int argc, char** argv) return -1; } + struct stat stat_buffer; + if (stat(img1_filename, &stat_buffer) != 0) + { + printf("Command-line parameter error: could not find the first input image file\n"); + return -1; + } + + if (stat(img2_filename, &stat_buffer) != 0) + { + printf("Command-line parameter error: could not find the second input image file\n"); + return -1; + } + if( (intrinsic_filename != 0) ^ (extrinsic_filename != 0) ) { printf("Command-line parameter error: either both intrinsic and extrinsic parameters must be specified, or none of them (when the stereo pair is already rectified)\n"); From 9e3a2cbab2a91c4f6f1cd6e0f64916e5c1eed856 Mon Sep 17 00:00:00 2001 From: Brian Park Date: Mon, 3 Nov 2014 21:38:15 -0800 Subject: [PATCH 2/3] check input paramter by checking the image size --- samples/cpp/stereo_match.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/samples/cpp/stereo_match.cpp b/samples/cpp/stereo_match.cpp index ad4670f73..1ec65d6e9 100644 --- a/samples/cpp/stereo_match.cpp +++ b/samples/cpp/stereo_match.cpp @@ -144,19 +144,6 @@ int main(int argc, char** argv) return -1; } - struct stat stat_buffer; - if (stat(img1_filename, &stat_buffer) != 0) - { - printf("Command-line parameter error: could not find the first input image file\n"); - return -1; - } - - if (stat(img2_filename, &stat_buffer) != 0) - { - printf("Command-line parameter error: could not find the second input image file\n"); - return -1; - } - if( (intrinsic_filename != 0) ^ (extrinsic_filename != 0) ) { printf("Command-line parameter error: either both intrinsic and extrinsic parameters must be specified, or none of them (when the stereo pair is already rectified)\n"); @@ -173,7 +160,18 @@ int main(int argc, char** argv) Mat img1 = imread(img1_filename, color_mode); Mat img2 = imread(img2_filename, color_mode); - if( scale != 1.f ) + if (img1.empty()) + { + printf("Command-line parameter error: could not load the first input image file\n"); + return -1; + } + if (img2.empty()) + { + printf("Command-line parameter error: could not load the second input image file\n"); + return -1; + } + + if (scale != 1.f) { Mat temp1, temp2; int method = scale < 1 ? INTER_AREA : INTER_CUBIC; From e4fa217a62911d353519a0a7267c94bf46f59a35 Mon Sep 17 00:00:00 2001 From: Brian Park Date: Wed, 5 Nov 2014 20:12:18 -0800 Subject: [PATCH 3/3] remove the unnecessary header file --- samples/cpp/stereo_match.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/cpp/stereo_match.cpp b/samples/cpp/stereo_match.cpp index 1ec65d6e9..fa5ee7bad 100644 --- a/samples/cpp/stereo_match.cpp +++ b/samples/cpp/stereo_match.cpp @@ -14,7 +14,6 @@ #include "opencv2/core/utility.hpp" #include -#include using namespace cv;