Skip to content

Commit cfb68e8

Browse files
committedFeb 10, 2017
OpenCV Stitching
Creación de imágenes panorámicas con el módulo stitching
1 parent a8672c4 commit cfb68e8

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
 

‎opencv-stitching/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.4)
2+
3+
project( Tutorial_OpenCV_Stitching )
4+
5+
find_package( OpenCV 3.0.0 REQUIRED )
6+
7+
file(COPY images DESTINATION images)
8+
9+
add_executable( ${PROJECT_NAME} source.cpp )
10+
target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS} )

‎opencv-stitching/images/imagen1.jpg

147 KB
Loading

‎opencv-stitching/images/imagen2.jpg

187 KB
Loading

‎opencv-stitching/source.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <iostream>
2+
#include <opencv2/imgcodecs.hpp>
3+
#include <opencv2/highgui.hpp>
4+
#include <opencv2/stitching.hpp>
5+
#include <opencv2/core/ocl.hpp>
6+
7+
using namespace cv;
8+
using namespace std;
9+
10+
int main(int argc, char** argv )
11+
{
12+
try {
13+
// desactivar aceleracion OpenCL
14+
ocl::setUseOpenCL(false);
15+
16+
vector<Mat> imgs;
17+
18+
// cargar las imagenes de prueba
19+
imgs.push_back(imread("images/images/imagen1.jpg"));
20+
imgs.push_back(imread("images/images/imagen2.jpg"));
21+
22+
Mat result;
23+
24+
// crear el stitcher e iniciar la operacion
25+
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA, false);
26+
Stitcher::Status status = stitcher->stitch(imgs, result);
27+
28+
// verificar errores
29+
if (status != Stitcher::OK)
30+
{
31+
cout << "Can't stitch images, error code = " << int(status) << endl;
32+
return -1;
33+
}
34+
35+
//// guardar la imagen resultante
36+
//if(imwrite("pano.jpg", pano))
37+
// cout << "save image: ./pano.jpg" << endl;
38+
39+
imshow("Imagen 1", imgs[0]);
40+
imshow("Imagen 2", imgs[1]);
41+
imshow("Stitching", result);
42+
43+
waitKey(0);
44+
}
45+
catch (Exception e) {
46+
cout << e.what() << endl;
47+
}
48+
49+
return 0;
50+
}

0 commit comments

Comments
 (0)
Please sign in to comment.