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

Add support for L8 and L16 image formats in WideAngleCameraSensor #494

Merged
merged 2 commits into from
Jan 10, 2025
Merged
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
16 changes: 15 additions & 1 deletion src/WideAngleCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ bool WideAngleCameraSensor::CreateCamera()
case sdf::PixelFormatType::RGB_INT8:
this->dataPtr->camera->SetImageFormat(gz::rendering::PF_R8G8B8);
break;
case sdf::PixelFormatType::L_INT8:
this->dataPtr->camera->SetImageFormat(gz::rendering::PF_L8);
break;
case sdf::PixelFormatType::L_INT16:
this->dataPtr->camera->SetImageFormat(gz::rendering::PF_L16);
break;
default:
gzerr << "Unsupported pixel format ["
<< static_cast<int>(pixelFormat) << "]\n";
Expand Down Expand Up @@ -367,7 +373,9 @@ void WideAngleCameraSensor::OnNewWideAngleFrame(
{
std::lock_guard<std::mutex> lock(this->dataPtr->mutex);

unsigned int len = _width * _height * _channels;
unsigned int bytesPerChannel = rendering::PixelUtil::BytesPerChannel(
this->dataPtr->camera->ImageFormat());
unsigned int len = _width * _height * _channels * bytesPerChannel;
unsigned int bufferSize = len * sizeof(unsigned char);

if (!this->dataPtr->imageBuffer)
Expand Down Expand Up @@ -467,6 +475,12 @@ bool WideAngleCameraSensor::Update(
format = gz::common::Image::RGB_INT8;
msgsPixelFormat = msgs::PixelFormatType::RGB_INT8;
break;
case gz::rendering::PF_L8:
msgsPixelFormat = msgs::PixelFormatType::L_INT8;
break;
case gz::rendering::PF_L16:
msgsPixelFormat = msgs::PixelFormatType::L_INT16;
break;
default:
gzerr << "Unsupported pixel format ["
<< this->dataPtr->camera->ImageFormat() << "]\n";
Expand Down
Loading