-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMulti Theading.cpp
More file actions
94 lines (90 loc) · 2.33 KB
/
Copy pathMulti Theading.cpp
File metadata and controls
94 lines (90 loc) · 2.33 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <thread>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <ctime>
#include <fstream>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/stitching.hpp"
#include <sstream>
#include <string.h>
#include <math.h>
using namespace std;
using namespace cv;
int img_col,tot_img;
void Stitch(int i)
{
bool try_use_gpu = false;
Stitcher::Mode mode = Stitcher::SCANS;
stringstream ss;
ss << i;
string path1 = "/home/atul/DeWinter/Stitcher/" + ss.str() + ".jpg" ;
Mat image1 = imread(path1);
vector <Mat> desk;
desk.push_back(image1);
for( int j=i+img_col ; j<=tot_img;j=j+img_col)
{
stringstream ss2;
ss2 << j;
string path2 = "/home/atul/DeWinter/Stitcher/" + ss2.str() + ".jpg" ;
Mat image2 = imread(path2);
desk.push_back(image2);
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(desk, image1);
if (status != Stitcher::OK)
{
cout << j;
cout << "\nUnable to perform stitching...";
cout << "\nError code: " << status;
desk.clear();
j=j+img_col;
}
imwrite("c" + ss.str() + ".jpg",image1);
}
}
void task1()
{
Stitch(1);
}
void task2()
{
Stitch(2);
}
int main ()
{
cout << "enter total number of images" << endl;
cin >> tot_img;
cout << "enter the number of images in one column" << endl;
cin >> img_col;
bool try_use_gpu = false;
Stitcher::Mode mode = Stitcher::SCANS;
thread thread_1 = thread(task1);
thread thread_2 = thread(task2);
thread_2.join();
thread_1.join();
Mat img1 = imread("c1.jpg");
vector <Mat> desk1;
desk1.push_back(img1);
for(int k=2;k<=2;k++)
{
stringstream ss5;
ss5 << k;
string path2 = "c" + ss5.str() + ".jpg" ;
Mat img2 = imread(path2);
desk1.push_back(img2);
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(desk1, img1);
if (status != Stitcher::OK)
{
cout << k;
cout << "\nUnable to perform stitching...";
cout << "\nError code: " << status;
desk1.clear();
k= k+1;
}
imwrite("part1.jpg",img1);
}
return 0;
}