kalibr是标定camera和imu外参的重要工具,但是原配的只支持ros的image消息。这里通过修改源代码使其支持compressed image消息。
- 搜索文件:ImageDatasetReader.py
- 修改函数def getImage为:
-
def getImage(self,idx): topic, data, stamp = self.bag._read_message(self.index[idx].position) ts = acv.Time( data.header.stamp.secs, data.header.stamp.nsecs ) if data._type == 'mv_cameras/ImageSnappyMsg': if self.uncompress is None: from snappy import uncompress self.uncompress = uncompress img_data = np.reshape(self.uncompress(np.fromstring(data.data, dtype='uint8')),(data.height,data.width), order="C") elif data._type == 'sensor_msgs/CompressedImage': np_arr = np.fromstring(data.data, np.uint8) img_data_rgb = cv2.imdecode(np_arr, cv2.IMREAD_COLOR) img_data = cv2.cvtColor(img