Android samples updated according onCameraFrame callback signature change.
FpsMeter class removed from Image Manipulations and Face Detection examples as unused code.
This commit is contained in:
@@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.opencv.android.BaseLoaderCallback;
|
||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
|
||||
import org.opencv.android.LoaderCallbackInterface;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.core.Core;
|
||||
@@ -16,7 +17,6 @@ import org.opencv.core.Scalar;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.android.CameraBridgeViewBase;
|
||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.objdetect.CascadeClassifier;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -157,10 +157,10 @@ public class FdActivity extends Activity implements CvCameraViewListener {
|
||||
mRgba.release();
|
||||
}
|
||||
|
||||
public Mat onCameraFrame(Mat inputFrame) {
|
||||
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
|
||||
|
||||
inputFrame.copyTo(mRgba);
|
||||
Imgproc.cvtColor(inputFrame, mGray, Imgproc.COLOR_RGBA2GRAY);
|
||||
mRgba = inputFrame.rgba();
|
||||
mGray = inputFrame.gray();
|
||||
|
||||
if (mAbsoluteFaceSize == 0) {
|
||||
int height = mGray.rows();
|
||||
|
@@ -1,50 +0,0 @@
|
||||
package org.opencv.samples.facedetect;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.Log;
|
||||
|
||||
public class FpsMeter {
|
||||
private static final String TAG = "OCVSample::FpsMeter";
|
||||
int step;
|
||||
int framesCouner;
|
||||
double freq;
|
||||
long prevFrameTime;
|
||||
String strfps;
|
||||
DecimalFormat twoPlaces = new DecimalFormat("0.00");
|
||||
Paint paint;
|
||||
|
||||
public void init() {
|
||||
step = 20;
|
||||
framesCouner = 0;
|
||||
freq = Core.getTickFrequency();
|
||||
prevFrameTime = Core.getTickCount();
|
||||
strfps = "";
|
||||
|
||||
paint = new Paint();
|
||||
paint.setColor(Color.BLUE);
|
||||
paint.setTextSize(50);
|
||||
}
|
||||
|
||||
public void measure() {
|
||||
framesCouner++;
|
||||
if (framesCouner % step == 0) {
|
||||
long time = Core.getTickCount();
|
||||
double fps = step * freq / (time - prevFrameTime);
|
||||
prevFrameTime = time;
|
||||
DecimalFormat twoPlaces = new DecimalFormat("0.00");
|
||||
strfps = twoPlaces.format(fps) + " FPS";
|
||||
Log.i(TAG, strfps);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas, float offsetx, float offsety) {
|
||||
canvas.drawText(strfps, 20 + offsetx, 10 + 50 + offsety, paint);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user