本文整理汇总了Java中org.bytedeco.javacv.OpenCVFrameConverter.ToMat方法的典型用法代码示例。如果您正苦于以下问题:Java OpenCVFrameConverter.ToMat方法的具体用法?Java OpenCVFrameConverter.ToMat怎么用?Java OpenCVFrameConverter.ToMat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bytedeco.javacv.OpenCVFrameConverter
的用法示例。
在下文中一共展示了OpenCVFrameConverter.ToMat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertCifar
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Preprocess and store cifar based on successful Torch approach by Sergey Zagoruyko
* Reference: https://github.com/szagoruyko/cifar.torch
*/
public opencv_core.Mat convertCifar(Mat orgImage) {
numExamples++;
Mat resImage = new Mat();
OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
// ImageTransform yuvTransform = new ColorConversionTransform(new Random(seed), COLOR_BGR2Luv);
// ImageTransform histEqualization = new EqualizeHistTransform(new Random(seed), COLOR_BGR2Luv);
ImageTransform yuvTransform = new ColorConversionTransform(new Random(seed), COLOR_BGR2YCrCb);
ImageTransform histEqualization = new EqualizeHistTransform(new Random(seed), COLOR_BGR2YCrCb);
if (converter != null) {
ImageWritable writable = new ImageWritable(converter.convert(orgImage));
// TODO determine if need to normalize y before transform - opencv docs rec but currently doing after
writable = yuvTransform.transform(writable); // Converts to chrome color to help emphasize image objects
writable = histEqualization.transform(writable); // Normalizes values to further clarify object of interest
resImage = converter.convert(writable.getFrame());
}
return resImage;
}
示例2: RandomCropTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
public RandomCropTransform(Random random, long seed, int height, int width) {
super(random);
this.outputHeight = height;
this.outputWidth = width;
this.rng = Nd4j.getRandom();
this.rng.setSeed(seed);
this.converter = new OpenCVFrameConverter.ToMat();
}
示例3: LargestBlobCropTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
*
* @param random Object to use (or null for deterministic)
* @param mode Contour retrieval mode
* @param method Contour approximation method
* @param blurWidth Width of blurring kernel size
* @param blurHeight Height of blurring kernel size
* @param lowerThresh Lower threshold for either Canny or Threshold
* @param upperThresh Upper threshold for either Canny or Threshold
* @param isCanny Whether the edge detector is Canny or Threshold
*/
public LargestBlobCropTransform(Random random, int mode, int method, int blurWidth, int blurHeight, int lowerThresh,
int upperThresh, boolean isCanny) {
super(random);
this.rng = Nd4j.getRandom();
this.mode = mode;
this.method = method;
this.blurWidth = blurWidth;
this.blurHeight = blurHeight;
this.lowerThresh = lowerThresh;
this.upperThresh = upperThresh;
this.isCanny = isCanny;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例4: WarpImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Constructs an instance of the ImageTransform.
*
* @param random object to use (or null for deterministic)
* @param dx1 maximum warping in x for the top-left corner (pixels)
* @param dy1 maximum warping in y for the top-left corner (pixels)
* @param dx2 maximum warping in x for the top-right corner (pixels)
* @param dy2 maximum warping in y for the top-right corner (pixels)
* @param dx3 maximum warping in x for the bottom-right corner (pixels)
* @param dy3 maximum warping in y for the bottom-right corner (pixels)
* @param dx4 maximum warping in x for the bottom-left corner (pixels)
* @param dy4 maximum warping in y for the bottom-left corner (pixels)
*/
public WarpImageTransform(Random random, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3,
float dx4, float dy4) {
super(random);
deltas = new float[8];
deltas[0] = dx1;
deltas[1] = dy1;
deltas[2] = dx2;
deltas[3] = dy2;
deltas[4] = dx3;
deltas[5] = dy3;
deltas[6] = dx4;
deltas[7] = dy4;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例5: ResizeImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Returns new ResizeImageTransform object
*
* @param random Random
* @param newWidth new Width for the outcome images
* @param newHeight new Height for outcome images
*/
public ResizeImageTransform(Random random, int newWidth, int newHeight) {
super(random);
this.newWidth = newWidth;
this.newHeight = newHeight;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例6: makeRandomBufferedImage
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
BufferedImage makeRandomBufferedImage(int height, int width, int channels) {
Mat img = makeRandomImage(height, width, channels);
OpenCVFrameConverter.ToMat c = new OpenCVFrameConverter.ToMat();
Java2DFrameConverter c2 = new Java2DFrameConverter();
return c2.convert(c.convert(img));
}
示例7: run
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
@Override
protected void run() throws GrabberServiceException {
final OpenCVFrameConverter.ToMat convertToMat = new OpenCVFrameConverter.ToMat();
final Stopwatch stopwatch = Stopwatch.createStarted();
while (super.isRunning()) {
runOneGrab(convertToMat, stopwatch);
}
}
示例8: runOneGrab
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
@VisibleForTesting
final void runOneGrab(final OpenCVFrameConverter.ToMat convertToMat, final Stopwatch stopwatch)
throws GrabberServiceException {
final Frame videoFrame;
try {
videoFrame = frameGrabber.grab();
} catch (FrameGrabber.Exception ex) {
throw new GrabberServiceException("Failed to grab image", ex);
}
final opencv_core.Mat frameMat = convertToMat.convert(videoFrame);
if (frameMat == null || frameMat.isNull()) {
throw new GrabberServiceException("Returned a null frame Mat");
}
if (frameMat.empty()) {
throw new GrabberServiceException("Returned an empty Mat");
}
updater.copyNewMat(frameMat);
stopwatch.stop();
final long elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
stopwatch.reset();
stopwatch.start();
if (elapsedTime != 0) {
updater.setFrameRate(IntMath.divide(1000, Math.toIntExact(elapsedTime), RoundingMode.DOWN));
}
updater.updatesComplete();
exceptionClearedCallback.run();
}
示例9: asMatrix
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
public INDArray asMatrix(Bitmap image) throws IOException {
if (converter == null) {
converter = new OpenCVFrameConverter.ToMat();
}
return asMatrix(converter.convert(converter2.convert(image)));
}
示例10: setConf
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
@Override
public void setConf(Configuration conf) {
super.setConf(conf);
converter = new OpenCVFrameConverter.ToMat();
imageLoader = new NativeImageLoader(rows, cols);
}
示例11: ScreenConverter
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
public ScreenConverter() {
frameConverter = new OpenCVFrameConverter.ToMat();
imageConverter = new Java2DFrameConverter();
}
示例12: BoxImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Constructs an instance of the ImageTransform.
*
* @param random object to use (or null for deterministic)
* @param width of the boxed image (pixels)
* @param height of the boxed image (pixels)
*/
public BoxImageTransform(Random random, int width, int height) {
super(random);
this.width = width;
this.height = height;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例13: CropImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Constructs an instance of the ImageTransform.
*
* @param random object to use (or null for deterministic)
* @param cropTop maximum cropping of the top of the image (pixels)
* @param cropLeft maximum cropping of the left of the image (pixels)
* @param cropBottom maximum cropping of the bottom of the image (pixels)
* @param cropRight maximum cropping of the right of the image (pixels)
*/
public CropImageTransform(Random random, int cropTop, int cropLeft, int cropBottom, int cropRight) {
super(random);
this.cropTop = cropTop;
this.cropLeft = cropLeft;
this.cropBottom = cropBottom;
this.cropRight = cropRight;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例14: ScaleImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Constructs an instance of the ImageTransform.
*
* @param random object to use (or null for deterministic)
* @param dx maximum scaling in width of the image (pixels)
* @param dy maximum scaling in height of the image (pixels)
*/
public ScaleImageTransform(Random random, float dx, float dy) {
super(random);
this.dx = dx;
this.dy = dy;
this.converter = new OpenCVFrameConverter.ToMat();
}
示例15: RotateImageTransform
import org.bytedeco.javacv.OpenCVFrameConverter; //导入方法依赖的package包/类
/**
* Constructs an instance of the ImageTransform.
*
* @param random object to use (or null for deterministic)
* @param centerx maximum deviation in x of center of rotation (relative to image center)
* @param centery maximum deviation in y of center of rotation (relative to image center)
* @param angle maximum rotation (degrees)
* @param scale maximum scaling (relative to 1)
*/
public RotateImageTransform(Random random, float centerx, float centery, float angle, float scale) {
super(random);
this.centerx = centerx;
this.centery = centery;
this.angle = angle;
this.scale = scale;
this.converter = new OpenCVFrameConverter.ToMat();
}