void testExternalRepeat() { report(0,"checking that setExternal can be called multiple times..."); unsigned char buf[EXT_HEIGHT*EXT_WIDTH*3]; unsigned char buf2[EXT_HEIGHT*2*EXT_WIDTH*2*3]; ImageOf<PixelRgb> img; img.setExternal(&buf[0],EXT_WIDTH,EXT_HEIGHT); checkEqual(img.width(),EXT_WIDTH,"width check"); checkEqual(img.height(),EXT_HEIGHT,"height check"); img.setExternal(&buf2[0],EXT_WIDTH*2,EXT_HEIGHT*2); checkEqual(img.width(),EXT_WIDTH*2,"width check"); checkEqual(img.height(),EXT_HEIGHT*2,"height check"); }
bool BayerCarrier::processDirect(const yarp::os::Bytes& bytes) { if (have_result) { memcpy(bytes.get(),out.getRawImage(),bytes.length()); return true; } //printf("Copyless conversion\n"); ImageOf<PixelRgb> wrap; wrap.setQuantum(out.getQuantum()); wrap.setExternal(bytes.get(),out.width(),out.height()); if (half) { debayerHalf(in,wrap); } else { debayerFull(in,wrap); } return true; }
void ArmarxFrameGrabber::process() { if(!waitForImages()) { ARMARX_WARNING << "Timeout or error in wait for images" << armarx::flush; } else { // poll images int nNumberImages = getImages(m_ppImages); for(int i = 0 ; i < nNumberImages ; i++) { //m_ImageFormat.dimension.width, m_ImageFormat.dimension.height; ImageOf<PixelRgb>& out = m_imagePorts[i].prepare(); ImageOf<PixelRgb> ext; CByteImage& img = *m_ppImages[i]; ext.setExternal(img.pixels, img.width, img.height); out.copy(ext); // this could be avoided with a little more work m_imagePorts[i].write(); } } }
bool OdeSdlSimulation::getImage(ImageOf<PixelRgb>& target) { int w = cameraSizeWidth; int h = cameraSizeHeight; int p = 3; char *buf=new char[w * h * p]; glReadPixels( 0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buf); ImageOf<PixelRgb> img; img.setQuantum(1); img.setExternal(buf,w,h); // inefficient flip! target.resize(img); int ww = img.width(); int hh = img.height(); for (int x=0; x<ww; x++) { for (int y=0; y<hh; y++) { target(x,y) = img(x,hh-1-y); } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); delete[] buf; return true; }
void RGBDSensorWrapper::shallowCopyImages(const ImageOf<PixelFloat>& src, ImageOf<PixelFloat>& dest) { dest.setQuantum(src.getQuantum()); dest.setExternal(src.getRawImage(), src.width(), src.height()); }