chrisbatt / AndroidFastImageProcessing

A framework for speeding up image processing on android devices by taking advantage of shaders on the GPU.
MIT License
285 stars 118 forks source link

CameraPreviewInput not working (including in examples) #10

Closed leeicmobile closed 10 years ago

leeicmobile commented 10 years ago

The View just remains blank with no camera preview updating, it does appear the render loops are being called and camTex.update is called, perhaps an issue with the shaders or the transform matrix? Any help much appreciated. code below:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.camera_layout);

    mGPUImageView = (FastImageProcessingView) findViewById(R.id.gpuImageView);

    pipeline = new FastImageProcessingPipeline();
    mGPUImageView.setPipeline(pipeline);

    input = new CameraPreviewInput(mGPUImageView);

    screen = new ScreenEndpoint(pipeline);

    input.addTarget(screen);

    pipeline.addRootRenderer(input);
    pipeline.startRendering();

}

onResume calls ((CameraPreviewInput) input).onResume();

onPause calls ((CameraPreviewInput) input).onPause();

R.layout.cameralayout includes: <project.android.imageprocessing.FastImageProcessingView
android:id="@+id/gpuImageView" android:layout_width="match_parent" android:layout_height="match_parent" />

leeicmobile commented 10 years ago

Added markAsDirty yo the CameraPreviewInput when notified of new frame available this fixed it it seems :)

public void onFrameAvailable(SurfaceTexture arg0) {
    markAsDirty();//<------this line
    view.requestRender();
}
chrisbatt commented 10 years ago

Yes, I recently added the only render when dirty, but it seems I missed it in both the image and video inputs. I will push up your change. Thanks!