ios - GPUImage show histogram in another view -
i trying display histogram using gpuimage. have following code:
gpuimageoutput<gpuimageinput> *filter = [[gpuimagehistogramfilter alloc] initwithhistogramtype:kgpuimagehistogramluminance]; [self.stillcamera removetarget:filter]; gpuimagegammafilter *gammafilter = [[gpuimagegammafilter alloc] init]; [self.stillcamera addtarget:gammafilter]; [gammafilter addtarget:filter]; gpuimagehistogramgenerator *histogramgraph = [[gpuimagehistogramgenerator alloc] init]; [histogramgraph forceprocessingatsize:cgsizemake(500.0, 500)]; [filter addtarget:histogramgraph]; gpuimagealphablendfilter *blendfilter = [[gpuimagealphablendfilter alloc] init]; blendfilter.mix = 0.75; [blendfilter forceprocessingatsize:cgsizemake(500, 500)]; [self.stillcamera addtarget:blendfilter]; [histogramgraph addtarget:blendfilter]; [blendfilter addtarget:previewview];
above shows histogram overplayed on previewview. (it flicker however, issue, day)
i want show histogram on smaller view in particular location on view. how can this?
to show histogram in separate view need add gpuimageview
main view , point histogram filter it. here source code based on simpleimagefilter
sample.
- (void)loadview { cgrect mainscreenframe = [[uiscreen mainscreen] applicationframe]; gpuimageview *primaryview = [[gpuimageview alloc] initwithframe:mainscreenframe]; self.view = primaryview; uiimage *inputimage = [uiimage imagenamed:@"wid-small.jpg"]; gpuimagepicture *sourcepicture = [[gpuimagepicture alloc] initwithimage:inputimage smoothlyscaleoutput:yes]; // creating view show histogram gpuimageview *histview = [[gpuimageview alloc] initwithframe:cgrectmake(mainscreenframe.size.width - 100, mainscreenframe.size.height - 100, 100, 100)]; [primaryview addsubview:histview]; // create histogram filter , generator , point histogram view gpuimageoutput<gpuimageinput> *histfilter = [[gpuimagehistogramfilter alloc] initwithhistogramtype:kgpuimagehistogramluminance]; gpuimageoutput<gpuimageinput> *histgenerator = [[gpuimagehistogramgenerator alloc] init]; [histgenerator forceprocessingatsize:histview.sizeinpixels]; [sourcepicture addtarget:histfilter]; [histfilter addtarget:histgenerator]; // note target - hist view [histgenerator addtarget:histview]; // setup sepia filter show main picture gpuimageoutput<gpuimageinput> *sepiafilter = [[gpuimagesepiafilter alloc] init]; [sepiafilter forceprocessingatsize:primaryview.sizeinpixels]; [sourcepicture addtarget:sepiafilter]; // note target - main view [sepiafilter addtarget:primaryview]; [sourcepicture processimage]; }
and final result:
Comments
Post a Comment