-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetProjectionMatrix.cpp
More file actions
46 lines (37 loc) · 1.1 KB
/
GetProjectionMatrix.cpp
File metadata and controls
46 lines (37 loc) · 1.1 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
//Skeletonization through the Zhang-Suen algorithm. This function assumes the image is in 0 or 255 binary.
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cassert>
#include "GetProjectionMatrix.h"
using namespace std;
vector<Mat> getProjectionMatrix(char* filename) {
ifstream input(filename);
assert(input);
vector<Mat> projs;
char line[1024];
int num;
input.getline(line, sizeof(line));
sscanf(line, "%d", &num);
// Creates projection matricies for all images
for(int i=0; i < num; i++) {
Mat P(3, 4, CV_32F);
//Gets the next line (that contains data)
input.getline(line, sizeof(line)); // blank
//Goes through each row of the projection matrix (3 x 4 matrix)
for(int j=0; j < 3; j++) {
input.getline(line, sizeof(line));
stringstream a(line);
//Enters data into projection matrix from each column
a >> P.at<float>(j, 0);
a >> P.at<float>(j, 1);
a >> P.at<float>(j, 2);
a >> P.at<float>(j, 3);
}
// Adds the data in the last entry (increasing the vector size by 1)
projs.push_back(P);
}
return projs;
}