mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
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:
-50
@@ -1,50 +0,0 @@
|
||||
package org.opencv.samples.imagemanipulations;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-3
@@ -3,6 +3,7 @@ package org.opencv.samples.imagemanipulations;
|
||||
import java.util.Arrays;
|
||||
|
||||
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;
|
||||
@@ -258,8 +259,8 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
|
||||
mZoomWindow = null;
|
||||
}
|
||||
|
||||
public Mat onCameraFrame(Mat inputFrame) {
|
||||
inputFrame.copyTo(mRgba);
|
||||
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
|
||||
mRgba = inputFrame.rgba();
|
||||
|
||||
switch (ImageManipulationsActivity.viewMode) {
|
||||
case ImageManipulationsActivity.VIEW_MODE_RGBA:
|
||||
@@ -315,7 +316,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
|
||||
break;
|
||||
|
||||
case ImageManipulationsActivity.VIEW_MODE_SOBEL:
|
||||
Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGBA2GRAY);
|
||||
mGray = inputFrame.gray();
|
||||
|
||||
if ((mRgbaInnerWindow == null) || (mGrayInnerWindow == null) || (mRgba.cols() != mSizeRgba.width) || (mRgba.height() != mSizeRgba.height))
|
||||
CreateAuxiliaryMats();
|
||||
|
||||
Reference in New Issue
Block a user