OpenMVG官网docs
还是有必要读一下的,一个是提高读代码的水平,一个是提高英文水平,一个是更深入了解openmvg。
样例都在D:\openMVG\src\openMVG里。
image图像
Image Container
类Image<T>
是基于Eigen
库的图像容器,T代表像素类型,这个类可以处理灰度,RGB,RGBA或者自定义类型的图像。Image<T>
可以提供基本的像素读写操作(pixel read and write operation)
See examples from openMVG/images/image_test.cpp:
// A 8-bit gray image:
Image<unsigned char> grayscale_image_8bit;
// A 32-bit gray image:
Image<double> grayscale_image_32bit;
// Multichannel image: (use pre-defined pixel type)
// A 8-bit RGB image:
Image<RGBColor> rgb_image_8bit;
Image<Rgb<unsigned char> > rgb_image2_8bit;
// 8-bit RGBA image
Image<RGBAColor> rgba_image_8bit;
Image<Rgba<unsigned char> > rgba_image2_8bit;
// 32 bit RGB image:
Image<Rgb<double> > rgb_image_32bit;
Image I/O(输入输出)
以下格式支持8bit(灰和彩)图像的加载写入ppm/pgm,jpeg,png,tiff.
See examples from openMVG/images/image_IO_test.cpp:
// Read a grayscale image (if conversion need, it is done on the fly)
Image<unsigned char> gray_image;
bool bRet = ReadImage("Foo.imgExtension", &gray_image);
// Read a color image
Image<RGBColor> rgb_image_gray;
bool bRet = ReadImage("Foo.imgExtension", &rgb_image);
Drawing operations
可以在图像上画直线、圆、椭圆
See examples from openMVG/images/image_drawing_test.cpp:
Image<unsigned char> image(10,10);
image.fill(0);
// Pixel access is done as matrix (row, line)
int row = 2;
int column = 4;
image(row, column) = 127;
// Horizontal scanline
DrawLine( 0, 5, w-1, 5, 255, &image);
// Circle of radius 3 and center (5,5)
const int radius = 3;
const int x = 5, y = 5;
DrawCircle(x, y, radius, (unsigned char)255, &image);
// Ellipse of center (5,5) and (3,0
const int radius1 = 3, radius2 = 1, angle = 0;
const int x = 5, y = 5;
DrawEllipse(x, y, radius1, radius2, (unsigned char)255, &image, (double)angle);
// Example with a RGB image
Image<RGBColor> imageRGB(10,10);
DrawCircle(x, y, radius, RGBColor(255,0,0), &imageRGB);
Docs » openMVG libraries » numeric
numeric数值
该模块提供基于Eigen
库的数学和线性代数utils
类,为openmvg提供:
1.用于矩阵和向量的高级存储容器,
2.简单操作矩阵和向量,
3.数值求解器和相关算法的集合,
Vector, Matrix containers矩阵容器
OpenMVG为代码的一致性和清晰性重新定义了一些Eigen
基础类型(点、向量、矩阵):
Vec2
代表一个列矩阵(x,y)存储的二维点
Vec3
代表一个列矩阵(x,y,z)存储的三维点
Vec2f, Vec3f
是float型
Vec
一个向量值(双精度),
Vecf
浮点型
Mat
通用矩阵容器
Mat2X
二维点的集合,按列存储
Mat3X
三维点的集合,按列存储
Note: 默认内存对齐(memory alignment)以列为主。
// Create a set of 2D points store as column
Mat2X A(2, 5);
A << 1, 2, 3, 4, 5,
6, 7, 8, 9, 10;
A.col(); // return a column vector : (1,6)^T
A.row(); // return a row vector : (1,2,3,4,5)
线性代数
SVD/QR/LU分解。
Please visit: http://eigen.tuxfamily.org/dox/group__QuickRefPage.html
Docs » openMVG libraries » features
这个模块主要是提供特征容器的封装,包括特征,特征描述,关键点集。
Features
Provide basic structure and IO to store Point based features.
PointFeature
存储特征(x,y)的位置
SIOPointFeature
存储一个特征(x,y,s,o)的位置、方向和比例
Descriptors
Provide basic structure and IO for descriptor data.
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)>;
KeypointSet
Store a collection of features and their associated descriptors:
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>;