-
Notifications
You must be signed in to change notification settings - Fork 0
/
DimensionConvertor.cu
78 lines (61 loc) · 1.95 KB
/
DimensionConvertor.cu
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
#include "DimensionConvertor.h"
void DimensionConvertor::projectiveToReal(float* data, float3* out){
thrust::counting_iterator<int> index(0);
float3 reset;
reset.x = 0.0;
reset.y = 0.0;
reset.z = 0.0;
thrust::fill(
thrust::device_ptr<float3>(out),
thrust::device_ptr<float3>(out) + Width*Height,
reset
);
thrust::device_ptr<float> dev_ptr(data);
thrust::transform(
thrust::make_zip_iterator(thrust::make_tuple(dev_ptr, index)),
thrust::make_zip_iterator(thrust::make_tuple(dev_ptr + Width*Height, index + Width*Height)),
thrust::device_ptr<float3>(out),
convert_ptr(Width, Height, Fx, Fy, Cx, Cy)
);
}
void DimensionConvertor::projectiveToReal(float3* data, float3* out){
thrust::transform(
thrust::device_ptr<float3>(data),
thrust::device_ptr<float3>(data) + Width*Height,
thrust::device_ptr<float3>(out),
convert_ptr(Width, Height, Fx, Fy, Cx, Cy)
);
}
void DimensionConvertor::realToProjective(float3* data, float3* out){
thrust::transform(
thrust::device_ptr<float3>(data),
thrust::device_ptr<float3>(data) + Width*Height,
thrust::device_ptr<float3>(out),
convert_rtp(Width, Height, Fx, Fy, Cx, Cy)
);
}
void DimensionConvertor::projectiveToRealInterp(float* data, float3* out){
thrust::counting_iterator<int> index(0);
float3 reset;
reset.x = 0.0;
reset.y = 0.0;
reset.z = 0.0;
thrust::fill(
thrust::device_ptr<float3>(out),
thrust::device_ptr<float3>(out) + Width*Height,
reset
);
thrust::device_ptr<float> dev_ptr(data);
//thrust::transform(
// thrust::make_zip_iterator(thrust::make_tuple(dev_ptr, index)),
// thrust::make_zip_iterator(thrust::make_tuple(dev_ptr + size, index + size)),
// thrust::device_ptr<float3>(out),
// cvt
//);
thrust::transform(
thrust::make_zip_iterator(thrust::make_tuple(dev_ptr, index)),
thrust::make_zip_iterator(thrust::make_tuple(dev_ptr + Width*Height, index + Width*Height)),
thrust::device_ptr<float3>(out),
convert_ptr_int(Width, Height, Fx, Fy, Cx, Cy)
);
}