forked from cyberbotics/webots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
164 lines (126 loc) · 4.47 KB
/
Camera.cpp
File metadata and controls
164 lines (126 loc) · 4.47 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 1996-2023 Cyberbotics Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#define WB_ALLOW_MIXING_C_AND_CPP_API
#include <webots/camera.h>
#include <webots/Camera.hpp>
using namespace std;
using namespace webots;
void Camera::enable(int sampling_period) {
wb_camera_enable(getTag(), sampling_period);
}
void Camera::disable() {
wb_camera_disable(getTag());
}
int Camera::getSamplingPeriod() const {
return wb_camera_get_sampling_period(getTag());
}
const unsigned char *Camera::getImage() const {
return wb_camera_get_image(getTag());
}
unsigned char Camera::imageGetRed(const unsigned char *image, int width, int x, int y) {
return wb_camera_image_get_red(image, width, x, y);
}
unsigned char Camera::imageGetGreen(const unsigned char *image, int width, int x, int y) {
return wb_camera_image_get_green(image, width, x, y);
}
unsigned char Camera::imageGetBlue(const unsigned char *image, int width, int x, int y) {
return wb_camera_image_get_blue(image, width, x, y);
}
unsigned char Camera::imageGetGray(const unsigned char *image, int width, int x, int y) {
return wb_camera_image_get_gray(image, width, x, y);
}
unsigned char Camera::imageGetGrey(const unsigned char *image, int width, int x, int y) {
return wb_camera_image_get_grey(image, width, x, y);
}
int Camera::getWidth() const {
return wb_camera_get_width(getTag());
}
int Camera::getHeight() const {
return wb_camera_get_height(getTag());
}
double Camera::getFov() const {
return wb_camera_get_fov(getTag());
}
double Camera::getMaxFov() const {
return wb_camera_get_max_fov(getTag());
}
double Camera::getMinFov() const {
return wb_camera_get_min_fov(getTag());
}
void Camera::setFov(double fov) {
wb_camera_set_fov(getTag(), fov);
}
double Camera::getExposure() const {
return wb_camera_get_exposure(getTag());
}
void Camera::setExposure(double exposure) {
wb_camera_set_exposure(getTag(), exposure);
}
double Camera::getFocalLength() const {
return wb_camera_get_focal_length(getTag());
}
double Camera::getFocalDistance() const {
return wb_camera_get_focal_distance(getTag());
}
double Camera::getMaxFocalDistance() const {
return wb_camera_get_max_focal_distance(getTag());
}
double Camera::getMinFocalDistance() const {
return wb_camera_get_min_focal_distance(getTag());
}
void Camera::setFocalDistance(double focalDistance) {
wb_camera_set_focal_distance(getTag(), focalDistance);
}
double Camera::getNear() const {
return wb_camera_get_near(getTag());
}
int Camera::saveImage(const string &filename, int quality) const {
return wb_camera_save_image(getTag(), filename.c_str(), quality);
}
bool Camera::hasRecognition() const {
return wb_camera_has_recognition(getTag());
}
void Camera::recognitionEnable(int samplingPeriod) {
wb_camera_recognition_enable(getTag(), samplingPeriod);
}
void Camera::recognitionDisable() {
wb_camera_recognition_disable(getTag());
}
int Camera::getRecognitionSamplingPeriod() const {
return wb_camera_recognition_get_sampling_period(getTag());
}
int Camera::getRecognitionNumberOfObjects() const {
return wb_camera_recognition_get_number_of_objects(getTag());
}
const CameraRecognitionObject *Camera::getRecognitionObjects() const {
return wb_camera_recognition_get_objects(getTag());
}
bool Camera::hasRecognitionSegmentation() const {
return wb_camera_recognition_has_segmentation(getTag());
}
void Camera::enableRecognitionSegmentation() {
wb_camera_recognition_enable_segmentation(getTag());
}
void Camera::disableRecognitionSegmentation() {
wb_camera_recognition_disable_segmentation(getTag());
}
bool Camera::isRecognitionSegmentationEnabled() const {
return wb_camera_recognition_is_segmentation_enabled(getTag());
}
const unsigned char *Camera::getRecognitionSegmentationImage() const {
return wb_camera_recognition_get_segmentation_image(getTag());
}
int Camera::saveRecognitionSegmentationImage(const string &filename, int quality) const {
return wb_camera_recognition_save_segmentation_image(getTag(), filename.c_str(), quality);
}