4

I would like to stitch multiple (5 or 6) images using python. I'm new to python but I want to use this since it runs on the server and is opensource. OpenCV seems very well capable of doing this and would be my prefered option, but the functions are mostly in C++ and I can't find any example that does it in python (although it should be capable). I found this link: http://richardt.name/teaching/supervisions/vision-2011/practical/ but I think that I'm not capable of doing the exercise.

I also found a lot about panotools and Hugin. Hugin is supposed to be able to do the stitching using HSI (Hugin Scripting Interface) but the documentation is very scarce. The example I found should maybe work, but I can't get Hugin and HSI to work in python, there is no explaination on how to install/import the library.

Is there anyone that can help me with this? I come from programming in php and am really new to Python, OpenCV and Hugin.

Many thanks

Yorian
  • 2,002
  • 5
  • 34
  • 60
  • possible duplicate of [Stitching Photos together](http://stackoverflow.com/questions/10657383/stitching-photos-together) – Jayanth Koushik Feb 17 '14 at 09:40
  • 1
    I saw that post as well, however that post simply want to put two images into one without the problem of blending and fitting the image well. In my case I want to make a panorama from two photo's – Yorian Feb 17 '14 at 09:43
  • Hugin requires the user to identify points in common between overlapping photos. How do you plan to automate that if programming in Python? – unutbu Feb 17 '14 at 09:50
  • The camera's are static. They are on the same location all the time. So I would select the point manually once and then for future images these points would be equal. I would however prefer to use OpenCV (or PIL), but I do not know if someone can help me with this. – Yorian Feb 17 '14 at 10:15
  • It looks like [Hugin's Scripting Interface](http://hugin.sourceforge.net/docs/manual/Hugin_Scripting_Interface.html) may do what you want. – unutbu Feb 18 '14 at 13:07

2 Answers2

1

If you don't have to use python, hugin alone can do this. See here for some of the relevant commands. Here's an example you can just run from a terminal:

$ cd to/your/images
$ pto_gen -o project.pto *.jpg
$ cpfind --multirow -o project.pto project.pto
$ celeste_standalone -i project.pto project.pto
$ hugin_executor --stitching --prefix=my_panorama project.pto

I ran a quick sanity check on 3 shots and it looks reasonable. I'm using hugin 2016.0.0.

Wisco crew
  • 1,337
  • 1
  • 17
  • 25
-1

I think this is the code you want

import cv2
import numpy as np

img1 = cv2.imread('Bird1.jpg')
img2 = cv2.imread('Bird2.jpg')

img3 = np.hstack((img1,img2))
cv2.imwrite('Bird3.jpg',img3)

Note : These two input images size(height,width) should be same.
Input Image:-

enter image description here


Output Image :-
enter image description here

Thamizh
  • 566
  • 3
  • 6
  • 16
  • Thank you for your response. This simply puts two images next to eachother. I would however like to make a panorama – Yorian Feb 17 '14 at 10:40