Giter VIP home page Giter VIP logo

androidfastimageprocessing's People

Contributors

chrisbatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidfastimageprocessing's Issues

NormalBlendFilter doesn't work as I think.

Hello, thanks for your great framework.
It's really a helpful for me.

I have some issues to use and need your help.
Following is my code part.

protected void onCreate(Bundle savedInstanceState) {
....
// For Camera Input
view1 = new FastImageProcessingView(this);
pipeline1 = new FastImageProcessingPipeline();
view1.setPipeline(pipeline1);

    cameraInput = new CameraPreviewInput(view1);
    screen1 = new ScreenEndpoint(pipeline1);
    cameraInput.addTarget(screen1);

    pipeline1.addRootRenderer(cameraInput);
    pipeline1.startRendering();

// For Image Input
view2 = new FastImageProcessingView(this);
pipeline2 = new FastImageProcessingPipeline();
view2.setPipeline(pipeline2);
screen2 = new ScreenEndpoint(pipeline2);
....
}

private void applyFilter {
...
TransformFilter transformFilter = new TransformFilter(new float[] {
transformScale, 0f, 0f, 0f,
0f, transformScale, 0f, 0f,
0f, 0f, 1f, 0f,
0f, 0f, 0f, 1f
}, false, false);
GaussianBlurFilter gaussianBlurFilter;
gaussianBlurFilter = new GaussianBlurFilter(3.0f);

        // blend
        NormalBlendFilter normalBlendFilter = new NormalBlendFilter();

        ImageResourceInput sourcePicture = new ImageResourceInput(view2, this, R.drawable.blob_texture);
        pipeline2.addRootRenderer(sourcePicture);

        // swirl
        SwirlFilter swirlFilter = new SwirlFilter(new PointF(0.5f, 0.5f), 0.5f, swirlAngle);
        swirlFilter.addTarget(gaussianBlurFilter);
        normalBlendFilter.addTarget(swirlFilter);

        curFilter = normalBlendFilter;
        cameraInput.addTarget(curFilter);
        gaussianBlurFilter.addTarget(screen1);

        sourcePicture.addTarget(transformFilter);
        transformFilter.addTarget(normalBlendFilter);

        pipeline1.startRendering();
        pipeline2.startRendering();
        view1.requestRender();

...
}

I found that NormalBlendFilter doesn't work properly. Please check my code.

Thanks.

JPGFileEndpoint quality.

Thanks for your great framework.
I would like to get the high-quality screenshot from the various filter.
Now, JPGFileEndPoint returns the low-quality image.
Can you resolve this issue?

Thanks.

GroupFilter does not work

I've noticed that GroupFilter doesn't work or maybe I use it in a wrong way.
I want to process image from ImageView that is set in RelativeLayout.

My GroupFilter class:

class MyGroupFilter extends GroupFilter {

    public void register(BasicFilter filter) {
        super.registerFilter(filter);
    }

    public void registerInitial(BasicFilter filter) {
        super.registerInitialFilter(filter);
    }

    public void registerTerminal(BasicFilter filter) {
        super.registerTerminalFilter(filter);
    }
}

MyGroupFilter groupFilter = new MyGroupFilter();

Here is my init code:

            view = new FastImageProcessingView(this);
    pipeline = new FastImageProcessingPipeline();
    view.setPipeline(pipeline);
    imageIn = new ImageResourceInput(view, this, R.drawable.penguins2);
    screen = new ScreenEndpoint(pipeline);
    imageIn.addTarget(screen);
    pipeline.addRootRenderer(imageIn);
    pipeline.startRendering();

    relativeLayout.addView(view);

I have two buttons (plus and minus) for controlling brightness level and also two buttons for controlling saturation level. Every time I push any button, my filter method is invoked with appropriate value of brighnessLevelF and saturationLevelF (which are floats and represent levels of brightness and saturation). Method body:

    pipeline.pauseRendering();
    imageIn.removeTarget(groupFilter);
    pipeline.addFilterToDestroy(groupFilter);

    BrightnessFilter brightnessFilter = new BrightnessFilter(brighnessLevelF);
    brightnessFilter.addTarget(screen);
    SaturationFilter saturationFilter = new SaturationFilter(saturationLevelF);
    saturationFilter.addTarget(screen);

    groupFilter.registerInitial(brightnessFilter);
    groupFilter.registerTerminal(saturationFilter);
    imageIn.addTarget(groupFilter);

    pipeline.startRendering();
    view.requestRender();

It works but only brightness level is changing. Am I doing something wrong?

MultiInputFilter not working for 3 inputs

I am trying to run filters in parallel like we do in iOS GPUIMAGE library, but I am having issues while adding 3 inputs to one filter which extends MultiInputFilter.
I am trying to combine

