Difference between revisions of "OpenCV/CommonTasks/DecomposeProjectionMatrix"
From ProgrammingExamples
< OpenCV
Daviddoria (Talk | contribs) (Created page with '==DecomposeProjectionMatrix.cxx== <source lang="cpp"> #include <cv.h> #include <highgui.h> #include <iostream> int main(int argc, char*argv[]) { // Create a synthetic project…') |
(No difference)
|
Revision as of 10:20, 21 January 2011
DecomposeProjectionMatrix.cxx
#include <cv.h> #include <highgui.h> #include <iostream> int main(int argc, char*argv[]) { // Create a synthetic projection matrix cv::Mat P(3,4,CV_32FC1); P.at<float>(0,0) = 1; P.at<float>(1,0) = 0; P.at<float>(2,0) = 0; P.at<float>(0,1) = 0; P.at<float>(1,1) = 1; P.at<float>(2,1) = 0; P.at<float>(0,2) = 5; P.at<float>(1,2) = 4; P.at<float>(2,2) = 1; P.at<float>(0,3) = 1; P.at<float>(1,3) = 2; P.at<float>(2,3) = 3; std::cout << "P: " << P << std::endl; // Decompose the projection matrix into: cv::Mat K(3,3,CV_32FC1); // intrinsic parameter matrix cv::Mat R(3,3,CV_32FC1); // rotation matrix cv::Mat T(4,1,CV_32FC1); // translation vector cv::decomposeProjectionMatrix(P, K, R, T); std::cout << "K: " << K << std::endl; std::cout << "R: " << R << std::endl; std::cout << "T: " << T << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(DecomposeProjectionMatrix) FIND_PACKAGE( OpenCV REQUIRED ) INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} ) ADD_EXECUTABLE(DecomposeProjectionMatrix DecomposeProjectionMatrix.cxx) TARGET_LINK_LIBRARIES(DecomposeProjectionMatrix ${OPENCV_LIBRARIES} opencv_core opencv_highgui opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_calib3d opencv_legacy opencv_contrib )