-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelperCode.h
More file actions
83 lines (70 loc) · 1.92 KB
/
HelperCode.h
File metadata and controls
83 lines (70 loc) · 1.92 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
#pragma once
#include <iostream>
#include <chrono>
#include <Vector>
#include <iomanip>
#include <opencv2/opencv.hpp>
#include <fstream>
cv::VideoCapture LoadVideo(std::string a) {
cv::VideoCapture Capture(a);
if (!Capture.isOpened()) {
std::cerr << "Can Not Open Video File\n";
return 1;
};
return Capture;
};
std::vector<cv::Scalar> GenRandomColors(int a) {
std::vector<cv::Scalar> colors;
cv::RNG rng;
for (int i = 0; i < a; i++) {
int r = rng.uniform(0, 256);
int b = rng.uniform(0, 256);
int g = rng.uniform(0, 256);
colors.push_back(cv::Scalar(r, g, b));
};
return colors;
};
int ImageLoadingChecker(cv::Mat img) {
if (img.empty()) {
std::cerr << "Failure To Correctly Load Image" << img;
return 1;
}
};
int CorrectCommoandLineInput(int a, int b) {
// pass argc as b for this to work right.
if (b != a) {
std::cout << "Error Please make sure the right inputs where pased /n";
return 1;
}
};
void LoadImages(const std::string& strPathToSequence, std::vector<std::string>& vstrImageLeft,
std::vector<std::string>& vstrImageRight, std::vector<double>& vTimestamps)
{
std::ifstream fTimes;
std::string strPathTimeFile = strPathToSequence + "/times.txt";
fTimes.open(strPathTimeFile.c_str());
while (!fTimes.eof())
{
std::string s;
getline(fTimes, s);
if (!s.empty())
{
std::stringstream ss;
ss << s;
double t;
ss >> t;
vTimestamps.push_back(t);
}
}
std::string strPrefixLeft = strPathToSequence + "/image_0/";
std::string strPrefixRight = strPathToSequence + "/image_1/";
const int nTimes = vTimestamps.size();
vstrImageLeft.resize(nTimes);
vstrImageRight.resize(nTimes);
for(int i = 0; i < nTimes; i++){
std::stringstream ss;
ss << std::setfill('0') << std::setw(6) << i;
vstrImageLeft[i] = strPrefixLeft + ss.str() + ".png";
vstrImageRight[i] = strPrefixRight + ss.str() + ".png";
}
}