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

Yongqiang Gao's profile - activity

2014-03-25 17:21:33 -0500 received badge  Great Question (source)
2014-01-28 17:22:13 -0500 marked best answer OpenCV can't be used in ROS

I have been trouble by opencv problems. I have planed to transport my windows's code into ROS, which I have tested by local video files. I found that ROS doesn't support local video files, until ffmpeg has been installed. And Checking my ubuntu that it had been installed, I find ROS didn't support local video files neither.

I reinstall my ffmpeg and my opencv2.2, which I find my ROS doesn't support opencv unluckily. I test my older packages, such as gencam_cu. It all doesn't work, while it will works very well without opencv, like usb_cam. I think my ROS system maybe disorder. So I reinstall my ROS refer to ROS.

But also it doesn't work. Especially, when uses "cvCaptureFromCAM" it can't get frames information. Try to find the reason for this problem, but I am so disappointed. I have been bored for many days. Could some one give me helps?

Given a example, codes below

Class UsbCamNode {Public :


ros::NodeHandle &node_;
sensor_msgs::Image img_;

std::string video_device_name_;
std::string io_method_name_;
int image_width_, image_height_;
std::string pixel_format_name_;

ros::Time next_time_;
int count_;

IplImage* src;
IplImage* src_canny;
CvCapture* capture;

image_transport::Publisher image_pub;

UsbCamNode(ros::NodeHandle &node):node_(node)
{
    src=NULL;
    capture=NULL;

    image_transport::ImageTransport it(node);

    image_pub=it.advertise("image_raw",1);
    int camera_num=0;
    ros::NodeHandle nh("~");
    nh.getParam("camera_index",camera_num);
    printf("%d",camera_num);

    if(NULL==(capture=cvCaptureFromCAM(camera_num)))
    {
        printf("\nError on cvCaptureFromCAM");
    }
    if(NULL==(src=cvQueryFrame(capture)))
    {
        printf("\nError on cvQueryFrame");  
    }



    printf("Acquired image (%d/%d%)\n",src->width,src->height);
    printf("Channels (%d)\n",src->nChannels);
    printf("Depth (%d)\n",src->depth);

cvNamedWindow("Capture",CV_WINDOW_AUTOSIZE);
cvNamedWindow("Canny",CV_WINDOW_AUTOSIZE);
cvMoveWindow("Capture",60,70);
next_time_=ros::Time::now();
count_=0;
}

virtual ~UsbCamNode()
{
    cvReleaseCapture(&capture);

    cvDestroyWindow("Capture");
    cvDestroyWindow("Canny");
}

bool take_and_send_image()
{
    int key;
    if(NULL==(src=cvQueryFrame(capture)))
    {   
        printf("\nError on cvQueryFrame");
    }
    else
    {

        cvShowImage("Capture",src);
        src_canny=DoCanny(src);
        cvShowImage("Canny",src_canny);
        key=cvWaitKey(10);

    //fill image message
    fillImage(img_,"mono8",src_canny->height,src_canny->width,src_canny->nChannels*src_canny->width,src_canny->imageData);
    //publish
    image_pub.publish(img_);
    return true;
    }
}

bool spin()
{
    while(node_.ok())
    {   
          if(take_and_send_image())
      {
        count_++;
        ros::Time now_time=ros::Time::now();
        if(now_time>next_time_)
        {   
            std::cout<<count_<<"frames/sec at"<<now_time<<std::endl;
            count_=0;
            next_time_=next_time_+ros::Duration(1,0);
        }
      } else {
        ROS_ERROR("could not take the image");
        usleep(1000000);
        }
    }
    return true;
} };

And it will show the results that: 0 Error on cvCaptureFromCAM Segmentation fault

More, I find my problems are similar with dkst. I try all my methods as possible as I can think,but I did solve these problems. So call for help here

Thanks.

2014-01-28 17:22:03 -0500 marked best answer Cannot get the left image with bumblebee2 camera by "bumblebee1394" package

Hi, There some confusion for me by bumblebee1394, that i always cannot get the left image.

I try

$ roscore
$ coriander
$ rosrun bumblebee1394 bumblebee1394
$ rosrun image_view image_view image:=/dcam_1300157075816067926/left/image_raw
$ rosrun image_view image_view image:=/dcam_1300157075816067926/right/image_raw

where there always get the same image which is published by right camera. And I read the code carefully that i cannot get any idea. Have somebody faced this problem by bumblebee2 camera?

and for more, when I command $ rosrun bumblebee1394 bumblebee1394 that the terminal show:

~$ rosrun bumblebee1394 bumblebee1394 
[dcam] Reset bus
[dcam] Initializing camera, turning off ISO
[dcam] Color device
[Dcam] Setting type of video mode to 1047752033
[Dcam] Feature register hi: ff9d0000
[Dcam] Feature register lo: 40000000
[Dcam] Exposure min/max: [1,1023]
[Dcam] Gain min/max: [0,683]
[Dcam] Brightness min/max: [0,255]
[Dcam] Setting type of video mode to 75
left imagebumblebee_optical_frame
right imagebumblebee_optical_frame

which I only get the mono image, could somebody explain to me?

