當前位置: 首頁>>代碼示例>>Java>>正文


Java Core.flip方法代碼示例

本文整理匯總了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();
    }
 
開發者ID:hollaus,項目名稱:TinyPlanetMaker,代碼行數:26,代碼來源:PlanetMaker.java

示例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;
    }
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:41,代碼來源:FdActivity.java

示例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;
}
 
開發者ID:ravindu1024,項目名稱:android-imaging-utils,代碼行數:26,代碼來源:ImagingUtils.java

示例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;
}
 
開發者ID:jocstech,項目名稱:AndroidCameraSudokuSolver,代碼行數:8,代碼來源:PortraitCameraView.java

示例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;
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:24,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:jorenham,項目名稱:fingerblox,代碼行數:12,代碼來源:ImageProcessing.java

示例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;
}
 
開發者ID:jorenham,項目名稱:fingerblox,代碼行數:38,代碼來源:ImageProcessing.java

示例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;
}
 
開發者ID:typer9527,項目名稱:FaceDetectDemo,代碼行數:31,代碼來源:DetectActivity.java

示例9: flip

import org.opencv.core.Core; //導入方法依賴的package包/類
public static void flip(Mat img, FlipType flipType) {
    Core.flip(img, img, flipType.val);
}
 
開發者ID:TheBigBombman,項目名稱:RobotIGS,代碼行數:4,代碼來源:Transform.java

示例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;
}
 
開發者ID:jocstech,項目名稱:AndroidCameraSudokuSolver,代碼行數:8,代碼來源:PortraitCameraView.java

示例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();

    }
 
開發者ID:hollaus,項目名稱:TinyPlanetMaker,代碼行數:25,代碼來源:PlanetMaker.java

示例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();

    }
 
開發者ID:hollaus,項目名稱:TinyPlanetMaker,代碼行數:22,代碼來源:PlanetMaker.java

示例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);
    
}
 
開發者ID:Plasmoxy,項目名稱:AquamarineLake,代碼行數:20,代碼來源:Controller.java

示例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);
}
 
開發者ID:Plasmoxy,項目名稱:AquamarineLake,代碼行數:5,代碼來源:Controller.java

示例15: reset

import org.opencv.core.Core; //導入方法依賴的package包/類
public void reset() {

        setInitValues();

        if (mIsPlanetInverted && mInputImage != null)
            Core.flip(mInputImage, mInputImage, -1);

        mIsPlanetInverted = false;
        updatePlanet();

    }
 
開發者ID:hollaus,項目名稱:TinyPlanetMaker,代碼行數:12,代碼來源:PlanetMaker.java


注:本文中的org.opencv.core.Core.flip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。