GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

capturePhotoProcessedUpToFilter does not save correctly the previewed image

Open valvoline opened this issue 14 years ago • 5 comments

Hi Brad,

Thank you for your excellent work!

I just noticed a (perhaps) bug. I tried the SimplePhotoFilter , adjusting the filters as follow:

  • (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.

    stillCamera = [[GPUImageStillCamera alloc] init];

    filter = [[GPUImageSketchFilter alloc] init];

    [filter prepareForImageCapture];

    GPUImageRotationFilter *rotationFilter = [[GPUImageRotationFilter alloc] initWithRotation:kGPUImageRotateRight];

    [stillCamera addTarget:rotationFilter]; [rotationFilter addTarget:filter];

    GPUImageView *filterView = (GPUImageView *)self.view;

    [rotationFilter addTarget:filter]; [filter addTarget:filterView]; [stillCamera startCameraCapture]; }

However, the saved image differs slightly from the previewed one. I think that the problem is about the different resolution of the previewed image and the output one.

I used a 4S for my test.

Best regards,

c.

valvoline avatar Apr 28 '12 16:04 valvoline

The sketch filter uses Sobel edge detection to determine the edges in an image. The preview images come in at 852x640, where the photo images are much larger. The Sobel filter by default checks only the neighboring pixels to determine edges, so when you take a higher-resolution photo, these edges are much finer in the final image.

You can override this behavior by setting the width and height factors used to sample surrounding pixels with code like the following:

  [(GPUImageSketchFilter *)filter setImageHeightFactor:640.0];
  [(GPUImageSketchFilter *)filter setImageWidthFactor:480.0];

You can adjust these values to produce the desired edge thickness you want. Once set, the same thickness should then be used for all image sizes processed by this filter.

BradLarson avatar Apr 28 '12 21:04 BradLarson

Hi Brad,

Thank you for the hint!

Now all the sobel-based filter looks really closer to the image preview. I tried ToonFilter and SketchFilter.

valvoline avatar Apr 28 '12 23:04 valvoline

Hi Brad, I might be missing something, but i can't get this to work: [(GPUImageSketchFilter *)filter setImageHeightFactor:640.0]; [(GPUImageSketchFilter *)filter setImageWidthFactor:480.0];

error message: No visible @interface for 'GPUImageSketchFilter' declares the selector 'setImageWidthFactor'

Can you give an example of use?

The effect im trying for is to get preview and taken photo to be somewhat similar. Peder

pednaa avatar Jan 10 '13 14:01 pednaa

@pednaa - The names of these properties were changed a few months ago when I restructured the filter hierarchy. You now want texelWidth and texelHeight, which would now be 1.0/640.0 and 1.0/480.0 in your example above.

BradLarson avatar Jan 10 '13 16:01 BradLarson

Thank You :)

Peder

pednaa avatar Jan 10 '13 21:01 pednaa