@Override public int getNextHeight() { return image.getWidth(); }
@Override public int getNextWidth() { return image.getWidth(); }
@Override public int getNextWidth() { return image.getWidth(); }
public int getWidth() { if( sequence == null ) return queueBoof[selected].getWidth(); return sequence.getNextWidth(); }
@Override public int getWidth() { return image.getImage().getWidth(); }
@Override public int getWidth() { return image.getImage().getWidth(); }
/** * If null the dst is declared, otherwise it checks to see if the 'dst' as the same shape as 'src'. * * The returned image will be 8-bit RGB */ private static BufferedImage checkInputs(ImageBase src, BufferedImage dst) { if (dst != null) { if (dst.getWidth() != src.getWidth() || dst.getHeight() != src.getHeight()) { throw new IllegalArgumentException("image dimension are different"); } } else { dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB); } return dst; }
/** * If null the dst is declared, otherwise it checks to see if the 'dst' as the same shape as 'src'. * * The returned image will be 8-bit RGB */ private static BufferedImage checkInputs(ImageBase src, BufferedImage dst) { if (dst != null) { if (dst.getWidth() != src.getWidth() || dst.getHeight() != src.getHeight()) { throw new IllegalArgumentException("image dimension are different. src=" +src.width+"x"+src.height+" dst="+dst.getWidth()+"x"+dst.getHeight()); } } else { dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB); } return dst; }
/** * If null the dst is declared, otherwise it checks to see if the 'dst' as the same shape as 'src'. */ public static BufferedImage checkInputs(ImageBase src, BufferedImage dst) { if (dst != null) { if (dst.getWidth() != src.getWidth() || dst.getHeight() != src.getHeight()) { throw new IllegalArgumentException("image dimension are different"); } } else { if( GrayI8.class.isInstance(src)) dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_GRAY); else if( GrayF.class.isInstance(src) ) // no good equivalent. Just assume the image is a regular gray scale image // with pixel values from 0 to 255 dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_GRAY); // throw new RuntimeException("Fail!"); else if( GrayI.class.isInstance(src)) // no good equivalent. I'm giving it the biggest pixel for the range dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_USHORT_GRAY); else dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB); } return dst; }
/** * Renders the bitmap image to output. If you don't wish to have this behavior then override this function. * Jsut make sure you respect the bitmap mode or the image might not render as desired or you could crash the app. */ protected void renderBitmapImage( BitmapMode mode , ImageBase image ) { switch( mode ) { case UNSAFE: { if (image.getWidth() == bitmap.getWidth() && image.getHeight() == bitmap.getHeight()) ConvertBitmap.boofToBitmap(image, bitmap, bitmapTmp); } break; case DOUBLE_BUFFER: { // TODO if there are multiple processing threads bad stuff will happen here. Need one work buffer // per thread // convert the image. this can be a slow operation if (image.getWidth() == bitmapWork.getWidth() && image.getHeight() == bitmapWork.getHeight()) ConvertBitmap.boofToBitmap(image, bitmapWork, bitmapTmp); // swap the two buffers. If it's locked don't swap. This will skip a frame but will not cause // a significant slow down if( bitmapLock.tryLock() ) { try { Bitmap tmp = bitmapWork; bitmapWork = bitmap; bitmap = tmp; } finally { bitmapLock.unlock(); } } } break; } }
public void run() { gui.setPreferredSize(new Dimension(color.getWidth(), color.getHeight())); gui.setImage(input); gui.revalidate(); processImage = true; } });
int width = image.getWidth() / scalefactor; int height = image.getHeight() / scalefactor;
@Override protected void handleInputChange(int source, InputMethod method, int width, int height) { super.handleInputChange(source, method, width, height); if( inputCopy.getWidth() != width || inputCopy.getHeight() != height ) { panelImage.setPreferredSize(new Dimension(width,height)); distortImage.setModel(distorter); // let it know the transform has changed } distorter.setEquirectangularShape(width, height); }
@Override public synchronized void processImage(int sourceID, long frameID, final BufferedImage buffered, ImageBase input) { if( buffered != null ) { original = ConvertBufferedImage.checkCopy(buffered,original); work = ConvertBufferedImage.checkDeclare(buffered,work); binary.reshape(input.getWidth(), input.getHeight()); filtered.reshape(input.getWidth(),input.getHeight()); inputPrev.setTo((GrayU8)input); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Dimension d = gui.getPreferredSize(); if( d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight() ) { gui.setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight())); } }}); } else { input = inputPrev; } process((GrayU8)input); }
@Override public void processImage(int sourceID, long frameID, final BufferedImage buffered, ImageBase gray) { this.input = buffered; synchronized ( this ) { binary = ConvertBufferedImage.checkDeclare(gray.getWidth(), gray.getHeight(), binary, BufferedImage.TYPE_INT_RGB); grayPrev.setTo((GrayF32)gray); } try { processFrame(); } catch( RuntimeException e ) { e.printStackTrace(); UtilImageIO.saveImage(buffered,"crash_image.png"); } if( controlPanel instanceof DetectCalibrationPolygonPanel ) { DetectCalibrationPolygonPanel c = (DetectCalibrationPolygonPanel)controlPanel; c.polygonPanel.getThresholdPanel().updateHistogram(grayPrev); } else { if( controlPanel.threshold != null ) controlPanel.threshold.updateHistogram(grayPrev); } }
@Override public void process(T input ) { if( periodX <= 0 || periodY <= 0 ) throw new IllegalArgumentException("Must call configure() first"); alg.setImage(input); int x0 = featureWidth/2; int x1 = input.getWidth()-featureWidth/2; int y0 = featureWidth/2; int y1 = input.getHeight()-featureWidth/2; descriptions.reset(); locations.reset(); for (int y = y0; y < y1; y += periodY ) { for (int x = x0; x < x1; x += periodX ) { Desc d = descriptions.grow(); if( !alg.process(x,y,0,radius,d) ) { descriptions.removeTail(); } else { locations.grow().set(x,y); } } } }