• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Writing a core image custom filter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing a core image custom filter


  • Subject: Writing a core image custom filter
  • From: Kevin Meaney <email@hidden>
  • Date: Sun, 23 Feb 2014 22:06:39 +0000

Apologies for the cross posting from quartz-dev. But it seems these days that it is hard to work out which forum, lists/devforum and then which of the discussions to then post.

I've been playing with creating a core image filter for OS X. I've got simple chroma key filter working as I would like, except for two issues. The first issue is a compile warning which if I ignore doesn't stop the filter from working. But I'd still like it resolved even if it is only for me to understand what is going on, or perhaps that it highlights something that I'm doing wrong but non-critical.

The filter is defined like so in the header:

@interface YVSChromaKeyFilter : CIFilter

Because I'm currently using the filter in a simple stand alone command line tool and I want to keep this option as a use for the filter I'm not packaging the filter up into a image unit as the recommended way to distribute image filters by apple so I'm using the alternate method which uses the registerFilterName method called from the filter's class initialize method:

@implementation YVSChromaKeyFilter

+(void)initialize
{
   if (self == [YVSChromaKeyFilter class])
   {
       NSArray *kernels = [CIKernel kernelsWithString:YVSChromaKeyFilterString];
       chromaKeyKernel = kernels[0];
       [CIFilter registerFilterName:@"YVSChromaKeyFilter"
                        constructor:(id<CIFilterConstructor>)self
                    classAttributes:@{
           kCIAttributeFilterDisplayName : @"Simple Chroma Key.",
            kCIAttributeFilterCategories : @[
                  kCICategoryColorAdjustment, kCICategoryVideo,
                  kCICategoryStillImage, kCICategoryInterlaced,
                  kCICategoryNonSquarePixels]
                                    }
        ];
   }
}

+(CIFilter *)filterWithName:(NSString *)name
{
   CIFilter  *filter;
   filter = [[YVSChromaKeyFilter alloc] init];
   return filter;
}

Note the cast in the constructor: option of the registerFilterName method, this was done to remove the compiler warning but really should not be there. I tried adding the protocol to the YVSChromaKeyFilter interface but that made no difference. My filter gets created correctly when I set things up as above and do:

CIFilter *filter =  [CIFilter filterWithName:@"YVSChromaKeyFilter"];

Now the protocol CIFilterConstructor interface is as follows:

@protocol CIFilterConstructor
- (CIFilter *)filterWithName:(NSString *)name;
@end

Which confuses me since I have to implement a class method filterWithName not an object method.

As I said, the filter works and does what I want but I'm missing something here that I'd like clarified and hopefully resolve things in a way that the ugly cast can be removed.

I'll put the second issue into a new e-mail as I think putting it here now will just add confusion.

Kevin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: 6.1.6 for iPhones?
  • Next by Date: Writing a custom core image filter part 2
  • Previous by thread: Re: Issues with CIFilters and CALayers
  • Next by thread: Writing a custom core image filter part 2
  • Index(es):
    • Date
    • Thread