1>BasicCameraInputFilter
2>CannyEdgeDetectionFilter
3>SobelEdgeDetectionFilter

where BasicCameraInputFilter is direct camera input .

	BasicCameraInputFilter cameraInput=new BasicCameraInputFilter();
	CannyEdgeDetectionFilter cannyEdgeDetectionFilter =
			new CannyEdgeDetectionFilter(1.0f,0.3f,0.6f);
	SobelEdgeDetectionFilter sobelEdgeDetectionFilter=new SobelEdgeDetectionFilter();

	CombinationFilter combinationFilter=new CombinationFilter();

	cameraInput.addTarget(combinationFilter);
	cannyEdgeDetectionFilter.addTarget(combinationFilter);
	sobelEdgeDetectionFilter.addTarget(combinationFilter);
	combinationFilter.registerFilterLocation(cameraInput,0);
	combinationFilter.registerFilterLocation(cannyEdgeDetectionFilter,1);
	combinationFilter.registerFilterLocation(sobelEdgeDetectionFilter,2);
	combinationFilter.addTarget(this);

	registerInitialFilter(cameraInput);
	registerFilter(cannyEdgeDetectionFilter);
	registerFilter(sobelEdgeDetectionFilter);
	registerTerminalFilter(combinationFilter);

Here is my fragment shader

"precision mediump float;\n"
						+"uniform sampler2D "+UNIFORM_TEXTURE0+";\n"
						+"uniform sampler2D "+UNIFORM_TEXTUREBASE+1+";\n"
						+"uniform sampler2D "+UNIFORM_TEXTUREBASE+2+";\n"
						+"varying vec2 "+VARYING_TEXCOORD+";\n"

						+"void main(){\n"
						+"   vec4 color1 = texture2D("+UNIFORM_TEXTURE0+","+VARYING_TEXCOORD+");\n"
						+"   vec4 color2 = texture2D("+UNIFORM_TEXTUREBASE+1+","+VARYING_TEXCOORD+");\n"
						+"   vec4 color3 = texture2D("+UNIFORM_TEXTUREBASE+2+","+VARYING_TEXCOORD+");\n"

						+"   vec4 whiteColor = vec4(1.0);\n"
						+" 		whiteColor.r=color1.r*color2.r*color3.r;\n	"
						+" 		whiteColor.g=color1.g*color2.g*color3.g;\n	"
						+" 		whiteColor.b=color1.b*color2.b*color3.b;\n	"
						+"   gl_FragColor =  whiteColor;\n"
						+"}\n";

Black screen in some devices

Any image I open specifically in Nexus 7 and Galaxy Tab 3 gets completely black. I figured out that the only way it works is inputing images of sizes power of 2 (512x512).

Filter Slow when I set 3 or 4 filter.

I custome Gaussian blur like TiltShiftFilter Instagram. If only 1 filter Gaussian Blur it's ok but I using Filter Group add 3 or 4 filter. It's slow and lag

Blend filters don't work correctly with images that has transparency.

I've also noticed that not only normal blend filter has an error, but when trying to apply almost all blend filters I've got either black screen or my overlay image but with black color in place where transparent should be. Also I've noticed some differences in behaviour of filters on htc ONE X and samsung galaxy SIII.
HTC behaves like nexus genymotion emulator in blending, but samsung works another way and some of filters working. But normal filter don't work too.
I've tried to change colors in NormalBlend shader to this.
+"void main(){\n"
+" vec4 color2 = texture2D("+UNIFORM_TEXTURE+","+VARYING_TEXCOORD+");\n"
+" vec4 color1 = texture2D("+UNIFORM_TEXTURE2+","+VARYING_TEXCOORD+");\n"

I've made a little videos.
https://www.youtube.com/watch?v=FBimYZQZWy4 - sgs3
https://www.youtube.com/watch?v=5Dccx4nW0N4 - htc one x

Store Filtered video in video formated file (like .mp4)

First of all, I would like to thank you for giving us a great library similar to GPUImage framework of iOS.

While viewing Library, I could find VideoToImageExample filtering sample. But it storing output as image in .jpg format in JPGFileEndpoint.java class.
I wanted to filter video and store filtered video in video formate file (like .mp4). That means VideoToVideoExample. Please help me for the same.

Thanks in advance.

only a ext

sorry,my English is poor,so I don't know how to express my mind

Project doesn't seem to have a LICENSE

I'd love to use this library, but it doesn't seem to have a license, or at least I couldn't find it.

Please could you add a LICENSE.md file to the project root? GitHub makes it pretty easy, just click the + here:

image

and then choose a license template:

image

Either CC0 1.0 Universal or the MIT License would be awesome. Thank you! 😄

High memory usage

