Search in sources :

Example 1 with SobelEdgeDetectionFilter

use of com.marshalchen.common.uimodule.imageprocessing.filter.processing.SobelEdgeDetectionFilter in project UltimateAndroid by cymcsg.

the class ImageProcessingVideotoImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    view = new FastImageProcessingView(this);
    pipeline = new FastImageProcessingPipeline();
    video = new VideoResourceInput(view, this, R.raw.image_processing_birds);
    edgeDetect = new SobelEdgeDetectionFilter();
    image = new JPGFileEndpoint(this, false, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/outputImage", false);
    screen = new ScreenEndpoint(pipeline);
    video.addTarget(edgeDetect);
    edgeDetect.addTarget(image);
    edgeDetect.addTarget(screen);
    pipeline.addRootRenderer(video);
    view.setPipeline(pipeline);
    setContentView(view);
    pipeline.startRendering();
    video.startWhenReady();
    view.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent me) {
            if (System.currentTimeMillis() - 100 > touchTime) {
                touchTime = System.currentTimeMillis();
                if (video.isPlaying()) {
                    video.stop();
                } else {
                    video.startWhenReady();
                }
            }
            return true;
        }
    });
}
Also used : JPGFileEndpoint(com.marshalchen.common.uimodule.imageprocessing.outputs.JPGFileEndpoint) OnTouchListener(android.view.View.OnTouchListener) SobelEdgeDetectionFilter(com.marshalchen.common.uimodule.imageprocessing.filter.processing.SobelEdgeDetectionFilter) FastImageProcessingView(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView) ScreenEndpoint(com.marshalchen.common.uimodule.imageprocessing.outputs.ScreenEndpoint) FastImageProcessingView(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView) View(android.view.View) FastImageProcessingPipeline(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingPipeline) VideoResourceInput(com.marshalchen.common.uimodule.imageprocessing.input.VideoResourceInput) MotionEvent(android.view.MotionEvent)

Aggregations

MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 OnTouchListener (android.view.View.OnTouchListener)1 FastImageProcessingPipeline (com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingPipeline)1 FastImageProcessingView (com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView)1 SobelEdgeDetectionFilter (com.marshalchen.common.uimodule.imageprocessing.filter.processing.SobelEdgeDetectionFilter)1 VideoResourceInput (com.marshalchen.common.uimodule.imageprocessing.input.VideoResourceInput)1 JPGFileEndpoint (com.marshalchen.common.uimodule.imageprocessing.outputs.JPGFileEndpoint)1 ScreenEndpoint (com.marshalchen.common.uimodule.imageprocessing.outputs.ScreenEndpoint)1