{"id":26872,"library":"cv-bridge","title":"cv-bridge","description":"CvBridge converts between ROS Image messages and OpenCV images. Current version is 1.13.0.post0. Release cadence follows ROS distributions.","status":"active","version":"1.13.0.post0","language":"python","source_language":"en","source_url":"https://github.com/ros-perception/vision_opencv","tags":["ros","opencv","image","conversion","cvbridge"],"install":[{"cmd":"pip install cv-bridge","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for OpenCV image operations.","package":"opencv-python","optional":false}],"imports":[{"note":"The direct import from the package is shorter and correct.","wrong":"from cv_bridge.cv_bridge import CvBridge","symbol":"CvBridge","correct":"from cv_bridge import CvBridge"}],"quickstart":{"code":"import cv2\nfrom cv_bridge import CvBridge\nfrom sensor_msgs.msg import Image\n\nbridge = CvBridge()\n# Convert a ROS Image message to OpenCV image\ncv_image = bridge.imgmsg_to_cv2(image_message, desired_encoding='bgr8')\n# Convert back\nimage_message = bridge.cv2_to_imgmsg(cv_image, encoding='bgr8')","lang":"python","description":"Basic usage of CvBridge to convert between ROS Image messages and OpenCV images."},"warnings":[{"fix":"Use `desired_encoding='bgr8'` (or appropriate encoding) in `imgmsg_to_cv2`.","message":"Forgetting to specify `desired_encoding` results in default encoding which may not match expected format. Always specify encoding explicitly.","severity":"gotcha","affected_versions":"all"},{"fix":"Always set encoding to 'bgr8' for OpenCV compatibility.","message":"OpenCV uses BGR channel order, but most other libraries use RGB. Converting to/from ROS Image without specifying encoding can swap channels.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from cv_bridge import CvBridge` instead of importing boost submodules.","message":"The `cv_bridge.boost.cv_bridge_boost` module is deprecated and may be removed in future versions.","severity":"deprecated","affected_versions":">=1.13.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install cv-bridge` or install ROS environment with cv-bridge.","cause":"cv-bridge package not installed.","error":"ImportError: No module named cv_bridge"},{"fix":"Use correct import: `from cv_bridge import CvBridge` then instantiate with `CvBridge()`.","cause":"Trying to import CvBridge from wrong location, e.g., `import cv_bridge` then `cv_bridge.CvBridge()`.","error":"AttributeError: module 'cv_bridge' has no attribute 'CvBridge'"},{"fix":"Ensure encoding matches the actual image type. Common: 'bgr8', 'rgb8', 'mono8'.","cause":"Invalid encoding string or incompatible image formats.","error":"RuntimeError: cv_bridge exception: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}