7 PCL_ERROR (
"%s: NxLib error %s (%d) occurred while accessing item %s.\n", func_nam.c_str (), ex.getErrorText ().c_str (), ex.getErrorCode (),
8 ex.getItemPath ().c_str ());
9 if (ex.getErrorCode () == NxLibExecutionFailed)
11 NxLibCommand
cmd (
"");
12 PCL_WARN (
"\n%s\n", cmd.result ().asJson (
true, 4,
false).c_str ());
19 mono_device_open_(false),
20 last_stereo_pattern_(
""),
21 store_calibration_pattern_ (false),
32 PCL_INFO (
"Initialising nxLib\n");
36 root_.reset (
new NxLibItem);
38 catch (NxLibException &ex)
41 PCL_THROW_EXCEPTION (pcl::IOException,
"Could not initialise NxLib.");
52 disconnect_all_slots<sig_cb_ensenso_point_cloud> ();
53 disconnect_all_slots<sig_cb_ensenso_point_cloud_rgb> ();
54 disconnect_all_slots<sig_cb_ensenso_images> ();
55 disconnect_all_slots<sig_cb_ensenso_images_rgb> ();
56 disconnect_all_slots<sig_cb_ensenso_image_depth> ();
69 const Eigen::Affine3d &camera_seed,
70 const Eigen::Affine3d &pattern_seed,
71 const std::string
setup,
72 Eigen::Affine3d &estimated_camera_pose,
73 Eigen::Affine3d &estimated_pattern_pose,
75 double &reprojection_error)
const 77 if ( (*
root_)[itmVersion][itmMajor] <= 1 && (*
root_)[itmVersion][itmMinor] < 3)
79 PCL_WARN(
"EnsensoSDK 1.3.x fixes bugs into calibration optimization\n");
80 PCL_WARN(
"please update your SDK! http://www.ensenso.de/support/sdk-download\n");
82 NxLibCommand calibrate (cmdCalibrateHandEye);
86 if (!boost::iequals (setup, valFixed) && !boost::iequals (setup, valMoving))
88 PCL_WARN(
"Received invalid setup value: %s\n", setup.c_str());
92 PCL_DEBUG(
"Setting calibration parameters\n");
94 if (boost::iequals (setup, valFixed))
95 target = valWorkspace;
98 Eigen::Affine3d eigen_pose;
100 PCL_DEBUG(
"Populating robot poses\n");
101 std::vector<std::string> json_poses;
102 json_poses.resize (robot_poses.size ());
103 for (uint i = 0; i < robot_poses.size(); ++i)
105 eigen_pose = robot_poses[i];
106 eigen_pose.translation () *= 1000.0;
109 PCL_DEBUG(
"Executing...\n");
111 std::string json_camera_seed, json_pattern_seed;
112 PCL_DEBUG(
"Populating seeds\n");
113 eigen_pose = camera_seed;
114 eigen_pose.translation () *= 1000.0;
116 PCL_DEBUG(
"camera_seed:\n %s\n", json_camera_seed.c_str());
118 eigen_pose = pattern_seed;
119 eigen_pose.translation () *= 1000.0;
121 PCL_DEBUG(
"pattern_seed:\n %s\n", json_pattern_seed.c_str());
124 calibrate.parameters ()[itmLink].setJson(json_camera_seed,
false);
125 calibrate.parameters ()[itmPatternPose].setJson(json_pattern_seed,
false);
126 calibrate.parameters ()[itmSetup] = setup;
127 calibrate.parameters ()[itmTarget] = target;
128 for (uint i = 0; i < json_poses.size(); ++i)
129 calibrate.parameters ()[itmTransformations][i].setJson(json_poses[i],
false);
131 calibrate.execute ();
132 if (calibrate.successful())
135 iterations = calibrate.result()[itmIterations].asInt();
136 std::string json_camera_pose = calibrate.result()[itmLink].asJson (
true);
137 std::string json_pattern_pose = calibrate.result()[itmPatternPose].asJson (
true);
138 reprojection_error = calibrate.result()[itmReprojectionError].asDouble();
141 estimated_camera_pose.translation () /= 1000.0;
143 jsonToMatrix(json_pattern_pose, estimated_pattern_pose);
144 estimated_pattern_pose.translation () /= 1000.0;
145 PCL_DEBUG(
"Result:\n %s\n", json_camera_pose.c_str());
151 catch (NxLibException &ex)
164 PCL_INFO (
"Closing Ensenso cameras\n");
168 NxLibCommand (cmdClose).execute ();
172 catch (NxLibException &ex)
184 nxLibCloseTcpPort ();
187 catch (NxLibException &ex)
201 NxLibCommand (cmdCapture).execute ();
202 NxLibCommand collect_pattern (cmdCollectPattern);
203 collect_pattern.parameters ()[itmBuffer].set (buffer);
204 collect_pattern.parameters ()[itmDecodeData].set (
false);
205 collect_pattern.execute ();
207 catch (NxLibException &ex)
217 double grid_spacing = -1.0;
222 NxLibCommand (cmdCapture).execute ();
223 NxLibCommand collect_pattern (cmdCollectPattern);
224 collect_pattern.parameters ()[itmBuffer].set (
false);
225 collect_pattern.parameters ()[itmDecodeData].set (
true);
226 collect_pattern.execute ();
227 grid_spacing = collect_pattern.result()[itmGridSpacing].asDouble();
229 catch (NxLibException &ex)
241 NxLibCommand (cmdDiscardPatterns).execute ();
243 catch (NxLibException &ex)
255 NxLibCommand estimate_pattern_pose (cmdEstimatePatternPose);
256 estimate_pattern_pose.parameters ()[itmAverage].set (average);
257 estimate_pattern_pose.execute ();
258 NxLibItem
tf = estimate_pattern_pose.result ()[itmPatternPose];
262 pose.translation () /= 1000.0;
265 catch (NxLibException &ex)
274 int camera_count = 0;
277 NxLibItem cams = NxLibItem (
"/Cameras/BySerialNo");
278 camera_count = cams.count ();
280 PCL_INFO (
"Number of connected cameras: %d\n", camera_count);
281 PCL_INFO (
"Serial No Model Status\n");
282 for (
int n = 0; n < cams.count (); ++n)
284 PCL_INFO (
"%s %s %s\n", cams[n][itmSerialNumber].asString ().c_str (),
285 cams[n][itmModelName].asString ().c_str (),
286 cams[n][itmStatus].asString ().c_str ());
290 catch (NxLibException &ex)
294 return (camera_count);
308 NxLibItem camera_mat = (cam ==
"RGB") ?
monocam_[itmCalibration][itmCamera] :
camera_[itmCalibration][itmDynamic][itmStereo][cam][itmCamera];
309 NxLibItem camera_dist = (cam ==
"RGB") ?
monocam_[itmCalibration][itmDistortion] :
camera_[itmCalibration][itmMonocular][cam][itmDistortion];
311 cam_info.width = camera[itmSensor][itmSize][0].asInt();
312 cam_info.height = camera[itmSensor][itmSize][1].asInt();
313 cam_info.distortion_model =
"plumb_bob";
316 cam_info.D.resize(5);
319 for(std::size_t i = 0; i < cam_info.D.size(); ++i)
326 cam_info.D[0] = camera_dist[0].asDouble();
327 cam_info.D[1] = camera_dist[1].asDouble();
328 cam_info.D[2] = camera_dist[5].asDouble();
329 cam_info.D[3] = camera_dist[6].asDouble();
330 cam_info.D[4] = camera_dist[2].asDouble();
334 for(std::size_t i = 0; i < 3; ++i)
336 for(std::size_t j = 0; j < 3; ++j)
340 cam_info.R[3*i+j] = camera[itmCalibration][itmDynamic][itmStereo][cam][itmRotation][j][i].asDouble();
341 cam_info.K[3*i+j] =
camera_[itmCalibration][itmMonocular][cam][itmCamera][j][i].asDouble();
345 cam_info.K[3*i+j] = camera_mat[j][i].asDouble();
356 cam_info.P[0] = camera_mat[0][0].asDouble();
357 cam_info.P[1] = camera_mat[1][0].asDouble();
358 cam_info.P[2] = camera_mat[2][0].asDouble();
361 cam_info.P[4] = camera_mat[0][1].asDouble();
362 cam_info.P[5] = camera_mat[1][1].asDouble();
363 cam_info.P[6] = camera_mat[2][1].asDouble();
368 cam_info.P[10] = 1.0;
369 cam_info.P[11] = 0.0;
372 double B = camera[itmCalibration][itmStereo][itmBaseline].asDouble() / 1000.0;
373 double fx = cam_info.P[0];
374 cam_info.P[3] = (-fx * B);
378 catch (NxLibException &ex)
393 NxLibCommand
convert(cmdConvertTransformation,
"convert");
394 convert.parameters()[itmTransformation].setJson(
monocam_[itmLink].asJson());
396 Eigen::Affine3d transform;
397 for (
int i = 0; i < 4 ; ++i)
399 for (
int j = 0; j < 4 ; ++j)
401 transform(j,i) = convert.result()[itmTransformation][i][j].asDouble();
404 Eigen::Affine3d inv_transform = transform.inverse();
405 Eigen::Quaterniond q(inv_transform.rotation());
411 tf.
tx = inv_transform.translation().x() / 1000.0;
412 tf.
ty = inv_transform.translation().y() / 1000.0;
413 tf.
tz = inv_transform.translation().z() / 1000.0;
416 catch (NxLibException &ex)
426 std::vector<Eigen::Vector2d> &left_points,
427 std::vector<Eigen::Vector2d> &right_points,
428 Eigen::Affine3d &pose)
const 436 if ( stereo_pattern_json.empty() )
439 NxLibItem stereo_pattern (
"/tmpStereoPattern");
440 stereo_pattern.setJson(stereo_pattern_json);
443 grid_size[0] = stereo_pattern[itmPattern][itmGridSize][0].asInt();
444 grid_size[1] = stereo_pattern[itmPattern][itmGridSize][1].asInt();
445 grid_spacing = stereo_pattern[itmPattern][itmGridSpacing].asDouble();
446 int rows = grid_size[0];
447 int cols = grid_size[1];
448 left_points.resize(rows*cols);
449 right_points.resize(rows*cols);
450 for (uint i = 0; i < left_points.size(); ++i)
452 left_points[i][0] = stereo_pattern[itmPoints][0][i][0].asDouble();
453 left_points[i][1] = stereo_pattern[itmPoints][0][i][1].asDouble();
454 right_points[i][0] = stereo_pattern[itmPoints][1][i][0].asDouble();
455 right_points[i][1] = stereo_pattern[itmPoints][1][i][1].asDouble();
457 stereo_pattern.erase();
469 return (
"EnsensoGrabber");
477 char type = isFlt ?
'F' : (bpe > 3 ?
'S' :
'U');
478 return (boost::str (boost::format (
"CV_%i%cC%i") % bits % type % channels));
483 #if defined _WIN32 || defined _WIN64 484 return (ensenso_stamp * 1000000.0);
486 return ( (ensenso_stamp - 11644473600.0) * 1000000.0);
492 return ( (*
root_)[itmParameters][itmPatternCount].asInt ());
505 NxLibCommand (cmdCapture).execute ();
507 NxLibCommand (cmdComputeDisparityMap).execute ();
509 NxLibCommand (cmdComputePointMap).execute ();
512 std::vector<float> pointMap;
514 camera_[itmImages][itmRaw][itmLeft].getBinaryDataInfo (0, 0, 0, 0, 0, ×tamp);
515 camera_[itmImages][itmPointMap].getBinaryDataInfo (&width, &height, 0, 0, 0, 0);
516 camera_[itmImages][itmPointMap].getBinaryData (pointMap, 0);
519 cloud.resize (height * width);
521 cloud.height = height;
522 cloud.is_dense =
false;
524 for (
size_t i = 0; i < pointMap.size (); i += 3)
526 cloud.points[i / 3].x = pointMap[i] / 1000.0;
527 cloud.points[i / 3].y = pointMap[i + 1] / 1000.0;
528 cloud.points[i / 3].z = pointMap[i + 2] / 1000.0;
532 catch (NxLibException &ex)
553 NxLibCommand
convert (cmdConvertTransformation);
554 convert.parameters ()[itmTransformation].setJson (json);
556 Eigen::Affine3d tmp (Eigen::Affine3d::Identity ());
558 tmp.linear ().col (0) = Eigen::Vector3d (convert.result ()[itmTransformation][0][0].asDouble (),
559 convert.result ()[itmTransformation][0][1].asDouble (),
560 convert.result ()[itmTransformation][0][2].asDouble ());
561 tmp.linear ().col (1) = Eigen::Vector3d (convert.result ()[itmTransformation][1][0].asDouble (),
562 convert.result ()[itmTransformation][1][1].asDouble (),
563 convert.result ()[itmTransformation][1][2].asDouble ());
564 tmp.linear ().col (2) = Eigen::Vector3d (convert.result ()[itmTransformation][2][0].asDouble (),
565 convert.result ()[itmTransformation][2][1].asDouble (),
566 convert.result ()[itmTransformation][2][2].asDouble ());
568 tmp.translation () = Eigen::Vector3d (convert.result ()[itmTransformation][3][0].asDouble (),
569 convert.result ()[itmTransformation][3][1].asDouble (),
570 convert.result ()[itmTransformation][3][2].asDouble ());
574 catch (NxLibException &ex)
582 const bool pretty_format)
const 586 NxLibCommand
convert (cmdConvertTransformation);
588 convert.parameters ()[itmTransformation][0][0].set (matrix.linear ().col (0)[0]);
589 convert.parameters ()[itmTransformation][0][1].set (matrix.linear ().col (0)[1]);
590 convert.parameters ()[itmTransformation][0][2].set (matrix.linear ().col (0)[2]);
591 convert.parameters ()[itmTransformation][0][3].set (0.0);
592 convert.parameters ()[itmTransformation][1][0].set (matrix.linear ().col (1)[0]);
593 convert.parameters ()[itmTransformation][1][1].set (matrix.linear ().col (1)[1]);
594 convert.parameters ()[itmTransformation][1][2].set (matrix.linear ().col (1)[2]);
595 convert.parameters ()[itmTransformation][1][3].set (0.0);
596 convert.parameters ()[itmTransformation][2][0].set (matrix.linear ().col (2)[0]);
597 convert.parameters ()[itmTransformation][2][1].set (matrix.linear ().col (2)[1]);
598 convert.parameters ()[itmTransformation][2][2].set (matrix.linear ().col (2)[2]);
599 convert.parameters ()[itmTransformation][2][3].set (0.0);
601 convert.parameters ()[itmTransformation][3][0].set (matrix.translation ()[0]);
602 convert.parameters ()[itmTransformation][3][1].set (matrix.translation ()[1]);
603 convert.parameters ()[itmTransformation][3][2].set (matrix.translation ()[2]);
604 convert.parameters ()[itmTransformation][3][3].set (1.0);
606 json = convert.result ()[itmTransformation].asJson (pretty_format);
609 catch (NxLibException &ex)
619 PCL_THROW_EXCEPTION (pcl::IOException,
"Cannot open multiple devices!");
620 PCL_INFO (
"Opening Ensenso stereo camera S/N: %s\n", serial.c_str());
624 camera_ = (*root_)[itmCameras][itmBySerialNo][serial];
626 PCL_THROW_EXCEPTION (pcl::IOException,
"Please connect a single stereo camera to your computer!");
627 if (!(*
root_)[itmCameras][itmBySerialNo][serial][itmStatus][itmAvailable].asBool())
628 PCL_THROW_EXCEPTION (pcl::IOException,
"The device cannot be opened.");
629 NxLibCommand open (cmdOpen);
630 open.parameters ()[itmCameras] =
camera_[itmSerialNumber].asString ();
633 catch (NxLibException &ex)
645 PCL_THROW_EXCEPTION (pcl::IOException,
"Cannot open multiple devices!");
646 PCL_INFO (
"Opening Ensenso mono camera S/N: %s\n", serial.c_str());
650 monocam_ = (*root_)[itmCameras][itmBySerialNo][serial];
652 PCL_THROW_EXCEPTION (pcl::IOException,
"Please connect a single mono camera to your computer!");
653 if (!(*
root_)[itmCameras][itmBySerialNo][serial][itmStatus][itmAvailable].asBool())
654 PCL_THROW_EXCEPTION (pcl::IOException,
"The device cannot be opened.");
655 NxLibCommand open (cmdOpen);
656 open.parameters ()[itmCameras] =
monocam_[itmSerialNumber].asString ();
659 catch (NxLibException &ex)
672 nxLibOpenTcpPort (port);
675 catch (NxLibException &ex)
691 while (continue_grabbing)
696 bool need_cloud = num_slots<sig_cb_ensenso_point_cloud> () > 0;
697 bool need_cloud_rgb = num_slots<sig_cb_ensenso_point_cloud_rgb> () > 0;
698 bool need_images = num_slots<sig_cb_ensenso_images> () > 0;
699 bool need_images_rgb = num_slots<sig_cb_ensenso_images_rgb> () > 0;
700 bool need_depth = num_slots<sig_cb_ensenso_image_depth> () > 0;
702 if (need_cloud || need_cloud_rgb || need_images || need_images_rgb || need_depth)
704 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr rgb_cloud (
new pcl::PointCloud<pcl::PointXYZRGBA>);
705 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (
new pcl::PointCloud<pcl::PointXYZ>);
712 static double last = pcl::getTime ();
713 double now = pcl::getTime ();
715 fps_ = float( 1.0 / (now - last) );
725 camera_[itmImages][itmRaw][itmLeft].getBinaryDataInfo (0, 0, 0, 0, 0, &
timestamp_);
726 bool rectified =
false;
728 if (need_cloud || need_cloud_rgb || need_depth)
731 NxLibCommand (cmdComputeDisparityMap).execute ();
748 if (need_images || need_images_rgb)
752 NxLibCommand rectify_images (cmdRectifyImages);
753 rectify_images.execute ();
755 bool collected_pattern =
false;
764 NxLibCommand collect_pattern (cmdCollectPattern);
766 collect_pattern.parameters ()[itmDecodeData].set (
true);
767 collect_pattern.execute ();
772 NxLibCommand get_pattern_buffers (cmdGetPatternBuffers);
773 get_pattern_buffers.execute ();
780 collected_pattern =
true;
782 catch (
const NxLibException &ex)
795 getImage(
camera_[itmImages][itmWithOverlay][itmLeft], images_raw->first);
796 getImage(
camera_[itmImages][itmWithOverlay][itmRight], images_raw->second);
811 getImage(
camera_[itmImages][itmRectified][itmLeft], images_rect->first);
812 getImage(
camera_[itmImages][itmRectified][itmRight], images_rect->second);
840 catch (NxLibException &ex)
842 NxLibItem result = NxLibItem()[itmExecute][itmResult];
843 if (ex.getErrorCode() == NxLibExecutionFailed && result[itmErrorSymbol].asString() ==
"CUDA")
845 PCL_WARN(
"Encountered error due to use of CUDA. Disabling CUDA support.\n");
857 NxLibCommand renderPM (cmdRenderPointMap);
858 renderPM.parameters()[itmCamera].set(
monocam_[itmSerialNumber].asString());
860 renderPM.parameters()[itmFar].set(
far_plane_);
864 std::vector<float> point_map;
865 std::vector<char> rgb_data;
866 (*root_)[itmImages][itmRenderPointMap].getBinaryDataInfo (&width, &height, 0, 0, 0, 0);
867 (*root_)[itmImages][itmRenderPointMap].getBinaryData (point_map, 0);
868 (*root_)[itmImages][itmRenderPointMapTexture].getBinaryDataInfo (&width, &height, 0, 0, 0, 0);
869 (*root_)[itmImages][itmRenderPointMapTexture].getBinaryData (rgb_data, 0);
870 bool get_cloud = (num_slots<sig_cb_ensenso_point_cloud_rgb> () > 0);
871 bool get_depth = (num_slots<sig_cb_ensenso_image_depth> () > 0);
876 cloud->points.resize (height * width);
877 cloud->width = width;
878 cloud->height = height;
879 cloud->is_dense =
false;
884 depth_image->width = width;
885 depth_image->height = height;
886 depth_image->data.resize (width * height);
887 depth_image->encoding =
"CV_32FC1";
889 for (
size_t i = 0; i < point_map.size (); i += 3)
893 depth_image->data[i / 3] = point_map[i + 2] / 1000.0;
899 cloud->points[i / 3].z = point_map[i + 2] / 1000.0;
904 for (
size_t i = 0; i < rgb_data.size (); i += 4)
906 cloud->points[i / 4].r = rgb_data[i];
907 cloud->points[i / 4].g = rgb_data[i + 1];
908 cloud->points[i / 4].b = rgb_data[i + 2];
909 cloud->points[i / 4].a = rgb_data[i + 3];
916 NxLibCommand (cmdComputePointMap).execute ();
918 std::vector<float> point_map;
919 camera_[itmImages][itmPointMap].getBinaryDataInfo (&width, &height, 0, 0, 0, 0);
920 camera_[itmImages][itmPointMap].getBinaryData (point_map, 0);
922 bool get_cloud = (num_slots<sig_cb_ensenso_point_cloud> () > 0);
923 bool get_depth = (num_slots<sig_cb_ensenso_image_depth> () > 0);
928 cloud->points.resize (height * width);
929 cloud->width = width;
930 cloud->height = height;
931 cloud->is_dense =
false;
937 depth_image->width = width;
938 depth_image->height = height;
939 depth_image->data.resize (width * height);
940 depth_image->encoding =
"CV_32FC1";
942 for (
size_t i = 0; i < point_map.size (); i += 3)
946 depth_image->data[i / 3] = point_map[i + 2] / 1000.0;
950 cloud->points[i / 3].x = point_map[i] / 1000.0;
951 cloud->points[i / 3].y = point_map[i + 1] / 1000.0;
952 cloud->points[i / 3].z = point_map[i + 2] / 1000.0;
960 NxLibCommand (cmdTrigger).execute();
961 NxLibCommand retrieve (cmdRetrieve);
965 retrieve.parameters()[itmTimeout] = 1000;
967 bool retrievedIR = retrieve.result()[
camera_[itmSerialNumber].asString().c_str()][itmRetrieved].asBool();
968 bool retrievedRGB =
use_rgb_ ? retrieve.result()[
monocam_[itmSerialNumber].asString().c_str()][itmRetrieved].asBool() :
true;
969 if (retrievedIR && retrievedRGB)
974 catch (
const NxLibException &ex) {
982 int width, height, channels, bpe;
984 image_node.getBinaryDataInfo (&width, &height, &channels, &bpe, &isFlt, 0);
986 image_out.width = width;
987 image_out.height = height;
988 image_out.
data.resize (width * height *
sizeof(
float));
990 image_node.getBinaryData (image_out.
data.data (), image_out.
data.size (), 0, 0);
997 PCL_WARN (
"Storing calibration pattern. This will clean the pattern buffer continuously\n");
1031 #ifdef CUDA_IMPLEMENTED 1034 if ((*
root_)[itmParameters][itmCUDA][itmAvailable].asBool())
1036 (*root_)[itmParameters][itmCUDA][itmEnabled].set (enable);
1040 PCL_WARN(
"CUDA is not supported on this machine.");
1043 catch (NxLibException &ex)
1049 PCL_WARN(
"CUDA is not supported. Upgrade EnsensoSDK to Version >= 2.1.7 in order to use CUDA.");
1067 camera_[itmParameters][itmCapture][itmAutoBlackLevel].set (enable);
1069 catch (NxLibException &ex)
1083 camera_[itmParameters][itmCapture][itmAutoExposure].set (enable);
1085 catch (NxLibException &ex)
1099 camera_[itmParameters][itmCapture][itmAutoGain].set (enable);
1101 catch (NxLibException &ex)
1115 camera_[itmParameters][itmCapture][itmBinning].set (binning);
1117 catch (NxLibException &ex)
1132 camera_[itmParameters][itmCapture][itmBlackLevelOffset].set (offset);
1134 catch (NxLibException &ex)
1148 camera_[itmParameters][itmCapture][itmExposure].set (exposure);
1150 catch (NxLibException &ex)
1164 if (enable && 2 <= imagepairs && imagepairs <= 8)
1165 camera_[itmParameters][itmCapture][itmFlexView].set (imagepairs);
1167 camera_[itmParameters][itmCapture][itmFlexView].set (
false);
1169 catch (NxLibException &ex)
1184 camera_[itmParameters][itmCapture][itmFrontLight].set (enable);
1186 catch (NxLibException &ex)
1200 camera_[itmParameters][itmCapture][itmGain].set (gain);
1202 catch (NxLibException &ex)
1216 camera_[itmParameters][itmCapture][itmGainBoost].set (enable);
1218 catch (NxLibException &ex)
1230 (*root_)[itmParameters][itmPattern][itmGridSpacing].set (grid_spacing);
1232 catch (NxLibException &ex)
1246 camera_[itmParameters][itmCapture][itmHardwareGamma].set (enable);
1248 catch (NxLibException &ex)
1262 camera_[itmParameters][itmCapture][itmHdr].set (enable);
1264 catch (NxLibException &ex)
1278 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmMinimumDisparity].set (disparity);
1280 catch (NxLibException &ex)
1294 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmNumberOfDisparities].set (number);
1296 catch (NxLibException &ex)
1310 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmOptimizationProfile].set (profile);
1312 catch (NxLibException &ex)
1326 camera_[itmParameters][itmCapture][itmPixelClock].set (pixel_clock);
1328 catch (NxLibException &ex)
1342 camera_[itmParameters][itmCapture][itmProjector].set (enable);
1344 catch (NxLibException &ex)
1358 camera_[itmParameters][itmCapture][itmTargetBrightness].set (target);
1360 catch (NxLibException &ex)
1374 camera_[itmParameters][itmDisparityMap][itmScaling].set (scaling);
1376 catch (NxLibException &ex)
1390 camera_[itmParameters][itmCapture][itmTriggerMode].set (mode);
1392 catch (NxLibException &ex)
1411 monocam_[itmParameters][itmCapture][itmTriggerDelay] = delay;
1413 catch (NxLibException &ex) {
1426 camera_[itmParameters][itmCapture][itmUseDisparityMapAreaOfInterest].set (enable);
1428 catch (NxLibException &ex)
1442 (*root_)[itmParameters][itmRenderPointMap][itmUseOpenGL].set (enable);
1444 catch (NxLibException &ex)
1465 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmDepthChangeCost].set (changecost);
1467 catch (NxLibException &ex)
1481 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmDepthStepCost].set (stepcost);
1483 catch (NxLibException &ex)
1497 camera_[itmParameters][itmDisparityMap][itmStereoMatching][itmShadowingThreshold].set (shadowingthreshold);
1499 catch (NxLibException &ex)
1513 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmUniquenessRatio].set (ratio);
1515 catch (NxLibException &ex)
1529 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmMedianFilterRadius].set (radius);
1531 catch (NxLibException &ex)
1545 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmSpeckleRemoval][itmComponentThreshold].set (threshold);
1547 catch (NxLibException &ex)
1561 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmSpeckleRemoval][itmRegionSize].set (regionsize);
1563 catch (NxLibException &ex)
1577 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmFilling][itmBorderSpread].set (maximumspread);
1579 catch (NxLibException &ex)
1593 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmFilling][itmRegionSize].set (regionsize);
1595 catch (NxLibException &ex)
1609 camera_[itmParameters][itmDisparityMap][itmPostProcessing][itmFilling][itmRegionSize].set (threshold);
1611 catch (NxLibException &ex)
bool getLastCalibrationPattern(std::vector< int > &grid_size, double &grid_spacing, std::vector< Eigen::Vector2d > &left_points, std::vector< Eigen::Vector2d > &right_points, Eigen::Affine3d &pose) const
Get the raw stereo pattern information and the pattern pose. Before using it enable the storeCalibrat...
boost::signals2::signal< sig_cb_ensenso_point_cloud_rgb > * point_cloud_rgb_signal_
Boost point cloud signal with RGB.
double decodePattern() const
Decodes the pattern grid size and thickness.
boost::signals2::signal< sig_cb_ensenso_images > * images_signal_
Boost images signal.
void getDepthDataRGB(const pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &cloud, const pcl::PCLGenImage< float >::Ptr &depthimage)
Retrieve RGB depth data from NxLib.
bool matrixToJson(const Eigen::Affine3d &matrix, std::string &json, const bool pretty_format=true) const
Converts an Eigen::Affine3d into a JSON string transformation (4x4)
boost::signals2::signal< sig_cb_ensenso_point_cloud > * point_cloud_signal_
Boost point cloud signal.
bool grabSingleCloud(pcl::PointCloud< pcl::PointXYZ > &cloud)
Capture a single point cloud and store it.
bool setHdr(const bool enable=false) const
Enables the camera's high dynamic range function with a fixed, piece-wise linear response curve...
bool setFillRegionSize(const int regionsize) const
Defines an upper limit on the region size in pixels, up to which a region is accepted for filling...
bool getCameraInfo(std::string cam, sensor_msgs::CameraInfo &cam_info) const
Get meta information for a monocular camera.
static std::string getOpenCVType(const int channels, const int bpe, const bool isFlt)
Get OpenCV image type corresponding to the parameters given.
void processGrabbing()
Continuously asks for images and or point clouds data from the device and publishes them if available...
bool setNearPlane(const int near)
Specifies the minimum distance to the ViewPose below which surface elements will be excluded from the...
bool setGainBoost(const bool enable=false) const
Enables the cameras analog gain boost function.
bool setEnableCUDA(const bool enable=true) const
Enables CUDA support.
boost::mutex fps_mutex_
Mutual exclusion for FPS computation.
int enumDevices() const
Searches for available devices.
bool setFindPattern(const bool enable=true)
Controls, whether the grabber will try finding the pattern in the scene.
bool setExposure(const float exposure=1.0) const
The current image exposure time.
std::string last_stereo_pattern_
Last raw stereo info of the detected pattern during processGrabbing()
bool setFillBorderSpread(const int maximumspread) const
Defines which missing regions will be filled by setting a threshold on the maximum spread of the disp...
bool setRGBTriggerDelay(const float delay=10) const
The delay between trigger of the stereo camera (and projector) and the RGB camera.
bool discardPatterns() const
Clears the pattern buffers of monocular and stereo pattern observations.
bool running_
Whether an Ensenso device is running or not.
bool setScaling(const float scaling=1.0) const
Scaling allows to reduce the camera resolution by an arbitrary non-integer factor during rectificatio...
bool setOptimizationProfile(const std::string profile="AlignedAndDiagonal") const
The type of Semi-Global-Matching optimization carried out on the cost function.
bool setFarPlane(const int far)
Specifies the maximum distance to the ViewPose below which surface elements will be excluded from the...
bool setAutoGain(const bool enable=true) const
Controls whether the gain should be adjusted after each image capture.
bool isTcpPortOpen() const
Check if a TCP port is opened.
bool jsonToMatrix(const std::string json, Eigen::Affine3d &matrix) const
Converts a JSON string into an Eigen::Affine3d.
double timestamp_
timestamp of the current frame
bool getTFLeftToRGB(Transform &tf) const
Get transformation between stereo frame and rgb frame.
bool mono_device_open_
Whether an Ensenso device is opened or not.
boost::thread grabber_thread_
Grabber thread.
static pcl::uint64_t getPCLStamp(const double ensenso_stamp)
Convert an Ensenso time stamp into a PCL/ROS time stamp.
bool setBlackLevelOffset(const float offset=1.0) const
The current black level offset. When AutoBlackLevel is false this value specifies the sensor black le...
boost::signals2::signal< sig_cb_ensenso_image_depth > * image_depth_signal_
Boost depth image signal.
bool setUseOpenGL(const bool enable) const
Configures the use of OpenGL.
bool estimatePatternPose(Eigen::Affine3d &pose, const bool average=false) const
Estimate the calibration pattern pose.
bool setDepthChangeCost(const int changecost) const
The penalty for changes of +/- 1 disparity along an optimization path. Setting a larger value for Dep...
bool openTcpPort(const int port=24000)
Open TCP port to enable access via the nxTreeEdit program.
bool setUniquenessRatio(const int ratio) const
Filters the pixels depending on the uniqueness of the found correspondence. The value indicates the p...
std::string getName() const
Get class name.
bool setUseDisparityMapAreaOfInterest(const bool enable=false) const
Reduces the camera's capture AOI to the region necessary for the currently set stereo matching AOI...
bool setFrontLight(const bool enable=false) const
Enables the diffuse front light during exposure. This should only be used when calibrating or trackin...
std::pair< pcl::PCLGenImage< pcl::uint8_t >, pcl::PCLGenImage< pcl::uint8_t > > PairOfImages
bool setTargetBrightness(const int target=80) const
The desired average image brightness in gray values used for AutoExposure and AutoGain.
bool setMinimumDisparity(const int disparity=-64) const
The minimum disparity in pixels where correspondences in the stereo image pair are being searched...
NxLibItem camera_
References to the camera tree.
bool setShadowingThreshold(const int shadowingthreshold) const
The disparity map is checked for occluded pixels. This is usually called 'left-right consistency chec...
void stop()
Stop the data acquisition.
bool setDepthStepCost(const int stepcost) const
The penalty for steps (changes of more than one disparity) along an optimization path. Setting a larger value for DepthStepCost will yield better detection of planar surfaces in low contrast areas, but too large values will lead to a loss of geometry details and precise object boundaries.
bool closeDevices()
Closes all Ensenso devices.
bool setGain(const float gain=1.0) const
The current analog gain factor. See also MaxGain.
bool closeTcpPort(void)
Close TCP port program.
int getPatternCount() const
Gets the number of collected patterns with successful observations in two cameras.
void storeCalibrationPattern(const bool enable)
Enables collecting the calibration pattern continuous during processGrabbing()
bool setPixelClock(const int pixel_clock=24) const
Sets the pixel clock in MHz. If you have too many devices on the same bus the image transfer might fa...
void ensensoExceptionHandling(const NxLibException &ex, std::string func_nam)
int collectPattern(const bool buffer=true) const
Collects a calibration pattern.
float fps_
Camera frames per second (FPS)
bool restoreDefaultConfiguration() const
Restores the default capture configuration parameters.
boost::mutex pattern_mutex_
Mutual exclusion for reading pattern pose.
bool calibrateHandEye(const std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > &robot_poses, const Eigen::Affine3d &camera_seed, const Eigen::Affine3d &pattern_seed, const std::string setup, Eigen::Affine3d &estimated_camera_pose, Eigen::Affine3d &estimated_pattern_pose, int &iterations, double &reprojection_error) const
With this command you can calibrate the position of the camera with respect to a robot. The calibration routine currently supports two types of setups: either your camera is fixed with respect to the robot origin, or your camera mounted on the robot hand and is moving with the robot.
bool device_open_
Whether an Ensenso device is opened or not.
boost::signals2::signal< sig_cb_ensenso_images_rgb > * images_rgb_signal_
Boost images rgb signal.
void getImage(const NxLibItem &image_node, pcl::PCLGenImage< pcl::uint8_t > &image_out)
Retrieve Image from NxLib.
bool store_calibration_pattern_
Whether to read the pattern pose at processGrabbing() or not.
bool find_pattern_
Whether the grabber tries to find the pattern or not.
bool openDevice(std::string serial)
Opens an Ensenso device.
bool setSurfaceConnectivity(const int threshold) const
The distance along a camera's z direction below which two neighboring points will be connected to a s...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EnsensoGrabber()
Constructor.
bool setNumberOfDisparities(const int number=128) const
The number of disparities in pixels where correspondences in the stereo image pair are being searched...
bool isRunning() const
Check if the data acquisition is still running.
bool setAutoBlackLevel(const bool enable=true) const
Controls whether the sensor black level should be adjusted automatically by the image sensor...
bool use_rgb_
Whether the grabber uses RGB or not.
virtual ~EnsensoGrabber()
Destructor inherited from the Grabber interface. It never throws.
bool setGridSpacing(const double grid_spacing) const
Sets the grid spacing of the calibration pattern.
bool openMonoDevice(std::string serial)
Opens an Ensenso mono device.
boost::shared_ptr< const NxLibItem > root_
Reference to the NxLib tree root.
bool setHardwareGamma(const bool enable=true) const
Enables the camera's internal analog gamma correction. This boosts dark pixels while compressing high...
bool setMedianFilterRadius(const int radius) const
Specifies the size of the median filter as radius in pixels, excluding the center pixel...
int far_plane_
Far plane Parameter for the RenderPointMap command.
int near_plane_
Near plane Parameter for the RenderPointMap command.
void start()
Start the point cloud and or image acquisition.
void triggerCameras()
triggers all available cameras
void convert(const A &a, B &b)
bool setProjector(const bool enable=true) const
Enables the texture projector during exposure. This should only be used for depth map computation...
void getDepthData(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const pcl::PCLGenImage< float >::Ptr &depthimage)
Retrieve depth data from NxLib.
bool setFlexView(const bool enable=false, const int imagepairs=2) const
The number of image pairs to capture. When FlexView is set to false the camera will operate in normal...
float getFramesPerSecond() const
Obtain the number of frames per second (FPS)
bool setSpeckleRegionSize(const int threshold) const
The size in pixels of a disparity map region below which the region will be removed from the disparit...
bool setBinning(const int binning=1) const
Adjusts the camera's binning factor. Binning reduces the image resolution by an integer factor direct...
bool setUseRGB(const bool enable=true)
Controls, whether the grabber will use an external ensenso rgb camera.
Eigen::Affine3d last_pattern_pose_
Last pose of the detected pattern during processGrabbing()
bool setSpeckleComponentThreshold(const int threshold) const
Defines how the image is divided into regions for speckle filtering. Whenever two neighboring pixel d...
Transform tf_left_to_rgb_
translation from left camera to RGB frame
bool setAutoExposure(const bool enable=true) const
Controls whether the exposure should be adjusted after each image capture.
bool setTriggerMode(const std::string mode="Software") const
Specifies how an image capture is initiated.
bool tcp_open_
Whether an TCP port is opened or not.