cv_bridge.boost error

asked 2018-07-20 19:32:45 -0600

pnambiar gravatar image

updated 2018-07-20 20:05:17 -0600

jayess gravatar image

I am trying to create a ROS wrapper for caffe2 (Ros Kinetic, opencv version-3.4.1) and I get the following error:

[ERROR] [1532132328.463265]: bad callback: <bound method image_converter.callback of <__main__.image_converter instance at 0x7f01bdc8e7a0>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/", line 750, in _invoke_callback
  File "", line 72, in callback
    cv_image = self.bridge.imgmsg_to_cv2(data, 'bgr8')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/", line 182, in imgmsg_to_cv2
    res = cvtColor2(im, img_msg.encoding, desired_encoding)
ArgumentError: Python argument types in
    cv_bridge.boost.cv_bridge_boost.cvtColor2(numpy.ndarray, str, unicode)
did not match C++ signature:
    cvtColor2(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)

Any help will be highly appreciated

#!/usr/  bin/env python

"""Perform inference on a single image or all images with a certain extension
(e.g., .jpg) in a folder.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from collections import defaultdict
import argparse
import cv2  # NOQA (Must import before importing caffe2 due to bug in cv2)
import glob
import logging
import os
import sys
import time

from caffe2.python import workspace

import roslib
import sys
import rospy
#import cv2
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
class image_converter:  

    def __init__(self):

        self.bridge = CvBridge()
        self.image_sub = rospy.Subscriber("/usb_cam/image_raw",Image,self.callback)
    def callback(self, data):
        currentframe = 0
            while True:

                cv_image = self.bridge.imgmsg_to_cv2(data, 'bgr8')

        except CvBridgeError as e:  
def main(args):
    ic = image_converter()
    rospy.init_node('image_converter', anonymous=True)
    except KeyboardInterrupt:
        print('Shutting Down')

if __name__ == '__main__':

        workspace.GlobalInit(['caffe2', '--caffe2_log_level=0'])
  #      setup_logging(__name__)
edit retag flag offensive close merge delete


Did you fix it? I am having similar problem.

pedro_bb72 gravatar image pedro_bb72  ( 2019-04-19 00:36:58 -0600 )edit