确定碰撞时间

时间:2015-01-19 12:35:20

标签: java android c++

我正在开发一个Android应用程序,它将确定距离相机前方障碍物的距离。如果我计算碰撞时间,我将能够确定距离。我能够获得光流向量,如何从那里继续确定碰撞时间。 这是我到目前为止所拥有的;

    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


    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);
            }
        }

0 个答案:

没有答案