Skip to content

Commit

Permalink
Extend wide angle cameras to support L8 and L16 image formats
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jan 9, 2025
1 parent aaef365 commit eadafa7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions 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,8 +373,10 @@ void WideAngleCameraSensor::OnNewWideAngleFrame(
{
std::lock_guard<std::mutex> lock(this->dataPtr->mutex);

unsigned int len = _width * _height * _channels;
unsigned int bufferSize = len * sizeof(unsigned char);
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)
this->dataPtr->imageBuffer = new unsigned char[len];
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

0 comments on commit eadafa7

Please sign in to comment.