Ask Your Question

Converting raw image into mono8

asked 2015-06-11 15:59:47 -0500

dshimano gravatar image

Hi, I'm trying to use the ethzasl_ptam node. Curently, I am passing an image to it using my webcam with the uvc_camera node. I am getting clean raw footage from the uvc_camer node (I can see in with rqt), but the screan that comes up with the ptam node is weird looking. After looking around online, I think this is happening becouse the ptam node needs mono8 video, not color. I have been looking around for how to change the video type, and the best way seems to be with opencv. However, I haven't fpund any tutorials I understand. I've tried to follow this one, but I am not sure I followed it corectlly. My computer didn't think I wrote a node when I tried to implement the file on the tutorial (auto-tab didn't work, and when I used rosrun I got a "cv in neithe a node or a package" error message) and when I ran it with ./ an error poped up

 Traceback (most recent call last):
  File "./", line 3, in <module>
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/", line 62, in load_manifest
    sys.path = _generate_python_path(package_name, _rospack) + sys.path
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/", line 93, in _generate_python_path
    m = rospack.get_manifest(pkg)
  File "/usr/lib/python2.7/dist-packages/rospkg/", line 163, in get_manifest
    return self._load_manifest(name)
  File "/usr/lib/python2.7/dist-packages/rospkg/", line 207, in _load_manifest
    retval = self._manifests[name] = parse_manifest_file(self.get_path(name), self._manifest_name, rospack=self)
  File "/usr/lib/python2.7/dist-packages/rospkg/", line 199, in get_path
    raise ResourceNotFound(name, ros_paths=self._ros_paths)
rospkg.common.ResourceNotFound: my_package

Any direction anyone can offer would be apriciated.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2015-06-11 17:26:37 -0500

updated 2015-06-11 17:27:36 -0500

One possibly easier way to solve your original problem is to use image_proc. If you run image_proc correctly it will automatically create a /my_camera/image_mono topic that your ethzasl_ptam node can subscribe to (probably with some remapping).

edit flag offensive delete link more


Thanks, I just got it to work using image proc. Now I'm need to put it in a nice little launch file.

dshimano gravatar imagedshimano ( 2015-06-15 14:23:21 -0500 )edit

answered 2018-09-25 10:24:21 -0500

lucasw gravatar image

I've added a nodelet here to convert most types to most other types: rgb, bgr and mono of 8/16/32/64 to any other (but yuv422 isn't supported yet). Dynamic reconfigure is used to change the destination types.

I haven't tested all the combinations so likely there is some wrong behavior and errors.

image description

rqt_image_view doesn't support some of the types, though adding mono32 or bgr64 etc. support to it won't be too hard.

This is an example launch file using a stored image.

edit flag offensive delete link more

answered 2015-06-13 23:21:29 -0500

I've wrote a simple program to transform raw image(in RGB) to grayscale image.

Here's the code:

 #include <ros/ros.h>
 #include <cv_bridge/cv_bridge.h>
 #include <sensor_msgs/image_encodings.h>
 #include <opencv2/imgproc/imgproc.hpp>
 using namespace cv;

 ros::Publisher pub;
 void transformer(const sensor_msgs::Image::ConstPtr& img)
      cv_bridge::CvImagePtr cvimg = cv_bridge::toCvCopy(img , sensor_msgs::image_encodings::BGR8);
      //To Grayscale
      cv::Mat img_conv;

      //Publish it
      cvimg->image = img_conv;
      cvimg->encoding = "mono8";  //This is easily forgotten

 int main(int argc, char** argv)
      ros::init(argc, argv, "color_to_gray_node");
      ros::NodeHandle node;

      pub = node.advertise("/usb_cam/image_mono", 1000);
      ros::Subscriber sub = node.subscribe("/usb_cam/image_raw", 1, transformer);

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-06-11 15:59:47 -0500

Seen: 1,776 times

Last updated: Sep 25 '18