GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

Sometimes camera shows black screen

Open jadelmag opened this issue 14 years ago • 11 comments

Sometimes when you change filters you have a black screen in your output. I have this problem with AdaptiveThreshold and GPUImageSmoothToonFilter with stillcamera.

How can i solve it? Only happens with this filters

jadelmag avatar Jul 20 '12 09:07 jadelmag

How many filter do you have in your pipe? For my case, it works if I have less than 3 filters. More than that, sometimes it turns black...

nocaseguy avatar Jul 20 '12 10:07 nocaseguy

well, my problem is with GPUImageToonFilter and AdaptiveThreshold, and they use more than 3 filters So i think this is the problem.

Thanks

jadelmag avatar Jul 20 '12 10:07 jadelmag

Have you tried "prepareForImageCapture" on the last filter?

nocaseguy avatar Jul 20 '12 10:07 nocaseguy

Yes, or I think so...

  • (void)applySelectedEffect { //Paramos la cámara [stillCamera stopCameraCapture];

    //Borramos las dependencias de los filtros existentes y la cámara [filter removeAllTargets]; [stillCamera removeAllTargets];

    //Creamos un nuevo filtro filter = nil;

    [self selectedEffect]; [filter prepareForImageCapture];

    //Creamos las dependencias entre ellos [stillCamera addTarget:filter]; GPUImageView filterView =(GPUImageView)viewCamera; [filter addTarget:filterView];

    //Encendemos la cámara [stillCamera startCameraCapture]; }

  • (void)selectedEffect { if ([observerFilter.effect isEqualToString:@"3x3Convolution"]) { filter = [[GPUImage3x3ConvolutionFilter alloc] init]; [(GPUImage3x3ConvolutionFilter *)filter setConvolutionKernel:(GPUMatrix3x3){ {-1.0f, 0.0f, 1.0f}, {-2.0f, 0.0f, 2.0f}, {-1.0f, 0.0f, 1.0f} }]; } else if ([observerFilter.effect isEqualToString:@"3D"]) { filter = [[GPUImage3DFilter alloc] init]; } else if ([observerFilter.effect isEqualToString:@"AdaptiveThreshold"]) { filter = [[GPUImageAdaptiveThresholdFilter alloc] init]; [(GPUImageAdaptiveThresholdFilter *)filter setBlurSize:42.6]; } ....

jadelmag avatar Jul 20 '12 10:07 jadelmag

each filters use prepareForImageCapture。

ordinary avatar Jul 20 '12 11:07 ordinary

This is a known issue (see other issues here) that I am working on.

BradLarson avatar Jul 20 '12 14:07 BradLarson

Well, I'm glad I found this before spending too much time. My filter chain looks something like crop -> {group} -> output, where group is subclassed and constructs ToneCurve -> Monochrome -> Vignette. Seems that removing the vignette is the most reliable, though not perfect. Calling prepareForImageCapture doesn't seem to work reliably as it should.

iamcam avatar Jul 23 '12 21:07 iamcam

Try this now. I believe that I've tracked down where the black frames were coming from. The latest code in the repository should fix this.

BradLarson avatar Jul 25 '12 02:07 BradLarson

Tested. It works! And now I dont even have to use "prepareForImageCapture". Nice work, Brad-san!

nocaseguy avatar Jul 25 '12 03:07 nocaseguy

I think that did it! I can't reproduce the bug anymore.

Great work!

iamcam avatar Jul 25 '12 06:07 iamcam

When I use GPUImageSmoothToonFilter, it is quite easy to reproduce this black screen issue again. When use GPUImageToonFilter , this issue happen randomly. Even it is black screen, it can still provide the valid data because it is okay capture the real image.

What is the root cause of the black screen ?

ForrestShi avatar Nov 10 '12 09:11 ForrestShi