2014-01-28 17:21:45 -0500 marked best answer An error for connecting two different packages

Hi, there some problems for connecting two packages. That, i learn learning_image_transport, and i create anther package named "subscriber" for subscribing the image which "learning_image_transport" published.

And the code of "subscriber" packages, /src/subscriber.cpp:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <cv_bridge/CvBridge.h>
IplImage* img_original=NULL;
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
sensor_msgs::CvBridge bridge;
img_original=bridge.imgMsgToCv(msg,"bgr8");
try
{
    cvShowImage("view",img_original);
}
catch(sensor_msgs::CvBridgeException& e)
{
    ROS_ERROR("Could not convert from '%s' to ''bgr8",msg->encoding.c_str());
}
}

int main(int argc,char**argv)
{
    ros::init(argc,argv,"image_subscriber",ros::init_options::AnonymousName);
ros::NodeHandle nh;
cvNamedWindow("Subscriber");
cvStartWindowThread();
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub=it.subscribe(argv[1],1,imageCallback);
ros::spin();
cvDestroyWindow("Subscriber");
}

for checking my rxgraph:image description

that "image_subscriver" node has already connected "image_publisher" node. But why it does not preform the image?

PS: my rostopic list as follow: /camera/image /camera/image/compressed /camera/image/compressed/parameter_descriptions /camera/image/compressed/parameter_updates /camera/image/theora /camera/image/theora/parameter_descriptions /camera/image/theora/parameter_updates /rosout /rosout_agg

2014-01-28 17:21:44 -0500 marked best answer How to compile opencv with camera

Hello, I try to compile my old projection with opencv. And about connecting camera, I try run code, and to run this node, I should open the camera stream. so I try rosrun usb_cam, which open the Logitech Quick-cam. But I have no idea about how to get this camera stream to link the my own node.

and this is my rxgraph: C:\fakepath\Screenshot.png

and also my rostopic list as belows:

/image_topic /image_topic_2 /image_topic_2/compressed /image_topic_2/compressed/parameter_descriptions /image_topic_2/compressed/parameter_updates /image_topic_2/theora /image_topic_2/theora/parameter_descriptions /image_topic_2/theora/parameter_updates /rosout /rosout_agg /usb_cam/camera_info /usb_cam/image_raw /usb_cam/image_raw/compressed /usb_cam/image_raw/compressed/parameter_descriptions /usb_cam/image_raw/compressed/parameter_updates /usb_cam/image_raw/theora /usb_cam/image_raw/theora/parameter_descriptions /usb_cam/image_raw/theora/parameter_updates

Any one can help me? and I aim to build my own opecv-projection on ROS system.

Best wishes!

2014-01-28 17:21:41 -0500 marked best answer Something is wrong with "cv_bridge" when I rosmake "gencam_cu" package.

There are 2 cameras in our project: bumblebee2 and Logitech quickcam C160. And then I want do my research use Logitech quickcam C160, while I can't install the device very well. And I reference to "http://www.ros.org/wiki/gencam_cu", which is said to combine the Logitech Quickcam using OpenCV and publishes image data.

