1#ifndef BITSIM_SENSORS_DOWNWARD_CAMERA_H
2#define BITSIM_SENSORS_DOWNWARD_CAMERA_H
4#include "bitsim/bitsim_config.h"
9#include "bitsim/extern/nlohmann/json/json.hpp"
11#include <opencv2/core.hpp>
52 const std::function<
bool(
real_t,
real_t)> &is_ink, uchar paper = 235,
61 const cv::Mat &
image() const noexcept {
return image_; }
71 real_t height() const noexcept {
return metres_per_pixel_ * image_.rows; }
86 std::array<real_t, 2>
to_world(
const cv::Point2d &pixel)
const;
150 void read(
const nlohmann::json &j);
187 real_t min_share = 0.02)
const;
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
std::array< real_t, 2 > to_robot(real_t column, real_t row) const
Where a pixel of the camera's image is relative to the robot.
Definition downward_camera.cpp:135
std::vector< std::array< real_t, 2 > > line_points(const cv::Mat &view, uint_t n_bands=4, real_t dark_ratio=0.6, real_t min_share=0.02) const
Where a dark line crosses the camera's image: the image is cut into n_bands bands across the robot's ...
Definition downward_camera.cpp:143
cv::Mat view(const FloorImage &floor, real_t x, real_t y, real_t yaw) const
What the camera sees with the robot at (x, y) heading yaw.
Definition downward_camera.cpp:195
std::array< std::array< real_t, 2 >, 4 > footprint(real_t x, real_t y, real_t yaw) const
The corners of the floor the camera sees, in world coordinates: far left, far right,...
Definition downward_camera.cpp:180
const Config & config() const noexcept
Definition downward_camera.h:160
DownwardCamera()
A camera with the default Config.
Definition downward_camera.cpp:117
An image of the floor, centred on the world origin.
Definition downward_camera.h:31
real_t width() const noexcept
The width of the floor, along x [m].
Definition downward_camera.h:66
real_t reflectance(real_t x, real_t y) const
How bright the floor is at a point, from 0 for black to 1 for white: the brightness of the pixel ther...
Definition downward_camera.cpp:84
std::array< real_t, 2 > to_world(const cv::Point2d &pixel) const
The point of the floor at the given pixel, with fractions.
Definition downward_camera.cpp:78
real_t height() const noexcept
The height of the floor, along y [m].
Definition downward_camera.h:71
FloorImage(const cv::Mat &image, real_t width)
Constructor.
Definition downward_camera.cpp:18
static FloorImage draw(real_t width, real_t height, real_t metres_per_pixel, const std::function< bool(real_t, real_t)> &is_ink, uchar paper=235, uchar ink=25)
Draw a floor: a grey picture of width x height metres of paper, with ink wherever is_ink(x,...
Definition downward_camera.cpp:32
void write_texture(const std::string &path) const
Write the image as a colour PNG, for a texture: Irrlicht reads colour pictures more reliably than gre...
Definition downward_camera.cpp:54
cv::Point2d to_pixel(real_t x, real_t y) const
The pixel, with fractions, at the given point of the floor.
Definition downward_camera.cpp:71
real_t metres_per_pixel() const noexcept
The size of a pixel [m].
Definition downward_camera.h:76
const cv::Mat & image() const noexcept
Definition downward_camera.h:61
Definition infrared_line_follower.h:9
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
The camera's mounting and image.
Definition downward_camera.h:118
real_t update_rate
How many images the camera takes per second [1/s].
Definition downward_camera.h:145
uint_t image_height
Definition downward_camera.h:140
uint_t image_width
The size of the camera's image [pixels].
Definition downward_camera.h:139
real_t view_length
The length of the floor the camera sees along the robot's heading [m].
Definition downward_camera.h:129
void read(const nlohmann::json &j)
Read the values that the json gives.
Definition downward_camera.cpp:107
real_t offset
How far ahead of the reference point the centre of the view is [m].
Definition downward_camera.h:123
real_t view_width
The width of the floor the camera sees across the robot [m].
Definition downward_camera.h:134