Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROS-O] patches to build on modern systems #80

Open
wants to merge 4 commits into
base: ros1
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
avoid "register" keyword
it was officially deprecated since c++11 and removed in c++17
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4340
leading to compiler failure on standard systems by now.
  • Loading branch information
v4hn committed Aug 14, 2024
commit 1dae828893830e44f6ecd682c4a194048c1069b6
54 changes: 27 additions & 27 deletions openni_camera/src/openni_image_bayer_grbg.cpp
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
if (debayering_method_ == Bilinear)
{
// first line GRGRGR
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0]; // green pixel
gray_buffer[1] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[1 + line_skip]); // interpolated green pixel
@@ -89,22 +89,22 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer += 2 + gray_line_skip;
bayer_pixel += 2;

for (register unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
for (unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
{
// blue line
gray_buffer[0] = AVG3 (bayer_pixel[-line_skip], bayer_pixel[line_skip], bayer_pixel[1]);
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = AVG4 (bayer_pixel[-line_skip], bayer_pixel[line_skip], bayer_pixel[-1], bayer_pixel[1]);
gray_buffer[1] = bayer_pixel[1];
}
gray_buffer += gray_line_skip;

// red line
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0]; // green pixel
gray_buffer[1] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[-line_skip + 1], bayer_pixel[line_skip + 1]); // interpolated green pixel
@@ -120,7 +120,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = AVG3 (bayer_pixel[-1], bayer_pixel[1], bayer_pixel[-line_skip]);
gray_buffer[1] = bayer_pixel[1];
@@ -130,7 +130,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
{
int dv, dh;
// first line GRGRGR
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0]; // green pixel
gray_buffer[1] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[1 + line_skip]); // interpolated green pixel
@@ -140,14 +140,14 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer += 2 + gray_line_skip;
bayer_pixel += 2;