And I command it with $ rosmake theora_image_transport, and it report a bug:

   /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: 
   At global scope:  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:136: error: ISO C++ forbids declaration of ‘std_msgs’ with no type
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:136: error: expected ‘,’ or ‘...’ before ‘::’ token
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: In function ‘cv_bridge::CvImagePtr cv_bridge::toCvCopyImpl(const cv::Mat&, int)’:
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:144: error: ‘class cv_bridge::CvImage’ has no member named ‘header’
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:144: error: ‘src_header’ was not declared in this scope
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:147: error: ‘dst_encoding’ was not declared in this scope
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:147: error: ‘src_encoding’ was not declared in this scope
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: In member function ‘void cv_bridge::CvImage::toImageMsg(sensor_msgs::Image&) const’:
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:190: error: ‘header’ was not declared in this scope
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: In function ‘cv_bridge::CvImagePtr cv_bridge::toCvCopy(const sensor_msgs::Image&, const std::string&)’:
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:216: error: cannot convert ‘const roslib::Header_<std::allocator<void> >’ to ‘int’ for argument ‘2’ to ‘cv_bridge::CvImagePtr cv_bridge::toCvCopyImpl(const cv::Mat&, int)’
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: In function ‘cv_bridge::CvImageConstPtr cv_bridge::toCvShare(const sensor_msgs::Image&, const boost::shared_ptr<const void>&, const std::string&)’:
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:234: error: ‘class cv_bridge::CvImage’ has no member named ‘header’
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp: In function ‘cv_bridge::CvImagePtr cv_bridge::cvtColor(const cv_bridge::CvImageConstPtr&, const std::string&)’:
  /home/jason/stacks/vision_opencv/cv_bridge/src/cv_bridge.cpp:246: error: ‘const class cv_bridge::CvImage’ has no member named ‘header’
  make[3]: *** [CMakeFiles/cv_bridge.dir/src/cv_bridge.o] Error 1
  make[3]: Leaving directory `/home/jason/stacks/vision_opencv/cv_bridge/build'
  make[2]: *** [CMakeFiles/cv_bridge.dir/all] Error 2
  make[2]: Leaving directory `/home/jason/stacks/vision_opencv/cv_bridge/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `/home/jason/stacks/vision_opencv/cv_bridge/build'
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package cv_bridge written to:
[ rosmake ]    /home/jason/.ros/rosmake/rosmake_output-20110301-105339/cv_bridge/build_output.log
[rosmake-1] Finished <<< cv_bridge [FAIL] [ 1.32 seconds ]                      
[ rosmake ] Halting due to failure in package cv_bridge. 

[ rosmake ] /home/jason/.ros/rosmake/rosmake_output-20110301-105339

Any one can help me?

PS: and i try anther package which include cv_bridge, but i find the same problems. They all report that :/home/jason/stacks/find_object/cv_bridge/include/cv_bridge/cv_bridge.h:62: error: ‘std_msgs’ has not been declared ... (more)

2014-01-28 17:21:38 -0500 marked best answer Are there somebodies use OpenCV2.2 with ROS ?

I want to translate my previous code by opencv2.2 into ROS, and I have found many differences between opencv and ROS in image type and some other types. So I wander if some one have already developed a long time on it, please give me some advices?

Thanks a lot!

2014-01-28 17:21:38 -0500 marked best answer Some problems about the ROS path

Hi,

My ROS has been installed at /opt/ros/cturtles

/opt/ros/cturtle$ ls

it shows: jason ros setup.bash setup.sh setup.zsh stacks

where the file of "jason" which I create, is to be contained myself packages.

Question1, could i create this file for including myself packages? I mean could i create this file under "cturtles" file, or "ros" file , or "stacks" file?

Question2,I create a package with 'roscreate-pkg', then I update my ros path.and the command is :

$ export ROS_PACKAGE_PATH=/opt/ros/cturtle/jason/:$ROS_PACKAGE_PATH

and then

$ rospack find ros_opencv   %ros_opencv is what i have created

but it shows [rospack] warning: trailing slash found in ROS_PACKAGE_PATH /opt/ros/cturtle/jason/ros_opencv

at the terminal, and the next time,I input the command

$ rospack find ros_opencv

it shows :[rospack] couldn't find package [ros_opencv] why?

Best regards

2013-04-03 07:41:42 -0500 received badge  Famous Question (source)
2012-11-26 04:45:29 -0500 received badge  Famous Question (source)
2012-11-20 03:14:37 -0500 received badge  Famous Question (source)
2012-11-20 03:14:37 -0500 received badge  Notable Question (source)
2012-11-20 03:14:37 -0500 received badge  Popular Question (source)
2012-10-01 02:56:43 -0500 received badge  Famous Question (source)
2012-10-01 02:56:43 -0500 received badge  Notable Question (source)
2012-08-16 11:01:52 -0500 received badge  Notable Question (source)
2012-08-16 11:01:52 -0500 received badge  Famous Question (source)
2012-08-15 05:20:24 -0500 received badge  Famous Question (source)
2012-08-15 05:20:24 -0500 received badge  Notable Question (source)
2012-08-06 15:30:26 -0500 received badge  Notable Question (source)
2012-08-01 01:03:08 -0500 received badge  Famous Question (source)
2012-05-21 04:45:53 -0500 received badge  Notable Question (source)
2012-04-02 21:33:11 -0500 marked best answer For new package downloading

Hi,

May I ask a fresh question, that when i try to run find_object package,it does not be downloaded. And reference is "http://www.ros.org/wiki/find_object/Tutorials/Running%20the%20basic%20find%20object%20demo" I ask some of my colleagues that it only should download one by one files at "https://code.ros.org/svn/wg-ros-pkg/branches/trunk_cturtle/stacks/find_object/",. which is so confused to me, cause it has too many files and sub-files.

So could there be anther way to download this SVN source quickly?

Best regards.

2012-01-02 13:23:49 -0500 marked best answer For new package downloading

That tutorial skips over several important preliminary steps. This is the best answer I know. Maybe someone else has a better approach.

Install the ROS binary packages if you have not already (see: Ubuntu C-turtle installation).

Create your own rosinstall file (find_object.rosinstall for this example), containing these three lines:

- other: {local-name: /opt/ros/cturtle/ros}
- other: {local-name: /opt/ros/cturtle/stacks}
- svn: {local-name: find_object, uri: 'https://code.ros.org/svn/wg-ros-pkg/branches/trunk_cturtle/stacks/find_object'}

Run rosinstall on that file, and source the setup.bash script (which you should probably add to your ~/.bashrc script).

You can do all of the above with these shell commands:

$ cp /opt/ros/cturtle/.rosinstall find_object.rosinstall
$ roslocate info find_object >> find_object.rosinstall
$ rosinstall ~/ros find_object.rosinstall
$ source ~/ros/setup.bash

Follow the tutorial after that.

2011-12-18 15:05:06 -0500 received badge  Popular Question (source)
2011-11-29 00:37:55 -0500 received badge  Notable Question (source)
2011-11-11 14:09:01 -0500 received badge  Popular Question (source)
2011-09-23 02:09:29 -0500 received badge  Popular Question (source)