3

I am developing a OCR app with OpenCV. For that I created onCameraFrame(), but showing 'Cannot resolve method putText()'. I found some answers from stackOverFlow that saying to

import org.opencv.core.Point;

But I already import both

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

but still showing same error. Any other way to resolve this error? Thanks in Advance. Please help me.

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;
}
Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
Waseem
  • 439
  • 3
  • 18
  • This could probably be a missing native lib I believe hence resulting with building error, make sure that you've added the OpenCV sdk properly. You could check my answer for some help: https://stackoverflow.com/a/43886764/2949966 – ahasbini Oct 05 '17 at 08:55
  • Thanks for your reply, I re installed OpenCV again and I made Andrii Omelchenko sir's change also. Now error gone. Thanks a lot. :) – Waseem Oct 07 '17 at 11:25

1 Answers1

6

It depends on Android OpenCV library version: from version 3.0 .putText() (with same parameters) moved from Core to Imgproc class. So you should use:

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

instead of:

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

and so on.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
  • Hello Sir, I removed OpenCV and reinstall it. And I tried your method. it is working now. Thanks a lot sir. – Waseem Oct 07 '17 at 11:22