@@ -251,24 +251,30 @@ void acquisition::Capture::load_cameras() {
251
251
// camera_info_pubs.push_back(nh_.advertise<sensor_msgs::CameraInfo>("camera_array/"+cam_names_[j]+"/camera_info", 1));
252
252
253
253
img_msgs.push_back (sensor_msgs::ImagePtr ());
254
+
255
+ sensor_msgs::CameraInfoPtr ci_msg (new sensor_msgs::CameraInfo ());
256
+ int image_width = 0 ;
257
+ int image_height = 0 ;
258
+ std::string distortion_model = " " ;
259
+ nh_pvt_.getParam (" image_height" , image_height);
260
+ nh_pvt_.getParam (" image_width" , image_width);
261
+ nh_pvt_.getParam (" distortion_model" , distortion_model);
262
+ ci_msg->header .frame_id = " cam_" +to_string (j)+" _optical_frame" ;
263
+ // full resolution image_size
264
+ ci_msg->height = image_height;
265
+ ci_msg->width = image_width;
266
+ // distortion
267
+ ci_msg->distortion_model = distortion_model;
268
+ // binning
269
+ ci_msg->binning_x = binning_;
270
+ ci_msg->binning_y = binning_;
271
+
254
272
if (PUBLISH_CAM_INFO_){
255
- sensor_msgs::CameraInfoPtr ci_msg (new sensor_msgs::CameraInfo ());
256
- int image_width = 0 ;
257
- int image_height = 0 ;
258
- std::string distortion_model = " " ;
259
- nh_pvt_.getParam (" image_height" , image_height);
260
- nh_pvt_.getParam (" image_width" , image_width);
261
- nh_pvt_.getParam (" distortion_model" , distortion_model);
262
- ci_msg->header .frame_id = " cam_" +to_string (j)+" _optical_frame" ;
263
- // full resolution image_size
264
- ci_msg->height = image_height;
265
- ci_msg->width = image_width;
266
- // distortion
267
- ci_msg->distortion_model = distortion_model;
268
273
ci_msg->D = distortion_coeff_vec_[j];
269
274
// intrinsic coefficients
270
- for (int count = 0 ; count<intrinsic_coeff_vec_[j].size ();count++)
275
+ for (int count = 0 ; count<intrinsic_coeff_vec_[j].size ();count++){
271
276
ci_msg->K [count] = intrinsic_coeff_vec_[j][count];
277
+ }
272
278
// Rectification matrix
273
279
if (!rect_coeff_vec_.empty ())
274
280
ci_msg->R = {
@@ -287,7 +293,8 @@ void acquisition::Capture::load_cameras() {
287
293
proj_coeff_vec_[j][8 ], proj_coeff_vec_[j][9 ],
288
294
proj_coeff_vec_[j][10 ], proj_coeff_vec_[j][11 ]};
289
295
}
290
- else if (numCameras_ == 1 ){
296
+ // else if(numCameras_ == 1){
297
+ else if (cam_ids_.size () == 1 ){
291
298
// for case of monocular camera, P[1:3,1:3]=K
292
299
ci_msg->P = {
293
300
intrinsic_coeff_vec_[j][0 ], intrinsic_coeff_vec_[j][1 ],
@@ -297,19 +304,23 @@ void acquisition::Capture::load_cameras() {
297
304
intrinsic_coeff_vec_[j][6 ], intrinsic_coeff_vec_[j][7 ],
298
305
intrinsic_coeff_vec_[j][8 ], 0 };
299
306
}
300
- // binning
301
- ci_msg->binning_x = binning_;
302
- ci_msg->binning_y = binning_;
303
-
304
- cam_info_msgs.push_back (ci_msg);
305
307
}
308
+
309
+ cam_info_msgs.push_back (ci_msg);
310
+
306
311
cam_counter++;
312
+
307
313
}
308
314
}
309
315
if (!current_cam_found) ROS_WARN_STREAM (" Camera " <<cam_ids_[j]<<" not detected!!!" );
310
316
}
311
317
ROS_ASSERT_MSG (cams.size ()," None of the connected cameras are in the config list!" );
312
318
ROS_ASSERT_MSG (master_set," The camera supposed to be the master isn't connected!" );
319
+ // Setting numCameras_ variable to reflect number of camera objects used.
320
+ // numCameras_ variable is used in other methods where it means size of cams list.
321
+ numCameras_ = cams.size ();
322
+ // setting PUBLISH_CAM_INFO_ to true so export to ros method can publish it_.advertiseCamera msg with zero intrisics and distortion coeffs.
323
+ PUBLISH_CAM_INFO_ = true ;
313
324
}
314
325
315
326
@@ -558,7 +569,7 @@ void acquisition::Capture::read_parameters() {
558
569
if (PUBLISH_CAM_INFO_)
559
570
ROS_INFO (" Camera coeffs provided, camera info messges will be published." );
560
571
else
561
- ROS_INFO (" Camera coeffs not provided correctly, camera info messges will not be published." );
572
+ ROS_WARN (" Camera coeffs not provided correctly, camera info messges intrinsics and distortion coeffs will be published with zeros ." );
562
573
563
574
// ROS_ASSERT_MSG(my_list.getType()
564
575
// int num_ids = cam_id_vec.size();
0 commit comments