-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw.cpp
More file actions
59 lines (45 loc) · 1.52 KB
/
Copy pathdraw.cpp
File metadata and controls
59 lines (45 loc) · 1.52 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
#include <stdio.h>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <string>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
using namespace cv;
int main(int argc, const char** argv) {
Mat frame = imread(argv[1], CV_LOAD_IMAGE_COLOR);
const char* imgName = argv[1];
// Manipulate string to get correct CSV file name
string fileExtension = "points.csv";
string current_line;
std::string imgNameString(imgName);
string::size_type i = imgNameString.rfind('.', imgNameString.length());
if (i != string::npos) {
imgNameString.replace(i, fileExtension.length(), fileExtension);
}
const char *c = imgNameString.c_str();
ifstream inputFile(c);
// Go through CSV file line by line
while(getline(inputFile, current_line)){
// Array of values for each rectangle
std::vector<int> values;
std::stringstream convertor(current_line);
std::string token; // somewhere to put the comma separated value
// Insert each value into values array
while (std::getline(convertor, token, ',')) {
values.push_back(std::atoi(token.c_str()));
}
std::cout << values[0];
// Populate array with ground truth rectangles
rectangle(frame, Point(values[0], values[1]), Point(values[0] + values[2], values[1] + values[3]), Scalar( 0, 0, 255 ), 2);
}
imwrite( "annotated.jpg", frame );
return 0;
}