3
votes

I creating set of GPUImageToneCurveFilter and storing in an array.

First i am creating preview video view for all filters using GPUImageVideoCamera after selecting any filter i am trying to add that filter detail view (GPUImageStillCamera ). But i am getting black screen for this.

If i recreate new filter instead of reusing and then add to GPUImageStillCamera it work fine. any solution to this.

Preview view creating code:

    -(void)setUpUI{

    self.videoView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;
    }




-(void)addFilter:(id)filter
        {
        // For thumbnails smaller than the input video size, we currently need to make them render at a smaller size.
        // This is to avoid wasting processing time on larger frames than will be displayed.
        // You'll need to use -forceProcessingAtSize: with a zero size to re-enable full frame processing of video.
        self.filter = filter;
        [filter forceProcessingAtSize:self.videoView.sizeInPixels];
        [[CameraProvider sharedProvider] addTarget:filter];
        [filter addTarget:self.videoView];

        [[CameraProvider sharedProvider] startCameraCapture];
        self.titleLabel.text = [filter fliterName];
        }



 -(void)stopCamera
        {
        [self.filter removeAllTargets];
        [[CameraProvider sharedProvider] removeTarget:self.filter];
        [[CameraProvider sharedProvider] stopCameraCapture];

        }



-(IBAction)selectionDone:(id)sender { 

            [[CameraProvider sharedProvider] removeInputsAndOutputs]; 
             self.selectedFilter(self.filter);

     }


 // Adding to detail view (GPUImageStillCamera0:





  - (void)didSelectFilter:(id)newfilter;
        {
        NSLog(@"fliter");
        // newfilter = [[GPUImageToneCurveFilter alloc] initWithACV:@"california-gold-rush.acv"];
        [newfilter prepareForImageCapture];
        [stillCamera addTarget:newfilter];
        [newfilter addTarget:self.imageView];

        [stillCamera startCameraCapture];
    }
1
Even i created issue here github.com/BradLarson/GPUImage/issues/598 but so answer till yet.ShivaPrasad

1 Answers

0
votes

If i recreate new filter instead of reusing and then add to GPUImageStillCamera it work fine.

I hate to state the obvious, but the solution is to recreate the filter when you need it rather than trying to reuse it.

What you want from that array is "a way of getting a filter object given an index". There are many ways of getting that filter object. One of them is to preallocate an array and index into the array. Another is to write a function that, given an index, returns a newly-created object of the same type as you would have retrieved from the array. Instead of having an array of filters, use an array of factories for filters.