-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.cpp
More file actions
32 lines (30 loc) · 880 Bytes
/
Copy pathProject.cpp
File metadata and controls
32 lines (30 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/utility.hpp>
using namespace std;
using namespace cv;
int main() {
Mat logo = imread("logo.png", IMREAD_COLOR);
vector<string> fn; // std::string in opencv2.4, but cv::String in 3.0
string path = "Picture/*.jpg";
glob(path, fn, true);
cout << fn.size() << endl;
int count_img = 0;
for (size_t i = 0; i < fn.size(); i++) {
Mat img = imread(fn[i], IMREAD_COLOR);
if (img.empty())
continue;
Mat imgROI;
String window_name = "Image " + to_string(count_img);
imgROI = img(Rect(100, 100, logo.cols, logo.rows));
addWeighted(imgROI, 0.5, logo, 0.5, 0, imgROI);
cout << window_name <<" Completed!" << endl;
namedWindow(window_name, WINDOW_AUTOSIZE);
imshow(window_name, img);
imwrite("AfterImg/"+window_name+".jpg", img);
count_img++;
}
waitKey(0);
system("pause");
return 0;
}