Ask Your Question

lamparta's profile - activity

2016-09-08 07:31:47 -0500 received badge  Famous Question (source)
2015-11-30 16:22:10 -0500 received badge  Student (source)
2015-11-10 12:09:43 -0500 received badge  Famous Question (source)
2015-10-28 05:39:35 -0500 answered a question Image comparison - two image files in different directories

You should use opencv_bridge to load and convert your images. Then use a similarity method: It depends an what you want to get. Do you only want to recognize the object in the image or also localize it?

  1. If only detection is needed: Use a Sift descriptor and detect all features in your image. If you have more images do it on each one and choose the principal components i.e. the features that occur in all of the training images. Then check for features in the image you want to detect the object in. If it has the same features up to some percentage, accept it as a valid detection.

  2. Template matching, if the object is of about the same size in each image. This is not rotation invariant nor scale invariant and also strongly affected by viewpoint changes. Very slow btw.

  3. If the object is not textured and the rest is highly textured, remove the textured components, p.e. by using a Canny Edge Detector. If your object is round you might also use Hough transform for circles.

There would be much more and it all depends on precise problem formulation. Try to give all information possible when asking questions.

2015-10-28 05:24:30 -0500 answered a question Reference errors after opencv3 installation

I solved it by deleting all the new opencv3 libraries on the system, removing ros-indigo-opencv3 and working with 2.4.8 again. Another way would be to build cv_bridge and image_transport against opencv3.

2015-10-28 05:22:45 -0500 received badge  Notable Question (source)
2015-10-27 07:40:47 -0500 received badge  Enthusiast
2015-10-22 02:00:02 -0500 received badge  Popular Question (source)
2015-10-21 16:38:57 -0500 commented question Reference errors after opencv3 installation

I managed to get rid of most errors by just deleting the build and devel folders in catkin_ws and rebuilding the whole package. But now I'm getting a segmentation fault in my code because my new libopencv3 and 2.4.8 are somehow not compatible.

2015-10-21 16:02:08 -0500 asked a question Reference errors after opencv3 installation

