forked from fanweng/Udacity-Sensor-Fusion-Nanodegree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_matrix.cpp
42 lines (34 loc) · 1.19 KB
/
create_matrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
void createMatrix1()
{
// create matrix
int nrows = 480, ncols = 640;
cv::Mat m1_8u;
m1_8u.create(nrows, ncols, CV_8UC1); // two-channel matrix with 8bit unsigned elements
m1_8u.setTo(cv::Scalar(255)); // white
// STUDENT TASK :
// Create a variable of type cv::Mat* named m3_8u which has three channels with a
// depth of 8bit per channel. Then, set the first channel to 255 and display the result.
cv::Mat m3_8u;
m3_8u.create(nrows, ncols, CV_8UC3);
m3_8u.setTo(cv::Scalar(255, 0, 0));
// show result
string windowName = "First steps in OpenCV (m1_8u)";
cv::namedWindow(windowName, 1); // create window
cv::imshow(windowName, m1_8u);
cv::waitKey(0); // wait for keyboard input before continuing
// STUDENT TASK :
// Display the results from the STUDENT TASK above
string windowName2 = "First steps in OpenCV (m3_8u)";
cv::namedWindow(windowName2, 1); // create window
cv::imshow(windowName2, m3_8u);
cv::waitKey(0); // wait for keyboard input before continuing
}
int main()
{
createMatrix1();
return 0;
}