本文整理汇总了Java中org.opencv.core.Core.transpose方法的典型用法代码示例。如果您正苦于以下问题:Java Core.transpose方法的具体用法?Java Core.transpose怎么用?Java Core.transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.core.Core
的用法示例。
在下文中一共展示了Core.transpose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rotateImage
import org.opencv.core.Core; //导入方法依赖的package包/类
/**
* OpenCV only supports landscape pictures, so we gotta rotate 90 degrees.
*/
private Mat rotateImage(Mat image) {
Mat result = emptyMat(image.rows(), image.cols(), 3);
Core.transpose(image, result);
Core.flip(result, result, 1);
return result;
}
示例2: preprocess
import org.opencv.core.Core; //导入方法依赖的package包/类
static Bitmap preprocess(Mat frame, int width, int height) {
// convert to grayscale
Mat frameGrey = new Mat(height, width, CvType.CV_8UC1);
Imgproc.cvtColor(frame, frameGrey, Imgproc.COLOR_BGR2GRAY, 1);
// rotate
Mat rotatedFrame = new Mat(width, height, frameGrey.type());
Core.transpose(frameGrey, rotatedFrame);
Core.flip(rotatedFrame, rotatedFrame, Core.ROTATE_180);
// resize to match the surface view
Mat resizedFrame = new Mat(width, height, rotatedFrame.type());
Imgproc.resize(rotatedFrame, resizedFrame, new Size(width, height));
// crop
Mat ellipseMask = getEllipseMask(width, height);
Mat frameCropped = new Mat(resizedFrame.rows(), resizedFrame.cols(), resizedFrame.type(), new Scalar(0));
resizedFrame.copyTo(frameCropped, ellipseMask);
// histogram equalisation
Mat frameHistEq = new Mat(frame.rows(), frameCropped.cols(), frameCropped.type());
Imgproc.equalizeHist(frameCropped, frameHistEq);
// convert back to rgba
Mat frameRgba = new Mat(frameHistEq.rows(), frameHistEq.cols(), CvType.CV_8UC4);
Imgproc.cvtColor(frameHistEq, frameRgba, Imgproc.COLOR_GRAY2RGBA);
// crop again to correct alpha
Mat frameAlpha = new Mat(frameRgba.rows(), frameRgba.cols(), CvType.CV_8UC4, new Scalar(0, 0, 0, 0));
frameRgba.copyTo(frameAlpha, ellipseMask);
// convert to bitmap
Bitmap bmp = Bitmap.createBitmap(frameAlpha.cols(), frameAlpha.rows(), Bitmap.Config.ARGB_4444);
Utils.matToBitmap(frameAlpha, bmp);
return bmp;
}
示例3: onCameraFrame
import org.opencv.core.Core; //导入方法依赖的package包/类
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
//Get image size and draw a rectangle on the image for reference
Mat temp = inputFrame.rgba();
Imgproc.rectangle(temp, new Point(temp.cols()/2 - 200, temp.rows() / 2 - 200), new Point(temp.cols() / 2 + 200, temp.rows() / 2 + 200), new Scalar(255,255,255),1);
Mat digit = temp.submat(temp.rows()/2 - 180, temp.rows() / 2 + 180, temp.cols() / 2 - 180, temp.cols() / 2 + 180).clone();
Core.transpose(digit,digit);
int predict_result = mnist.FindMatch(digit);
Imgproc.putText(temp, Integer.toString(predict_result), new Point(50, 150), FONT_HERSHEY_SIMPLEX, 3.0, new Scalar(0, 0, 255), 5);
return temp;
}