[Discourse.ros.org] [General] ros_bridge boost error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [General] ros_bridge boost error

Tully Foote via ros-users


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/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "ros_mercnn.py", line 72, in callback
    cv_image = self.bridge.imgmsg_to_cv2(data, 'bgr8')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", 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
    #roslib.load_manifest('my_package')
    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)
                    cv2.waitKey(1000000)
            def callback(self, data):
                    currentframe = 0
                    try:
                            while True:
 
                            cv_image = self.bridge.imgmsg_to_cv2(data, 'bgr8')

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

    if __name__ == '__main__':

            workspace.GlobalInit(['caffe2', '--caffe2_log_level=0'])
     #      setup_logging(__name__)
            main(sys.argv)





---
[Visit Topic](https://discourse.ros.org/t/ros-bridge-boost-error/5438/1) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [General] ros_bridge boost error

Tully Foote via ros-users




Thanks for your question. However we ask that you please ask questions on http://answers.ros.org following our support guidelines: http://wiki.ros.org/Support



ROS Discourse is for news and general interest discussions. ROS Answers provides a forum which can be filtered by tags to make sure the relevant people can find and/or answer the question, and not overload everyone with hundreds of posts.



If youd like you can reply with a link to your answers.ros.org question, but in the future please start there.











---

[Visit Topic](https://discourse.ros.org/t/ros-bridge-boost-error/5438/2) or reply to this email to respond.







If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>