openMVG----features

本文详细介绍了一个模块,该模块提供了存储和操作特征点及描述子的通用容器。包括PointFeature和SIOPointFeature用于存储特征位置,以及Descriptor类模板用于存储描述子,如SIFT、SURF和二进制描述子。同时,介绍了如何使用KeypointSet类链接特征点和描述子,并演示了特征点集的创建、保存和读取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个模块提供特征和特征描述子的通用容器

特征

提供基本的结构和IO来存储`特征点。存储特征点的类:

  • PointFeature:存储特征的位置(x,y)
  • SIOPointFeature:存储特征的位置、方向和尺度(x,y,s,o)
描述子

提供基本的结构和IO来存储`特征描述子。

  • template <typename T, std::size_t N> class Descriptor:存储N个类型是T的值,连续内存
// SIFT like descriptor
using siftDescriptorData Descriptor<float, 128>;

// SURF like descriptor
using surfDescriptorData = Descriptor<float, 64>;

// Binary descriptor (128 bits)
using binaryDescriptor_bitset = Descriptor<std::bitset<128>,1> binaryDescriptor_bitset;
// or using unsigned chars
using binaryDescriptor_uchar = Descriptor<unsigned char, 128/sizeof(unsigned char)>;

特征点集

存储一系列特征及其描述子:

  • template<typename FeaturesT, typename DescriptorsT> class KeypointSet
// Define SIFT Keypoints:

// Define the SIFT descriptor [128 floating point value]
using Descriptor<float, 128> DescriptorT;

// Use SIFT compatible features (scale, orientation and position)
using FeatureT = SIOPointFeature;

// Describe what a collection of local feature is for a given image:
using FeatsT = std::vector<FeatureT>;
using DescsT = std::vector<DescriptorT>;

// Link features and their descriptors as a collection:
using KeypointSetT = KeypointSet<FeatsT, DescsT>;

//示例
  Feats_T vec_feats;
  for (int i = 0; i < CARD; ++i)
    vec_feats.push_back(Feature_T(i, i*2, i*3, i*4));
  //Save them to a file
  saveFeatsToFile("tempFeats.feat", vec_feats);
  Feats_T vec_feats_read;
  loadFeatsFromFile("tempFeats.feat", vec_feats_read);
  //vec_feats_read.size();
  //vec_feats[i].coords(), .scale(), .orientation()

// Create an input series of descriptor
  Descs_T vec_descs;
  for (int i = 0; i < CARD; ++i)
  {
    Desc_T desc;
    for (int j = 0; j < DESC_LENGTH; ++j)
      desc[j] = i*DESC_LENGTH+j;
    vec_descs.emplace_back(desc);
  }
  saveDescsToFile("tempDescs.desc", vec_descs);
  Descs_T vec_descs_read;
  loadDescsFromFile("tempDescs.desc", vec_descs_read);
  //vec_descs_read.size();
  //vec_descs[i][j]
  
  //保存为二进制文件
  saveDescsToBinFile("tempDescsBin.desc", vec_descs);
  loadDescsFromBinFile("tempDescsBin.desc", vec_descs_read)

还可以通过cereal把特征描述子保存为json格式

#ifndef OPENMVG_FEATURES_SIFT_SIFT_ANATOMY_IMAGE_DESCRIBER_HPP #define OPENMVG_FEATURES_SIFT_SIFT_ANATOMY_IMAGE_DESCRIBER_HPP #include <numeric> #include <vector> #include "openMVG/features/feature.hpp" #include "openMVG/features/image_describer.hpp" #include "openMVG/features/regions_factory.hpp" #include "openMVG/features/sift/hierarchical_gaussian_scale_space.hpp" #include "openMVG/features/sift/sift_DescriptorExtractor.hpp" #include "openMVG/features/sift/sift_keypoint.hpp" #include "openMVG/features/sift/sift_KeypointExtractor.hpp" #include "openMVG/system/logger.hpp" #ifdef _MSC_VER #pragma warning( once : 4244 ) #endif namespace openMVG { namespace features { class SIFT_Anatomy_Image_describer : public Image_describer { public: using Regions_type = SIFT_Regions; struct Params { Params( int first_octave = 0, int num_octaves = 6, int num_scales = 3, float edge_threshold = 10.0f, float peak_threshold = 0.04f, bool root_sift = true ): first_octave_(first_octave), num_octaves_(num_octaves), num_scales_(num_scales), edge_threshold_(edge_threshold), peak_threshold_(peak_threshold), root_sift_(root_sift) {} template<class Archive> inline void serialize( Archive & ar ); // Parameters int first_octave_; // Use original image, or perform an upscale if == -1 int num_octaves_; // Max octaves count int num_scales_; // Scales per octave float edge_threshold_; // Max ratio of Hessian eigenvalues float peak_threshold_; // Min contrast bool root_sift_; // see [1] }; explicit SIFT_Anatomy_Image_describer ( const Params & params = Params() ): Image_describer(), params_(params) {} bool Set_configuration_preset(EDESCRIBER_PRESET preset) override { switch (preset) { case NORMAL_PRESET: params_.peak_threshold_ = 0.04f; break; case HIGH_PRESET: params_.peak_threshold_
最新发布
03-15
### 使用 OpenMVG 和 OpenMVS 进行3D建模与视觉几何处理 #### 安装环境准备 为了成功运行OpenMVG和OpenMVS,在Windows环境下推荐使用Visual Studio 2015作为编译工具链。安装过程中需注意依赖库的版本兼容性,确保CMake等构建工具已正确配置[^1]。 #### 数据预处理 对于输入图像集,建议先进行初步筛选去除低质量图片,并保持场景覆盖均匀分布。这有助于提高后续特征匹配精度以及减少计算资源消耗。 #### 特征提取与匹配 利用OpenMVG可以高效完成多视角下的局部不变描述子检测及两两间同名点关联工作。具体而言,通过命令行调用`openMVG_main_SfMInit_ImageListing`来初始化项目并指定相机参数文件路径;接着执行`openMVG_main_ComputeFeatures`批量抽取SURF/SIFT特征向量;最后依靠`openMVG_main_ComputeMatches`实现跨帧之间稳定可靠的对应关系建立[^2]。 #### 结构从运动(SfM) 基于上述获取到的一系列二维观测信息,借助增量式方法逐步恢复三维空间结构及其相对姿态变换矩阵。此过程涉及全局优化步骤以消除累积误差影响,从而获得更加鲁棒的结果表示形式——稀疏点云模型。相关操作可通过连续调用如下几个模块达成目标: - `openMVG_main_IncrementalSfM`: 构造初始框架; - `openMVG_main_StructureFromMotion`: 执行整体平滑调整。 #### 多视图立体(MVS) 当得到较为完整的骨架之后,则可引入密集化流程进一步充实细节部分。此时转而采用开源软件包OpenMVS辅助完成深度估计任务。典型做法包括但不限于: - 利用`DensifyPointCloud`函数扩充原始采样密度; - 应用`ReconstructMesh`生成表面网格拓扑连接; - 调用`RefineMesh`细化边界轮廓线条流畅度; - 借助`TextureMapping`贴附真实纹理映射效果。 ```cpp // 示例代码片段展示如何启动特定阶段的任务进程 std::string command; command += "openMVG_main_DensifyPointCloud "; command += "-i incremental sfm_data.json "; // 输入sfm数据源位置 command += "-w output_directory"; // 输出成果保存目录 system(command.c_str()); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值