9 Replies Latest reply on Jan 12, 2018 12:42 PM by Intel Corporation

    R200 noisy point cloud, calibrator throws error

    GreFtoD

      I use R200 camera with librealsense and PCL 1.8.0 on UP Board with Lubuntu 16.04.3 LTS. I fill the point cloud with points from the camera with following code (how do I do code formatting here?):

       

      int main() {

          pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>(DEPTH_IMG_WIDTH, DEPTH_IMG_HEIGHT));

          //RealSense init

          rs::log_to_console(rs::log_severity::warn);

          //rs::log_to_file(rs::log_severity::debug, "librealsense.log");

       

       

          // Create a context object. This object owns the handles to all connected realsense devices.

          rs::context ctx;

          printf("There are %d connected RealSense devices.\n", ctx.get_device_count());

          if (ctx.get_device_count() == 0) return EXIT_FAILURE;

       

       

          rs::device *dev = ctx.get_device(0);

          printf("\nUsing device 0, an %s\n", dev->get_name());

          printf("    Serial number: %s\n", dev->get_serial());

          printf("    Firmware version: %s\n", dev->get_firmware_version());

       

       

          dev->enable_stream(rs::stream::depth, DEPTH_IMG_WIDTH, DEPTH_IMG_HEIGHT, rs::format::z16, 60);

          dev->start();

       

       

          while (true) {

              dev->wait_for_frames();

       

       

              const uint16_t *depthImage = (const uint16_t *) dev->get_frame_data(rs::stream::depth);

              rs::intrinsics depthIntrin = dev->get_stream_intrinsics(rs::stream::depth);

              float scale = dev->get_depth_scale();

       

       

              int dw = depthIntrin.width;

              int dh = depthIntrin.height;

              int dwh = dw * dh;

       

       

              // Set up the clouds to be used

              cloud->clear();

       

       

              cloud->width = DEPTH_IMG_WIDTH;

              cloud->height = DEPTH_IMG_HEIGHT;

       

       

              cloud->resize(dwh);

       

       

              cloud->is_dense = false;

       

       

       

       

       

       

              for (int dy = 0; dy < dh; dy++) {

                  for (int dx = 0; dx < dw; dx++) {

                      uint16_t depthValue = depthImage[dy * depthIntrin.width + dx];

       

       

                      float depth_in_meters = depthValue * scale;

       

       

                      if (depthValue == 0) continue;

       

       

                      rs::float2 depthPixel = {(float) dx, (float) dy};

                      rs::float3 depthPoint = depthIntrin.deproject(depthPixel, depth_in_meters);

                      cloud->points[dy * dw + dx] = pcl::PointXYZ(depthPoint.x, depthPoint.y,

                                                                  depthPoint.z);

                  }

              }

              //Visualization and PCL processing...

          }

      }

       

      Flat surfaces on the point cloud I get are "wavy":

      issue.jpeg

      When I try to run camera calibrator on windows, I get "INVALID_DS_ARG" error, even windows reinstall doesn't help.