ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Starsky Wong's profile - activity

2013-05-22 12:02:37 -0500 received badge  Famous Question (source)
2013-05-15 23:25:30 -0500 received badge  Notable Question (source)
2013-05-07 06:12:12 -0500 received badge  Popular Question (source)
2013-05-06 01:31:06 -0500 received badge  Editor (source)
2013-05-06 01:20:55 -0500 asked a question Can't process image using cv_bridge

I'm using a library called 'tpofinder' to recognize textured objects,but it can only work using opencv's videocapture() function,and it's very slow,about 1 fps or less. I'm using CMake to build it,in the same project,the one using videocapture can process image,but the other one using cv_bridge can't process,it just return the origin image.

The one using videocapture

//Include headers for OpenCV Image processing
#include <opencv2/imgproc/imgproc.hpp>
//Include headers for OpenCV GUI handling
#include <opencv2/highgui/highgui.hpp>

#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <iostream>

#include "tpofinder/configure.h"
#include "tpofinder/detect.h"
#include "tpofinder/visualize.h"

using namespace cv;
using namespace tpofinder;
using namespace std;
VideoCapture *capture = NULL;
bool verbose = true;

Mat image;
Detector detector;

void openCamera() {
    capture = new VideoCapture(0);
    if (!capture->isOpened()) {
        cerr << "Could not open default camera." << endl;
        exit(-1);
    }
}

void loadModel(Modelbase& modelbase, const string& path) {
    if (verbose) {
        cout << boost::format("Loading object %-20s ... ") % path;
    }
    modelbase.add(path);
    if (verbose) {
        cout << "[DONE]" << endl;
    }
}

void processImage(Detector& detector) {
    if (!image.empty()) {
        cout << "Detecting objects on image          ... ";
        Scene scene = detector.describe(image);
        vector<Detection> detections = detector.detect(scene);
        cout << "[DONE]" << endl;

        BOOST_FOREACH(Detection d, detections) {
        cout << "Drawing                             ..."; 
            drawDetection(image, d);
        cout << "[Done]" << endl;
        }
    }
}

void nextImage() 
{
    if (verbose) {
        cout << "Reading from webcam                 ... ";
    }
    *capture >> image;
    if (verbose) {
        cout << "[DONE]" << endl;
    }
}


/**
* This tutorial demonstrates simple image conversion between ROS image message and OpenCV formats and image processing
*/
int main(int argc, char **argv)
{

    // TODO: adapt to OpenCV 2.4.
    // TODO: remove duplication
    // TODO: support SIFT
    Ptr<FeatureDetector> fd = new OrbFeatureDetector(1000, 1.2, 8);
    Ptr<FeatureDetector> trainFd = new OrbFeatureDetector(250, 1.2, 8);
    Ptr<DescriptorExtractor> de = new OrbDescriptorExtractor(1000, 1.2, 8);
    Ptr<flann::IndexParams> indexParams = new flann::LshIndexParams(15, 12, 2);
    Ptr<DescriptorMatcher> dm = new FlannBasedMatcher(indexParams);

    Feature trainFeature(trainFd, de, dm);

    Modelbase modelbase(trainFeature);

    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/adapter");
    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/blokus");
    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/book1");
    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/book2");
    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/book3");
    loadModel(modelbase, PROJECT_BINARY_DIR + "/data/coffee");

    Feature feature(fd, de, dm);

    Ptr<DetectionFilter> filter = new AndFilter(
            Ptr<DetectionFilter> (new EigenvalueFilter(-1, 4.0)),
            Ptr<DetectionFilter> (new InliersRatioFilter(0.30)));

    Detector detector(modelbase, feature, filter);


    openCamera();

    while (true) {
        nextImage();
        processImage(detector);
    //Display the image using OpenCV
     cv::imshow("image processed", image);
    //Add some delay in miliseconds. The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.
     cv::waitKey(3);
    }


    //OpenCV HighGUI call to destroy a display window on shut-down.
    cv::destroyWindow("image processed");


}

The one using cv_bridge

//Includes all the headers necessary to use the most common public pieces of the ROS system.
#include <ros/ros.h>
//Use image_transport for publishing and subscribing to images in ROS
#include <image_transport/image_transport.h>
//Use cv_bridge to convert between ROS and OpenCV Image formats
#include <cv_bridge/cv_bridge.h>
//Include some useful constants for image encoding. Refer to: http://www ...
(more)
2012-10-07 05:57:58 -0500 received badge  Popular Question (source)
2012-10-07 05:57:58 -0500 received badge  Notable Question (source)
2012-10-07 05:57:58 -0500 received badge  Famous Question (source)
2012-04-26 06:14:29 -0500 commented answer Does ros need a high performance gpu?

Thank you!I think I'll do visualization in another PC,but needs data transmission.

2012-04-26 06:09:20 -0500 received badge  Scholar (source)
2012-04-25 05:15:39 -0500 received badge  Student (source)
2012-04-25 00:07:47 -0500 asked a question Does ros need a high performance gpu?

I want to make a robot like turtlebot,with kinect and a netbook,turtlebot's netbook has a discrete graphic. I want to do 2d or 3d slam and navigation,then is opencv's image processing,does the netbook need a high performance gpu?Or I just need a good cpu?Atom N570 can be ok?

Thank you.