Difference between revisions of "OpenCV/Basics/MatrixInverse"

From ProgrammingExamples
Jump to: navigation, search
(Created page with '==MatrixInverse.cxx== <source lang="cpp"> #include "cv.h" #include <iostream> int main() { cv::Mat A(3,3,CV_32FC1); for(unsigned int i = 0; i < 3; i++) { for(unsig…')
 
m
 
(One intermediate revision by the same user not shown)
Line 41: Line 41:
  
 
ADD_EXECUTABLE(MatrixInverse MatrixInverse.cxx)
 
ADD_EXECUTABLE(MatrixInverse MatrixInverse.cxx)
TARGET_LINK_LIBRARIES(MatrixInverse opencv_core opencv_highgui
+
TARGET_LINK_LIBRARIES(MatrixInverse ${OpenCV_LIBS})
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
+
          opencv_features2d opencv_calib3d opencv_legacy opencv_contrib
+
)
+
  
 
</source>
 
</source>

Latest revision as of 16:46, 21 January 2011

MatrixInverse.cxx

#include "cv.h"
 
#include <iostream>
 
int main()
{
  cv::Mat A(3,3,CV_32FC1);
 
  for(unsigned int i = 0; i < 3; i++)
    {
    for(unsigned int j = 0; j < 3; j++)
      {
      A.at<float>(i,j) = 2;
      }
    }
 
  cv::Mat inverted(3,3,CV_32FC1);
  inverted = A;
  inverted.inv();
 
  std::cout << "A: " << A << std::endl;
 
  std::cout << "inverted: " << inverted << std::endl;
 
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
PROJECT(MatrixInverse)
 
FIND_PACKAGE(OpenCV REQUIRED )
INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} )
 
ADD_EXECUTABLE(MatrixInverse MatrixInverse.cxx)
TARGET_LINK_LIBRARIES(MatrixInverse ${OpenCV_LIBS})