资源简介
经典的APAP论文描述的拼接方法源代码,C++语言,编译通过,有助于论文阅读。
代码片段和文件信息
#include “APAP_Processor.h“
#include “MathUtils.h“
/*
* \param points 特征点集
* \param x y x*的坐标
*/
using namespace cv;
using namespace std;
using namespace Eigen;
vector points;
MatrixXd calculate_Wi_forPoint(double x double y)
{
const double sigma_squared = sigma * sigma;
MatrixXd Wi(2 * points.size() 2 * points.size());
Wi.setZero();
for (size_t i = 0; i < points.size(); i++)
{
double u = (double)points[i].x v = (double)points[i].y;
double sqr_dist = getSqrDist(x y u v);
double candidate = exp(-sqr_dist / sigma_squared);
double omega_i = max(candidate gamma);
Wi(i * 2 i * 2) = omega_i;
Wi(i * 2 + 1 i * 2 + 1) = omega_i;
}
return Wi;
}
//计算每一个x*对应的*i
void calculate_Wi_Matrices(Mat img vector& obj vector& vec)
{
points = obj;
int Width = img.size().width Height = img.size().height;
ArrayXd heightArray = ArrayXd::LinSpaced(C1 + 1 0 Height - 1)
widthArray = ArrayXd::LinSpaced(C2 + 1 0 Width - 1);//分割
ofstream fout(“Wi.txt“);
int count = 0;
for (int i = 0; i < C1; i++) {
double y = (heightArray(i) + heightArray(i + 1)) / 2;
for (int j = 0; j < C2; j++) {
// cout << “i = “ << i << “ j = “ << j << endl;
double x = (widthArray(j) + widthArray(j + 1)) / 2;
MatrixXd Wi = calculate_Wi_forPoint(x y);
vec.push_back(Wi);
}
}
}
//每个分块的H*
vector calculate_CellHomography(vector& matrices MatrixXd& A)
{
vector H_vec;
for (size_t i = 0; i < matrices.size(); i++)
{
MatrixXd WA = matrices[i] * A;
Matrix3d H;
JacobiSVD svd(WA ComputeThinU | ComputeThinV);
MatrixXd V = svd.matrixV();
VectorXd h = V.col(V.cols() - 1);
H << h[0] h[1] h[2]
h[3] h[4] h[5]
h[6] h[7] h[8];
H_vec.push_back(H);
}
return H_vec;
}
GridBox** getIndex(const Mat& img int C1 int C2 int offset_x int offset_y vector H_vec)
{
GridBox** a = new GridBox*[C2 + 1];
for (int i = 0; i < C2 + 1; i++)
a[i] = new GridBox[C1 + 1];
ArrayXf widthArray = ArrayXf::LinSpaced(C2 + 1 0 img.size().width)
heightArray = ArrayXf::LinSpaced(C1 + 1 0 img.size().height); // 0 ~ C1 - 1 0 ~ C2 - 1
double min_x min_y;
for (int gy = 0; gy < C1; gy++)
for (int gx = 0; gx < C2; gx++)
{
int H_index = gy * C2 + gx;
double topleftx toplefty
toprightx toprighty
bottomleftx bottomlefty
bottomrightx bottomrighty;
ConvertCoordinates(widthArray[gx] heightArray[gy] topleftx toplefty H_vec[H_index]);
ConvertCoordinates(widthArray[gx + 1] heightArray[gy] toprightx toprighty H_vec[H_index]);
ConvertCoordinates(widthArray[gx] heightArray[gy + 1] bottomleftx bottomlefty H_vec[H_index]);
ConvertCoordinates(widthArray[gx + 1] heightArray[gy + 1] bottomrightx bottomrighty H_vec[H_index]);
GridBox gbox = GridBox(Point2d(topleftx + offset_x toplefty + offset_y)
Point2d(toprightx + offset_x toprighty + offset_y)
Point2d(bottomleftx + offset_x bottomlefty + offset_y)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-13 08:24 APAP-Processor-master\
文件 6001 2018-05-13 08:24 APAP-Processor-master\APAP_Processor.cpp
文件 372 2018-05-13 08:24 APAP-Processor-master\APAP_Processor.h
目录 0 2018-05-13 08:24 APAP-Processor-master\Debug\
文件 7574890 2018-05-13 08:24 APAP-Processor-master\Debug\APAP_Processor.obj
文件 348812 2018-05-13 08:24 APAP-Processor-master\Debug\FeatureMatcher.obj
文件 317936 2018-05-13 08:24 APAP-Processor-master\Debug\GridBox.obj
文件 6404936 2018-05-13 08:24 APAP-Processor-master\Debug\Homography.obj
文件 840296 2018-05-13 08:24 APAP-Processor-master\Debug\Main.obj
文件 649859 2018-05-13 08:24 APAP-Processor-master\Debug\MathUtils.obj
文件 519010 2018-05-13 08:24 APAP-Processor-master\Debug\Mesh2D.obj
文件 657635 2018-05-13 08:24 APAP-Processor-master\Debug\RANSAC_Processor.obj
文件 1932555 2018-05-13 08:24 APAP-Processor-master\Debug\SIFT_Matcher.obj
文件 465484 2018-05-13 08:24 APAP-Processor-master\Debug\Transform.obj
文件 1707 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.Build.CppClean.log
文件 3181 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.log
目录 0 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\
文件 7306 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\CL.command.1.tlog
文件 507202 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\CL.read.1.tlog
文件 12376 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\CL.write.1.tlog
文件 4366 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\li
文件 11308 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\li
文件 1310 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\li
文件 209 2018-05-13 08:24 APAP-Processor-master\Debug\opencvTest.tlog\opencvTest.lastbuildstate
文件 4164608 2018-05-13 08:24 APAP-Processor-master\Debug\vc141.idb
文件 16027648 2018-05-13 08:24 APAP-Processor-master\Debug\vc141.pdb
文件 722 2018-05-13 08:24 APAP-Processor-master\GridBox.cpp
文件 208 2018-05-13 08:24 APAP-Processor-master\GridBox.h
文件 1040 2018-05-13 08:24 APAP-Processor-master\Homography.cpp
文件 182 2018-05-13 08:24 APAP-Processor-master\Homography.h
文件 2059 2018-05-13 08:24 APAP-Processor-master\Main.cpp
............此处省略25个文件信息
- 上一篇:C语言程序设计 中文第二版教材+习题答案
- 下一篇:VC++串口通信源代码VC6.0
评论
共有 条评论