Skip to content

Instantly share code, notes, and snippets.

@GantMan
Created August 8, 2012 19:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GantMan/3297986 to your computer and use it in GitHub Desktop.
Save GantMan/3297986 to your computer and use it in GitHub Desktop.
def draw_feature(context, atPoint:feature_point)
size = 6
startx = feature_point.x - (size/2)
starty = feature_point.y - (size/2)
CGContextAddRect(context, [[startx, starty], [size, size]])
CGContextDrawPath(context, KCGPathFillStroke)
end
def print_features features
features.each_with_index do |feature, index|
p "Found Feature!"
if feature.hasLeftEyePosition
p "Left Eye Coord: #{feature.leftEyePosition.x}x#{feature.leftEyePosition.y}"
end
if feature.hasRightEyePosition
p "Right Eye Coord: #{feature.rightEyePosition.x}x#{feature.rightEyePosition.y}"
end
if feature.hasMouthPosition
p "Mouth Coord: #{feature.mouthPosition.x}x#{feature.mouthPosition.y}"
end
end
end
CGContextTranslateCTM(currentContext, 0, @me.size.height)
CGContextScaleCTM(currentContext, 1, -1)
def viewDidLoad
super
view.backgroundColor = UIColor.lightGrayColor
@me = UIImage.imageNamed("gantman.jpeg")
cme = CIImage.alloc.initWithImage(@me)
options = NSDictionary.dictionaryWithObject(CIDetectorAccuracyHigh, forKey:CIDetectorAccuracy)
detector = CIDetector.detectorOfType(CIDetectorTypeFace, context:nil, options:options)
features = detector.featuresInImage(cme)
Dispatch::Queue.concurrent.async do
print_features(features)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment