From 2c209c13c245c69061f1cea48373a794d89ef5cb Mon Sep 17 00:00:00 2001 From: Patrick de Kok Date: Tue, 9 Sep 2014 15:44:26 +0200 Subject: [PATCH] Grayscale images sometimes problem in calibration. When the sensor_msgs/Image is converted to its numpy `ndarray` representation, it sometimes has the shape `(n, m, 1)`. This gives an error even though it is a `sensor_msgs::image_encodings::MONO8`. The underlying algorithm only supports 2D arrays, and the images were stored as 3D objects. Error: ``` TypeError: Conversion is only valid for arrays with 1 or 2 dimensions. Argument has 3 dimensions ``` Transforming the image with a reshape if and only if it has a dimension of lenght 1 solves this problem. --- .../kalibr/python/kalibr_common/TargetExtractor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aslam_offline_calibration/kalibr/python/kalibr_common/TargetExtractor.py b/aslam_offline_calibration/kalibr/python/kalibr_common/TargetExtractor.py index 2b7ca395d..108ef7a60 100644 --- a/aslam_offline_calibration/kalibr/python/kalibr_common/TargetExtractor.py +++ b/aslam_offline_calibration/kalibr/python/kalibr_common/TargetExtractor.py @@ -18,6 +18,7 @@ def multicoreExtractionWrapper(detector, taskq, resultq, clearImages, noTransfor stamp = task[1] image = task[2] + image = image.reshape(filter(lambda dim: dim != 1, image.shape)) if noTransformation: success, obs = detector.findTargetNoTransformation(stamp, np.array(image)) else: