Skip to content

Instantly share code, notes, and snippets.

View AdibContractorCC's full-sized avatar
👋

Adib Contractor AdibContractorCC

👋
View GitHub Profile

Keybase proof

I hereby claim:

  • I am adibcontractorcc on github.
  • I am adibcontractor (https://keybase.io/adibcontractor) on keybase.
  • I have a public key ASBBQhKTl4-Ki6oBbh326tn4a0h0CxxFMpVfBv_SVWsPVQo

To claim this, I am signing this object:

@AdibContractorCC
AdibContractorCC / LiveCaptureViewController.swift
Last active June 14, 2017 18:33
Detect faces from live camera capture
import Foundation
import UIKit
import AVFoundation
import Vision
class LiveCaptureViewController: UIViewController {
public let cameraCapture = CameraCapture()
private var videoPreviewLayer : AVCaptureVideoPreviewLayer?
override func viewDidLoad()
@AdibContractorCC
AdibContractorCC / LiveCaptureHattingViewController.swift
Created June 13, 2017 17:05
Save our mad hattery to photos library
extension LiveCaptureHattingViewController {
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)
{
takeScreenShot()
}
func takeScreenShot()
{
guard let currentPixelBuffer = currentPixelBuffer else {
return
let rect = observation.boundingBox.denormalized(newRect: self.view.frame)
let hatWidth = rect.size.width
let hatHeight = rect.size.height
let hatX = rect.origin.x - hatWidth/4
let hatY = rect.origin.y - hatHeight
let hatRect = CGRect(x: hatX, y: hatY, width: hatWidth, height: hatHeight)
var hat : UIImageView? = nil
if faceNumber >= self.hats.count {
@AdibContractorCC
AdibContractorCC / LiveCaptureTaggingViewController.swift
Last active June 14, 2017 18:17
Detect and highlight faces in live camera feed
import UIKit
import CoreMedia
import Vision
class LiveCaptureTaggingViewController: LiveCaptureViewController {
private var faceLayers = [CAShapeLayer]()
override func processBufferCaptured(buffer: CMSampleBuffer!, faceDetectionRequest: VNDetectFaceRectanglesRequest) {
DispatchQueue.main.async { [unowned self] in
self.faceLayers.forEach{ $0.removeFromSuperlayer() }
@AdibContractorCC
AdibContractorCC / DetectFacesViewController.swift
Last active June 14, 2017 18:06
Detect and highlight faces
import UIKit
import Vision
import CoreMedia
class DetectFacesViewController: UIViewController {
private var imageView : UIImageView? = nil
override func viewDidLoad()
{
@AdibContractorCC
AdibContractorCC / gist:3816f807b36ef4345bd0
Last active August 29, 2015 14:18
Usage of dispatch_group_notify in Objective-C
#import "AppDelegate.h"
@interface AppDelegate ()
@property (nonatomic, strong) dispatch_group_t dispatchGroup;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.