After you go through PCL and Kinect Setup. You can start writing program. This time, I will try to capture the Point Cloud without using Grabber. Grabber is method provided by OpenNI library. So in this program, you do not need to add Open NI module inside your project. this program only use Kinect and PCL library as reference.

Initialization:

  • Create Win32 C++ Console Project
  • Add existing Property Sheet: PCL.props and Kinect SDK.props as configured here
  • Declare Include header as follows:

#include “stdafx.h”
#define NOMINMAX
#include <Windows.h>
#undef NOMINMAX
#include <Kinect.h>
#include <pcl\visualization\cloud_viewer.h>
#include <pcl\common\projection_matrix.h>
#include <pcl\point_cloud.h>
#include <iostream>

Something to notice is #define NOMINMAX and windows.h header. declare this before we declare PCL header and define NOMINMAX before windows.h. Because if you put it wrong, can cause another error while debugging.

I will not re-write the code, because the code shown in the reference is correct. please refer to below link. I just want to make some note about this program 🙂

References: 1 | 2 |

Result:

Error Troubleshooting:

1.Header Placement of NOMINMAX and Windows.h

Error 2589 and Error 2143 will be shown. ‘identifier’ : illegal token on right side of ‘::’

Solve: rearrange the header placement. declare NOMINMAX before windows.h and PCL header after that.

Reference: 1 | 2 |

2.LNK2019 unresolved external symbol

Solve: this was my stupid mistake haha I did the uncomplete config for PCL.props. I forgot to declare Additional Library Dependencies in the property, so that my program could not find the symbol . So, I did solve it with adding those many .lib in the setting. (refer to setup page)

3.Compiler Error

Error  4996 shown.

Solve: Add additional definition after header declaration

#ifdef _DEBUG
#define _SCL_SECURE_NO_WARNINGS
#endif

4.argument of type “ColorSpacePoint” is incompatible / too few arguments in function call

This error was also my silly mistake. haha I mistakenly use another method. This error was related to Mapping method. MapDepthPointToColorSpace and MapDepthPointToCameraSpace . I got this error because I use different method (MapDepthPointsToCameraSpace and MapDepthPointsToColorSpace). Points , not Point.

Solve: change using the correct method. I don’t know why my Intellisense is so slow. thats why I did not realize that there are two similar method there.

If you found another error, try to check the library, header, and property setting.

6 thoughts on “Capture Point Cloud with PCL 1.8 and Kinect V2 #2 – Without Grabber”
  1. Hello, first thanks your your tutorials they are really useful!

    I am getting the error” Error 4996″ in the file “xmemory” could you explain me were should I ad the additional definition? I tried after and before the include statements in my program but I still get the error. If I try to add it in the file xmemory it says it is writing protected, and as it is a VS file I really don´t know if I should modify it…

    Thanks!

    Juan

    1. as far as i remember, i put it after the header. if not working, there is probably another mistake, not really because of 4996. because of another error, but VS said that it was because of scl secure things bla bla bla.

      i experienced this before i guess, but i do not recall how i solved it ㅠㅠ
      sorry

      but you copied exactly the same right? i mean the code from tutorial

  2. Hello

    A wonderful tutorial. Was really easy to follow everything. Thank you for the same 🙂

    I am trying to save the captured Point Cloud as a pcd file. This question answers the problem:

    http://stackoverflow.com/questions/23768886/how-can-i-save-a-pcd-file-from-a-kinect

    This is the code I tried to implement

    viewer.showCloud(pointcloud);

    // To try and capture Point Cloud
    if (GetKeyState(VK_SPACE) < 0) {
    pcl::io::savePCDFile("test_pcd.pcd", pointcloud);
    }

    Basically that the user presses SPACE to save the pointcloud as an ASCII file

    I get an error however saying that namespace pcl::io has no member "savePCDFile"

    The header does contain the member however. Do you know a which I can save the PointCloud in order to process it further by modifying the same code as given in your tutorials?

    Much Regards. Thank you 🙂

    1. Update:
      It was due to missing headers. I added the headers

      #include
      #include

      as mentioned in the PCL Documentation

      http://pointclouds.org/documentation/tutorials/writing_pcd.php#writing-pcd

      The error I get now is –

      Error C2664 ‘int pcl::io::savePCDFile(const std::string &,const pcl::PCLPointCloud2 &,const Eigen::Vector4f &,const Eigen::Quaternionf &,const bool)’: cannot convert argument 2 from ‘boost::shared_ptr<pcl::PointCloud>’ to ‘const pcl::PCLPointCloud2 &’ ConsoleApplication1

Leave a Reply