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;
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.