for (register unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
for (unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
{
// blue line
gray_buffer[0] = AVG3 (bayer_pixel[-line_skip], bayer_pixel[line_skip], bayer_pixel[1]);
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
dv = abs (bayer_pixel[-line_skip] - bayer_pixel[line_skip]);
dh = abs (bayer_pixel[-1] - bayer_pixel[1]);
@@ -163,7 +163,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer += gray_line_skip;

// red line
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0];

@@ -187,7 +187,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = AVG3 (bayer_pixel[-1], bayer_pixel[1], bayer_pixel[-line_skip]);
gray_buffer[1] = bayer_pixel[1];
@@ -197,7 +197,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
{
int dv, dh;
// first line GRGRGR
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0]; // green pixel
gray_buffer[1] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[1 + line_skip]); // interpolated green pixel
@@ -207,14 +207,14 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer += 2 + gray_line_skip;
bayer_pixel += 2;

for (register unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
for (unsigned yIdx = 1; yIdx < height - 1; yIdx += 2)
{
// blue line
gray_buffer[0] = AVG3 (bayer_pixel[-line_skip], bayer_pixel[line_skip], bayer_pixel[1]);
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
dv = abs (bayer_pixel[-line_skip] - bayer_pixel[line_skip]);
dh = abs (bayer_pixel[-1] - bayer_pixel[1]);
@@ -230,7 +230,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer += gray_line_skip;

// red line
for (register unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 0; xIdx < width - 2; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = bayer_pixel[0];

@@ -253,7 +253,7 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
gray_buffer[1] = bayer_pixel[1];
gray_buffer += 2;
bayer_pixel += 2;
for (register unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
for (unsigned xIdx = 2; xIdx < width; xIdx += 2, gray_buffer += 2, bayer_pixel += 2)
{
gray_buffer[0] = AVG3 (bayer_pixel[-1], bayer_pixel[1], bayer_pixel[-line_skip]);
gray_buffer[1] = bayer_pixel[1];
@@ -269,15 +269,15 @@ void ImageBayerGRBG::fillGrayscale (unsigned width, unsigned height, unsigned ch
THROW_OPENNI_EXCEPTION ("Downsampling only possible for multiple of 2 in both dimensions. Request was %d x %d -> %d x %d.", image_md_->XRes (), image_md_->YRes (), width, height);

// fast method -> simply takes each or each 2nd pixel-group to get gray values out
register unsigned bayerXStep = image_md_->XRes () / width;
register unsigned bayerYSkip = (image_md_->YRes () / height - 1) * image_md_->XRes ();
unsigned bayerXStep = image_md_->XRes () / width;
unsigned bayerYSkip = (image_md_->YRes () / height - 1) * image_md_->XRes ();

// Downsampling and debayering at once
register const XnUInt8* bayer_buffer = image_md_->WritableData ();
const XnUInt8* bayer_buffer = image_md_->WritableData ();

for (register unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, gray_buffer += gray_line_skip) // skip a line
for (unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, gray_buffer += gray_line_skip) // skip a line
{
for (register unsigned xIdx = 0; xIdx < width; ++xIdx, ++gray_buffer, bayer_buffer += bayerXStep)
for (unsigned xIdx = 0; xIdx < width; ++xIdx, ++gray_buffer, bayer_buffer += bayerXStep)
{
*gray_buffer = AVG (bayer_buffer[0], bayer_buffer[ image_md_->XRes () + 1]);
}
@@ -298,8 +298,8 @@ void ImageBayerGRBG::fillRGB (unsigned width, unsigned height, unsigned char* rg

if (image_md_->XRes () == width && image_md_->YRes () == height)
{
register const XnUInt8 *bayer_pixel = image_md_->WritableData ();
register unsigned yIdx, xIdx;
const XnUInt8 *bayer_pixel = image_md_->WritableData ();
unsigned yIdx, xIdx;

int bayer_line_step = image_md_->XRes ();
int bayer_line_step2 = image_md_->XRes () << 1;
@@ -1400,15 +1400,15 @@ void ImageBayerGRBG::fillRGB (unsigned width, unsigned height, unsigned char* rg
THROW_OPENNI_EXCEPTION ("Downsampling only possible for integer scales in both dimensions. Request was %d x %d -> %d x %d.", image_md_->XRes (), image_md_->YRes (), width, height);

// get each or each 2nd pixel group to find rgb values!
register unsigned bayerXStep = image_md_->XRes () / width;
register unsigned bayerYSkip = (image_md_->YRes () / height - 1) * image_md_->XRes ();
unsigned bayerXStep = image_md_->XRes () / width;
unsigned bayerYSkip = (image_md_->YRes () / height - 1) * image_md_->XRes ();

// Downsampling and debayering at once
register const XnUInt8* bayer_buffer = image_md_->WritableData ();
const XnUInt8* bayer_buffer = image_md_->WritableData ();

for (register unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, rgb_buffer += rgb_line_skip) // skip a line
for (unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, rgb_buffer += rgb_line_skip) // skip a line
{
for (register unsigned xIdx = 0; xIdx < width; ++xIdx, rgb_buffer += 3, bayer_buffer += bayerXStep)
for (unsigned xIdx = 0; xIdx < width; ++xIdx, rgb_buffer += 3, bayer_buffer += bayerXStep)
{
rgb_buffer[ 2 ] = bayer_buffer[ image_md_->XRes () ];
rgb_buffer[ 1 ] = AVG (bayer_buffer[0], bayer_buffer[ image_md_->XRes () + 1]);
28 changes: 14 additions & 14 deletions openni_camera/src/openni_image_yuv_422.cpp
Original file line number Diff line number Diff line change
@@ -73,17 +73,17 @@ void ImageYUV422::fillRGB (unsigned width, unsigned height, unsigned char* rgb_b
THROW_OPENNI_EXCEPTION ("Downsampling only possible for power of two scale in both dimensions. Request was %d x %d -> %d x %d.", image_md_->XRes (), image_md_->YRes (), width, height);
}

register const XnUInt8* yuv_buffer = image_md_->WritableData();
const XnUInt8* yuv_buffer = image_md_->WritableData();

unsigned rgb_line_skip = 0;
if (rgb_line_step != 0)
rgb_line_skip = rgb_line_step - width * 3;

if (image_md_->XRes() == width && image_md_->YRes() == height)
{
for( register unsigned yIdx = 0; yIdx < height; ++yIdx, rgb_buffer += rgb_line_skip )
for( unsigned yIdx = 0; yIdx < height; ++yIdx, rgb_buffer += rgb_line_skip )
{
for( register unsigned xIdx = 0; xIdx < width; xIdx += 2, rgb_buffer += 6, yuv_buffer += 4 )
for( unsigned xIdx = 0; xIdx < width; xIdx += 2, rgb_buffer += 6, yuv_buffer += 4 )
{
int v = yuv_buffer[2] - 128;
int u = yuv_buffer[0] - 128;
@@ -100,13 +100,13 @@ void ImageYUV422::fillRGB (unsigned width, unsigned height, unsigned char* rgb_b
}
else
{
register unsigned yuv_step = image_md_->XRes() / width;
register unsigned yuv_x_step = yuv_step << 1;
register unsigned yuv_skip = (image_md_->YRes() / height - 1) * ( image_md_->XRes() << 1 );
unsigned yuv_step = image_md_->XRes() / width;
unsigned yuv_x_step = yuv_step << 1;
unsigned yuv_skip = (image_md_->YRes() / height - 1) * ( image_md_->XRes() << 1 );

for( register unsigned yIdx = 0; yIdx < image_md_->YRes(); yIdx += yuv_step, yuv_buffer += yuv_skip, rgb_buffer += rgb_line_skip )
for( unsigned yIdx = 0; yIdx < image_md_->YRes(); yIdx += yuv_step, yuv_buffer += yuv_skip, rgb_buffer += rgb_line_skip )
{
for( register unsigned xIdx = 0; xIdx < image_md_->XRes(); xIdx += yuv_step, rgb_buffer += 3, yuv_buffer += yuv_x_step )
for( unsigned xIdx = 0; xIdx < image_md_->XRes(); xIdx += yuv_step, rgb_buffer += 3, yuv_buffer += yuv_x_step )
{
int v = yuv_buffer[2] - 128;
int u = yuv_buffer[0] - 128;
@@ -132,14 +132,14 @@ void ImageYUV422::fillGrayscale (unsigned width, unsigned height, unsigned char*
if (gray_line_step != 0)
gray_line_skip = gray_line_step - width;

register unsigned yuv_step = image_md_->XRes() / width;
register unsigned yuv_x_step = yuv_step << 1;
register unsigned yuv_skip = (image_md_->YRes() / height - 1) * ( image_md_->XRes() << 1 );
register const XnUInt8* yuv_buffer = (image_md_->WritableData() + 1);
unsigned yuv_step = image_md_->XRes() / width;
unsigned yuv_x_step = yuv_step << 1;
unsigned yuv_skip = (image_md_->YRes() / height - 1) * ( image_md_->XRes() << 1 );
const XnUInt8* yuv_buffer = (image_md_->WritableData() + 1);

for( register unsigned yIdx = 0; yIdx < image_md_->YRes(); yIdx += yuv_step, yuv_buffer += yuv_skip, gray_buffer += gray_line_skip )
for( unsigned yIdx = 0; yIdx < image_md_->YRes(); yIdx += yuv_step, yuv_buffer += yuv_skip, gray_buffer += gray_line_skip )
{
for( register unsigned xIdx = 0; xIdx < image_md_->XRes(); xIdx += yuv_step, ++gray_buffer, yuv_buffer += yuv_x_step )
for( unsigned xIdx = 0; xIdx < image_md_->XRes(); xIdx += yuv_step, ++gray_buffer, yuv_buffer += yuv_x_step )
{
*gray_buffer = *yuv_buffer;
}