@Override public void reset() { background.reshape(1,1); }
@Override public void reset() { background.reshape(1,1); }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedU8} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedU8 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS8} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedS8 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedF64} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedF64 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedU16} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedU16 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
public static InterleavedF32 yuvToInterleavedRgbF32(ByteBuffer bufferY, ByteBuffer bufferU , ByteBuffer bufferV , int width, int height, int strideY , int strideUV , int stridePixelUV, InterleavedF32 output , byte work[] ) { if( output != null ) { output.reshape(width,height,3); } else { output = new InterleavedF32(width,height,3); } InterleavedF32 _output = output; ProcessorYuv processor = new ProcessorYuvRgb() { int indexOut = 0; @Override public void processRGB( final int r , final int g , final int b ) { _output.data[indexOut++] = r; _output.data[indexOut++] = g; _output.data[indexOut++] = b; } }; processYuv(bufferY,bufferU,bufferV,width,height,strideY,strideUV,stridePixelUV,work,processor); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS16} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedS16 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS32} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedS32 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
/** * <p> * Converts an {@link boofcv.struct.image.InterleavedS64} into a {@link boofcv.struct.image.InterleavedF32}. * </p> * * @param input Input image which is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert(InterleavedS64 input, InterleavedF32 output) { if (output == null) { output = new InterleavedF32(input.width, input.height, input.numBands); } else { output.reshape(input.width,input.height,input.numBands); } ImplConvertImage.convert(input, output); return output; }
@Override public void initialize(int backgroundWidth, int backgroundHeight, Motion homeToWorld) { background.reshape(backgroundWidth,backgroundHeight); GImageMiscOps.fill(background, -1); this.homeToWorld.set(homeToWorld); this.homeToWorld.invert(worldToHome); this.backgroundWidth = backgroundWidth; this.backgroundHeight = backgroundHeight; }
@Override public void setInputImage(GrayF32 image) { enlargedTemplate.reshape(image.width,image.height); fftImage.reshape(image.width,image.height); fftTemplate.reshape(image.width,image.height); fftMult.reshape(image.width,image.height); correlation.reshape(image.width,image.height); normalizedImage.reshape(image.width,image.height); maxValue = ImageStatistics.max(image)+0.0001f;// avoid divide by zero errors mean = ImageStatistics.mean(image); PixelMath.divide(image,maxValue,normalizedImage); PixelMath.minus(normalizedImage,mean/maxValue,normalizedImage); dft.forward(normalizedImage, fftImage); }
@Override public void initialize(int backgroundWidth, int backgroundHeight, Motion homeToWorld) { background.reshape(backgroundWidth,backgroundHeight); GImageMiscOps.fill(background, Float.MAX_VALUE); this.homeToWorld.set(homeToWorld); this.homeToWorld.invert(worldToHome); this.backgroundWidth = backgroundWidth; this.backgroundHeight = backgroundHeight; }
/** * Converts a {@link Planar} into the equivalent {@link InterleavedF32} * * @param input (Input) Planar image that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convert( Planar<GrayF32> input , InterleavedF32 output ) { if (output == null) { output = new InterleavedF32(input.width, input.height,input.getNumBands()); } else { output.reshape(input.width,input.height,input.getNumBands()); } ImplConvertImage.convert(input,output); return output; }
/** * Converts a {@link Planar} {@link GrayU8} into the equivalent {@link InterleavedF32} * * @param input (Input) ImageInterleaved that is being converted. Not modified. * @param output (Optional) The output image. If null a new image is created. Modified. * @return Converted image. */ public static InterleavedF32 convertU8F32(Planar<GrayU8> input , InterleavedF32 output ) { if (output == null) { output = new InterleavedF32(input.width,input.height,input.getNumBands()); } else { output.reshape(input.width,input.height,input.getNumBands()); } ImplConvertImage.convertU8F32(input,output); return output; } }
@Override public void inverse(InterleavedF32 transform, GrayF32 image ) { DiscreteFourierTransformOps.checkImageArguments(image,transform); if( image.isSubimage() || transform.isSubimage() ) throw new IllegalArgumentException("Subimages are not supported"); checkDeclareAlg(image); // If he user lets us, modify the transform InterleavedF32 workImage; if(modifyInputs) { workImage = transform; } else { tmp.reshape(transform.width,transform.height); tmp.setTo(transform); workImage = tmp; } alg.complexInverse(workImage.data, true); // copy the real portion. imaginary should be zeros int N = image.width*image.height; for( int i = 0; i < N; i++ ) { image.data[i] = workImage.data[i*2]; } }
@Override public void updateBackground( T frame) { if( background.width == 1 ) { background.reshape(frame.width, frame.height); GConvertImage.convert(frame, background); return; } else { InputSanityCheck.checkSameShape(background,frame); } inputWrapper.wrap(frame); int numBands = background.getNumBands(); float minusLearn = 1.0f - learnRate; int indexBG = 0; for (int y = 0; y < frame.height; y++) { int indexInput = frame.startIndex + y*frame.stride; int end = indexInput + frame.width*numBands; while( indexInput < end ) { int endIndexBG = indexBG + numBands; while( indexBG < endIndexBG ) { float valueBG = background.data[indexBG]; background.data[indexBG] = minusLearn*valueBG + learnRate*inputWrapper.getF(indexInput); indexBG++; indexInput++; } } } }
background.reshape(frame.width, frame.height);