PCL cloud upside down [closed]
Hello,
I have used a code from the PCL website that displays a Point Cloud from a Kinect using PCL Viewer. The Point Cloud that is displayed is upside down and is a fraction of the cloud that it would normally display. The exact same code works fine on an almost identical computer that does not have ROS installed, using the same Kinect. I am using Ubuntu 13.04 raring. I am wondering if the PCL code is interfering with ROS's PCL libraries. I have Hydro installed on this machine.
I have main.cpp in a src/ folder and am running the code from the build folder after making it.
Any help is appreciated, thank you in advance.
The code (main.cpp) I am running is as follows:
#include <iostream>
#include <pcl/io/openni_grabber.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/console/parse.h>
using namespace std;
using namespace pcl;
PointCloud<PointXYZRGBA>::Ptr cloudptr(new PointCloud<PointXYZRGBA>); // A cloud that will store colour info.
PointCloud<PointXYZ>::Ptr fallbackCloud(new PointCloud<PointXYZ>); // A fallback cloud with just depth data.
boost::shared_ptr<visualization::CloudViewer> viewer; // Point cloud viewer object.
Grabber* kinectGrabber; // OpenNI grabber that takes data from Kinect.
unsigned int filesSaved = 0; // For the numbering of the clouds saved to disk.
bool saveCloud(false), noColour(false); // Program control.
void
printUsage(const char* programName)
{
cout << "Usage: " << programName << " [options]"
<< endl
<< endl
<< "Options:\n"
<< endl
<< "\t<none> start capturing from a Kinect device.\n"
<< "\t-v NAME visualize the given .pcd file.\n"
<< "\t-h shows this help.\n";
}
// This function is called every time the Kinect has new data.
void
grabberCallback(const PointCloud<PointXYZRGBA>::ConstPtr& cloud)
{
if (! viewer->wasStopped())
viewer->showCloud(cloud);
if (saveCloud)
{
stringstream stream;
stream << "inputCloud" << filesSaved << ".pcd";
string filename = stream.str();
if (io::savePCDFile(filename, *cloud, true) == 0)
{
filesSaved++;
cout << "Saved " << filename << "." << endl;
}
else PCL_ERROR("Problem saving %s.\n", filename.c_str());
saveCloud = false;
}
}
// For detecting when SPACE is pressed.
void
keyboardEventOccurred(const visualization::KeyboardEvent& event,
void* nothing)
{
if (event.getKeySym() == "space" && event.keyDown())
saveCloud = true;
}
// Creates, initializes and returns a new viewer.
boost::shared_ptr<visualization::CloudViewer>
createViewer()
{
boost::shared_ptr<visualization::CloudViewer> v
(new visualization::CloudViewer("3D Viewer"));
v->registerKeyboardCallback(keyboardEventOccurred);
return(v);
}
int
main(int argc, char** argv)
{
if (console::find_argument(argc, argv, "-h") >= 0)
{
printUsage(argv[0]);
return 0;
}
bool justVisualize(false);
string filename;
if (console::find_argument(argc, argv, "-v") >= 0)
{
if (argc != 3)
{
printUsage(argv[0]);
return 0;
}
filename = argv[2];
justVisualize = true;
}
else if (argc != 1)
{
printUsage(argv[0]);
return 0;
}
viewer.resetCameraViewpoint("cloud");
// First mode, open and show a cloud from disk.
if (justVisualize)
{
// Try with colour information...
try
{
io::loadPCDFile<PointXYZRGBA>(filename.c_str(), *cloudptr);
}
catch (PCLException e1)
{
try
{
// ...and if it fails, fall back to just depth.
io::loadPCDFile<PointXYZ>(filename.c_str(), *fallbackCloud);
}
catch (PCLException e2)
{
return -1;
}
noColour = true;
}
cout << "Loaded " << filename << "." << endl;
if (noColour)
cout << "This file has no RGBA colour information present." << endl;
}
// Second mode, start fetching and displaying frames from Kinect.
else
{
kinectGrabber = new OpenNIGrabber();
if (kinectGrabber ...
I'd be curious if you found out how to correct the upsidedown part since I am also seeing this. It's a minor annoyance but still would be nice to get rid of.
Sorry, I didn't
All I had to do was take the negative y and z values to correct