-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtools.cpp
More file actions
71 lines (66 loc) · 1.39 KB
/
Copy pathtools.cpp
File metadata and controls
71 lines (66 loc) · 1.39 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
#pragma once
#include"help.h"
String intToString(int v) // 从一幅大图像中,取出一小块图像。
{
char buf[32] = { 0 };
snprintf(buf, sizeof(buf), "%u", v);
String str = buf;
return str;
}
void writePicture(Mat &frame, int type, int num) // 将图片写入文件 (type)/num.jpg
{
string s;
switch (type)
{
case LEFT:
s = "./left/" + intToString(num) + ".jpg";
break;
case RIGHT:
s = "./right/" + intToString(num) + ".jpg";
break;
case TEMP:
s = "./temp/" + intToString(num) + ".jpg";
break;
default:
help(3);
break;
}
imwrite(s, frame);
}
void readPicture(Mat &frame, int type, int num)// 读入图片到frame
{
string s;
switch (type)
{
case LEFT:
s = "./left/" + intToString(num) + ".jpg";
break;
case RIGHT:
s = "./right/" + intToString(num) + ".jpg";
break;
case TEMP:
s = "./temp/" + intToString(num) + ".jpg";
break;
default:
help(3);
break;
}
frame = imread(s);
}
void saveXYZ(const char*filename, const Mat&mat)
{
const double max_z = 1.0e4;
FILE* fp = fopen(filename, "wt");
for (int y = 0; y <mat.rows; y++)
{
for (int x = 0; x <mat.cols; x++)
{
Vec3f point = mat.at
<Vec3f>(y, x);
if (fabs(point[2] - max_z)<FLT_EPSILON || fabs(point[2])>max_z)continue;
if (point[2]>300)continue;
fprintf(fp, "%f %f %f \n", point[0], point[1], point[2]);
}
}
fclose(fp);
}