14

There are a lot of ways and libraries to show panorama picture in iOS, Although there is a panorama feature in the built-in camera there is no way to use it within an app.

Is there any library I can use to capture a panorama image?

Thanks!

Idan
  • 9,880
  • 10
  • 47
  • 76

1 Answers1

36

These people might sell you a license for a c++ library. Their code goes into the brilliant Autostich app available in the App Store.

Autostitch is based on SIFT image feature detection. SIFT and many other techniques are available in the openCv c++ library. A pre built iOS framework is available from that site.

update

OpenCV has a Stitcher class with mounds of documentation...

OpenCV Stitching pipline

OpenCV Stitcher class

"High level image stitcher. It’s possible to use this class without being aware of the entire stitching pipeline. However, to be able to achieve higher stitching stability and quality of the final images at least being familiar with the theory is recommended (see Stitching pipline )."

update 2

If you haven't used openCV before, the first hurdle is to get the library compiled and installed into your project. Can be tricky, see my questions and answers here (getting openCV installed and working) and here (an example how to keep c++ code separate from objective-c, with sample github project).

When you have openCV working, this should be the quickest way to get started with your query:

Stitcher::stitch(InputArray images, OutputArray pano)

Parameters:
images – Input images.
pano – Final pano.

Then to speed it up - if you have them - provide regions of interest rects (indicating where photos overlap)

Stitcher::stitch(InputArray images, const std::vector<std::vector<Rect>>& rois, OutputArray pano)  

You can dig into the stitching pipeline to optimise many details of the process, but this should be enough to get you started.

If you look in the samples/cpp folder of the openCV distro, you will see a couple of stitching examples, stitching.cpp and stitching_detailed.cpp.

To provide the input images you will want to hook up with the camera and design a decent user interface to assist the user in taking the right kind of pictures (eg with good overlaps).

If you want to look at an existing project using openCV, here is one for android that claims to do what you are after - different platform, but the principles will be the same (using a java interface into the same libraries). Take a look especially at PanoActivity.java.

update 3
I've uploaded a very basic sample to github. I'm impressed how good a job it does, without any optimising or tweaking. It stitches the sample photos in my github project almost as well as the Autostitch app.

update 4 some time later... I've made a new sample project updated for use with Swift and Cocoapods

Community
  • 1
  • 1
foundry
  • 31,615
  • 9
  • 90
  • 125
  • These people are not so cooperative. Any other suggestions? – Idan Jan 02 '13 at 08:29
  • @Idan, how deep do you want to dive? Take a look at my updated answer... – foundry Jan 02 '13 at 14:41
  • The deepest you can. A ref to a sample app/code is the best thing I could wish for. I'm sure someone have done this before. – Idan Jan 02 '13 at 19:07
  • @Idan, see my second update for jumping-off points. – foundry Jan 04 '13 at 12:35
  • 1
    @Idan, I've posted a link to some sample code on github. Your bounty period is over, perhaps you should consider awarding it (and maybe accepting this answer, I think it's pretty comprehensive!) – foundry Jan 09 '13 at 18:38
  • Great demo man! Thanks a lot. It works great. I was able to dump my own images in there and get great results. – VaporwareWolf Oct 08 '13 at 07:29
  • @foundry i tried using the following three images in your xcode project and got error code 1 invalid image size 0x0 although the array is correctly formed with three images. [image1](http://postimg.org/image/b4gg5cdiv/), [image2](http://postimg.org/image/e13h5mjcn/), [image3](http://postimg.org/image/tlauw5th3/) – meteors May 26 '15 at 11:44
  • @meteors, the (only) error code from the openCV stitching module is ERR_NEED_MORE_IMGS. You will get this result if the images you send do not have enough data for openCV to find common features. Certainly there is nearly zero overlap between image2 and image3. It is also failing with (just) image1 and image2, so my advice is to experiment more with different subjects, and different amounts of overlap. – foundry May 26 '15 at 13:17
  • @foundry, I tried to take pictures in an application I built on top of your own and then put those through the stitching algorithm and a null image resulted. Then I tried to save my images at the same time to my camera roll and then manually include the files for the images much as you do for the pano_... images and it was able to stitch the images together. Do you know why it isn't able to stitch the images in application? [image1](https://www.flickr.com/photos/51044866@N04/18462648875/in/datetaken/) [image2](https://www.flickr.com/photos/51044866@N04/17839990884/in/datetaken/) – MichaelGofron Jun 04 '15 at 18:36
  • 1
    @jacks4jokers - I imagine you are the same person who raised [this issue](https://github.com/foundry/OpenCVStitch/issues/2) on github. I will have a little dig into this later today to see if i can work out what is going on. Thanks for your interest. – foundry Jun 04 '15 at 19:06
  • @foundry Indeed that was me. I forked your project and built an application on top of [it](https://github.com/MichaelGofron/OpenCVStitch). I can stitch images, it appears, if I put them in the file system and access them the way that you did. But I can't stitch the images if I try to store them in the file system during application run time and then pass those images as an array into the CVWrapper – MichaelGofron Jun 04 '15 at 19:10
  • @jacks4jokers - i've had a quick look at your code, and posted up some comments [here](https://github.com/foundry/OpenCVStitch/issues/2). – foundry Jun 05 '15 at 12:54
  • @foundry would you be able to elaborate a bit more on how to use the framework for sphere panoramic image creator? If this is a different topic, I will create a new question. Much appreciated and very grateful. – Septronic Jul 26 '15 at 16:54
  • @Septronic - playing with the 'warping' stage on the pipeline might be a way for you to get started. The sample code is already using the 'spherical' preset for warping input images. This is a big topic, so opening a new question could be worthwhile. – foundry Jul 26 '15 at 19:42
  • Thanks a lot @foundry, I totally agree. I will start a new question, and put the link to this question and your answers as well for others to refer to :) – Septronic Jul 29 '15 at 22:38