-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPreProcessing.cpp
More file actions
71 lines (67 loc) · 1.94 KB
/
PreProcessing.cpp
File metadata and controls
71 lines (67 loc) · 1.94 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
#include "PreProcessing.h"
vector<string> getGroundTruthPose(const char* fileName){
ifstream myReadFile;
myReadFile.open(fileName);
char output[100];
vector<string> poses;
if (myReadFile.is_open()) {
int count = 0;
while (!myReadFile.eof()) {
myReadFile >> output;
count++;
if(count > 16) poses.push_back(output);
}
//16
}
myReadFile.close();
return poses;
}
vector<string> getImageNames(const char* fileName){
ifstream myReadFile;
myReadFile.open(fileName);
char output[100];
vector<string> imageNames;
if (myReadFile.is_open()) {
int count = 0;
while (!myReadFile.eof()) {
myReadFile >> output;
count++;
if(count > 9 && count%2 == 0) imageNames.push_back(output);
}
}
myReadFile.close();
return imageNames;
}
//Depth Map Retrieval
float *getDepthMap(const char* fileName){
FILE * pFile;
long lSize;
char * buffer;
size_t result;
pFile = fopen ( fileName , "rb" );
errno=0;
if (pFile==NULL) printf("Error %d \n", errno);
// obtain file size:
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file:
buffer = (char*) malloc (sizeof(char)*lSize);
if (buffer == NULL) fputs ("Memory error",stderr);
// copy the file into the buffer:
result = fread (buffer,1,lSize,pFile);
if (result != lSize) fputs ("Reading error",stderr);
static float depthMap[pixelWidth*pixelHeight];
for(int i = 0; i < pixelWidth*pixelHeight; i++){
if(buffer[2*i]!=0){
bitset<8> small8(buffer[2*i]);
bitset<8> big8(buffer[2*i+1]);
bitset<16> depth(big8.to_string()+small8.to_string());
depthMap[i]=depth.to_ulong()/depthFactor;
}
}
fclose (pFile);
free (buffer);
cout<<"depthMap get"<<endl;
return depthMap;
}