无法使用Android解析OpenCV中的putText()

时间:2017-10-05 08:10:27

标签: java android opencv

我正在使用OpenCV开发一个OCR应用程序。为此,我创建了onCameraFrame(),但显示了“无法解析方法putText()'”。 我从stackOverFlow中找到了一些回答

的答案

import org.opencv.core.Point;

但我已经导入了两个

org.opencv.core.Point; org.opencv.core.Scalar;

但仍然显示相同的错误。有没有其他方法来解决这个错误?提前致谢。请帮帮我。

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inFrame) {
Mat inputFrame = inFrame.rgba();

    inputFrame.copyTo(mRgba);

   switch (HelloV.viewMode) {

        case HelloV.VIEW_MODE_RGBA: {

            //cannot resolve method putText 
            Core.putText(mRgba, "Video Mode", new Point(10, 50), 3, 1, 

         new Scalar(255, 0, 0, 255), 2);

            // Update start recordtime until starting recording

        }break;

        case HelloV.SAVE_IMAGE_MAT: {

            long curTime = new Date().getTime();
  //cannot resolve method putText
    Core.putText(mRgba, "Record Mode", new Point(10, 50), 3, 1,                   

           new Scalar(255, 0, 0, 255), 2);
           long timeDiff = curTime - recordStart;   

           Log.i("timeDiff",Long.toString(timeDiff));

           if ( timeDiff < MAX_VIDEO_INTERVAL_IN_SECONDS) {
                if ((mframeNum % FRAME2GRAB) == 0) {
                    saveImageToArray(inputFrame);
                    mframeNum++;
                }
                else
                    mframeNum++;
            }
            else
            {
                mframeNum = 0;
                turnOffCapture();
            }
        }break;
        case HelloV.CAPT_STILL_IM :
        {
            saveImageToArray(inputFrame);

            //RIGHT HERE IS WHERE I NEED TO MODIFY!  CAPTURE IMAGE
            //WITH THE CAMERA INSTEAD OF USING THE PREVIEW.
            //IF I CAN DO THIS, WE CAN GET AND STITCH FULL-RES IMAGES...
            //Camera.Parameters params = mCamera.getParameters();
            //Mat theImage = imageCapturer.getCapturedImage(1);
            //saveImageToArray(theImage);
            HelloV.viewMode = HelloV.VIEW_MODE_RGBA;
        }
    }
    return mRgba;
}

1 个答案:

答案 0 :(得分:0)

这取决于Android OpenCV库版本:从版本3.0 .putText()(具有相同参数)从Core移至Imgproc类。所以你应该使用:

Imgproc.putText(mRgba, "Video Mode", new Point(10, 50), 3, 1, new Scalar(255, 0, 0, 255), 2);

而不是:

Core.putText(mRgba, "Video Mode", new Point(10, 50), 3, 1, new Scalar(255, 0, 0, 255), 2);

等等。