mirror of https://github.com/2martens/uni.git
[CCV] Finished sheet2
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
parent
27b11b6a01
commit
cc1084ec77
|
@ -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})
|
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue