mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
samples: use findFile() in "cpp"
This commit is contained in:
committed by
Alexander Alekhin
parent
2fa9bd221d
commit
c4c31f5bba
@@ -17,8 +17,7 @@
|
||||
* The program takes as input a source and a destination image (for 1-3 methods)
|
||||
* and outputs the cloned image.
|
||||
*
|
||||
* Download test images from opencv_extra folder @github.
|
||||
*
|
||||
* Download test images from opencv_extra repository.
|
||||
*/
|
||||
|
||||
#include "opencv2/photo.hpp"
|
||||
@@ -27,7 +26,6 @@
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
@@ -35,6 +33,7 @@ using namespace cv;
|
||||
int main()
|
||||
{
|
||||
cout << endl;
|
||||
cout << "Note: specify OPENCV_SAMPLES_DATA_PATH_HINT=<opencv_extra>/testdata/cv" << endl << endl;
|
||||
cout << "Cloning Module" << endl;
|
||||
cout << "---------------" << endl;
|
||||
cout << "Options: " << endl;
|
||||
@@ -54,9 +53,9 @@ int main()
|
||||
if(num == 1)
|
||||
{
|
||||
string folder = "cloning/Normal_Cloning/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "destination1.png";
|
||||
string original_path3 = folder + "mask.png";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "destination1.png");
|
||||
string original_path3 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat destination = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -86,14 +85,14 @@ int main()
|
||||
seamlessClone(source, destination, mask, p, result, 1);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else if(num == 2)
|
||||
{
|
||||
string folder = "cloning/Mixed_Cloning/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "destination1.png";
|
||||
string original_path3 = folder + "mask.png";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "destination1.png");
|
||||
string original_path3 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat destination = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -123,14 +122,14 @@ int main()
|
||||
seamlessClone(source, destination, mask, p, result, 2);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else if(num == 3)
|
||||
{
|
||||
string folder = "cloning/Monochrome_Transfer/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "destination1.png";
|
||||
string original_path3 = folder + "mask.png";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "destination1.png");
|
||||
string original_path3 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat destination = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -160,13 +159,13 @@ int main()
|
||||
seamlessClone(source, destination, mask, p, result, 3);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else if(num == 4)
|
||||
{
|
||||
string folder = "cloning/Color_Change/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "mask.png";
|
||||
string folder = "cloning/color_change/";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat mask = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -187,13 +186,13 @@ int main()
|
||||
colorChange(source, mask, result, 1.5, .5, .5);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else if(num == 5)
|
||||
{
|
||||
string folder = "cloning/Illumination_Change/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "mask.png";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat mask = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -214,13 +213,13 @@ int main()
|
||||
illuminationChange(source, mask, result, 0.2f, 0.4f);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else if(num == 6)
|
||||
{
|
||||
string folder = "cloning/Texture_Flattening/";
|
||||
string original_path1 = folder + "source1.png";
|
||||
string original_path2 = folder + "mask.png";
|
||||
string original_path1 = samples::findFile(folder + "source1.png");
|
||||
string original_path2 = samples::findFile(folder + "mask.png");
|
||||
|
||||
Mat source = imread(original_path1, IMREAD_COLOR);
|
||||
Mat mask = imread(original_path2, IMREAD_COLOR);
|
||||
@@ -241,7 +240,12 @@ int main()
|
||||
textureFlattening(source, mask, result, 30, 45, 3);
|
||||
|
||||
imshow("Output",result);
|
||||
imwrite(folder + "cloned.png", result);
|
||||
imwrite("cloned.png", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Invalid selection: " << num << endl;
|
||||
exit(1);
|
||||
}
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user