Skip to content

Commit

Permalink
Fix vpImageConvert::YUYVToRGBa() and YUYVToRGB() color conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Jul 3, 2024
1 parent a19b3c5 commit ea397a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
42 changes: 22 additions & 20 deletions modules/core/src/image/vpImageConvert_yuv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ namespace
{
void vpSAT(int &c)
{
if (c < 0) {
c = 0;
}
else {
const unsigned int val_255 = 255;
c = val_255;
if (c & (~255)) {
if (c < 0) {
c = 0;
}
else {
const unsigned int val_255 = 255;
c = val_255;
}
}
}
};
Expand All @@ -73,13 +75,13 @@ void vpImageConvert::YUYVToRGBa(unsigned char *yuyv, unsigned char *rgba, unsign
unsigned char *d;
int w, h;
int r, g, b, cr, cg, cb, y1, y2;
const unsigned int val_2 = 2;
const unsigned int val_88 = 88;
const unsigned int val_128 = 128;
const unsigned int val_183 = 183;
const unsigned int val_256 = 256;
const unsigned int val_359 = 359;
const unsigned int val_454 = 454;
const int val_2 = 2;
const int val_88 = 88;
const int val_128 = 128;
const int val_183 = 183;
const int val_256 = 256;
const int val_359 = 359;
const int val_454 = 454;

h = static_cast<int>(height);
w = static_cast<int>(width);
Expand Down Expand Up @@ -142,13 +144,13 @@ void vpImageConvert::YUYVToRGB(unsigned char *yuyv, unsigned char *rgb, unsigned
unsigned char *d;
int h, w;
int r, g, b, cr, cg, cb, y1, y2;
const unsigned int val_2 = 2;
const unsigned int val_88 = 88;
const unsigned int val_128 = 128;
const unsigned int val_183 = 183;
const unsigned int val_256 = 256;
const unsigned int val_359 = 359;
const unsigned int val_454 = 454;
const int val_2 = 2;
const int val_88 = 88;
const int val_128 = 128;
const int val_183 = 183;
const int val_256 = 256;
const int val_359 = 359;
const int val_454 = 454;

h = static_cast<int>(height);
w = static_cast<int>(width);
Expand Down
3 changes: 2 additions & 1 deletion modules/sensor/src/framegrabber/v4l2/vpV4l2Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,9 @@ void vpV4l2Grabber::acquire(vpImage<vpRGBa> &I, struct timeval &timestamp, const
vpImageTools::crop(bitmap, width, height, roi, I);
break;
case V4L2_RGB24_FORMAT: // tested
if (roi == vpRect())
if (roi == vpRect()) {
vpImageConvert::RGBToRGBa((unsigned char *)bitmap, (unsigned char *)I.bitmap, width * height);
}
else {
vpImage<vpRGBa> tmp(height, width);
vpImageConvert::RGBToRGBa((unsigned char *)bitmap, (unsigned char *)tmp.bitmap, width * height);
Expand Down

0 comments on commit ea397a3

Please sign in to comment.