virtual bool threadInit() override { p.open("/readWriteTest_writer"); image.resize(100, 100); image.zero(); return true; }
bool MapGrid2D::getMapImage(yarp::sig::ImageOf<PixelRgb>& image) const { image.setQuantum(1); image.resize(m_width, m_height); image.zero(); for (size_t y = 0; y < m_height; y++) { for (size_t x = 0; x < m_width; x++) { image.safePixel(x, y) = CellDataToPixel(m_map_flags.safePixel(x, y)); } } return true; }
void TestFrameGrabber::createTestImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image) { // to test IPreciselyTimed, make timestamps be mysteriously NNN.NNN42 double t = Time::now(); t -= ((t*1000)-(int)t)/1000; t+= 0.00042; stamp.update(t); if (background.width()>0) { image.copy(background); } else { image.zero(); image.resize(w,h); } switch (mode) { case VOCAB_BALL: { addCircle(image,PixelRgb(0,255,0),bx,by,15); addCircle(image,PixelRgb(0,255,255),bx,by,8); if (ct%5!=0) { rnd *= 65537; rnd += 17; bx += (rnd%5)-2; rnd *= 65537; rnd += 17; by += (rnd%5)-2; } else { int dx = w/2 - bx; int dy = h/2 - by; if (dx>0) { bx++; } if (dx<0) { bx--; } if (dy>0) { by++; } if (dy<0) { by--; } } } break; case VOCAB_GRID: { int ww = image.width(); int hh = image.height(); if (ww>1&&hh>1) { for (int x=0; x<ww; x++) { for (int y=0; y<hh; y++) { double xx = ((double)x)/(ww-1); double yy = ((double)y)/(hh-1); int r = int(0.5+255*xx); int g = int(0.5+255*yy); bool act = (y==ct); image.pixel(x,y) = PixelRgb(r,g,act*255); } } } } break; case VOCAB_LINE: default: { for (int i=0; i<image.width(); i++) { image.pixel(i,ct).r = 255; } } break; case VOCAB_RAND: { // from Alessandro Scalzo static unsigned char r=128,g=128,b=128; int ww = image.width(); int hh = image.height(); if (ww>1&&hh>1) { for (int x=0; x<ww; x++) { for (int y=0; y<hh; y++) { //r+=(rand()%3)-1; //g+=(rand()%3)-1; //b+=(rand()%3)-1; r += Random::uniform(-1,1); g += Random::uniform(-1,1); b += Random::uniform(-1,1); image.pixel(x,y) = PixelRgb(r,g,b); } } } } break; case VOCAB_NONE: break; } ct++; if (ct>=image.height()) { ct = 0; } if (by>=image.height()) { by = image.height()-1; } if (bx>=image.width()) { bx = image.width()-1; } if (bx<0) bx = 0; if (by<0) by = 0; }