Skip to content

cameracalibrator fails for mono image in ROS 2 Humble. #1086

Open
@TannerGilbert

Description

@TannerGilbert

I have a camera that publishes images in mono8:

ros_image = self.bridge.cv2_to_imgmsg(arr, encoding="mono8")
ros_image.header.stamp = self.get_clock().now().to_msg()
ros_image.header.frame_id = self.frame_id
self.publisher_.publish(ros_image)

I wanted to do the calibration with cameracalibrator but when running ros2 run camera_calibration cameracalibrator --size 8x10 --square 0.015 --ros-args -r image:=/camera/image_raw I get the following output:

Waiting for service camera/set_camera_info ...
OK
Waiting for service left_camera/set_camera_info ...
OK
Waiting for service right_camera/set_camera_info ...
OK
[WARN] [1744132236.138276860] [cameracalibrator]: No publishers available for topic /left. Using system default QoS for subscriber.
[WARN] [1744132236.140784587] [cameracalibrator]: No publishers available for topic /right. Using system default QoS for subscriber.
Exception in thread Thread-1:
TypeError: unknown is not a numpy array, neither a scalar

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/sapience/sapience_ws/build/camera_calibration/src/camera_calibration/camera_calibrator.py", line 91, in run
    self.function(m)
  File "/home/sapience/sapience_ws/build/camera_calibration/src/camera_calibration/camera_calibrator.py", line 175, in handle_monocular
    drawable = self.c.handle_msg(msg)
  File "/home/sapience/sapience_ws/build/camera_calibration/src/camera_calibration/calibrator.py", line 958, in handle_msg
    gray = self.mkgray(msg)
  File "/home/sapience/sapience_ws/build/camera_calibration/src/camera_calibration/calibrator.py", line 378, in mkgray
    return self.br.imgmsg_to_cv2(msg, "mono8")
  File "/home/sapience/sapience_ws/install/cv_bridge/local/lib/python3.10/dist-packages/cv_bridge/core.py", line 194, in imgmsg_to_cv2
    res = cvtColor2(im, img_msg.encoding, desired_encoding)
SystemError: <Boost.Python.function object at 0xaaaacaeb7ed0> returned a result with an exception set

In calibrator.py it correctly detects that the image is mono8 (

return self.br.imgmsg_to_cv2(msg, "mono8")
) but then cvtColor2 fails in the cv_bridge (https://github.com/ros-perception/vision_opencv/blob/27de9ecf9862e6fba509b7e49e3c2511c7d11627/cv_bridge/src/module.cpp#L42). Note cv_bridge was also build from source with the Humble branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions