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

Fix vpImageConvert::YUYVToRGBa() and YUYVToRGB() color conversion #1432

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading