42 for (
int i=0; i<=m_w; i+=m_w/10) {
47 std::uniform_real_distribution<double> udist1(-m_w/4,m_w/4);
48 std::uniform_real_distribution<double> udist2(-
int(m_h*0.2),rr);
49 for (
int j=0; j<40; j++) {
55 m_x = (back.
width()-this->m_w)/2;
56 m_y = (back.
height()-this->m_h)/2;
59 std::normal_distribution<double> ndist(0,255);
60 for (
int & rnd : rnds) {
66 m_tx = back.
width()/2;
77 x += (int)(rnds[idx]*f);
85 ch = (
unsigned char) x;
90 std::string backFile = config.
check(
"background",
Value(
"textures/back.ppm"),
91 "background image to use").asString();
95 std::string foreFile = config.
check(
"target",
Value(
"textures/fore.ppm"),
96 "target image to use").asString();
100 noiseLevel = config.
check(
"noise",
Value(0.05),
101 "pixel noise level").asFloat64();
104 "scaling for x coordinate").asFloat64();
106 "scaling for y coordinate").asFloat64();
108 lifetime = config.
check(
"lifetime",
Value(-1.0),
109 "device should exist for this length of time (in seconds)").asFloat64();
119 if (fabs(dpos[0])>0.001||fabs(dpos[0])>0.001) {
120 pos[0] = m_dx+dpos[0];
122 pos[1] = m_dy+dpos[1];
129 double dx = (xx-m_dx)*5;
130 double dy = (yy-m_dy)*5;
133 if (m_tdx>0 && m_tx>back.
width()*0.75) {
136 if (m_tdx<0 && m_tx<back.
width()*0.25) {
152 double m_dx_scaled = m_dx*xScale;
153 double m_dy_scaled = m_dy*yScale;
155 int x0 = int(x+m_x+m_dx_scaled*0.5+0.5);
156 int y0 = int(y+m_y+m_dy_scaled*0.5+0.5);
159 if (fore.
isPixel(
int(x0-m_tx),
int(y0-m_ty))) {
160 PixelRgb& pix = fore(
int(x0-m_tx),
int(y0-m_ty));
161 if (pix.
r<200||pix.
g>100||pix.
b>100) {
168 auto f = (float)(noiseLevel);
const yarp::os::LogComponent & FAKEBOT()
void scramble(unsigned char &ch, float f)
#define IMGFOR(img, i, j)
std::default_random_engine randengine
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an image from the frame grabber.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void run() override
Main body of the new thread.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
bool start()
Start the new thread running.
A single value (typically within a Bottle).
T & safePixel(size_t x, size_t y)
size_t width() const
Gets width of image in pixels.
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
bool isPixel(size_t x, size_t y) const
Check whether a coordinate lies within the image.
void zero()
Set all pixels to 0.
size_t height() const
Gets height of image in pixels.
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)