Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NilStack committed Jun 11, 2017
1 parent 6e55fe9 commit ec69b26
Show file tree
Hide file tree
Showing 15 changed files with 733 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .gitignore
@@ -0,0 +1,31 @@
# OS X
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.xccheckout
# AppCode
.idea/

Carthage

Demo/Pods
.ruby-version
.ruby-gemset
# Swift Package Manager
.build
Packages
41 changes: 41 additions & 0 deletions HelloVision.xcodeproj/project.pbxproj
Expand Up @@ -12,6 +12,16 @@
B8597FBA1EE94B7800B71E00 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B8597FB81EE94B7800B71E00 /* Main.storyboard */; };
B8597FBC1EE94B7800B71E00 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B8597FBB1EE94B7800B71E00 /* Assets.xcassets */; };
B8597FBF1EE94B7800B71E00 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B8597FBD1EE94B7800B71E00 /* LaunchScreen.storyboard */; };
B8597FC71EE9578E00B71E00 /* MobileNet.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = B8597FC61EE9578E00B71E00 /* MobileNet.mlmodel */; };
B8597FDC1EE9639600B71E00 /* image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B8597FDB1EE9639000B71E00 /* image.jpg */; };
B8597FE01EE970F100B71E00 /* FaceDetectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8597FDF1EE970F100B71E00 /* FaceDetectionViewController.swift */; };
B8BC8B7D1EEA6A1A0029579B /* faces.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B8BC8B7C1EEA6A120029579B /* faces.jpg */; };
B8BC8B831EEA8AAD0029579B /* FaceLandMarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8BC8B821EEA8AAD0029579B /* FaceLandMarksViewController.swift */; };
B8F62C5E1EEBC69E008BE757 /* face.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B8F62C5D1EEBC693008BE757 /* face.jpg */; };
B8F62C601EEBEC21008BE757 /* BarcodesDetectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F62C5F1EEBEC21008BE757 /* BarcodesDetectViewController.swift */; };
B8F62C621EEBEE7E008BE757 /* QRCode.png in Resources */ = {isa = PBXBuildFile; fileRef = B8F62C611EEBEE74008BE757 /* QRCode.png */; };
B8F62C641EECE672008BE757 /* TextDetectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F62C631EECE672008BE757 /* TextDetectionViewController.swift */; };
B8F62C6C1EECF0DA008BE757 /* text.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B8F62C6B1EECF0D2008BE757 /* text.jpg */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -22,6 +32,16 @@
B8597FBB1EE94B7800B71E00 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
B8597FBE1EE94B7800B71E00 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
B8597FC01EE94B7800B71E00 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B8597FC61EE9578E00B71E00 /* MobileNet.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; name = MobileNet.mlmodel; path = ../../../../Desktop/MobileNet.mlmodel; sourceTree = "<group>"; };
B8597FDB1EE9639000B71E00 /* image.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = image.jpg; sourceTree = "<group>"; };
B8597FDF1EE970F100B71E00 /* FaceDetectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceDetectionViewController.swift; sourceTree = "<group>"; };
B8BC8B7C1EEA6A120029579B /* faces.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = faces.jpg; sourceTree = "<group>"; };
B8BC8B821EEA8AAD0029579B /* FaceLandMarksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceLandMarksViewController.swift; sourceTree = "<group>"; };
B8F62C5D1EEBC693008BE757 /* face.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = face.jpg; sourceTree = "<group>"; };
B8F62C5F1EEBEC21008BE757 /* BarcodesDetectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodesDetectViewController.swift; sourceTree = "<group>"; };
B8F62C611EEBEE74008BE757 /* QRCode.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = QRCode.png; sourceTree = "<group>"; };
B8F62C631EECE672008BE757 /* TextDetectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextDetectionViewController.swift; sourceTree = "<group>"; };
B8F62C6B1EECF0D2008BE757 /* text.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = text.jpg; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -56,6 +76,16 @@
children = (
B8597FB41EE94B7800B71E00 /* AppDelegate.swift */,
B8597FB61EE94B7800B71E00 /* ViewController.swift */,
B8597FDF1EE970F100B71E00 /* FaceDetectionViewController.swift */,
B8BC8B821EEA8AAD0029579B /* FaceLandMarksViewController.swift */,
B8F62C5F1EEBEC21008BE757 /* BarcodesDetectViewController.swift */,
B8F62C631EECE672008BE757 /* TextDetectionViewController.swift */,
B8597FC61EE9578E00B71E00 /* MobileNet.mlmodel */,
B8597FDB1EE9639000B71E00 /* image.jpg */,
B8BC8B7C1EEA6A120029579B /* faces.jpg */,
B8F62C5D1EEBC693008BE757 /* face.jpg */,
B8F62C611EEBEE74008BE757 /* QRCode.png */,
B8F62C6B1EECF0D2008BE757 /* text.jpg */,
B8597FB81EE94B7800B71E00 /* Main.storyboard */,
B8597FBB1EE94B7800B71E00 /* Assets.xcassets */,
B8597FBD1EE94B7800B71E00 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -122,6 +152,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B8F62C6C1EECF0DA008BE757 /* text.jpg in Resources */,
B8F62C621EEBEE7E008BE757 /* QRCode.png in Resources */,
B8F62C5E1EEBC69E008BE757 /* face.jpg in Resources */,
B8BC8B7D1EEA6A1A0029579B /* faces.jpg in Resources */,
B8597FDC1EE9639600B71E00 /* image.jpg in Resources */,
B8597FBF1EE94B7800B71E00 /* LaunchScreen.storyboard in Resources */,
B8597FBC1EE94B7800B71E00 /* Assets.xcassets in Resources */,
B8597FBA1EE94B7800B71E00 /* Main.storyboard in Resources */,
Expand All @@ -135,8 +170,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B8F62C601EEBEC21008BE757 /* BarcodesDetectViewController.swift in Sources */,
B8597FB71EE94B7800B71E00 /* ViewController.swift in Sources */,
B8597FB51EE94B7800B71E00 /* AppDelegate.swift in Sources */,
B8BC8B831EEA8AAD0029579B /* FaceLandMarksViewController.swift in Sources */,
B8597FC71EE9578E00B71E00 /* MobileNet.mlmodel in Sources */,
B8597FE01EE970F100B71E00 /* FaceDetectionViewController.swift in Sources */,
B8F62C641EECE672008BE757 /* TextDetectionViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -312,6 +352,7 @@
B8597FC51EE94B7800B71E00 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
53 changes: 53 additions & 0 deletions HelloVision/BarcodesDetectViewController.swift
@@ -0,0 +1,53 @@
//
// BarcodesDetectViewController.swift
// HelloVision
//
// Created by 郭朋 on 10/06/2017.
// Copyright © 2017 Peng Guo. All rights reserved.
//

import UIKit
import Vision

class BarcodesDetectViewController: UIViewController {

@IBOutlet weak var result: UILabel!

override func viewDidLoad() {
super.viewDidLoad()

let barcodeImage = UIImage(named: "QRCode.png")!

let barcodeRequest = VNDetectBarcodesRequest(completionHandler: {(request, error) in

for result in request.results! {

if let barcode = result as? VNBarcodeObservation {

if let desc = barcode.barcodeDescriptor as? CIQRCodeDescriptor {
print(desc.symbolVersion)
let content = String(data: desc.errorCorrectedPayload, encoding: .utf8)

let resultStr = """
Symbology: \(barcode.symbology.rawValue)\n
Payload: \(String(describing: content))\n
Error-Correction-Level:\(desc.errorCorrectionLevel)\n
Symbol-Version: \(desc.symbolVersion)\n
"""
DispatchQueue.main.async {
self.result.text = resultStr
}
}
}
}
})

let handler = VNImageRequestHandler(cgImage: barcodeImage.cgImage!, options: [:])

guard let _ = try? handler.perform([barcodeRequest]) else {
return print("Could not perform barcode-request!")
}

}

}

0 comments on commit ec69b26

Please sign in to comment.