Open alsora opened 5 years ago
It works to call rclpy.init()
after importing CvBridge
before, maybe you can refer to an example https://github.com/ros-perception/vision_opencv/blob/ros2/opencv_tests/nodes/source.py. thanks !
Hi @gaoethan, I tried to run the example and I get a segmentation fault error during rclpy.init()
.
I noticed that if I put from cv_bridge import CvBridge
after rclpy.init()
, the error disappears and I'm able to run the example.
I updated my snippet
import numpy as np
import cv2
import rclpy
def main(args=None):
rclpy.init(args=args)
from cv_bridge import CvBridge
br = CvBridge()
dtype, n_channels = br.encoding_to_dtype_with_channels('8UC3')
im = np.ndarray(shape=(480, 640, n_channels), dtype=dtype)
msg = br.cv2_to_imgmsg(im)
im2 = br.imgmsg_to_cv2(msg)
if __name__ == '__main__':
main()
Now I can use rclpy.init(args=args)
, but i still get a segmentation fault during dtype, n_channels = br.encoding_to_dtype_with_channels('8UC3')
Do you have any idea why?
EDIT: It looks like it's a Boost problem. The segmentation fault happens during the call to the functions binded from the C++ code. Which version of Boost are you using?
It's a little strange, because it works before and not sure whether it relates to the other latest changes, it needs further investigation, on the other hand, actually the ROS2 version has almost removed the using of Boost and used C++ 11 or later instead.
I tried to build and run the tests checking out old commits.
Tags 2.0.5
and 2.0.4
are not working either.
I also tried updating boost to 1.6.3 but the result does not change
Were you ever able to figure out the fix? Currently having the same exact issue when trying to run camera calibration for a kinect camera. Keeps giving me the segmentation error when trying to run self.br.encoding_to_dtype_with_channels(msg.encoding)[0]
I also have the same issue. Is this bug resolved?
Hi,
I'm using cv_bridge in some ROS2 Bouncy projects.
If I use the C++ APIs, everything works fine. On the other hand with the Python ones my program crashes with no error message.
If I try to run the following code, it crashes during
br.encoding_to_dtype_with_channels('8UC3')
.Moreover note that I'm not able to call
rclpy.init(args=args)
if I'm importingCvBridge
.I tried to run the unit tests contained in this repo using
colcon test
and they fail too.The system is generated through this Dockerfile
As a recap, I am using