C++ Build error was not declared in this scope

Neriman Arif

Im writing a small program in C++. I have created 2 files "Main.cpp" and "openni_grabber.cpp". As you can see from the code I'm starting a thread from the main. Once I try to build I get an error message: 'SimpleOpenNIProcessor' Was not declared in this scope.

Where in the code do I need to declare SimpleOpenNIProcessor?

Main.cpp

#include <pcl/io/openni_grabber.h>
#include <pcl/visualization/cloud_viewer.h>

int main()
{
    SimpleOpenNIProcessor v;
    v.run();
    return(0);
}

openni_grabber.cpp

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/openni_grabber.h>
#include <pcl/common/time.h>

class SimpleOpenNIProcessor
{
    SimpleOpenNIProcessor()
    {
    };

    public:
    void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
    {
        static unsigned count = 0;
        static double last = pcl::getTime ();
        if (++count == 30)
        {
            double now = pcl::getTime ();
            std::cout << "distance of center pixel :" << cloud->points [(cloud->width >> 1) * (cloud->height + 1)].z << " mm. Average framerate: " << double(count)/double(now - last) << " Hz" <<  std::endl;
            count = 0;
            last = now;
        }
    }

    void run ()
    {
        // create a new grabber for OpenNI devices
        pcl::Grabber* interface = new pcl::OpenNIGrabber();

        // make callback function from member function
        boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
            boost::bind (&SimpleOpenNIProcessor::cloud_cb_, this, _1);

        // connect callback function for desired signal. In this case its a point cloud with color values
        boost::signals2::connection c = interface->registerCallback (f);

        // start receiving point clouds
        interface->start ();

        // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
        while (true)
        boost::this_thread::sleep (boost::posix_time::seconds (1));

        // stop the grabber
        interface->stop ();
    }
}
Lightness Races in Orbit

Well, it's just as it says: SimpleOpenNIProcessor is not declared at the point you try to instantiate it.

We typically put class definitions in header files to conveniently sprinkle them around our project.

For more information, read your C++ book.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive