-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
24 lines (20 loc) · 841 Bytes
/
Camera.cpp
File metadata and controls
24 lines (20 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "Camera.hpp"
#include <iostream>
Camera::Camera(std::string picture_path, int& alpha)
{
_global_area = cv::imread(picture_path, 1);
_scope = (_global_area.rows>_global_area.cols) ? _global_area.rows : _global_area.cols;
_scope = _scope/(2*alpha);
std::cout << _global_area.rows << " " << _global_area.cols << " "<<_scope << std::endl;
}
void Camera::take_photo( Position pos, std::string save_path) {
// Create photo scope
int x = ((pos.longitude - _scope) > 0) ? pos.longitude : 0;
int y = ((pos.latitude - _scope) > 0) ? pos.latitude : 0;
int width = 10*_scope, height=10*_scope;
std::cout << x << " " << y << " "<< width << " " << height << std::endl;
// take photo
cv::Mat photo(_global_area, cv::Rect(x, y, width, height));
// save photo
cv::imwrite(save_path, photo);
}