@Override public List<Frame> execute(CVParticle particle) throws Exception { List<Frame> result = new ArrayList<Frame>(); if (!(particle instanceof Frame)) return result; Frame frame = (Frame) particle; BufferedImage image = frame.getImage(); if (image == null) return result; if (image.getWidth() < 2 * cols || image.getHeight() < 2 * rows) return result; int width = image.getWidth() / cols; int height = image.getHeight() / rows; int tileIndex = 0; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { Rectangle box = new Rectangle(c * width, r * height, width + pixelOverlap, height + pixelOverlap); box = box.intersection(frame.getBoundingBox()); BufferedImage tile = image.getSubimage(box.x, box.y, box.width, box.height); byte[] buffer = ImageUtils.imageToBytes(tile, imageType); result.add( new Frame( frame.getStreamId() + "_" + tileIndex, frame.getSequenceNr(), imageType, buffer, frame.getTimestamp(), box)); tileIndex++; } } return result; }