6

openCVhttp://code.google.com/p/android-opencv/を使用してAndroidにオプティカルフローを実装しようとしています基本的に私はこのhttp://www.youtube.com/watch?v=P_Sjn67jIJYのようなものを作りたいです。とにかく、Android開発は初めてなので、ビデオにあるようなものを構築するために、誰かがどこかにガイドできますか?私はすでにAndroidにopencvポートをインストールし、Eclipseを使用してcvcameraの例を正常にビルドしました。ありがとう、サノス

4

4 に答える 4

1

このスタンフォード OpenCV オプティカル フローリンクを参照してください。1.x と 2.x の C と C++ API の問題により、呼び出しがわずかに異なる場合があることを除いて、基本的に同じように動作するはずです。

CVCamera の例を編集するだけで、すぐに実行できます。CVCamera を動作させてから約 1 時間以内に、リアルタイムの顔検出アプリを作成しました。

于 2011-06-28T17:06:37.707 に答える
0

http://opencv.willowgarage.com/wiki/Android2.3.0にアクセスしてください。OpenCV 2.3.0 Release Candidate は Android を適切にサポートしています。その中にオプティカルフローがあります..それを使用しました

于 2011-06-28T17:13:19.510 に答える
0

私も同じことをしようとしていますが、現在、OpenCV4Android でのオプティカル フローのサポートが増えているようです。org.opencv.video OpenCV Java ドキュメントの API を見てください。calcOpticalFlowPyrLK と calcOpticalFlowFarneback があります。calcOpticalFlowFarneback を機能させることができました (ただし、結果はそれほど良くないように見えましたが、パラメーターを微調整する必要がある可能性があります)。FeatureDetector クラス (MatOfKeyPoint) によって返されたキーポイントを、calcOpticalFlowFarneback (MatOfPoint2f)他のスレッドで必要なポイントに変換できないようです

于 2013-01-15T21:29:01.670 に答える
0

このコードは、光学ベクトルを取得するのに役立ちます。そして、それはそれらを追跡します

@Override public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

    mRgba = inputFrame.rgba();
    if (mMOP2fptsPrev.rows() == 0) {

        //Log.d("Baz", "First time opflow");
        // first time through the loop so we need prev and this mats
        // plus prev points
        // get this mat
        Imgproc.cvtColor(mRgba, matOpFlowThis, Imgproc.COLOR_RGBA2GRAY);

        // copy that to prev mat
        matOpFlowThis.copyTo(matOpFlowPrev);

        // get prev corners
        Imgproc.goodFeaturesToTrack(matOpFlowPrev, MOPcorners, iGFFTMax, 0.05, 20);
        mMOP2fptsPrev.fromArray(MOPcorners.toArray());

        // get safe copy of this corners
        mMOP2fptsPrev.copyTo(mMOP2fptsSafe);
        }
    else
        {
        //Log.d("Baz", "Opflow");
        // we've been through before so
        // this mat is valid. Copy it to prev mat
        matOpFlowThis.copyTo(matOpFlowPrev);

        // get this mat
        Imgproc.cvtColor(mRgba, matOpFlowThis, Imgproc.COLOR_RGBA2GRAY);

        // get the corners for this mat
        Imgproc.goodFeaturesToTrack(matOpFlowThis, MOPcorners, iGFFTMax, 0.05, 20);
        mMOP2fptsThis.fromArray(MOPcorners.toArray());

        // retrieve the corners from the prev mat
        // (saves calculating them again)
        mMOP2fptsSafe.copyTo(mMOP2fptsPrev);

        // and save this corners for next time through

        mMOP2fptsThis.copyTo(mMOP2fptsSafe);
        }


    /*
    Parameters:
        prevImg first 8-bit input image
        nextImg second input image
        prevPts vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
        nextPts output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
        status output status vector (of unsigned chars); each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.
        err output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't found then the error is not defined (use the status parameter to find such cases).
    */
    Video.calcOpticalFlowPyrLK(matOpFlowPrev, matOpFlowThis, mMOP2fptsPrev, mMOP2fptsThis, mMOBStatus, mMOFerr);

    cornersPrev = mMOP2fptsPrev.toList();
    cornersThis = mMOP2fptsThis.toList();
    byteStatus = mMOBStatus.toList();

    y = byteStatus.size() - 1;

    for (x = 0; x < y; x++) {
        if (byteStatus.get(x) == 1) {
            pt = cornersThis.get(x);
            pt2 = cornersPrev.get(x);

            Core.circle(mRgba, pt, 5, colorRed, iLineThickness - 1);

            Core.line(mRgba, pt, pt2, colorRed, iLineThickness);
            }
        }

return mRgba;

    }
于 2015-01-12T15:00:05.683 に答える