pycolmap.match_exhaustive()

时间: 2024-02-28 14:56:07 浏览: 28
`pycolmap.match_exhaustive()`是一个函数,它可以在COLMAP中进行图像特征匹配。这个函数使用暴力匹配算法来计算两幅图像之间的所有可能的匹配,因此它可能会非常耗时。在使用这个函数之前,你需要先使用`pycolmap.extract_features()`函数来提取图像特征。这个函数的语法如下: ``` matches = pycolmap.match_exhaustive(db_path, query_image_id, num_matches, config_path) ``` 其中,`db_path`是COLMAP数据库的路径,`query_image_id`是要匹配的图像的ID,`num_matches`是要返回的匹配数目,`config_path`是COLMAP配置文件的路径。这个函数返回一个Numpy数组,其中每一行表示一组匹配,包括两个特征的索引和它们之间的距离。
相关问题

pycolmap.match_exhaustive()用的是RANSAC算法吗

`pycolmap.match_exhaustive()`函数并没有使用RANSAC算法。它仅仅是使用了暴力匹配算法(Brute-Force Matching)来计算两幅图像之间的所有可能的匹配。这个函数不会进行任何的特征筛选或匹配优化,因此它的结果可能会包含噪声和错误的匹配。如果你想要获得更加准确的匹配结果,可以使用RANSAC算法来进行匹配筛选和优化。在COLMAP中,可以使用`pycolmap.match_list()`函数来进行RANSAC匹配,它会返回一个包含RANSAC筛选后的匹配结果的Numpy数组。

t=time() pycolmap.match_exhaustive(database_path) t=time() - t timings['RANSAC'].append(t) print(f'RANSAC in {t:.4f} sec')这段代码在做什么

这段代码仅仅是在计算使用`pycolmap.match_exhaustive()`函数进行图像特征匹配的时间,并将这个时间记录到`timings`字典中的`'RANSAC'`键对应的值中。具体来说,这段代码的作用是: 1. 获取当前时间戳。 2. 使用`pycolmap.match_exhaustive()`函数进行图像特征匹配。 3. 计算匹配所花费的时间,并将这个时间记录到`timings`字典中的`'RANSAC'`键对应的值中。 4. 打印输出匹配所花费的时间。 需要注意的是,这段代码中并没有使用RANSAC算法,它使用的仅仅是暴力匹配算法。因此,`'RANSAC'`这个键名并不太准确,应该改为`'Brute-Force Matching'`或者`'Exhaustive Matching'`比较合适。

相关推荐

详细解释一下这段代码,每一句都要进行注解:tgt = f'/kaggle/working/{dataset}-{scene}' # Generate a simple reconstruction with SIFT (https://en.wikipedia.org/wiki/Scale-invariant_feature_transform). if not os.path.isdir(tgt): os.makedirs(f'{tgt}/bundle') os.system(f'cp -r {src}/images {tgt}/images') database_path = f'{tgt}/database.db' sift_opt = pycolmap.SiftExtractionOptions() sift_opt.max_image_size = 1500 # Extract features at low resolution could significantly reduce the overall accuracy sift_opt.max_num_features = 8192 # Generally more features is better, even if behond a certain number it doesn't help incresing accuracy sift_opt.upright = True # rotation invariance device = 'cpu' t = time() pycolmap.extract_features(database_path, f'{tgt}/images', sift_options=sift_opt, verbose=True) print(len(os.listdir(f'{tgt}/images'))) print('TIMINGS --- Feature extraction', time() - t) t = time() matching_opt = pycolmap.SiftMatchingOptions() matching_opt.max_ratio = 0.85 # Ratio threshold significantly influence the performance of the feature extraction method. It varies depending on the local feature but also on the image type # matching_opt.max_distance = 0.7 matching_opt.cross_check = True matching_opt.max_error = 1.0 # The ransac error threshold could help to exclude less accurate tie points pycolmap.match_exhaustive(database_path, sift_options=matching_opt, device=device, verbose=True) print('TIMINGS --- Feature matching', time() - t) t = time() mapper_options = pycolmap.IncrementalMapperOptions() mapper_options.extract_colors = False mapper_options.min_model_size = 3 # Sometimes you want to impose the first image pair for initialize the incremental reconstruction mapper_options.init_image_id1 = -1 mapper_options.init_image_id2 = -1 # Choose which interior will be refined during BA mapper_options.ba_refine_focal_length = True mapper_options.ba_refine_principal_point = True mapper_options.ba_refine_extra_params = True maps = pycolmap.incremental_mapping(database_path=database_path, image_path=f'{tgt}/images', output_path=f'{tgt}/bundle', options=mapper_options) print('TIMINGS --- Mapping', time() - t)

