HF-Net(三)基于NetVLAD及superpoint构建的sfm场景模型的查询图像位姿解算
参考:HF-Net git地址
0.数据准备
0.1NetVLAD预训练权重,存放在编译hfnet后生成的$DATA_PATH/weights/路径下
0.2aachen数据下载,存放在编译hfnet后生成的$DATA_PATH/路径下
0.3基于superpoint生成的aachen三维点云场景
0.4aachen数据对应的每张图像相机内参文件
1.基于NetVLAD生成aachen所有图像的global descriptors
参考HF-Net(一)基于NetVLAD的global descriptor的特征提取
2.基于superpoint的local descriptors生成
2.1执行代码
#对底库图像的superpoint特征提取
python3 hfnet/export_predictions.py hfnet/configs/superpoint_export_aachen_db.yaml superpoint/aachen --keys keypoints,scores,local_descriptor_map
#对查询图像的superpoint特征提取
python3 hfnet/export_predictions.py hfnet/configs/superpoint_export_aachen_queries.yaml superpoint/aachen --keys keypoints,scores,local_descriptor_map
2.2结果生成
3.基于NetVLAD及superpoint构建的sfm场景模型的查询图像位姿解算
3.1核心代码
import logging
from pathlib import Path
import argparse
from pprint import pformat
import yaml
import numpy as np
from pyquaternion import Quaternionfrom hfnet.evaluation.localization import Localization, evaluate
from hfnet.evaluation.loaders import export_loader
from hfnet.settings import EXPER_PATHconfigs_global = {'netvlad': {'db_name': 'globaldb_netvlad.pkl','experiment': 'netvlad/aachen','predictor': export_loader,'has_keypoints': False,'has_descriptors': False,'pca_dim': 1024,'num_prior': 10,},'hfnet': {'db_name': 'globaldb_hfnet.pkl','experiment': 'hfnet/aachen','predictor': export_loader,'has_keypoints': False,'has_descriptors': False,'pca_dim': 1024,'num_prior': 10,},
}configs_local = {'superpoint': {'db_name': 'localdb_superpoint.pkl','experiment': 'superpoint/aachen','predictor': export_loader,'has_keypoints': True,'has_descriptors': True,'binarize': False,# 'do_nms': True,# 'nms_thresh': 4,'num_features': 2000,'ratio_thresh': 0.9,},'hfnet': {'db_name': 'localdb_hfnet.pkl','experiment': 'hfnet/aachen','predictor': export_loader,'has_keypoints': True,'has_descriptors': True,# 'do_nms': True,# 'nms_thresh': 4,'num_features': 2000,'ratio_thresh': 0.9,},'sift': {'db_name': 'localdb_sift.pkl','colmap_db': 'aachen.db','root': False,'ratio_thresh': 0.7,'fast_matching': False,},'doap': {'db_name': 'localdb_doap_kpts-sp-nms4.pkl','experiment': 'doap/aachen_resize-960','predictor': export_loader,'keypoint_predictor': export_loader,'keypoint_config': {'experiment': 'superpoint/aachen',# 'do_nms': True,# 'nms_thresh': 4,},'num_features': 2000,'ratio_thresh': 0.9,},'netvlad': {'db_name': 'localdb_netvlad_kpts-sp-nms4.pkl','experiment': 'netvlad/aachen','predictor': export_loader,'keypoint_predictor': export_loader,'keypoint_config': {'experiment': 'superpoint/aachen',# 'do_nms': True,# 'nms_thresh': 4,},'num_features': 1000,'ratio_thresh': 0.7,}
}config_pose = {'reproj_error': 10,'min_inliers': 12,
}config_aachen = {'resize_max': 960,
}if __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument('model', type=str)parser.add_argument('eval_name', type=str)parser.add_argument('--local_method', type=str)parser.add_argument('--global_method', type=str)parser.add_argument('--build_db', action='store_true')parser.add_argument('--queries', type=str, default='day_time')parser.add_argument('--max_iter', type=int)parser.add_argument('--export_poses', action='store_true')parser.add_argument('--cpp_backend', action='store_true')args = parser.parse_args()config = {'global': configs_global[args.global_method],'local': configs_local[args.local_method],'aachen': config_aachen,'pose': config_pose,'model': args.model,'max_iter': args.max_iter,'queries': args.queries,'use_cpp': args.cpp_backend,}logging.info(f'Configuration: \n'+pformat(config))logging.info('Evaluating Aachen with configuration: ')loc = Localization('aachen', args.model, config, build_db=args.build_db)query_file = f'{args.queries}_queries_with_intrinsics.txt'queries, query_dataset = loc.init_queries(query_file, config_aachen)logging.info('Starting evaluation')metrics, results = evaluate(loc, queries, query_dataset, max_iter=args.max_iter)logging.info('Evaluation metrics: \n'+pformat(metrics))output = {'config': config, 'metrics': metrics}output_dir = Path(EXPER_PATH, 'eval/aachen')output_dir.mkdir(exist_ok=True, parents=True)eval_path = Path(output_dir, f'{args.eval_name}.yaml')with open(eval_path, 'w') as f:yaml.dump(output, f, default_flow_style=False)if args.export_poses:poses_path = Path(output_dir, f'{args.eval_name}_poses.txt')with open(poses_path, 'w') as f:for query, result in zip(queries, results):query_T_w = np.linalg.inv(result.T)qvec_nvm = list(Quaternion(matrix=query_T_w))pos_nvm = query_T_w[:3, 3].tolist()line = f'{Path(query.name).name}'line += ' ' + ' '.join(map(str, qvec_nvm+pos_nvm))f.write(line+'\n')
3.2执行代码
python3 hfnet/evaluate_aachen.py /path/superpoint_sfm /DATA_PATH/aachen/images_upright/query/night/milestone --local_method superpoint --global_method netvlad --build_db --queries night_time --export_poses
3.3执行结果
求解的位姿
HF-Net(三)基于NetVLAD及superpoint构建的sfm场景模型的查询图像位姿解算相关推荐
- 基于STM32的四旋翼无人机项目(二):MPU6050姿态解算(含上位机3D姿态显示教学)
前言:本文为手把手教学飞控核心知识点之一的姿态解算--MPU6050 姿态解算(飞控专栏第2篇).项目中飞行器使用 MPU6050 传感器对飞行器的姿态进行解算(四元数方法),搭配设计的卡尔曼滤波器与 ...
- 基于 IMU 的位姿解算
前言 IMU,即惯性测量元件,以牛顿经典力学定律为基本工作原理,三轴加速度计和三轴陀螺仪作为敏感元件,上电时分别输出加速度和角速度. 一般情况下,将捷联固定IMU的运动对象称为载体.当载体位姿发生变化 ...
- [Python人工智能] 三十.Keras深度学习构建CNN识别阿拉伯手写文字图像
从本专栏开始,作者正式研究Python深度学习.神经网络及人工智能相关知识.前一篇文章分享了生成对抗网络GAN的基础知识,包括什么是GAN.常用算法(CGAN.DCGAN.infoGAN.WGAN). ...
- 大数据分析案例-基于逻辑回归算法构建垃圾邮件分类器模型
- 大数据分析案例-基于随机森林算法构建新闻文本分类模型
- 大数据分析案例-基于多元线性回归算法构建广告投放收益模型
- 大数据分析案例-基于多元线性回归算法构建用户信用评分模型
- 空间三点定圆的解算过程
记得去年在上海船厂期间一次员工要我们检测一个圆形构件,用全站仪在一圆形构件的同一高度上测得三个点,然后算出构件的圆心坐标和半径,数学模型如下: 已知空间三点的坐标为(x1,y1,z1),(x2,y2, ...
- 阿里云进阶课程三——基于云服务器构建微信公众号管理系统
基于阿里云服务器构建微信公众号管理系统 准备工作 阿里云服务器镜像配置 FileZilla和终端工具安装 下载微擎压缩包 微擎的安装和配置 在云服务器上配置微擎文件 设置数据库信息 云服务器上安装微擎 ...
最新文章
- QT学习之图形视图框架
- matlab混合编程设置,matlab c++ 混合编程初始设置
- 从struts2拦截器到自定义拦截器
- Java反射学习总结五(Annotation(注解)-基础篇)
- 漫步线性代数二十七——矩阵对角化
- 2017.9.7 JC loves Mkk 失败总结
- 使用 HTML5, javascript, webrtc, websockets, Jetty 和 OpenCV 实现基于 Web 的人脸识别
- java的io中replace咋么使用_Java.io.ObjectOutputStream.replaceObject()方法实例
- 择师论(怎么有效的向别人学习)
- vue中进入详情页记住列表滚动位置keep-alive解决
- RESTful Web Services in Spring 3(上)转载
- 汇顶科技外包java_汇顶科技——好好掂一掂它的技术含量(只谈基本面)
- 结构梁配筋最牛插件_??Webpack 插件开发如此简单!
- java pdf转png格式_如何在Java中将PDF转换为PNG或JPG
- Excel图表制作(二):单选框和下拉菜单组合完成动态图
- Java使用zip4j库 压缩文件工具类(自适应压缩包编码格式)
- Hadoop 3.x安装部署详细手顺
- 夜神模拟器Nox.exe支持命令行参数列表
- Android ToolBar修改返回按钮图标
- 8月22日到26日工作收获