Panorama is an interesting subject in application development. In OpenCV, the stitching module can easily create a panorama image from a sequence of images. One benefit of the stitching module is that the sequence of images don't have to be in order and can be in any direction. However, in the OpenCV Android SDK, the stitching module does not exist. Therefore, we must use the stitching module in the C++ interface. Luckily, Android provides the Native Development Kit (NDK) to support native development in C/C++. In this chapter, we will guide you through the steps to capture camera frames from Java and process the data in OpenCV C++ with the NDK.
In this chapter, you will learn:
A panorama image gives the viewer a much broader field of view than a normal image and allows them to fully experience a scene. By extending the range of panorama to 360 degrees, viewers can simulate turning their head around. A panorama image can be created by stitching a sequence of overlapping images.
The following figure shows a demonstration of a panorama image captured with our application.
In order to capture a panorama image, you must capture many images of the scene at different angles, as in the following figure. For example, you take your first picture at the left side of the room. Then, you move the phone straight to a new angle to start capturing. All the images will be stitched together to create a panorama image.
Normally, a panorama application only supports capturing images in horizontal. With the stitching module in OpenCV, we can extend the height of an image by capturing more images in both directions. The following figure shows an image that can be captured by changing the camera view in a horizontal and vertical direction.
In this chapter, we will implement a panorama application in Android using OpenCV 3.0.0. The chapter contains two main sections:
In the following sections, we will show the process to create a user interface in Android Studio. If you want to review the OpenCV code, you can go to the Integrating OpenCV into the Android Studio section and come back to this later.