Skip to content

Commit b81e081

Browse files
committed
use bytes_per_pixel instead of hardcoded value
1 parent e9b337c commit b81e081

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/protonect/Protonect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
9090
cv::imshow("ir", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f);
9191
cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f);
9292

93-
uint8_t registered[depth->height*depth->width*3];
93+
uint8_t registered[depth->height*depth->width*rgb->bytes_per_pixel];
9494
registration.apply(rgb,depth,registered);
9595
cv::imshow("registered", cv::Mat(depth->height, depth->width, CV_8UC3, registered));
9696

examples/protonect/src/registration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void Registration::apply(Frame* rgb, Frame* depth, unsigned char* registered)
100100
for (int y = 0; y < depth->height; y++) {
101101

102102
d_off = y*depth->width + x;
103-
r_off = d_off*3;
103+
r_off = d_off*rgb->bytes_per_pixel;
104104

105105
float z_raw = depth_raw[d_off];
106106
if (z_raw == 0.0) {
@@ -113,8 +113,8 @@ void Registration::apply(Frame* rgb, Frame* depth, unsigned char* registered)
113113
apply(x,y,z_raw,cx,cy);
114114

115115
// is rounding the right way to go here - no subpixel precision?
116-
c_off = (round(cx) + round(cy) * rgb->width) * 3;
117-
if ((c_off < 0) || (c_off > rgb->width*rgb->height*3)) continue;
116+
c_off = (round(cx) + round(cy) * rgb->width) * rgb->bytes_per_pixel;
117+
if ((c_off < 0) || (c_off > rgb->width*rgb->height*rgb->bytes_per_pixel)) continue;
118118

119119
registered[r_off+0] = rgb->data[c_off+0];
120120
registered[r_off+1] = rgb->data[c_off+1];

0 commit comments

Comments
 (0)