Skip to content

Commit

Permalink
Ported another set of filters to the Mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradLarson committed Apr 24, 2013
1 parent b4613ca commit a4270b0
Show file tree
Hide file tree
Showing 22 changed files with 847 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
BCF8679717263FCF00912E34 /* SLSFilterShowcaseWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCF8679517263FCF00912E34 /* SLSFilterShowcaseWindowController.xib */; };
BCF8679A1726410E00912E34 /* GPUImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCF8678F17263F3500912E34 /* GPUImage.framework */; };
BCF867A1172762B500912E34 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCF867A0172762B500912E34 /* AVFoundation.framework */; };
BCF8680B17284D6A00912E34 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCF8680A17284D6A00912E34 /* QuartzCore.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -55,13 +56,15 @@
BCF8679417263FCF00912E34 /* SLSFilterShowcaseWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SLSFilterShowcaseWindowController.m; path = ../SLSFilterShowcaseWindowController.m; sourceTree = "<group>"; };
BCF8679517263FCF00912E34 /* SLSFilterShowcaseWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SLSFilterShowcaseWindowController.xib; path = ../SLSFilterShowcaseWindowController.xib; sourceTree = "<group>"; };
BCF867A0172762B500912E34 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
BCF8680A17284D6A00912E34 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
BCF8676717263EAC00912E34 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BCF8680B17284D6A00912E34 /* QuartzCore.framework in Frameworks */,
BCF867A1172762B500912E34 /* AVFoundation.framework in Frameworks */,
BCF8679A1726410E00912E34 /* GPUImage.framework in Frameworks */,
BCF8676E17263EAC00912E34 /* Cocoa.framework in Frameworks */,
Expand All @@ -74,7 +77,6 @@
BCF8676117263EAC00912E34 = {
isa = PBXGroup;
children = (
BCF867A0172762B500912E34 /* AVFoundation.framework */,
BCF8677317263EAC00912E34 /* FilterShowcase */,
BCF8676C17263EAC00912E34 /* Frameworks */,
BCF8676B17263EAC00912E34 /* Products */,
Expand All @@ -94,6 +96,8 @@
children = (
BCF8678A17263F3400912E34 /* GPUImageMac.xcodeproj */,
BCF8676D17263EAC00912E34 /* Cocoa.framework */,
BCF8680A17284D6A00912E34 /* QuartzCore.framework */,
BCF867A0172762B500912E34 /* AVFoundation.framework */,
BCF8676F17263EAC00912E34 /* Other Frameworks */,
);
name = Frameworks;
Expand Down
17 changes: 17 additions & 0 deletions examples/Mac/FilterShowcase/SLSFilterShowcaseWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,29 @@ typedef enum {
GPUIMAGE_HUE,
GPUIMAGE_WHITEBALANCE,
GPUIMAGE_MONOCHROME,
GPUIMAGE_FALSECOLOR,
GPUIMAGE_SHARPEN,
GPUIMAGE_UNSHARPMASK,
GPUIMAGE_TRANSFORM,
GPUIMAGE_TRANSFORM3D,
GPUIMAGE_CROP,
GPUIMAGE_PIXELLATE,
GPUIMAGE_GRAYSCALE,
GPUIMAGE_SOBELEDGEDETECTION,
GPUIMAGE_SKETCH,
GPUIMAGE_TOON,
GPUIMAGE_KUWAHARA,
GPUIMAGE_GAUSSIAN,

GPUIMAGE_GAUSSIAN_SELECTIVE,
GPUIMAGE_GAUSSIAN_POSITION,
GPUIMAGE_FASTBLUR,
GPUIMAGE_BOXBLUR,
GPUIMAGE_MEDIAN,
GPUIMAGE_BILATERAL,
GPUIMAGE_MOTIONBLUR,
GPUIMAGE_ZOOMBLUR,

GPUIMAGE_NUMFILTERS
} GPUImageShowcaseFilterType;

Expand Down
172 changes: 172 additions & 0 deletions examples/Mac/FilterShowcase/SLSFilterShowcaseWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ - (void)windowDidLoad
[super windowDidLoad];

inputCamera = [[GPUImageAVCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionUnspecified];
inputCamera.runBenchmark = YES;

currentlySelectedRow = 1;
[self changeSelectedRow:0];
Expand Down Expand Up @@ -139,6 +140,64 @@ - (void)changeSelectedRow:(NSUInteger)newRowIndex;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_FALSECOLOR:
{
currentlySelectedFilter = [[GPUImageFalseColorFilter alloc] init];
self.enableSlider = NO;
}; break;
case GPUIMAGE_SHARPEN:
{
currentlySelectedFilter = [[GPUImageSharpenFilter alloc] init];

self.minimumSliderValue = -1.0;
self.maximumSliderValue = 4.0;
self.currentSliderValue = 0.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_UNSHARPMASK:
{
currentlySelectedFilter = [[GPUImageUnsharpMaskFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 5.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_TRANSFORM:
{
currentlySelectedFilter = [[GPUImageTransformFilter alloc] init];
[(GPUImageTransformFilter *)currentlySelectedFilter setAffineTransform:CGAffineTransformMakeRotation(2.0)];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 6.28;
self.currentSliderValue = 2.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_TRANSFORM3D:
{
currentlySelectedFilter = [[GPUImageTransformFilter alloc] init];
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 0.4;
perspectiveTransform.m33 = 0.4;
perspectiveTransform = CATransform3DScale(perspectiveTransform, 0.75, 0.75, 0.75);
perspectiveTransform = CATransform3DRotate(perspectiveTransform, 0.75, 0.0, 1.0, 0.0);

[(GPUImageTransformFilter *)currentlySelectedFilter setTransform3D:perspectiveTransform];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 6.28;
self.currentSliderValue = 0.75;
self.enableSlider = YES;
}; break;
case GPUIMAGE_CROP:
{
currentlySelectedFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.0, 0.0, 1.0, 0.25)];

self.minimumSliderValue = 0.2;
self.maximumSliderValue = 1.0;
self.currentSliderValue = 0.5;
self.enableSlider = YES;
}; break;
case GPUIMAGE_GRAYSCALE:
{
currentlySelectedFilter = [[GPUImageGrayscaleFilter alloc] init];
Expand Down Expand Up @@ -177,6 +236,83 @@ - (void)changeSelectedRow:(NSUInteger)newRowIndex;
self.currentSliderValue = 3.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_GAUSSIAN:
{
currentlySelectedFilter = [[GPUImageGaussianBlurFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 10.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_GAUSSIAN_SELECTIVE:
{
currentlySelectedFilter = [[GPUImageGaussianSelectiveBlurFilter alloc] init];
[(GPUImageGaussianSelectiveBlurFilter*)currentlySelectedFilter setExcludeCircleRadius:40.0/320.0];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 0.75;
self.currentSliderValue = 40.0/320.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_GAUSSIAN_POSITION:
{
currentlySelectedFilter = [[GPUImageGaussianBlurPositionFilter alloc] init];
[(GPUImageGaussianBlurPositionFilter*)currentlySelectedFilter setBlurRadius:40.0/320.0];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 0.75;
self.currentSliderValue = 40.0/320.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_FASTBLUR:
{
currentlySelectedFilter = [[GPUImageFastBlurFilter alloc] init];

self.minimumSliderValue = 1.0;
self.maximumSliderValue = 10.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_BOXBLUR:
{
currentlySelectedFilter = [[GPUImageBoxBlurFilter alloc] init];

self.enableSlider = NO;
}; break;
case GPUIMAGE_MEDIAN:
{
currentlySelectedFilter = [[GPUImageMedianFilter alloc] init];

self.enableSlider = NO;
}; break;
case GPUIMAGE_BILATERAL:
{
currentlySelectedFilter = [[GPUImageBilateralFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 10.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_MOTIONBLUR:
{
currentlySelectedFilter = [[GPUImageMotionBlurFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 180.0;
self.currentSliderValue = 0.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_ZOOMBLUR:
{
currentlySelectedFilter = [[GPUImageZoomBlurFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 2.5;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
}

[inputCamera addTarget:currentlySelectedFilter];
Expand Down Expand Up @@ -206,6 +342,27 @@ - (void)setCurrentSliderValue:(CGFloat)newValue;
case GPUIMAGE_MONOCHROME: [(GPUImageMonochromeFilter *)currentlySelectedFilter setIntensity:_currentSliderValue]; break;
case GPUIMAGE_PIXELLATE: [(GPUImagePixellateFilter *)currentlySelectedFilter setFractionalWidthOfAPixel:_currentSliderValue]; break;
case GPUIMAGE_KUWAHARA: [(GPUImageKuwaharaFilter *)currentlySelectedFilter setRadius:round(_currentSliderValue)]; break;
case GPUIMAGE_SHARPEN: [(GPUImageSharpenFilter *)currentlySelectedFilter setSharpness:_currentSliderValue]; break;
case GPUIMAGE_UNSHARPMASK: [(GPUImageUnsharpMaskFilter *)currentlySelectedFilter setIntensity:_currentSliderValue]; break;
case GPUIMAGE_TRANSFORM: [(GPUImageTransformFilter *)currentlySelectedFilter setAffineTransform:CGAffineTransformMakeRotation(_currentSliderValue)]; break;
case GPUIMAGE_TRANSFORM3D:
{
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 0.4;
perspectiveTransform.m33 = 0.4;
perspectiveTransform = CATransform3DScale(perspectiveTransform, 0.75, 0.75, 0.75);
perspectiveTransform = CATransform3DRotate(perspectiveTransform, _currentSliderValue, 0.0, 1.0, 0.0);

[(GPUImageTransformFilter *)currentlySelectedFilter setTransform3D:perspectiveTransform];
}; break;
case GPUIMAGE_CROP: [(GPUImageCropFilter *)currentlySelectedFilter setCropRegion:CGRectMake(0.0, 0.0, 1.0, _currentSliderValue)]; break;
case GPUIMAGE_GAUSSIAN: [(GPUImageGaussianBlurFilter *)currentlySelectedFilter setBlurSize:_currentSliderValue]; break;
case GPUIMAGE_GAUSSIAN_SELECTIVE: [(GPUImageGaussianSelectiveBlurFilter *)currentlySelectedFilter setExcludeCircleRadius:_currentSliderValue]; break;
case GPUIMAGE_GAUSSIAN_POSITION: [(GPUImageGaussianBlurPositionFilter *)currentlySelectedFilter setBlurRadius:_currentSliderValue]; break;
case GPUIMAGE_FASTBLUR: [(GPUImageFastBlurFilter *)currentlySelectedFilter setBlurPasses:round(_currentSliderValue)]; break;
case GPUIMAGE_BILATERAL: [(GPUImageBilateralFilter *)currentlySelectedFilter setDistanceNormalizationFactor:_currentSliderValue]; break;
case GPUIMAGE_MOTIONBLUR: [(GPUImageMotionBlurFilter *)currentlySelectedFilter setBlurAngle:_currentSliderValue]; break;
case GPUIMAGE_ZOOMBLUR: [(GPUImageZoomBlurFilter *)currentlySelectedFilter setBlurSize:_currentSliderValue]; break;
}
}

Expand Down Expand Up @@ -238,6 +395,21 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
case GPUIMAGE_SKETCH: tableRowTitle = @"Sketch"; break;
case GPUIMAGE_TOON: tableRowTitle = @"Toon"; break;
case GPUIMAGE_KUWAHARA: tableRowTitle = @"Kuwahara"; break;
case GPUIMAGE_FALSECOLOR: tableRowTitle = @"False color"; break;
case GPUIMAGE_SHARPEN: tableRowTitle = @"Sharpen"; break;
case GPUIMAGE_UNSHARPMASK: tableRowTitle = @"Unsharp mask"; break;
case GPUIMAGE_TRANSFORM: tableRowTitle = @"Transform (2-D)"; break;
case GPUIMAGE_TRANSFORM3D: tableRowTitle = @"Transform (3-D)"; break;
case GPUIMAGE_CROP: tableRowTitle = @"Crop"; break;
case GPUIMAGE_GAUSSIAN: tableRowTitle = @"Gaussian blur"; break;
case GPUIMAGE_GAUSSIAN_SELECTIVE: tableRowTitle = @"Gaussian selective blur"; break;
case GPUIMAGE_GAUSSIAN_POSITION: tableRowTitle = @"Gaussian (centered)"; break;
case GPUIMAGE_FASTBLUR: tableRowTitle = @"Gaussian blur (optimized)"; break;
case GPUIMAGE_BOXBLUR: tableRowTitle = @"Box blur"; break;
case GPUIMAGE_MEDIAN: tableRowTitle = @"Median (3x3)"; break;
case GPUIMAGE_BILATERAL: tableRowTitle = @"Bilateral blur"; break;
case GPUIMAGE_MOTIONBLUR: tableRowTitle = @"Motion blur"; break;
case GPUIMAGE_ZOOMBLUR: tableRowTitle = @"Zoom blur"; break;
}

return tableRowTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case GPUIMAGE_KUWAHARARADIUS3: cell.textLabel.text = @"Kuwahara (fixed radius)"; break;
case GPUIMAGE_VIGNETTE: cell.textLabel.text = @"Vignette"; break;
case GPUIMAGE_GAUSSIAN: cell.textLabel.text = @"Gaussian blur"; break;
case GPUIMAGE_FASTBLUR: cell.textLabel.text = @"Fast blur"; break;
case GPUIMAGE_FASTBLUR: cell.textLabel.text = @"Gaussian blur (optimized)"; break;
case GPUIMAGE_MEDIAN: cell.textLabel.text = @"Median (3x3)"; break;
case GPUIMAGE_BILATERAL: cell.textLabel.text = @"Bilateral blur"; break;
case GPUIMAGE_MOTIONBLUR: cell.textLabel.text = @"Motion blur"; break;
Expand Down
Loading

0 comments on commit a4270b0

Please sign in to comment.