FpsMeter class removed from Image Manipulations and Face Detection examples as unused code.
package org.opencv.samples.puzzle15;
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.Mat;
public void onCameraViewStopped() {
}
- public Mat onCameraFrame(Mat inputFrame) {
- return mPuzzle15.puzzleFrame(inputFrame);
- }
-
public boolean onTouch(View view, MotionEvent event) {
int xpos, ypos;
return false;
}
+
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ return mPuzzle15.puzzleFrame(inputFrame.rgba());
+ }
}
import java.util.List;
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;
return false; // don't need subsequent touch events
}
- public Mat onCameraFrame(Mat inputFrame) {
- inputFrame.copyTo(mRgba);
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ mRgba = inputFrame.rgba();
if (mIsColorSelected) {
mDetector.process(mRgba);
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;
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;
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();
+++ /dev/null
-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);
- }
-
-}
+++ /dev/null
-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);
- }
-
-}
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;
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:
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();
package org.opencv.samples.tutorial1;
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.Mat;
public void onCameraViewStopped() {
}
- public Mat onCameraFrame(Mat inputFrame) {
- return inputFrame;
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ return inputFrame.rgba();
}
}
package org.opencv.samples.tutorial2;
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;
import org.opencv.core.Scalar;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
-import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import android.app.Activity;
mIntermediateMat.release();
}
- public Mat onCameraFrame(Mat inputFrame) {
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
switch (Sample2NativeCamera.viewMode) {
case Sample2NativeCamera.VIEW_MODE_GRAY:
{
- Imgproc.cvtColor(inputFrame, mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
+ Imgproc.cvtColor(inputFrame.gray(), mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
} break;
case Sample2NativeCamera.VIEW_MODE_RGBA:
{
- inputFrame.copyTo(mRgba);
- Core.putText(mRgba, "OpenCV+Android", new Point(10, inputFrame.rows() - 10), 3, 1, new Scalar(255, 0, 0, 255), 2);
+ mRgba = inputFrame.rgba();
+ Core.putText(mRgba, "OpenCV+Android", new Point(10, mRgba.rows() - 10), 3, 1, new Scalar(255, 0, 0, 255), 2);
} break;
case Sample2NativeCamera.VIEW_MODE_CANNY:
{
- Imgproc.Canny(inputFrame, mIntermediateMat, 80, 100);
+ Imgproc.Canny(inputFrame.gray(), mIntermediateMat, 80, 100);
Imgproc.cvtColor(mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2BGRA, 4);
} break;
}
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
if (item == mItemPreviewRGBA)
{
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
viewMode = VIEW_MODE_RGBA;
}
else if (item == mItemPreviewGray)
{
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
viewMode = VIEW_MODE_GRAY;
}
else if (item == mItemPreviewCanny)
{
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
viewMode = VIEW_MODE_CANNY;
}
package org.opencv.samples.tutorial3;
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.CvType;
import org.opencv.core.Mat;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
-import org.opencv.imgproc.Imgproc;
import android.app.Activity;
import android.os.Bundle;
private static final String TAG = "OCVSample::Activity";
private Mat mRgba;
- private Mat mGrayMat;
+ private Mat mGray;
private CameraBridgeViewBase mOpenCvCameraView;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(height, width, CvType.CV_8UC4);
- mGrayMat = new Mat(height, width, CvType.CV_8UC1);
+ mGray = new Mat(height, width, CvType.CV_8UC1);
}
public void onCameraViewStopped() {
mRgba.release();
- mGrayMat.release();
+ mGray.release();
}
- public Mat onCameraFrame(Mat inputFrame) {
- inputFrame.copyTo(mRgba);
- Imgproc.cvtColor(mRgba, mGrayMat, Imgproc.COLOR_RGBA2GRAY);
- FindFeatures(mGrayMat.getNativeObjAddr(), mRgba.getNativeObjAddr());
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ mRgba = inputFrame.rgba();
+ mGray = inputFrame.gray();
+ FindFeatures(mGray.getNativeObjAddr(), mRgba.getNativeObjAddr());
return mRgba;
}
package org.opencv.samples.tutorial4;
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.CvType;
import org.opencv.core.Mat;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
-import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import android.app.Activity;
private int mViewMode;
private Mat mRgba;
private Mat mIntermediateMat;
- private Mat mGrayMat;
+ private Mat mGray;
private MenuItem mItemPreviewRGBA;
private MenuItem mItemPreviewGray;
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(height, width, CvType.CV_8UC4);
mIntermediateMat = new Mat(height, width, CvType.CV_8UC4);
- mGrayMat = new Mat(height, width, CvType.CV_8UC1);
+ mGray = new Mat(height, width, CvType.CV_8UC1);
}
public void onCameraViewStopped() {
mRgba.release();
- mGrayMat.release();
+ mGray.release();
mIntermediateMat.release();
}
- public Mat onCameraFrame(Mat inputFrame) {
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
final int viewMode = mViewMode;
-
switch (viewMode) {
case VIEW_MODE_GRAY:
// input frame has gray scale format
- Imgproc.cvtColor(inputFrame, mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
+ Imgproc.cvtColor(inputFrame.gray(), mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
break;
case VIEW_MODE_RGBA:
// input frame has RBGA format
- inputFrame.copyTo(mRgba);
+ mRgba = inputFrame.rgba();
break;
case VIEW_MODE_CANNY:
// input frame has gray scale format
- Imgproc.Canny(inputFrame, mIntermediateMat, 80, 100);
+ mRgba = inputFrame.rgba();
+ Imgproc.Canny(inputFrame.gray(), mIntermediateMat, 80, 100);
Imgproc.cvtColor(mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2BGRA, 4);
break;
case VIEW_MODE_FEATURES:
// input frame has RGBA format
- inputFrame.copyTo(mRgba);
- Imgproc.cvtColor(mRgba, mGrayMat, Imgproc.COLOR_RGBA2GRAY);
- FindFeatures(mGrayMat.getNativeObjAddr(), mRgba.getNativeObjAddr());
+ mRgba = inputFrame.rgba();
+ mGray = inputFrame.gray();
+ Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGBA2GRAY);
+ FindFeatures(mGray.getNativeObjAddr(), mRgba.getNativeObjAddr());
break;
}
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
if (item == mItemPreviewRGBA) {
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
mViewMode = VIEW_MODE_RGBA;
} else if (item == mItemPreviewGray) {
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
mViewMode = VIEW_MODE_GRAY;
} else if (item == mItemPreviewCanny) {
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
mViewMode = VIEW_MODE_CANNY;
} else if (item == mItemPreviewFeatures) {
mViewMode = VIEW_MODE_FEATURES;
- mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
}
return true;
import java.util.ListIterator;
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.Mat;
public void onCameraViewStopped() {
}
- public Mat onCameraFrame(Mat inputFrame) {
- return inputFrame;
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ return inputFrame.rgba();
}
@Override