详细解释一下这段代码,每一句都要进行注解:for dataset in datasets: print(dataset) if dataset not in out_results: out_results[dataset] = {} for scene in data_dict[dataset]: print(scene) # Fail gently if the notebook has not been submitted and the test data is not populated. # You may want to run this on the training data in that case? img_dir = f'{src}/test/{dataset}/{scene}/images' if not os.path.exists(img_dir): continue # Wrap the meaty part in a try-except block. try: out_results[dataset][scene] = {} img_fnames = [f'{src}/test/{x}' for x in data_dict[dataset][scene]] print (f"Got {len(img_fnames)} images") feature_dir = f'featureout/{dataset}{scene}' if not os.path.isdir(feature_dir): os.makedirs(feature_dir, exist_ok=True) t=time() index_pairs = get_image_pairs_shortlist(img_fnames, sim_th = 0.5644583, # should be strict min_pairs = 33, # we select at least min_pairs PER IMAGE with biggest similarity exhaustive_if_less = 20, device=device) t=time() -t timings['shortlisting'].append(t) print (f'{len(index_pairs)}, pairs to match, {t:.4f} sec') gc.collect() t=time() if LOCAL_FEATURE != 'LoFTR': detect_features(img_fnames, 2048, feature_dir=feature_dir, upright=True, device=device, resize_small_edge_to=600 ) gc.collect() t=time() -t timings['feature_detection'].append(t) print(f'Features detected in {t:.4f} sec') t=time() match_features(img_fnames, index_pairs, feature_dir=feature_dir,device=device) else: match_loftr(img_fnames, index_pairs, feature_dir=feature_dir, device=device, resize_to=(600, 800)) t=time() -t timings['feature_matching'].append(t) print(f'Features matched in {t:.4f} sec') database_path = f'{feature_dir}/colmap.db' if os.path.isfile(database_path): os.remove(database_path) gc.collect() import_into_colmap(img_dir, feature_dir=feature_dir,database_path=database_path) output_path = f'{feature_dir}/colmap_rec_{LOCAL_FEATURE}' t=time() pycolmap.match_exhaustive(database_path) t=time() - t timings['RANSAC'].append(t) print(f'RANSAC in {t:.4f} sec')

详细解释一下这段代码,每一句都要进行注解:def get_image_pairs_shortlist(fnames, sim_th = 0.6, # should be strict min_pairs = 20, exhaustive_if_less = 20, device=torch.device('cpu')): num_imgs = len(fnames) if num_imgs <= exhaustive_if_less: return get_img_pairs_exhaustive(fnames) model = timm.create_model('tf_efficientnet_b7', checkpoint_path='/kaggle/input/tf-efficientnet/pytorch/tf-efficientnet-b7/1/tf_efficientnet_b7_ra-6c08e654.pth') model.eval() descs = get_global_desc(fnames, model, device=device) #这段代码使用 PyTorch 中的 torch.cdist 函数计算两个矩阵之间的距离,其中参数 descs 是一个矩阵,表示一个数据集中的所有样本的特征向量。函数将计算两个矩阵的 p 范数距离,即对于矩阵 A 和 B,其 p 范数距离为: #dist_{i,j} = ||A_i - B_j||_p #其中 i 和 j 分别表示矩阵 A 和 B 中的第 i 和 j 行,||.||_p 表示 p 范数。函数的返回值是一个矩阵,表示所有样本之间的距离。 # detach() 和 cpu() 方法是为了将计算结果从 GPU 转移到 CPU 上,并将其转换为 NumPy 数组。最终的结果将会是一个 NumPy 数组。 dm = torch.cdist(descs, descs, p=2).detach().cpu().numpy() # removing half mask = dm <= sim_th total = 0 matching_list = [] ar = np.arange(num_imgs) already_there_set = [] for st_idx in range(num_imgs-1): mask_idx = mask[st_idx] to_match = ar[mask_idx] if len(to_match) < min_pairs: to_match = np.argsort(dm[st_idx])[:min_pairs] for idx in to_match: if st_idx == idx: continue if dm[st_idx, idx] < 1000: matching_list.append(tuple(sorted((st_idx, idx.item())))) total+=1 matching_list = sorted(list(set(matching_list))) return matching_list

最新推荐

recommend-type

数据分析师轻松上路——拆解方法(MECE法则)

MECE分析法是 Mutually Exclusive Collectively Exhaustive的首字母缩写词,中文意思是"相互独立、完全穷尽",即所谓的 "无重复、无遗漏"。在按照 MECE 原则将某个整体(不论是客观存在的还是概念性的整体)划分为...
recommend-type

安装NumPy教程-详细版

附件是安装NumPy教程_详细版,文件绿色安全,请大家放心下载,仅供交流学习使用,无任何商业目的!
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

可见光定位LED及其供电硬件具体型号,广角镜头和探测器,实验设计具体流程步骤,

1. 可见光定位LED型号:一般可使用5mm或3mm的普通白色LED,也可以选择专门用于定位的LED,例如OSRAM公司的SFH 4715AS或Vishay公司的VLMU3500-385-120。 2. 供电硬件型号:可以使用常见的直流电源供电,也可以选择专门的LED驱动器,例如Meanwell公司的ELG-75-C或ELG-150-C系列。 3. 广角镜头和探测器型号:一般可采用广角透镜和CMOS摄像头或光电二极管探测器,例如Omron公司的B5W-LA或Murata公司的IRS-B210ST01。 4. 实验设计流程步骤: 1)确定实验目的和研究对象,例如车辆或机器人的定位和导航。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这
recommend-type

解释这行代码 c = ((double)rand() / RAND_MAX) * (a + b - fabs(a - b)) + fabs(a - b);

这行代码的作用是随机生成一个浮点数,范围在 a 和 b 之间(包括 a 和 b)。 其中,`rand()` 函数是 C 语言标准库中的一个函数,用于生成一个伪随机整数。`RAND_MAX` 是一个常量,它表示 `rand()` 函数生成的随机数的最大值。 因此,`(double)rand() / RAND_MAX` 表示生成的随机数在 [0, 1] 之间的浮点数。 然后,将这个随机数乘上 `(a - b) - fabs(a - b)`,再加上 `fabs(a - b)`。 `fabs(a - b)` 是 C 语言标准库中的一个函数,用于计算一个数的绝对值。因此,`fabs(a - b)