mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 21:33:04 +04:00
Merge pull request #23442 from LaurentBerger:tuto_findFile
Fix image loading in tutorials code #23442 Fixes https://github.com/opencv/opencv/issues/23378 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [X] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -26,26 +26,28 @@ int max_Trackbar = 5;
|
||||
/// Function Headers
|
||||
void MatchingMethod( int, void* );
|
||||
|
||||
const char* keys =
|
||||
"{ help h| | Print help message. }"
|
||||
"{ @input1 | Template_Matching_Original_Image.jpg | image_name }"
|
||||
"{ @input2 | Template_Matching_Template_Image.jpg | template_name }"
|
||||
"{ @input3 | | mask_name }";
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
cout << "Not enough parameters" << endl;
|
||||
cout << "Usage:\n" << argv[0] << " <image_name> <template_name> [<mask_name>]" << endl;
|
||||
return -1;
|
||||
}
|
||||
CommandLineParser parser( argc, argv, keys );
|
||||
samples::addSamplesDataSearchSubDirectory( "doc/tutorials/imgproc/histograms/template_matching/images" );
|
||||
|
||||
//! [load_image]
|
||||
/// Load image and template
|
||||
img = imread( argv[1], IMREAD_COLOR );
|
||||
templ = imread( argv[2], IMREAD_COLOR );
|
||||
img = imread( samples::findFile( parser.get<String>("@input1") ) );
|
||||
templ = imread( samples::findFile( parser.get<String>("@input2") ), IMREAD_COLOR );
|
||||
|
||||
if(argc > 3) {
|
||||
use_mask = true;
|
||||
mask = imread( argv[3], IMREAD_COLOR );
|
||||
mask = imread(samples::findFile( parser.get<String>("@input3") ), IMREAD_COLOR );
|
||||
}
|
||||
|
||||
if(img.empty() || templ.empty() || (use_mask && mask.empty()))
|
||||
|
||||
Reference in New Issue
Block a user