forked from vikas25992/read
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.cpp
160 lines (89 loc) · 2.42 KB
/
string.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include<iostream>
#include<fstream>
#include <opencv2/opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <vector>
#include <sstream>
#include<string>
using namespace std;
using namespace cv;
Mat readImgage(const string& read_address);
void showImage(Mat& image);
Mat siftDescriptors(const string& file_address);
int main()
{
Mat pic,Desc;
ostringstream oss;
for(int i=1; i<3; i++)
{
oss.clear();
oss.str("");
string address = "/home/vikas/Desktop/Project/string/pics/";
oss << address << i <<".jpeg";
pic = readImgage(oss.str());
Desc = siftDescriptors(oss.str());
cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
//cout<<oss.str()<<endl;
//pic = readImgage(oss.str());
//showImage(pic);
//pic = imread(oss.str(),0);
//imshow("pic",pic);
//waitKey(0);
}
cout<<oss.str()<<endl;
cout<<Desc<<endl;
//imshow( "Display window", pic );
//showImage(pic);
return 0;
}
Mat readImgage(const string& read_address)
{
cout<<"Reading Image"<<endl;
//cout<<file_address<<endl;
Mat image;
image = imread(read_address, CV_LOAD_IMAGE_GRAYSCALE);
return image;
}
Mat siftDescriptors(const string& file_address)
{
cout<<file_address<<endl;
Mat test_image = imread(file_address, CV_LOAD_IMAGE_GRAYSCALE);
if(test_image.empty())
{
cout<<"Can't read the images\n";
return -1;
}
SiftFeatureDetector detector(300);
vector<KeyPoint> Keypoints;
detector.detect(test_image, Keypoints);
SiftDescriptorExtractor extractor;
Mat trainDescriptors;
extractor.compute(test_image, Keypoints, trainDescriptors);
return trainDescriptors;
}
void showImage(Mat& image)
{
cout<<"show Image"<<endl;
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0);
}
//string address = main_folder + i + end;
//cout<<main_folder + i + end<<endl;
//char c = i;
//strcat(address,i);
//address.push_back(i);
//strcat(address,end);
//cout<<address<<endl;
//address += std::to_string(i);
//strcat(address,i);
//strcat(address,".jpeg");
//str += ss.str();
//ss << i;
//cout<<str<<endl;
//pic = imread(address,0);
//imshow("pic",pic);
//waitKey(0);