mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
9
ccv/sheet2/CMakeLists.txt
Normal file
9
ccv/sheet2/CMakeLists.txt
Normal file
@ -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})
|
||||||
37
ccv/sheet2/main.cpp
Normal file
37
ccv/sheet2/main.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// exercise 1
|
||||||
|
cv::Mat M = (cv::Mat_<uchar>(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<uchar>(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<int>(M.at<uchar>(row, col));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << std::endl << std::endl;
|
||||||
|
//exercise 4
|
||||||
|
cv::Mat K(M);
|
||||||
|
K.at<uchar>(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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user