Before see this docs, check below docs
Detailed Description part of OpenCV's official docs
Previous docs
Simply call stitch
Estimation and compose
In previous example,
- calculate camera parameters with estimateTransform
- compose images to panorama image with camera parameter
Stitcher::Status status = stitcher->estimateTransform(imgs);
///checking error
stitcher->composePanorama(output);In this example, Let's check how they store camera parameters in structure
Stitcher::Status status = stitcher->estimateTransform(imgs);
///checking error
vector<detail::CameraParams> cameras = stitcher->cameras();
for(int i = 0; i < imgs.size(); i++)
{
DEBUG_PRINT_OUT("----Image index " << i << " camera parameters----");
DEBUG_PRINT_OUT("Camera intrinsic matrix");
DEBUG_PRINT_OUT(cameras[i].K());
DEBUG_PRINT_OUT("Focal length : " << cameras[i].focal);
DEBUG_PRINT_OUT("Aspect ratio : " << cameras[i].aspect);
DEBUG_PRINT_OUT("Principle Point X : " << cameras[i].ppx);
DEBUG_PRINT_OUT("Principle Point Y : " << cameras[i].ppy);
DEBUG_PRINT_OUT("Rotation matrix");
DEBUG_PRINT_OUT(cameras[i].R);
DEBUG_PRINT_OUT("Translation matrix");
DEBUG_PRINT_OUT(cameras[i].t);
DEBUG_PRINT_OUT(" ");
}Call cameras getter from Stitcher API, You can get camera parameters
vector<detail::CameraParams> cameras = stitcher->cameras();Definition of this structure is in OpenCV's stitcher moduls's detail
"include/opencv2/stitching/detail/camera.hpp"
struct CV_EXPORTS CameraParams
{
CameraParams();
CameraParams(const CameraParams& other);
const CameraParams& operator =(const CameraParams& other);
Mat K() const;
double focal; // Focal length
double aspect; // Aspect ratio
double ppx; // Principal point X
double ppy; // Principal point Y
Mat R; // Rotation
Mat t; // Translation
};- K matrix
camera's intrinsic matrix, include Focal length and Principle point - focal
Focal length - aspect
Scale factor - ppx and ppy
Principle point - R matrix
Rotation matrix - t matrix
Translation matrix
With these informations, You can do another work that camera parmameter related.
With this repo's sample images
----Image index 0 camera parameters----
Camera intrinsic matrix
[709.650348798485, 0, 447;
0, 709.650348798485, 335.5;
0, 0, 1]
Focal length : 709.65
Aspect ratio : 1
Principle Point X : 447
Principle Point Y : 335.5
Rotation matrix
[0.93108684, 0.035384167, -0.36307758;
0.0001988858, 0.99523526, 0.097501867;
0.36479765, -0.090854913, 0.92664331]
Translation matrix
[0;
0;
0]
----Image index 1 camera parameters----
Camera intrinsic matrix
[719.9602633448541, 0, 447;
0, 719.9602633448541, 335.5;
0, 0, 1]
Focal length : 719.96
Aspect ratio : 1
Principle Point X : 447
Principle Point Y : 335.5
Rotation matrix
[0.99949676, 0.0036283, -0.031512056;
-0.00032901776, 0.99456888, 0.10407893;
0.031718541, -0.10401618, 0.99406964]
Translation matrix
[0;
0;
0]
----Image index 2 camera parameters----
Camera intrinsic matrix
[743.4787164662755, 0, 447;
0, 743.4787164662755, 335.5;
0, 0, 1]
Focal length : 743.479
Aspect ratio : 1
Principle Point X : 447
Principle Point Y : 335.5
Rotation matrix
[0.91788989, -0.042156182, 0.39458963;
0.00015651435, 0.99437976, 0.10587097;
-0.39683512, -0.09711612, 0.91273779]
Translation matrix
[0;
0;
0]