Hi, I had earlier my Ros-Indigo running with the visensor_node stereo camera. It all worked well with the old opencv I had on my pc. But since I installed opencv 3 in usr/lib the following errors occur. Need help. I'm relatively new to ROS.

 Linking CXX executable /home/andy/catkin_ws/devel/lib/stereo_proc/stereo_proc_node
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `SSD(cv::Mat, cv::Mat, unsigned int, cv::Mat)':
stereo_proc_node.cpp:(.text+0xfd): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `Correspondence(cv::Mat&, cv::Mat&, unsigned int)':
stereo_proc_node.cpp:(.text+0x4fd): undefined reference to `cv::StereoBM::create(int, int)'
stereo_proc_node.cpp:(.text+0x6ac): undefined reference to `cv::namedWindow(cv::String const&, int)'
stereo_proc_node.cpp:(.text+0x701): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `Process(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, image_transport::Publisher&, image_transport::Publisher&)':
stereo_proc_node.cpp:(.text+0xbdb): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
stereo_proc_node.cpp:(.text+0xc4d): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `main':
stereo_proc_node.cpp:(.text+0x11a1): undefined reference to `cv::namedWindow(cv::String const&, int)'
stereo_proc_node.cpp:(.text+0x11d8): undefined reference to `cv::namedWindow(cv::String const&, int)'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `cv::String::String(char const*)':
stereo_proc_node.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4f): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `cv::String::~String()':
stereo_proc_node.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/stereo_proc_node.dir/src/stereo_proc_node.cpp.o: In function `cv::String::String(std::string const&)':
stereo_proc_node.cpp:(.text._ZN2cv6StringC2ERKSs[_ZN2cv6StringC5ERKSs]+0x69): undefined reference to `cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/andy/catkin_ws/devel/lib/stereo_proc/stereo_proc_node] Error 1
make[1]: *** [stereo_proc/CMakeFiles/stereo_proc_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX executable /home/andy/catkin_ws/devel/lib/visensor_node/visensor_node
CMakeFiles/visensor_node.dir/src/visensor.cpp.o: In function `cv::String::String(char const*)':
visensor.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4f): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/visensor_node.dir/src/visensor.cpp.o: In function `cv::String::~String()':
visensor.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/visensor_node.dir/src/visensor.cpp.o: In function `cv::Mat::Mat(int, int, int, void*, unsigned long)':
visensor.cpp:(.text._ZN2cv3MatC2EiiiPvm[_ZN2cv3MatC5EiiiPvm]+0x1b5): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/andy/catkin_ws/devel/lib/visensor_node/visensor_node] Error 1
make[1]: *** [visensor_node/CMakeFiles/visensor_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
2015-10-17 08:00:23 -0500 received badge  Notable Question (source)
2015-10-15 08:30:57 -0500 received badge  Popular Question (source)
2015-10-14 19:50:22 -0500 asked a question TimeSynchronizer in a class using stereo input

Hi, I'm relatively new to ROS. I want to write a class which gets two raw images and creates a callback,where I can afterwards manipulate both obtained images at the same time. I tried TimeSynchronizer but it seems to never reach the Process() function. I want to create later on a disparity map (but not with the stereo_view) so I need synchronized input images. Time stamps are telling me that my input images are synchronized. So how can I get the two corresponding images in a callback function?

#include <ros/ros.h>
#include <std_msgs/String.h>
#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>
#include <sensor_msgs/image_encodings.h>
#include <cv_bridge/cv_bridge.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <message_filters/time_synchronizer.h>
#include <message_filters/subscriber.h>

class ImgProcessor
{



ros::NodeHandle nh_;
image_transport::ImageTransport it_;


sensor_msgs::ImageConstPtr img_L;
sensor_msgs::ImageConstPtr img_R;


image_transport::Publisher image_pub_L;
image_transport::Publisher image_pub_R;

std::string IMG_TARGET_L_;
std::string IMG_TARGET_R_;

std::string IMG_DEST_L_;
std::string IMG_DEST_R_;
public:


// Constructor: Initialize the subscribe-act-publish-cycle
ImgProcessor(const std::string IMG_DEST_L, const std::string IMG_TARGET_L,const std::string IMG_DEST_R, const std::string IMG_TARGET_R)
    : it_(nh_)
{
    // Open Window to show output stream
    IMG_TARGET_L_ = IMG_TARGET_L;
    IMG_TARGET_R_ = IMG_TARGET_R;
    IMG_DEST_L_ = IMG_DEST_L;
    IMG_DEST_R_ = IMG_DEST_R;

    // Create output window
    cv::namedWindow(IMG_TARGET_L_);
    cv::namedWindow(IMG_TARGET_R_);

    // Subscribe to input video and publish output video
    message_filters::Subscriber<sensor_msgs::Image> image_sub_L(nh_,IMG_DEST_L_,40);
    message_filters::Subscriber<sensor_msgs::Image> image_sub_R(nh_,IMG_DEST_R_,40);
    message_filters::TimeSynchronizer<sensor_msgs::Image,sensor_msgs::Image> sync(image_sub_L,image_sub_R,40);
    sync.registerCallback(boost::bind(&ImgProcessor::Process,this, _1, _2));

    ROS_INFO("Synched.");

    image_pub_L = it_.advertise(IMG_TARGET_L_,1);
    image_pub_R = it_.advertise(IMG_TARGET_R_,1);

}

// Destructor: Close all opened images
~ImgProcessor()
{
    cv::destroyAllWindows();
}


// Process a message obtained in IMG_DEST
void Process(const sensor_msgs::ImageConstPtr& msg_l,const sensor_msgs::ImageConstPtr& msg_r)
{

    ROS_INFO("Origin Stamp = [%i] ", int(msg_l->header.stamp.toSec()));

    // Create a CV image copy from incoming message
    cv_bridge::CvImagePtr cv_ptr[2];
    try
    {
        cv_ptr[0] = cv_bridge::toCvCopy(msg_l, sensor_msgs::image_encodings::MONO8);
        cv_ptr[1] = cv_bridge::toCvCopy(msg_r, sensor_msgs::image_encodings::MONO8);
    }
    catch(cv_bridge::Exception& e)
    {
        ROS_ERROR("cv_bridge exception: %s", e.what());
        return;
    }


    // Process the incoming image
    //cv::medianBlur(cv_ptr->image,cv_ptr->image,3);
    cv::equalizeHist(cv_ptr[0]->image,cv_ptr[0]->image);
    cv::Canny(cv_ptr[0]->image,cv_ptr[0]->image,50,255);

    cv::equalizeHist(cv_ptr[1]->image,cv_ptr[1]->image);
    cv::Canny(cv_ptr[1]->image,cv_ptr[1]->image,50,255);


    // Update GUI
    cv::imshow(IMG_TARGET_L_, cv_ptr[0]->image);
    cv::waitKey(3);
    cv::imshow(IMG_TARGET_R_, cv_ptr[1]->image);
    cv::waitKey(3);

    img_L = cv_ptr[0]->toImageMsg();
    img_R = cv_ptr[1]->toImageMsg();
    //ROS_INFO("Processed Stamp = [%i] ", int(msg_o->header.stamp.nsecs));
    //Publish transformed video
    image_pub_L.publish(img_L);
    image_pub_R.publish(img_R);
}

};





int main(int argc, char **argv)
{
// Initialize the ROS system
ros::init(argc, argv, "stereo_proc_node");

// Tell the user that the node has started to process images
ROS_INFO("Processing images...");

// Create image processor object
ImgProcessor ip("/stereo/left/image_rect","stereo_proc/left/image","/stereo/right/image_rect","stereo_proc/right/image");


//sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;

}