本文整理匯總了Java中org.opencv.core.Core.flip方法的典型用法代碼示例。如果您正苦於以下問題:Java Core.flip方法的具體用法?Java Core.flip怎麽用?Java Core.flip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.opencv.core.Core
的用法示例。
在下文中一共展示了Core.flip方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setCropRect
import org.opencv.core.Core; //導入方法依賴的package包/類
public void setCropRect(RectF cropRect) {
mCropRect = cropRect;
if (mIsPlanetInverted)
Core.flip(mInputImage, mInterimImage, -1);
else
mInterimImage = mInputImage.clone();
if (mCropRect != null) {
// Take care here, because the images are flipped after they have been loaded:
Rect flippedRect = flipCropRect(mInterimImage.width(), mInterimImage.height());
mInterimImage = mInterimImage.submat(flippedRect).clone();
}
// // mInterimImage is null if no cropping or invert is done yet:
// if (mInterimImage == null)
// mInterimImage = mInputImage.clone();
if (mIsFaded)
mInterimImage = getFadeImg(mInterimImage);
updatePlanet();
}
示例2: onCameraFrame
import org.opencv.core.Core; //導入方法依賴的package包/類
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
mGray = inputFrame.gray();
if (mAbsoluteFaceSize == 0) {
int height = mGray.rows();
if (Math.round(height * mRelativeFaceSize) > 0) {
mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
}
mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
}
MatOfRect faces = new MatOfRect();
if (mDetectorType == JAVA_DETECTOR) {
if (mJavaDetector != null)
mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
} else if (mDetectorType == NATIVE_DETECTOR) {
if (mNativeDetector != null)
mNativeDetector.detect(mGray, faces);
} else {
Log.e(TAG, "Detection method is not selected!");
}
Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++) {
Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);
}
//轉置90度
Mat rotateMat = Imgproc.getRotationMatrix2D(new Point(mRgba.rows() / 2, mRgba.cols() / 2), 90, 1);
Imgproc.warpAffine(mRgba, mRgba, rotateMat, mRgba.size());
//以y軸翻轉
Core.flip(mRgba, mRgba, 1);
return mRgba;
}
示例3: rotateFrame
import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat rotateFrame(Mat in, PreviewResizeParams.Rotation rotation)
{
Mat out = in;
if (rotation == PreviewResizeParams.Rotation.Clockwise_90)
{
out = in.t();
Core.flip(out, out, -1);
}
else if (rotation == PreviewResizeParams.Rotation.Clockwise_180)
{
out = in;
}
else if (rotation == PreviewResizeParams.Rotation.Clockwise_270)
{
out = in.t();
Core.flip(out, out, 1);
}
else
{
Core.flip(in, out, 1);
}
return out;
}
示例4: rgba
import org.opencv.core.Core; //導入方法依賴的package包/類
public Mat rgba() {
Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2BGR_NV12, 4);
if (mRotated != null) mRotated.release();
mRotated = mRgba.t();
Core.flip(mRotated, mRotated, 1);
return mRotated;
}
示例5: onCameraFrame
import org.opencv.core.Core; //導入方法依賴的package包/類
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
//Rotating the input frame
Mat mGray = inputFrame.gray();
mRgba = inputFrame.rgba();
if (mIsFrontCamera)
{
Core.flip(mRgba, mRgba, 1);
Core.flip(mGray, mGray, 1);
}
//Detecting face in the frame
MatOfRect faces = new MatOfRect();
if(haarCascade != null)
{
haarCascade.detectMultiScale(mGray, faces, 1.1, 2, 2, new Size(200,200), new Size());
}
Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++)
Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), new Scalar(100), 3);
return mRgba;
}
示例6: 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;
}
示例7: 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;
}
示例8: onCameraFrame
import org.opencv.core.Core; //導入方法依賴的package包/類
@Override
// 這裏執行人臉檢測的邏輯, 根據OpenCV提供的例子實現(face-detection)
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
mGray = inputFrame.gray();
// 翻轉矩陣以適配前後置攝像頭
if (isFrontCamera) {
Core.flip(mRgba, mRgba, 1);
Core.flip(mGray, mGray, 1);
} else {
Core.flip(mRgba, mRgba, -1);
Core.flip(mGray, mGray, -1);
}
float mRelativeFaceSize = 0.2f;
if (mAbsoluteFaceSize == 0) {
int height = mGray.rows();
if (Math.round(height * mRelativeFaceSize) > 0) {
mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
}
}
MatOfRect faces = new MatOfRect();
if (classifier != null)
classifier.detectMultiScale(mGray, faces, 1.1, 2, 2,
new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
Rect[] facesArray = faces.toArray();
Scalar faceRectColor = new Scalar(0, 255, 0, 255);
for (Rect faceRect : facesArray)
Imgproc.rectangle(mRgba, faceRect.tl(), faceRect.br(), faceRectColor, 3);
return mRgba;
}
示例9: flip
import org.opencv.core.Core; //導入方法依賴的package包/類
public static void flip(Mat img, FlipType flipType) {
Core.flip(img, img, flipType.val);
}
示例10: gray
import org.opencv.core.Core; //導入方法依賴的package包/類
public Mat gray() {
if (mRotated != null) mRotated.release();
mRotated = mYuvFrameData.submat(0, mWidth, 0, mHeight); //submat with reversed width and height because its done on the landscape frame
mRotated = mRotated.t();
Core.flip(mRotated, mRotated, 1);
return mRotated;
}
示例11: fade
import org.opencv.core.Core; //導入方法依賴的package包/類
public void fade(boolean isFaded) {
mIsFaded = isFaded;
if (!mIsImageLoaded)
return;
if (mIsPlanetInverted)
Core.flip(mInputImage, mInterimImage, -1);
else
mInterimImage = mInputImage.clone();
if (mCropRect != null) {
Rect flippedRect = flipCropRect(mInterimImage.width(), mInterimImage.height());
mInterimImage = mInterimImage.submat(flippedRect).clone();
}
if (mIsFaded)
mInterimImage = getFadeImg(mInterimImage);
updatePlanet();
}
示例12: initImages
import org.opencv.core.Core; //導入方法依賴的package包/類
private void initImages() {
Imgproc.resize(mInputImage, mInputImage, new Size(mOutputSize, mOutputSize), 0, 0, Imgproc.INTER_CUBIC);
// Creates the planet and inverts it:
Core.flip(mInputImage.t(), mInputImage, 1);
if (mIsPlanetInverted)
Core.flip(mInputImage, mInputImage, -1);
mOutputImage = new Mat(mInputImage.rows(), mInputImage.cols(), mInputImage.type());
mOutputImage = mInputImage.clone();
mInterimImage = mInputImage.clone();
if (mIsFaded)
mInterimImage = getFadeImg(mInterimImage);
updatePlanet();
}
示例13: process
import org.opencv.core.Core; //導入方法依賴的package包/類
private void process(Mat f)
{
Mat gen = new Mat();
if (flipActive) Core.flip(f, f, 1);
Imgproc.cvtColor(f, gen, Imgproc.COLOR_BGR2RGB);
if (weirdRenderActive) Imgproc.cvtColor(gen, gen, Imgproc.COLOR_HSV2RGB);
Point mid = new Point(gen.size().width/2, gen.size().height/2);
midPoint = gen.get((int)mid.y, (int)mid.x);
Imgproc.circle(gen, mid, 5, new Scalar(255-(int)(midPoint[0]), 255-(int)(midPoint[1]), 255-(int)(midPoint[2])), 2);
Imgproc.cvtColor(gen, f, Imgproc.COLOR_RGB2BGR);
}
示例14: process
import org.opencv.core.Core; //導入方法依賴的package包/類
private void process(Mat f, Mat a, Mat b) {
if (renderAlphaActive) Core.flip(f, a, 1);
if (renderBetaActive) Core.flip(f, b, 0);
}
示例15: reset
import org.opencv.core.Core; //導入方法依賴的package包/類
public void reset() {
setInitValues();
if (mIsPlanetInverted && mInputImage != null)
Core.flip(mInputImage, mInputImage, -1);
mIsPlanetInverted = false;
updatePlanet();
}