Commit aaef365 1 parent 2f22722 commit aaef365 Copy full SHA for aaef365
File tree 7 files changed +55
-6
lines changed
7 files changed +55
-6
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,13 @@ bool BoundingBoxCameraSensor::CreateCamera()
293
293
auto width = sdfCamera->ImageWidth ();
294
294
auto height = sdfCamera->ImageHeight ();
295
295
296
+ if (width == 0u || height == 0u )
297
+ {
298
+ gzerr << " Unable to create a bounding box camera sensor with 0 width or "
299
+ << " height. " << std::endl;
300
+ return false ;
301
+ }
302
+
296
303
// Set Camera Properties
297
304
this ->dataPtr ->rgbCamera ->SetImageFormat (rendering::PF_R8G8B8);
298
305
this ->dataPtr ->rgbCamera ->SetImageWidth (width);
Original file line number Diff line number Diff line change @@ -144,6 +144,13 @@ bool CameraSensor::CreateCamera()
144
144
unsigned int width = cameraSdf->ImageWidth ();
145
145
unsigned int height = cameraSdf->ImageHeight ();
146
146
147
+ if (width == 0u || height == 0u )
148
+ {
149
+ gzerr << " Unable to create a camera sensor with 0 width or height."
150
+ << std::endl;
151
+ return false ;
152
+ }
153
+
147
154
this ->dataPtr ->camera = this ->Scene ()->CreateCamera (this ->Name ());
148
155
this ->dataPtr ->camera ->SetImageWidth (width);
149
156
this ->dataPtr ->camera ->SetImageHeight (height);
Original file line number Diff line number Diff line change @@ -337,8 +337,15 @@ bool DepthCameraSensor::CreateCamera()
337
337
return false ;
338
338
}
339
339
340
- int width = cameraSdf->ImageWidth ();
341
- int height = cameraSdf->ImageHeight ();
340
+ unsigned int width = cameraSdf->ImageWidth ();
341
+ unsigned int height = cameraSdf->ImageHeight ();
342
+
343
+ if (width == 0u || height == 0u )
344
+ {
345
+ gzerr << " Unable to create a depth camera sensor with 0 width or height."
346
+ << std::endl;
347
+ return false ;
348
+ }
342
349
343
350
double far = cameraSdf->FarClip ();
344
351
double near = cameraSdf->NearClip ();
Original file line number Diff line number Diff line change @@ -278,8 +278,15 @@ bool RgbdCameraSensor::CreateCameras()
278
278
return false ;
279
279
}
280
280
281
- int width = cameraSdf->ImageWidth ();
282
- int height = cameraSdf->ImageHeight ();
281
+ unsigned int width = cameraSdf->ImageWidth ();
282
+ unsigned int height = cameraSdf->ImageHeight ();
283
+
284
+ if (width == 0u || height == 0u )
285
+ {
286
+ gzerr << " Unable to create an RGBD camera sensor with 0 width or height."
287
+ << std::endl;
288
+ return false ;
289
+ }
283
290
284
291
this ->dataPtr ->depthCamera =
285
292
this ->Scene ()->CreateDepthCamera (this ->Name ());
Original file line number Diff line number Diff line change @@ -353,6 +353,13 @@ bool SegmentationCameraSensor::CreateCamera()
353
353
auto width = sdfCamera->ImageWidth ();
354
354
auto height = sdfCamera->ImageHeight ();
355
355
356
+ if (width == 0u || height == 0u )
357
+ {
358
+ gzerr << " Unable to create a segmentation camera sensor with 0 width or "
359
+ << " height." << std::endl;
360
+ return false ;
361
+ }
362
+
356
363
math::Angle angle = sdfCamera->HorizontalFov ();
357
364
if (angle < 0.01 || angle > GZ_PI*2 )
358
365
{
Original file line number Diff line number Diff line change @@ -255,8 +255,15 @@ bool ThermalCameraSensor::CreateCamera()
255
255
return false ;
256
256
}
257
257
258
- int width = cameraSdf->ImageWidth ();
259
- int height = cameraSdf->ImageHeight ();
258
+ unsigned int width = cameraSdf->ImageWidth ();
259
+ unsigned int height = cameraSdf->ImageHeight ();
260
+
261
+ if (width == 0u || height == 0u )
262
+ {
263
+ gzerr << " Unable to create a thermal camera sensor with 0 width or height."
264
+ << std::endl;
265
+ return false ;
266
+ }
260
267
261
268
sdf::PixelFormatType pixelFormat = cameraSdf->PixelFormat ();
262
269
Original file line number Diff line number Diff line change @@ -228,6 +228,13 @@ bool WideAngleCameraSensor::CreateCamera()
228
228
unsigned int width = cameraSdf->ImageWidth ();
229
229
unsigned int height = cameraSdf->ImageHeight ();
230
230
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
+
231
238
this ->dataPtr ->camera = this ->Scene ()->CreateWideAngleCamera (this ->Name ());
232
239
233
240
if (!this ->dataPtr ->camera )
You can’t perform that action at this time.
0 commit comments