Skip to content

The image is not being saved to the Sdcard.. Ihave used the follwing code #1

Open

Description

@swayangjit

imageOut = new JPGFileEndpoint(this, true, Environment.getExternalStorageDirectory().getAbsolutePath()+"/FilterPictures/outputImage", true);

but its not working

Activity

  1. chrisbatt commented on Aug 21, 2013

    @chrisbatt
    Owner

    Seems to be working on the devices I have tested so far. There is a couple configuration issues that may be the problem:

    1. Is in your manifest?
    2. Does the filepath Environment.getExternalStorageDirectory().getAbsolutePath()+"/FilterPictures" exist on the device at the time the image is written out?
    3. Currently, JPGFileEndpoint will not create the any non-existent folders in the file path. It assumes that the folder structure is already created.
    4. Is there an input of some sort outputting to your imageOut? For example:
            FastImageProcessingView view = new FastImageProcessingView(this);
            FastImageProcessingPipeline pipeline = new FastImageProcessingPipeline();
            VideoResourceInput video = new VideoResourceInput(view, this, R.raw.birds);
            JPGFileEndpoint image = new JPGFileEndpoint(this, true, Environment.getExternalStorageDirectory().getAbsolutePath()+"/FilterPictures/outputImage", true);
    
     /*The video input is outputting to the JPGFileEndpoint*/
            video.addTarget(image);
            pipeline.addRootRenderer(video);
            view.setPipeline(pipeline);
            setContentView(view);
            pipeline.startRendering();
    1. Does the VideoToImage sample work?
    2. Assuming that Environment.getExternalStorageDirectory().getAbsolutePath()+"/Pictures" is a valid path on the device you are testing with.

    If none of that works, would it be possible for you to post the full class that you are using or a small sample that demonstrates the code that is not working for you. This would allow me to see if the issue is device specific or a general error.

    Thanks,
    Chris Batt

  2. swayangjit commented on Aug 21, 2013

    @swayangjit
    Author

    I am using your AllFiltersExample example source code but in that class the target for for JPGFileEndpoint is not mentioned anywhere So i want know where to mention the output target so that each time when I apply a filter it will create one image or else I want to put a button over there that will create Filtered image for the selected Filter. I am using the following code but it is not creating any image. I can send you the project if you want to see.

    Thanks and Regards
    Swayangjit

  3. chrisbatt commented on Aug 22, 2013

    @chrisbatt
    Owner

    Being able to see the project or a similar project with the same issue would be helpful. To convert the AllFiltersExample to use the JPGFileEndpoint, all you have to do is replace all of the lines with "screen" with your new JPGFileEndpoint. If you would like to render to the screen as well as the file endpoint, simply place a copy of the screen line after the line calling to the file endpoint. For example:

    ...
            screen = new ScreenEndpoint(pipeline);
    
    /* Create a new JPGFileEndpoint that will write to the image gallery */
            output = new JPGFileEndpoint(this, true, Environment.getExternalStorageDirectory().getAbsolutePath()+"/Download/outputImage", false);
    
    /* Set the JPGFileEndpoint as the output for the initial image */
            input.addTarget(output);
            input.addTarget(screen);
    
            for(BasicFilter filter : filters) {
    /* Set the JPGFileEndpoint as the output for all of the filters */
                filter.addTarget(output);
                filter.addTarget(screen);
            }
    ...
                        if(curFilter == 0) {
    
    /* If we are on the first image it is not being filtered so instead of removing a filter we must remove the JPGFileEndpoint and the ScreenEndpoint because we want it to pass through the filter now*/
                            input.removeTarget(output);
                            input.removeTarget(screen);
                        } else {
                            input.removeTarget(filters.get(curFilter-1));
                            pipeline.addFilterToDestroy(filters.get(curFilter-1));
                        }
                        curFilter=(curFilter+1)%(filters.size()+1);
                        if(curFilter == 0) {
    
    /* If we are switching back to the first image it should not be getting filtered so we need to add the JPGFileEndpoint and ScreenEndpoint back as the output targets */
                            input.addTarget(output);
                            input.addTarget(screen);
                        } else {
                            input.addTarget(filters.get(curFilter-1));
    ...

    On a side note, if you are using the AllFiltersExample, the layout should not matter because the view is being set programmatically. The only two files that should effect the project are the Activity and the AndroidManifest.xml. If the files are small enough to send by email, you can reach me at [email protected]; otherwise, I would recommend posting the project on github and leaving a link for me.

    Cheers,
    Chris Batt

  4. swayangjit commented on Aug 22, 2013

    @swayangjit
    Author

    outputimage

    Please check your mail I have sent you the project of the application can you check the application if possible also I have sent you the image after filtration which is distorted .

    Thanks and Regards
    Swayangjit

  5. chrisbatt commented on Aug 23, 2013

    @chrisbatt
    Owner

    Sadly, your code ran fine on the device I am testing with. I did run into an issue yesterday with a particular device. It seems that had to set the width and height of the JPGFileEndpoint to half the source image width and half the source image height to get the image to render properly. It was showing the bottom half of the image as black. I believe the issue was either being cause by:

    1. the screen pixel density causing the a difference in width and height between the screen and the output image or
    2. by the image trying to draw off partially screen causing the image to be black.
      I should be able to grab a couple different devices this weekend to try find what problem actually is.

    In JPGFileEndpoint.java in the newTextureReady method try replacing

            setWidth(source.getWidth());
            setHeight(source.getHeight());

    with different values. If it is the first issue then the solution may be replacing it with

            setWidth(source.getWidth()/2); /* or some other scale factor other than 2 */
            setHeight(source.getHeight()/2);

    If it is the second issue then the solution may be replacing it with a small constant value such as 256. If neither of those work, then it is a completely different issue. I would be interested in knowing what kind of device(s) you are testing with or what the screen size / pixel ratio is.

    On a side note, you should be able to do the whole layout in xml (I noticed that you were adding the FastImageProcessingView to the layout programatically). I think the FastImageProcessingView is missing a required constructor at the moment though which would prevent this. Adding

        public FastImageProcessingView(Context context, AttributeSet attrs) {
            super(context, attrs);
            setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR | GLSurfaceView.DEBUG_LOG_GL_CALLS);
            setEGLContextClientVersion(2);
        }

    to FastImageProcessingView.java should allow you to do it all in the layout.xml. I will try to get the fix in the repo as well.

    Here are the some of the output images I am getting with your code:
    1377238071729
    1377238076677

    Chris Batt

  6. swayangjit commented on Aug 23, 2013

    @swayangjit
    Author

    Thanks I will try the code and if I get any problem then I will post the problem here.

    Regards
    Swayangjit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions