此方法基于事件流重建图像进行,流程如下:
1、事件相机采集含标定板的事件流数据
2、使用e2vid将事件流重建出图片
3、将图片转为rosbag包
4、将含有图片的rosbag包与原始录制的含有lmu的rosbag包合并成一个rosbag包
5、将合并的rosbag包使用kalibr进行外参标定(前提相机与imu的内参数据已知)
一、上述流程的前3步见我的另一篇博客
Event Camera Calib 单目事件相机内参标定
二、合并rosbag包
合并代码(我这里命名是rosbag_togther.py)
#!/usr/bin/env python
import sys
import argparse
from fnmatch import fnmatchcase
from rosbag import Bag
def main():
parser = argparse.ArgumentParser(description='Merge one or more bag files with the possibilities of filtering topics.')
parser.add_argument('outputbag',
help='output bag file with topics merged')
parser.add_argument('inputbag', nargs='+',
help='input bag files')
parser.add_argument('-v', '--verbose', action="store_true", default=False,
help='verbose output')
parser.add_argument('-t', '--topics', default="*",
help='string interpreted as a list of topics (wildcards \'*\' and \'?\' allowed) to include in the merged bag file')
args = parser.parse_args()
topics = args.topics.split(' ')
total_included_count = 0
total_skipped_count = 0
if (args.verbose):
print("Writing bag file: " + args.outputbag)
print("Matching topics against patters: '%s'" % ' '.join(topics))
with Bag(args.outputbag, 'w') as o:
for ifile in args.inputbag:
matchedtopics = []
included_count = 0
skipped_count = 0
if (args.verbose):
print("> Reading bag file: " + ifile)
with Bag(ifile, 'r') as ib:
for topic, msg, t in ib:
if any(fnmatchcase(topic, pattern) for pattern in topics):
if not topic in matchedtopics:
matchedtopics.append(topic)
if (args.verbose):
print("Including matched topic '%s'" % topic)
o.write(topic, msg, t)
included_count += 1
else:
skipped_count += 1
total_included_count += included_count
total_skipped_count += skipped_count
if (args.verbose):
print("< Included %d messages and skipped %d" % (included_count, skipped_count))
if (args.verbose):
print("Total: Included %d messages and skipped %d" % (total_included_count, total_skipped_count))
if __name__ == "__main__":
main()
运行命令:
python rosbag_togther.py -v --topic "/dvs/image_reconstructed /capture_node/imu" total.bag reconstruction.bag 2023-05-11-22-24-46.bag
/dvs/image_reconstructed和/capture_node/imu,是要合并的话题名,分别是重建的图像和原始的imu数据
total.bag是合并后的包名,reconstruction.bag是重建图像的包名,2023-05-11-22-24-46.bag是imu的包名
三、将合并的rosbag包使用kalibr进行外参标定
见kalibr使用方法