Difference between revisions of "OpenCV/Basics/MatrixMultiplication"
From ProgrammingExamples
< OpenCV
Daviddoria (Talk | contribs) (Created page with '==MatrixMultiplication.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…') |
Daviddoria (Talk | contribs) m |
||
Line 50: | Line 50: | ||
ADD_EXECUTABLE(MatrixMultiplication MatrixMultiplication.cxx) | ADD_EXECUTABLE(MatrixMultiplication MatrixMultiplication.cxx) | ||
− | TARGET_LINK_LIBRARIES(MatrixMultiplication | + | TARGET_LINK_LIBRARIES(MatrixMultiplication ${OpenCV_LIBS}) |
− | + | ||
− | + | ||
− | ) | + | |
</source> | </source> |
Latest revision as of 16:46, 21 January 2011
MatrixMultiplication.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) = 1; } } std::cout << "A: " << A << std::endl; cv::Mat B(3,3,CV_32FC1); for(unsigned int i = 0; i < 3; i++) { for(unsigned int j = 0; j < 3; j++) { B.at<float>(i,j) = 2; } } std::cout << "B: " << B << std::endl; cv::Mat result = A * B; std::cout << "result: " << result << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(MatrixMultiplication) FIND_PACKAGE(OpenCV REQUIRED ) INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} ) ADD_EXECUTABLE(MatrixMultiplication MatrixMultiplication.cxx) TARGET_LINK_LIBRARIES(MatrixMultiplication ${OpenCV_LIBS})