Open swayangjit opened 11 years ago
Seems to be working on the devices I have tested so far. There is a couple configuration issues that may be the problem:
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();
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
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
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 cwbatt@gmail.com; otherwise, I would recommend posting the project on github and leaving a link for me.
Cheers, Chris Batt
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
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:
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:
Chris Batt
Thanks I will try the code and if I get any problem then I will post the problem here.
Regards Swayangjit
imageOut = new JPGFileEndpoint(this, true, Environment.getExternalStorageDirectory().getAbsolutePath()+"/FilterPictures/outputImage", true);
but its not working