本文整理匯總了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;
}