|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
30 void FakeBot::init() {
45 for (
int i=0; i<=m_w; i+=m_w/10) {
50 std::uniform_real_distribution<double> udist1(-m_w/4,m_w/4);
51 std::uniform_real_distribution<double> udist2(-
int(m_h*0.2),rr);
52 for (
int j=0; j<40; j++) {
58 m_x = (back.width()-this->m_w)/2;
59 m_y = (back.height()-this->m_h)/2;
62 std::normal_distribution<double> ndist(0,255);
63 for (
int & rnd : rnds) {
69 m_tx = back.width()/2;
70 m_ty = back.height()*0.4;
80 x += (int)(rnds[idx]*f);
84 ch = (
unsigned char) x;
89 std::string backFile = config.
check(
"background",
Value(
"textures/back.ppm"),
90 "background image to use").asString();
94 std::string foreFile = config.
check(
"target",
Value(
"textures/fore.ppm"),
95 "target image to use").asString();
100 "pixel noise level").asFloat64();
103 "scaling for x coordinate").asFloat64();
105 "scaling for y coordinate").asFloat64();
107 lifetime = config.
check(
"lifetime",
Value(-1.0),
108 "device should exist for this length of time (in seconds)").asFloat64();
118 if (fabs(dpos[0])>0.001||fabs(dpos[0])>0.001) {
119 pos[0] = m_dx+dpos[0];
121 pos[1] = m_dy+dpos[1];
128 double dx = (xx-m_dx)*5;
129 double dy = (yy-m_dy)*5;
132 if (m_tdx>0 && m_tx>back.width()*0.75) {
135 if (m_tdx<0 && m_tx<back.width()*0.25) {
146 image.resize(m_w,m_h);
151 double m_dx_scaled = m_dx*xScale;
152 double m_dy_scaled = m_dy*yScale;
154 int x0 = int(x+m_x+m_dx_scaled*0.5+0.5);
155 int y0 = int(y+m_y+m_dy_scaled*0.5+0.5);
158 if (fore.isPixel(
int(x0-m_tx),
int(y0-m_ty))) {
159 PixelRgb& pix = fore(
int(x0-m_tx),
int(y0-m_ty));
160 if (pix.
r<200||pix.
g>100||pix.
b>100) {
167 auto f = (float)(noiseLevel);
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
A base class for nested structures that can be searched.
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
std::default_random_engine randengine
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
T & safePixel(size_t x, size_t y)
void run() override
Main body of the new thread.
#define IMGFOR(img, i, j)
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
Very basic drawing functions, in case you don't have anything better available.
An interface to the operating system, including Port based communication.
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
const yarp::os::LogComponent & FAKEBOT()
A single value (typically within a Bottle).
void delay(double seconds)
Wait for a certain number of seconds.
void scramble(unsigned char &ch, float f)