资源简介
通过opencv2.4.9和VS2013写的三段代码,一段是n张图片实现360度拼接;二是任意两张图片进行拼接;三是对二拼接之后的优化
代码片段和文件信息
// Image_Stitching.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
#include “windows.h“
#include“io.h“
#include
#include
#include
#include “opencv2/nonfree/nonfree.hpp“
#include“opencv2/calib3d/calib3d.hpp“
#include
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector imgs;
string result_name = “dst1.jpg“;
//opencv stitch算法 方法1 //变形的,弧度的 2张
int main00(int argc char * argv[])
{
Mat img1 = imread(“1.jpg“);
Mat img2 = imread(“2.jpg“);
imshow(“p1“ img1);
imshow(“p2“ img2);
if (img1.empty() || img2.empty())
{
cout << “Can‘t read image“ << endl;
return -1;
}
imgs.push_back(img1);
imgs.push_back(img2);
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
// 使用stitch函数进行拼接
Mat pano;
Stitcher::Status status = stitcher.stitch(imgs pano);
if (status != Stitcher::OK)
{
cout << “Can‘t stitch images error code = “ << int(status) << endl;
return -1;
}
imwrite(result_name pano);
Mat pano2 = pano.clone();
// 显示源图像,和结果图像
imshow(“全景图像“ pano);
if (waitKey() == 27)
return 0;
}
//SURF算法 方法2 去除弧度的,无变形的
void OptimizeSeam(Mat& img1 Mat& trans Mat& dst);
typedef struct
{
Point2f left_top;
Point2f left_bottom;
Point2f right_top;
Point2f right_bottom;
}four_corners_t;
four_corners_t corners;
void CalcCorners(const Mat& H const Mat& src)
{
double v2[] = { 0 0 1 };//左上角
double v1[3];//变换后的坐标值
Mat V2 = Mat(3 1 CV_64FC1 v2); //列向量
Mat V1 = Mat(3 1 CV_64FC1 v1); //列向量
V1 = H * V2;
//左上角(001)
cout << “V2: “ << V2 << endl;
cout << “V1: “ << V1 << endl;
corners.left_top.x = v1[0] / v1[2];
corners.left_top.y = v1[1] / v1[2];
//左下角(0src.rows1)
v2[0] = 0;
v2[1] = src.rows;
v2[2] = 1;
V2 = Mat(3 1 CV_64FC1 v2); //列向量
V1 = Mat(3 1 CV_64FC1 v1); //列向量
V1 = H * V2;
corners.left_bottom.x = v1[0] / v1[2];
corners.left_bottom.y = v1[1] / v1[2];
//右上角(src.cols01)
v2[0] = src.cols;
v2[1] = 0;
v2[2] = 1;
V2 = Mat(3 1 CV_64FC1 v2); //列向量
V1 = Mat(3 1 CV_64FC1 v1); //列向量
V1 = H * V2;
corners.right_top.x = v1[0] / v1[2];
corners.right_top.y = v1[1] / v1[2];
//右下角(src.colssrc.rows1)
v2[0] = src.cols;
v2[1] = src.rows;
v2[2] = 1;
V2 = Mat(3 1 CV_64FC1 v2); //列向量
V1 = Mat(3 1 CV_64FC1 v1); //列向量
V1 = H * V2;
corners.right_bottom.x = v1[0] / v1[2];
corners.right_bottom.y = v1[1] / v1[2];
}
int main01(int argc char *argv[])
{
Mat image01 = imread(“2.jpg“ 1); //右图
Mat image02 = imread(“1.jpg“ 1); //左图
imshow(“p2“ image01);
imshow(“p1“ image02);
//灰度图转换
Mat image1 image2;
cvtColor(image01 image1 CV_RGB2GRAY);
cvtColor(image02 image2 CV_RGB2GRAY);
//提取特征点
SurfFeatureDetector Detector(2000);
vector
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-17 22:21 Image_Stitching\
目录 0 2018-07-02 20:21 Image_Stitching\Debug\
文件 174080 2018-07-17 10:39 Image_Stitching\Debug\Image_Stitching.exe
文件 1528776 2018-07-17 10:39 Image_Stitching\Debug\Image_Stitching.ilk
文件 3083264 2018-07-17 10:39 Image_Stitching\Debug\Image_Stitching.pdb
目录 0 2018-07-17 15:01 Image_Stitching\Image_Stitching\
目录 0 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\
文件 5027 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.log
文件 818973 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.obj
文件 1638400 2018-07-02 11:12 Image_Stitching\Image_Stitching\Debug\Image_Stitching.pch
目录 0 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\
文件 32402 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\CL.read.1.tlog
文件 1432 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\CL.write.1.tlog
文件 177 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\Image_Stitching.lastbuildstate
文件 1762 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\cl.command.1.tlog
文件 2894 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\li
文件 6224 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\li
文件 758 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\Image_Stitching.tlog\li
文件 11594 2018-07-02 11:12 Image_Stitching\Image_Stitching\Debug\stdafx.obj
文件 1035264 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\vc120.idb
文件 1478656 2018-07-17 10:39 Image_Stitching\Image_Stitching\Debug\vc120.pdb
文件 8595 2018-07-17 10:39 Image_Stitching\Image_Stitching\Image_Stitching.cpp
文件 4549 2018-07-02 11:07 Image_Stitching\Image_Stitching\Image_Stitching.vcxproj
文件 1322 2018-07-02 11:07 Image_Stitching\Image_Stitching\Image_Stitching.vcxproj.filters
文件 1566 2018-07-02 11:07 Image_Stitching\Image_Stitching\ReadMe.txt
文件 221 2018-07-02 11:07 Image_Stitching\Image_Stitching\stdafx.cpp
文件 234 2018-07-02 11:07 Image_Stitching\Image_Stitching\stdafx.h
文件 236 2018-07-02 11:07 Image_Stitching\Image_Stitching\targetver.h
文件 470920 2018-07-17 15:48 Image_Stitching\Image_Stitching\全景拼接.jpg
文件 40632320 2018-07-17 22:21 Image_Stitching\Image_Stitching.sdf
文件 991 2018-07-02 11:07 Image_Stitching\Image_Stitching.sln
............此处省略4个文件信息
相关资源
- zw_摄像头实时监控与报警系统Opencv.
- 基于OpenCV的计算机视觉技术实现
- LearningOpenCV.7z
- Opencv manager
- 学习opencv中文版+英文版PDF电子书+原书
- opencv双目视觉棋盘格标定,特征匹配
- 毕业设计:基于ARM-Linux的应用OpenCV和
- 图像放大waifu2x算法vs opencv实现
- Dalsa Nano 相机采集数据导入OpenCV
- 数码管数字识别--穿线法
- 基于背景差法的运动目标检测
- 2017年研究生数学建模D题二等奖
- 学习OpenCV(中文版高清扫描版带目录
- 2018 Learning OpenCV3 第三版 英文 高清完
- 基于opencv的车辆动态追踪
- opencv-4.10.zip
- 人脸识别,基于VS+openCV
- opencv3.4.0 vs2017编译的x86版本,可以直
- opencv-3.4.0 x86的Debug 和Release版本
- learning opencv3英文原版电子版学习ope
- opencv3.4.1+contrib+win10+vs2017已经编译好的
- opencv下实现显示并更改摄像头分辨率
- 利用openCV识别图片Demo
- OpenCV1.1版
- 基于opencv实现 LK跟踪算法
- OpenCV 3 Computer Vision Application Programmi
- cvMatchShapes
- 贾志刚Opencv图像处理视频教程学习笔
- opencv_3rdparty-ffmpeg-master_20161202.zip
- 学习opencv pdf
评论
共有 条评论