Hi, we notice high memory usage on this library even on simple image filters (for example, 2 blends, brightness, contrast). We tested different filters on small image (640x640) and for one filter from 100MB to 300MB RAM memory was used. This amount is very large just for simple image processing and if this is true, this library is impractical to include in projects. We tested this with modifying GenericFilterExample included in this project. Do you have any information/idea/help about this problem?

Get filtrated bitmap

Framework should support to get filtrated image. It means that when we pass a image, after applying these filters, we can get processed image.

Which filter should I use to remove shadow from a bitmap

I took an image of a file and would like to process it to black and white text image. However, I'm having problem filtering out the shadow, would be great if you can give me a hint. Also is there a way to apply a black and white image filter as well? Thx for the great library!

Set Filtred Bitmap to ImageView

Hi,

I would like to use that framework in my app, I need to set the result to imageview, I saw the examples, but I don't want use setContentView.
It is possible? Thanks.

CameraPreviewInput not working (including in examples)

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" />

AllFilterExample throw exception (java.lang.IllegalArgumentException: No config chosen)

It throw exception and stoped when I try to run.

12-03 10:30:23.931 11314-11331/project.android.allfiltersexample E/AndroidRuntime: FATAL EXCEPTION: GLThread 227
                                                                                   Process: project.android.allfiltersexample, PID: 11314
                                                                                   java.lang.IllegalArgumentException: No config chosen
                                                                                       at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:869)
                                                                                       at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1023)
                                                                                       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1400)
                                                                                       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

Memory leak

Although I recycled all bitmaps in Lookup filters, but memory continue increasing and never go down. :(( You can use DDMS to see it.

Example not work in Emulator

This project is helpful for learning.

I tried the example. (such as AllFiltersExample)
It work well in physical device. but failed in emulator. (Black screen)

The emulator cannot open the camera. ( It work randomly sometimes, I tried the Android Emulator and genymotion.)

CameraPreviewInput.java is valid?

Run this processing in background service

I'm curious if possible we can run this processing function in background? For the current steps, we need first add the FastImageProcessingView to activity layout, can we bypass this to enable processing in a background service?
Thanks so much if anybody can help with this.

Memory leak

Hi all, we are trying to apply several filters on one photo (for example, the user can apply different filter on the photo several times one by one - something like on Instagram, user select filters from sliding bar and see the preview). In our implementation we use one pipeline and for each filter we use addRootRenderer(), and when next filter should be applied we call pipeline.removeRootRenderer() from the previous filter. The problem is that memory usage increases for about 200MB each time we apply filter and after several filters the application crashes. Can you give us a solution how to overcame this problem, what we are doing wrong?

Camera activity crashes after screen unlock

I've noticed that the app crashes (i've tried also the TwoInputFilterExample) everytime i lock the screen with the camera activity on focus and then i unlock the screen.
I've tried to manage this with onStop/onRestart but this solve the issue only on some devices (Asus TF201, Galaxy S4) but not in others (Galaxy S, S2).

Proper way to change matrix from TransformFilter

So, I'm testing a very basic setup:

             Image1 \
                     \
                       - >  blend -> view
                     /
Image2 -> transform /

Problem is, I want to modify the transform matrix based on user input. As I couldn't find any way to modify TransformFilter matrix after it's created, I'm destroying it and recreating it with the new matrix.

It's working fine on emulator, but when running on device, it always crash after a few edits. Sometimes it crashes due OutOfMemory error, and sometimes it crashes with:

08-26 15:56:13.173    4312-4327/? E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 270
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=-2
            at project.android.imageprocessing.filter.MultiInputFilter.newTextureReady(MultiInputFilter.java:87)
            at project.android.imageprocessing.input.GLTextureOutputRenderer.drawFrame(GLTextureOutputRenderer.java:88)
            at project.android.imageprocessing.input.ImageResourceInput.drawFrame(ImageResourceInput.java:67)
            at project.android.imageprocessing.GLRenderer.onDrawFrame(GLRenderer.java:232)
            at project.android.imageprocessing.FastImageProcessingPipeline.onDrawFrame(FastImageProcessingPipeline.java:91)
            at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1463)
            at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)

And here are the methods I'm calling to remove the transform, and then reinstall it:

private void clean() {
        pipeline.pauseRendering();

        input2.removeTarget(transform);
        blend.clearRegisteredFilterLocations();

        pipeline.addFilterToDestroy(transform);

        transform.removeTarget(blend);
        transform.destroy();
    }

    private void reinstallFilters() {

        Matrix.translateM(matrix, 0, matrix, 0, translatex, translatey, 0);

        transform = new TransformFilter(matrix, false, false);

//        debugMatrix();

        input2.addTarget(transform);
        transform.addTarget(blend);

        blend.registerFilterLocation(input);
        blend.registerFilterLocation(transform);

        pipeline.startRendering();
        preview.requestRender();
    }

License

hello, i was wondering what type of license is applied to this project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.