package com.example.daniel.opencvtest2;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceView;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.JavaCameraView;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{

    private static final String TAG = "Patito";
    private JavaCameraView javaCameraView;
    //private CameraBridgeViewBase javaCameraView;
    private Mat mRgba;
    BaseLoaderCallback mLoaderCallBack = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status){
                case BaseLoaderCallback.SUCCESS:{
                    javaCameraView.enableView();
                    break;
                }
                default:{
                    super.onManagerConnected(status);
                    break;
                }
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        javaCameraView = (JavaCameraView) findViewById(R.id.java_camera_view);
        javaCameraView.setVisibility(SurfaceView.VISIBLE);
        javaCameraView.setCvCameraViewListener(this);
    }

    @Override
    protected void onPause(){
        super.onPause();
        if(javaCameraView != null){
            javaCameraView.disableView();
        }
    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        if(javaCameraView != null){
            javaCameraView.disableView();
        }
    }

    @Override
    protected void onResume(){
        super.onResume();
        if(OpenCVLoader.initDebug()){
            Log.d(TAG, "OpenCV successfully loaded");
            mLoaderCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }
        else{
            Log.d(TAG, "OpenCV not loaded");
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallBack);
        }
    }

    @Override
    public void onCameraViewStarted(int width, int height) {
        mRgba = new Mat(height, width, CvType.CV_8SC4);
    }

    @Override
    public void onCameraViewStopped() {
        mRgba.release();
    }

    @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        return inputFrame.rgba();
    }

}

@@ -138,37 +138,8 @@
 og;%0A
-import android.view.Surface;%0A
 impo
@@ -167,16 +167,16 @@
 ceView;%0A
+
 %0Aimport 
@@ -453,16 +453,51 @@
 ore.Mat;
+%0Aimport org.opencv.imgproc.Imgproc;
 %0A%0Apublic
@@ -736,24 +736,24 @@
 CameraView;%0A
-
     private 
@@ -763,16 +763,66 @@
  mRgba;%0A
+    private Imgproc imgprocCanny = new Imgproc();%0A
     Base
@@ -2724,25 +2724,24 @@
 rame) %7B%0A
-%0A
         
 return i
@@ -2736,14 +2736,15 @@
     
-return
+mRgba =
  inp
@@ -2755,21 +2755,93 @@
 ame.rgba();%0A
+        imgprocCanny.Canny(mRgba, mRgba, 36, 86);%0A        return mRgba;%0A
     %7D%0A%0A%7D%0A

Implementa el Canny, solo falta los sliders para los thresholds