From cc1084ec77ab38fda2c15b846e288ab3be7a9043 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 11 Apr 2017 15:03:23 +0200 Subject: [PATCH] [CCV] Finished sheet2 Signed-off-by: Jim Martens --- ccv/sheet2/CMakeLists.txt | 9 +++++++++ ccv/sheet2/main.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 ccv/sheet2/CMakeLists.txt create mode 100644 ccv/sheet2/main.cpp diff --git a/ccv/sheet2/CMakeLists.txt b/ccv/sheet2/CMakeLists.txt new file mode 100644 index 0000000..54c2e03 --- /dev/null +++ b/ccv/sheet2/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) +project(sheet2) + +set(CMAKE_CXX_STANDARD 11) + +find_package( OpenCV REQUIRED ) + +add_executable(sheet2 main.cpp) +target_link_libraries(sheet2 ${OpenCV_LIBS}) diff --git a/ccv/sheet2/main.cpp b/ccv/sheet2/main.cpp new file mode 100644 index 0000000..2a05e48 --- /dev/null +++ b/ccv/sheet2/main.cpp @@ -0,0 +1,37 @@ +#include +#include + +int main() +{ + // exercise 1 + cv::Mat M = (cv::Mat_(4, 4) << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); + std::cout << M << std::endl << std::endl; + // exercise 2 + M.at(1, 2) = 100; + std::cout << M << std::endl << std::endl; + // exercise 3 + std::cout << "The elements of the matrix: "; + for (int row = 0; row < M.rows; ++row) + { + for (int col = 0; col < M.cols; ++col) + { + if (row != 0 || col != 0) + { + std::cout << ","; + } + std::cout << " " << static_cast(M.at(row, col)); + } + } + std::cout << std::endl << std::endl; + //exercise 4 + cv::Mat K(M); + K.at(1, 2) = 200; + std::cout << "M: " << M << std::endl << "K: " << K << std::endl << std::endl; + //exercise 5 + cv::Mat B = cv::Mat(400, 400, CV_8UC3, cv::Scalar(255, 0, 0)); + cv::namedWindow("Display Image", cv::WINDOW_FULLSCREEN); + cv::imshow("Display Image", B); + cv::waitKey(0); + return 0; +} +