@@ -228,6 +228,13 @@ bool WideAngleCameraSensor::CreateCamera()
228228 unsigned int width = cameraSdf->ImageWidth ();
229229 unsigned int height = cameraSdf->ImageHeight ();
230230
231+ if (width == 0u || height == 0u )
232+ {
233+ gzerr << " Unable to create a wide angle camera sensor with 0 width or "
234+ << " height." << std::endl;
235+ return false ;
236+ }
237+
231238 this ->dataPtr ->camera = this ->Scene ()->CreateWideAngleCamera (this ->Name ());
232239
233240 if (!this ->dataPtr ->camera )
@@ -326,6 +333,12 @@ bool WideAngleCameraSensor::CreateCamera()
326333 case sdf::PixelFormatType::RGB_INT8:
327334 this ->dataPtr ->camera ->SetImageFormat (gz::rendering::PF_R8G8B8);
328335 break ;
336+ case sdf::PixelFormatType::L_INT8:
337+ this ->dataPtr ->camera ->SetImageFormat (gz::rendering::PF_L8);
338+ break ;
339+ case sdf::PixelFormatType::L_INT16:
340+ this ->dataPtr ->camera ->SetImageFormat (gz::rendering::PF_L16);
341+ break ;
329342 default :
330343 gzerr << " Unsupported pixel format ["
331344 << static_cast <int >(pixelFormat) << " ]\n " ;
@@ -360,7 +373,9 @@ void WideAngleCameraSensor::OnNewWideAngleFrame(
360373{
361374 std::lock_guard<std::mutex> lock (this ->dataPtr ->mutex );
362375
363- unsigned int len = _width * _height * _channels;
376+ unsigned int bytesPerChannel = rendering::PixelUtil::BytesPerChannel (
377+ this ->dataPtr ->camera ->ImageFormat ());
378+ unsigned int len = _width * _height * _channels * bytesPerChannel;
364379 unsigned int bufferSize = len * sizeof (unsigned char );
365380
366381 if (!this ->dataPtr ->imageBuffer )
@@ -460,6 +475,12 @@ bool WideAngleCameraSensor::Update(
460475 format = gz::common::Image::RGB_INT8;
461476 msgsPixelFormat = msgs::PixelFormatType::RGB_INT8;
462477 break ;
478+ case gz::rendering::PF_L8:
479+ msgsPixelFormat = msgs::PixelFormatType::L_INT8;
480+ break ;
481+ case gz::rendering::PF_L16:
482+ msgsPixelFormat = msgs::PixelFormatType::L_INT16;
483+ break ;
463484 default :
464485 gzerr << " Unsupported pixel format ["
465486 << this ->dataPtr ->camera ->ImageFormat () << " ]\n " ;
0 commit comments