{"id":20617801,"url":"https://github.com/keithito/swiftmaskdetection","last_synced_at":"2025-04-15T11:36:41.149Z","repository":{"id":45230949,"uuid":"286591766","full_name":"keithito/SwiftMaskDetection","owner":"keithito","description":"CoreML face mask detector for iOS apps","archived":false,"fork":false,"pushed_at":"2021-12-29T20:34:43.000Z","size":3756,"stargazers_count":21,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T18:23:28.140Z","etag":null,"topics":["computer-vision","coreml","covid-19","ios","iphone","machine-learning","mask-detector","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keithito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-10T22:33:20.000Z","updated_at":"2025-01-06T02:47:02.000Z","dependencies_parsed_at":"2022-08-21T03:10:24.722Z","dependency_job_id":null,"html_url":"https://github.com/keithito/SwiftMaskDetection","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithito%2FSwiftMaskDetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithito%2FSwiftMaskDetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithito%2FSwiftMaskDetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keithito%2FSwiftMaskDetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keithito","download_url":"https://codeload.github.com/keithito/SwiftMaskDetection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249061662,"owners_count":21206541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","coreml","covid-19","ios","iphone","machine-learning","mask-detector","swift"],"created_at":"2024-11-16T12:06:00.558Z","updated_at":"2025-04-15T11:36:41.104Z","avatar_url":"https://github.com/keithito.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftMaskDetection\n\n\u003c!--\n[![CI Status](https://img.shields.io/travis/keithito/SwiftMaskDetection.svg?style=flat)](https://travis-ci.org/keithito/SwiftMaskDetection)\n--\u003e\n[![Version](https://img.shields.io/cocoapods/v/SwiftMaskDetection.svg?style=flat)](https://cocoapods.org/pods/SwiftMaskDetection)\n[![License](https://img.shields.io/cocoapods/l/SwiftMaskDetection.svg?style=flat)](https://cocoapods.org/pods/SwiftMaskDetection)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftMaskDetection.svg?style=flat)](https://cocoapods.org/pods/SwiftMaskDetection)\n\n\nSwiftMaskDetection is a face mask detection library with a Swift interface.\n\nIt is a port of [AIZOO's FaceMaskDetection model](https://github.com/AIZOOTech/FaceMaskDetection) to\nCoreML. The model runs at over 30fps on recent iPhones and iPads. For more information on the model and training data,\nplease see https://github.com/AIZOOTech/FaceMaskDetection (AIZOO did all the hard work).\n\n## Demo\n\n![Demo video](https://data.keithito.com/maskdetection/detection1.gif)\n![Demo video](https://data.keithito.com/maskdetection/detection2.gif)\n\nTo run the demo:\n\n  1. Make sure you have [Xcode](https://developer.apple.com/support/xcode/) and [CocoaPods](https://cocoapods.org/).\n  \n  2. Clone this repo and open the example project:\n     ```\n     git clone https://github.com/keithito/SwiftMaskDetection.git\n     cd SwiftMaskDetection/Example \n     pod install\n     open SwiftMaskDetection.xcworkspace\n     ```\n     \n  3. Run the project from XCode on a device (it needs the camera)\n      * If you see an error that signing needs a development team, open the \"SwiftMaskDetection\" project, click on\n        the \"Signing \u0026 Capabilities\" tab, and select an option from the \"Team\" menu.\n  \n\n## Installation\n\nSwiftMaskDetection is available through [CocoaPods](https://cocoapods.org). To install it, add the following\nline to your Podfile:\n\n```ruby\npod 'SwiftMaskDetection'\n```\n\n\nIf you don't use CocoaPods, you can simply copy the files in [SwiftMaskDetection/Classes](https://github.com/keithito/SwiftMaskDetection/tree/master/SwiftMaskDetection/Classes) into your Xcode project.\n\n\n## Usage\n\n### Images\n\nTo recognize an image:\n\n```swift\nimport SwiftMaskDetection\n\nlet detector = MaskDetector()\nlet image = UIImage(named: \"my_photo\")!\nif let results = try? detector.detectMasks(cgImage: image.cgImage!) {\n  // Do something with the results.\n}\n```\n\nThe image **must be 260x260 pixels**. `detectMasks` supports `CGImage`, `CIImage`, and `CVPixelBuffer` inputs and\nreturns an array of `Results`, one for each detected face:\n\n```swift\npublic struct Result {\n  /// The status of the detection (.mask or .noMask)\n  public let status: Status\n\n  /// The bounding box of the face in normalized coordinates (the top-left corner of the image\n  /// is [0, 0], and the bottom-right corner is [1, 1]).\n  public let bound: CGRect\n\n  /// Value between 0 and 1 representing the confidence in the result\n  public let confidence: Float\n}\n```\n\n\n### Video\n\n`MaskDetectionVideoHelper` may come in handy for running on live video. First, create the helper:\n\n```swift\nlet helper = MaskDetectionVideoHelper(maskDetector: MaskDetector())\n```\n\nThen call `detectInFrame` on each video frame:\n\n```swift\nif let results = try? helper.detectInFrame(cmSampleBuffer) {\n  // Do something with the results.\n}\n\n```\n\nYou don't need to resize the image to 260x260; the helper does that for you. See the example app's\n[ViewController](./Example/SwiftMaskDetection/ViewController.swift) for a complete example.\n\n\n\n## Requirements\n  * iOS 13 or later\n\n\n\n## License\n\nSwiftMaskDetection is available under the MIT license. See the LICENSE file for more info.\n\nThe face mask detection model is (c) 2020 AIZOOTech and is also available under the\n[MIT License](https://github.com/AIZOOTech/FaceMaskDetection/blob/6068769c7a6/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeithito%2Fswiftmaskdetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeithito%2Fswiftmaskdetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeithito%2Fswiftmaskdetection/lists"}