Permalink
Browse files

video chroma bla bla

  • Loading branch information...
1 parent cde3fd0 commit 4145c355c5e75f1c31197bc1b2167076ab108eb0 @HalfdanJ committed Oct 24, 2012
@@ -29,6 +29,7 @@
DDDC24201626B11800FBC44F /* BeamSync.m in Sources */ = {isa = PBXBuildFile; fileRef = DDDC241D1626B0C000FBC44F /* BeamSync.m */; };
DDDC242A16271BE200FBC44F /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDDC242916271BE200FBC44F /* AVFoundation.framework */; };
DDDC242C16271CAA00FBC44F /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDDC242B16271CAA00FBC44F /* CoreMedia.framework */; };
+ DDE868B31638AB2C00FB0477 /* MyAVPlayerItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DDE868B21638AB2C00FB0477 /* MyAVPlayerItem.m */; };
DDF6E3C216286BFB0049D444 /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF6E3C116286BFB0049D444 /* CoreMIDI.framework */; };
/* End PBXBuildFile section */
@@ -71,6 +72,8 @@
DDDC24231626D54500FBC44F /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = System/Library/Frameworks/QuickTime.framework; sourceTree = SDKROOT; };
DDDC242916271BE200FBC44F /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
DDDC242B16271CAA00FBC44F /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
+ DDE868B11638AB2C00FB0477 /* MyAVPlayerItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyAVPlayerItem.h; sourceTree = "<group>"; };
+ DDE868B21638AB2C00FB0477 /* MyAVPlayerItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyAVPlayerItem.m; sourceTree = "<group>"; };
DDF6E3C116286BFB0049D444 /* CoreMIDI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMIDI.framework; path = System/Library/Frameworks/CoreMIDI.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
@@ -155,6 +158,8 @@
DDDC241C1626B0C000FBC44F /* BeamSync.h */,
DDDC241D1626B0C000FBC44F /* BeamSync.m */,
DD9C845B1628053600089567 /* MavController.h */,
+ DDE868B11638AB2C00FB0477 /* MyAVPlayerItem.h */,
+ DDE868B21638AB2C00FB0477 /* MyAVPlayerItem.m */,
DD9C845C1628053600089567 /* MavController.mm */,
DD303C0D1625FA4400A4764C /* Supporting Files */,
);
@@ -262,6 +267,7 @@
DD303C56162605FF00A4764C /* DeinterlaceFilter.m in Sources */,
DDDC24201626B11800FBC44F /* BeamSync.m in Sources */,
DD9C845D1628053600089567 /* MavController.mm in Sources */,
+ DDE868B31638AB2C00FB0477 /* MyAVPlayerItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4,7 +4,7 @@
version = "1.0">
<ExceptionBreakpoints>
<ExceptionBreakpoint
- shouldBeEnabled = "No"
+ shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
@@ -74,7 +74,6 @@
@property (strong) CIFilter * perspectiveFilter;
@property (strong) CIFilter * perspectiveFilterMovie;
-@property (strong) CIFilter * chromaGaussian;
@property (strong) CIFilter * chromaTransform;
@property (strong) CIFilter * chromaCrop;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -9,5 +9,5 @@
#import <AVFoundation/AVFoundation.h>
@interface MyAVPlayerItem : AVPlayerItem
-
+@property NSNumber * chromaKey;
@end

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -10,17 +10,18 @@
@interface ChromaFilter : CIFilter{
CIImage * _inputImage;
- CIImage * _inputForegroundImage;
- CIImage * _backgroundImage;
- CIFilter *colorCube;
+// CIImage * _inputForegroundImage;
+ CIImage * _inputBackgroundImage;
CIFilter * sourceOverFilter;
}
@property (strong) CIImage *inputImage;
-@property (strong) CIImage *inputForegroundImage;
+//@property (strong) CIImage *inputForegroundImage;
@property (strong) CIImage *inputBackgroundImage;
+
+
-(void) setMinHueAngle:(float)minHueAngle maxHueAngle:(float)maxHueAngle minValue:(float)minValue minSaturation:(float)minSaturation;
-(CIImage*)outputImage;
-
+-(void) setGaussianRadius:(float)radius setGaussianRadius2:(float)radius2 noiseReduction:(float)noiseReduction;
@end
@@ -58,28 +58,58 @@ void rgb2hsv(float * rgb, float * hsv)
static CIKernel *alphaOverKernel = nil;
+static CIKernel *alphaThresholdKernel = nil;
@implementation ChromaFilter
@synthesize inputImage = _inputImage;
@synthesize inputBackgroundImage = _inputBackgroundImage;
-@synthesize inputForegroundImage = _inputForegroundImage;
+//@synthesize inputForegroundImage = _inputForegroundImage;
+
+static dispatch_once_t onceToken;
+static CIFilter *colorCube;
+static CIFilter * gaussianFilter;
+static CIFilter * gaussianFilter2;
+static CIFilter * noiseReductionFilter;
+static CIFilter * scaleFilter;
- (id)init
{
self = [super init];
- colorCube = [CIFilter filterWithName:@"CIColorCube"];
- sourceOverFilter = [CIFilter filterWithName:@"CISourceOverCompositing"];
-
-
- if(alphaOverKernel == nil)// 1
- {
- NSBundle *bundle = [NSBundle bundleForClass: [self class]];// 2
- NSString *code = [NSString stringWithContentsOfFile: [bundle// 3
- pathForResource: @"alphaOver"
- ofType: @"cikernel"]];
- NSArray *kernels = [CIKernel kernelsWithString: code];// 4
- alphaOverKernel = [kernels objectAtIndex:0];// 5
- }
+ //sourceOverFilter = [CIFilter filterWithName:@"CISourceOverCompositing"];
+
+ dispatch_once(&onceToken, ^{
+
+ colorCube = [CIFilter filterWithName:@"CIColorCube"];
+
+
+ if(alphaOverKernel == nil)// 1
+ {
+ NSBundle *bundle = [NSBundle bundleForClass: [self class]];// 2
+ NSString *code = [NSString stringWithContentsOfFile: [bundle// 3
+ pathForResource: @"alphaOver"
+ ofType: @"cikernel"]];
+ NSArray *kernels = [CIKernel kernelsWithString: code];// 4
+ alphaOverKernel = [kernels objectAtIndex:0];// 5
+
+ alphaThresholdKernel = [kernels objectAtIndex:1];// 5
+
+ }
+
+
+ gaussianFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
+ [gaussianFilter setDefaults];
+
+ gaussianFilter2 = [CIFilter filterWithName:@"CIGaussianBlur"];
+ [gaussianFilter2 setDefaults];
+
+ noiseReductionFilter = [CIFilter filterWithName:@"CINoiseReduction"] ;
+ [noiseReductionFilter setDefaults];
+
+ scaleFilter = [CIFilter filterWithName:@"CIAffineTransform"];
+ [scaleFilter setDefaults];
+
+ });
+
return self;
}
@@ -142,15 +172,38 @@ -(void) setMinHueAngle:(float)minHueAngle maxHueAngle:(float)maxHueAngle minValu
}
-(NSArray *)inputKeys{
- return @[@"inputImage", @"inputBackgroundImage", @"inputForegroundImage"];
+ return @[@"inputImage", @"inputBackgroundImage"];
}
+-(void) setGaussianRadius:(float)radius setGaussianRadius2:(float)radius2 noiseReduction:(float)noiseReduction{
+ [gaussianFilter setValue:@(radius) forKey:@"inputRadius"];
+ [gaussianFilter2 setValue:@(radius2) forKey:@"inputRadius"];
+ [noiseReductionFilter setValue:@(noiseReduction) forKey:@"inputNoiseLevel"];
+}
- (CIImage *)outputImage
{
- if(self.inputImage == nil)
+ if(self.inputImage == nil || self.inputBackgroundImage == nil){
+ NSLog(@"No image");
return nil;
- [colorCube setValue:self.inputImage forKey:@"inputImage"];
+ }
+ // return self.inputBackgroundImage;
+
+ CIImage * image = self.inputImage ;
+
+ [noiseReductionFilter setValue:image forKey:@"inputImage"];
+ image =[noiseReductionFilter valueForKey:@"outputImage"];
+
+ [gaussianFilter setValue:image forKey:@"inputImage"];
+ image = [gaussianFilter valueForKey:@"outputImage"];
+
+
+ [colorCube setValue:image forKey:@"inputImage"];
+ image = [colorCube valueForKey:@"outputImage"];
+
+// NSLog(@"%i",[[colorCube valueForKey:@"inputCubeDimension"] intValue]);
+
+ // return image;
/*
[sourceOverFilter setValue:[colorCube valueForKey:@"outputImage"] forKey:@"inputImage"];
[sourceOverFilter setValue:self.inputBackgroundImage forKey:@"inputBackgroundImage"];
@@ -160,10 +213,31 @@ - (CIImage *)outputImage
*/
- CISampler *foreground = [CISampler samplerWithImage: self.inputForegroundImage];
+/* NSAffineTransform * transform = [NSAffineTransform transform];
+ [transform scaleBy:self.inputImage.extent.size.width / self.inputBackgroundImage.extent.size.width];
+ [scaleFilter setValue:transform forKey:@"inputTransform"];
+
+
+
+ [scaleFilter setValue:image forKeyPath:@"inputImage"];
+ image = [scaleFilter valueForKey:@"outputImage"];
+ */
+// NSLog(@" %f %f", self.inputImage.extent.size.width,self.inputBackgroundImage.extent.size.width);
+ if(image == nil){
+ NSLog(@"No alpha image");
+ }
+ CISampler *alpha = [CISampler samplerWithImage: image];
+ image = [self apply: alphaThresholdKernel, alpha, kCIApplyOptionDefinition, [alpha definition], nil];
+
+ [gaussianFilter2 setValue:image forKey:@"inputImage"];
+ image = [gaussianFilter2 valueForKey:@"outputImage"];
+
+
+ CISampler *foreground = [CISampler samplerWithImage: self.inputImage];
CISampler *background = [CISampler samplerWithImage: self.inputBackgroundImage];
- CISampler *alpha = [CISampler samplerWithImage: [colorCube valueForKey:@"outputImage"]];
+ alpha = [CISampler samplerWithImage: image];
// NSAssert(src, @" Nor Src");
+
return [self apply: alphaOverKernel, foreground, alpha, background, kCIApplyOptionDefinition, [foreground definition], nil];
}
@@ -29,9 +29,13 @@ - (id)init
- (CIImage *)outputImage
{
- CISampler *src = [CISampler samplerWithImage: self.inputImage];
- // NSAssert(src, @" Nor Src");
- return [self apply: deinterlaceKernel, src, kCIApplyOptionDefinition, [src definition], nil];
+ if(self.inputImage){
+ CISampler *src = [CISampler samplerWithImage: self.inputImage];
+ // NSAssert(src, @" Nor Src");
+ return [self apply: deinterlaceKernel, src, kCIApplyOptionDefinition, [src definition], nil];
+ } else {
+ return nil;
+ }
}
-(NSArray *)inputKeys{

0 comments on commit 4145c35

Please sign in to comment.