-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobot_lab3.cpp
More file actions
58 lines (44 loc) · 1.12 KB
/
Copy pathrobot_lab3.cpp
File metadata and controls
58 lines (44 loc) · 1.12 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "robot_lab3.h"
CRobot_3::CRobot_3()
{
}
CRobot_3::~CRobot_3()
{
}
void CRobot_3::create()
{
//Offsets to create robot box
vector<Point2f> translate = { Point2f(0, 0), Point2f(0, 0.05), Point2f(0.05, 0.1), Point2f(-0.05, 0.1), Point2f(0, 0.15) };
//Colors of diff boxes
vector<Scalar> colors = { RED, RED, GREEN, BLUE, RED };
for (int i = 0; i < translate.size(); i++)
{
//First create box normally
box _box;
_box.shape = createBox(0.05, 0.05, 0.05);
_box.color = colors[i];
//Translate each box
transformPoints(_box.shape, extrinsic(0, 0, 0, translate[i].x, translate[i].y + 0.025));
//Add it to robot
_simple_robot.push_back(_box);
}
}
void CRobot_3::draw()
{
//Reset canvas
_canvas = cv::Mat::zeros(_image_size, CV_8UC3) + CV_RGB(60, 60, 60);
//Apply camera angles
_virtualcam.update_settings(_canvas);
//Create base coordinate for worldview
std::vector<Mat> O = createCoord();
drawCoord(_canvas, O);
//Draw robot
for (auto x : _simple_robot)
{
drawBox(_canvas, x.shape, x.color);
}
//Update trackbars
cvui::update();
//Show final product
cv::imshow(CANVAS_NAME, _canvas);
}