资源简介
航拍图片全景拼接代码
代码片段和文件信息
#include “util.h“
#include “match.h“
#include “warp.h“
#include “mst.h“
#include “exposure_compensator.h“
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
using namespace cv::detail;
bool matchThreshold = 0.0f;
Rect compose_roi(vector imgs vector corners)
{
int n = imgs.size();
int x1 x2 y1 y2;
x1 = corners[0].x;
x2 = corners[0].x + imgs[0].cols;
y1 = corners[0].y;
y2 = corners[0].y + imgs[0].rows;
for(int i = 1; i < n; i++)
{
x1 = (std::min)(corners[i].x x1);
y1 = (std::min)(corners[i].y y1);
x2 = (std::max)(corners[i].x + imgs[i].cols x2);
y2 = (std::max)(corners[i].y + imgs[i].rows y2);
}
return Rect(x1 y1 x2-x1 y2-y1);
}
Point compose_images_rough(vector imgs vector masks vector corners Mat &dst Mat &dst_mask)
{
int n = imgs.size();
Rect roi = compose_roi(imgs corners);
Point corner = roi.tl();
dst.create(roi.size() CV_8UC3);
dst_mask.create(roi.size() CV_8U);
for(int i = 0; i < n; i++)
{
int x = corners[i].x - corner.x;
int y = corners[i].y - corner.y;
imgs[i].copyTo(dst(Rect(x y imgs[i].cols imgs[i].rows)) masks[i]);
masks[i].copyTo(dst_mask(Rect(x y imgs[i].cols imgs[i].rows)) masks[i]);
}
return corner;
}
Rect get_mask_roi(Mat mask)
{
int x1 x2 y1 y2;
x2 = y2 = 0;
x1 = mask.cols - 1;
y1 = mask.rows - 1;
for(int y = 0; y < mask.rows; y++)
{
uchar *mask_ptr = mask.ptr(y);
for(int x = 0; x < mask.cols; x++)
{
if(mask_ptr[x] != 0)
{
if(x < x1) x1 = x;
if(y < y1) y1 = y;
if(x > x2) x2 = x;
if(y > y2) y2 = y;
}
}
}
return Rect(x1 y1 x2-x1+1 y2-y1+1);
}
/*
所有的特征提取、匹配都是在work_scale
*/
double work_scale = 0.4;
static int stitch_idx = 1;
string src_dir;
/*
将srcs[1]~srcs[n]增量式拼接到srcs[0]
srcs: srcs[0]是基准图像,srcs[i]是增量图像
mask0: srcs[0]的mask
feat0: srcs[0]的特征
*/
int stitch_images(vector srcs Mat mask0 ImageFeatures feat0
Mat &dst Mat &dst_mask ImageFeatures &dst_feat vector &success_mask)
{
int num_img = srcs.size();
/*********** work scale ***********/
cout << “\textracting features ... “ << endl;
vector srcs_ws(num_img);
Mat mask0_ws;
resize(mask0 mask0_ws Size() work_scale work_scale);
vector feats(num_img);
Ptr finder = new SurfFeaturesFinder();
for(int i = 0; i < num_img; i++)
resize(srcs[i] srcs_ws[i] Size() work_scale work_scale);
// 是否开启增量式特征提取
bool is_acc_feat = false;
if(is_acc_feat)
{
// 如果feat0里面没有特征,就重新提取,否则直接使用
if(feat0.keypoints.size() == 0)
(*finder)(srcs_ws[0] feats[0]);
else
feats[0] = feat0;
for(int i = 1; i < num_img; i++)
(*finder)(srcs_ws[i] feats[i]);
}
else
{
#pragma omp parallel for
for(int i = 0; i < num_img; i++)
(*finder)(srcs_ws[i] feats[i]);
dst_feat = feats[0];
}
finder->collectGarbage();
// feature matching
cout << “\tmatching the
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-12-28 02:41 AerialImageStitch-master\
文件 22320 2016-12-28 02:41 AerialImageStitch-master\aerial_stitch.cpp
文件 6730 2016-12-28 02:41 AerialImageStitch-master\exposure_compensator.cpp
文件 1196 2016-12-28 02:41 AerialImageStitch-master\exposure_compensator.h
文件 3963 2016-12-28 02:41 AerialImageStitch-master\match.cpp
文件 381 2016-12-28 02:41 AerialImageStitch-master\match.h
文件 2308 2016-12-28 02:41 AerialImageStitch-master\mst.cpp
文件 651 2016-12-28 02:41 AerialImageStitch-master\mst.h
文件 16975 2016-12-28 02:41 AerialImageStitch-master\streetslide.cpp
文件 0 2016-12-28 02:41 AerialImageStitch-master\streetslide.h
文件 2544 2016-12-28 02:41 AerialImageStitch-master\util.cpp
文件 1247 2016-12-28 02:41 AerialImageStitch-master\util.h
文件 7992 2016-12-28 02:41 AerialImageStitch-master\warp.cpp
文件 604 2016-12-28 02:41 AerialImageStitch-master\warp.h
- 上一篇:FM350-1详细资料
- 下一篇:delphi版封包截取发送源码
相关资源
- delphi图像拼接
- sift动态背景下实现目标跟踪
- OpenCV3.0实现SIFT特征提取+RANSAC剔除误匹
- 中国地图及各省轮廓(可分).pdf
- David G.Lowe的sift算法中文翻译
- 图像拼接 综述与算法综述
- SIFT opencv 源代码
- featerMatch.rar
- sift和surf的比较
- 基于SIFT的图像拼接算法
- sift算法实现双目测距
- CUDA加速实现的sift图像配准+颜色校正
- sift和颜色直方图特征匹配
- SIFT实现特征点提取和匹配
- PCA-SIFT源码
- ASIFT
- IDL 开发图像拼接程序
- 全景图像拼接基于SIFT特征-Qt工程
- 基于opencv的图像拼接生成全景图C代码
评论
共有 条评论