2014年7月1日 星期二

Modify OpenCV Tutorial Project

OpenCV Tutorial 2 – Mixed Processing




1. Enter the src folder, and then open Tutorial2Activity.java

2. At the top of the file, add:

private static final int VIEW_MODE_THRESH = 3;
private MenuItem mItemPreviewThresh;


3.In the method “onCreateOptionsMenu”, add:

mItemPreviewThresh = menu.add(“Thresh.”);

4.In the method “onCameraFrame”, add:


case VIEW_MODE_THRESH:
mRgba = inputFrame.rgba();
       int maxValue = 255;
       int blockSize = 61;
       int meanOffset = 15;
       Imgproc.adaptiveThreshold(
              inputFrame.gray(),
              mIntermediateMat,
              maxValue,
              Imgproc.ADAPTIVE_THRESH_MEAN_C,
              Imgproc.THRESH_BINARY_INV,
              blockSize,
              meanOffset );
       Imgproc.cvtColor( mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2RGBA, 4 )


5.In the method “onOptionsItemSelected”, add:
else if (item == mItemPreviewThresh) {
mViewMode = VIEW_MODE_THRESH;
}

沒有留言:

張貼留言