diff --git a/FaceRecogAttendance/FaceRecogAttendance.xcworkspace/xcuserdata/Lucas.xcuserdatad/UserInterfaceState.xcuserstate b/FaceRecogAttendance/FaceRecogAttendance.xcworkspace/xcuserdata/Lucas.xcuserdatad/UserInterfaceState.xcuserstate index 5726d57594256da237020a94cd58ac49d47c5da2..1ddb1bc2d507e039b8b72115b28e645a046ea45b 100644 Binary files a/FaceRecogAttendance/FaceRecogAttendance.xcworkspace/xcuserdata/Lucas.xcuserdatad/UserInterfaceState.xcuserstate and b/FaceRecogAttendance/FaceRecogAttendance.xcworkspace/xcuserdata/Lucas.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/FaceRecogAttendance/FaceRecogAttendance/Controller/FaceClassificationViewController.swift b/FaceRecogAttendance/FaceRecogAttendance/Controller/FaceClassificationViewController.swift index 4575af38ad639c5f87d7fe01eb61aabf032ddcb4..971d23d94a513f1197e3e0849e64e06eee55609f 100644 --- a/FaceRecogAttendance/FaceRecogAttendance/Controller/FaceClassificationViewController.swift +++ b/FaceRecogAttendance/FaceRecogAttendance/Controller/FaceClassificationViewController.swift @@ -75,7 +75,7 @@ class FaceClassificationViewController: UIViewController, AVCaptureVideoDataOutp // if the correct face is identified, create attendance if capturedFaceCount > 100 { DispatchQueue.main.async { - let alert = UIAlertController.init(title: "Verify", message: "\(self.label.text!), please confirm", preferredStyle: .alert) + let alert = UIAlertController.init(title: "Verify", message: "\(self.label.text!)%, please confirm", preferredStyle: .alert) alert.addAction(UIAlertAction.init(title: "Yes", style: .default, handler: { (action) in self.verification = true print("verification is now true") @@ -114,7 +114,7 @@ class FaceClassificationViewController: UIViewController, AVCaptureVideoDataOutp print(topResult.identifier, topResult.confidence * 100) DispatchQueue.main.async {[weak self] in - self?.label.text = "\(topResult.identifier) - \(topResult.confidence)" + self?.label.text = "\(topResult.identifier) - \(topResult.confidence * 100)" } } diff --git a/FaceRecogAttendance/FaceRecogAttendance/Controller/SessionListViewController.swift b/FaceRecogAttendance/FaceRecogAttendance/Controller/SessionListViewController.swift index 3e8227021d4377394bf8f154b84b3adea23ad917..90d185942821abc891cf75ff9603c6ac8e81cd57 100644 --- a/FaceRecogAttendance/FaceRecogAttendance/Controller/SessionListViewController.swift +++ b/FaceRecogAttendance/FaceRecogAttendance/Controller/SessionListViewController.swift @@ -40,17 +40,6 @@ class SessionListViewController: UITableViewController { try! self.realm?.write { self.selectedModule?.sessions.append(newSession) } - // change session model to let user enter room and time only -// if let roomNo = sessionRoomNo.text { -// newSession.roomNo = roomNo -// } -// if let sessionDate = sessionDateTextField.text { -// newSession.sessionDate = sessionDate -// } -// if let sessionTime = sessionTimeTextField.text { -// newSession.sessionTime = sessionTime -// } -// self.saveSession(session: newSession) print("successfully created a session") self.tableView.reloadData() } diff --git a/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentDetailViewController.swift b/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentDetailViewController.swift index 81d5078c8e861222bda3bcea98950d8ca9e0df88..328315cc6ac3f3266de293d32ae3edfb0552e769 100644 --- a/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentDetailViewController.swift +++ b/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentDetailViewController.swift @@ -11,7 +11,8 @@ import RealmSwift class StudentDetailViewController: UIViewController { - let realm = try! Realm() + var realm : Realm? + var student: Student? @IBOutlet weak var studentNameLabel: UILabel! @IBOutlet weak var studentIDLabel: UILabel! @@ -19,8 +20,6 @@ class StudentDetailViewController: UIViewController { @IBOutlet weak var imageUploadLabel: UILabel! @IBOutlet weak var imageTrainedSegment: UISegmentedControl! - var student: Student? - override func viewDidLoad() { super.viewDidLoad() @@ -44,7 +43,7 @@ class StudentDetailViewController: UIViewController { @IBAction func imageTrainedPressed(_ sender: UISegmentedControl) { do { - try realm.write { + try self.realm?.write { switch imageTrainedSegment.selectedSegmentIndex { case 0: diff --git a/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentViewController.swift b/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentViewController.swift index b8f26d5590e9c6ee9593eec5b9c281469d7647eb..9f63d051aa84318eb6f1b3c0e2b87169f394c4df 100644 --- a/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentViewController.swift +++ b/FaceRecogAttendance/FaceRecogAttendance/Controller/StudentViewController.swift @@ -13,6 +13,7 @@ class StudentViewController: UITableViewController { var notificationToken: NotificationToken? var students: Results<Student>? + var realm : Realm? override func viewDidLoad() { super.viewDidLoad() @@ -45,6 +46,7 @@ class StudentViewController: UITableViewController { let destinationVC = segue.destination as! StudentDetailViewController if let indexPath = tableView.indexPathForSelectedRow { destinationVC.student = students?[indexPath.row] + destinationVC.realm = self.realm } } @@ -74,6 +76,7 @@ class StudentViewController: UITableViewController { print("Failed to open realm: \(error)") case .success(let realm): self.onRealmOpened(realm) + self.realm = realm } } } diff --git a/FaceRecogAttendance/FaceRecogAttendance/View/Base.lproj/Main.storyboard b/FaceRecogAttendance/FaceRecogAttendance/View/Base.lproj/Main.storyboard index 48b0e2fbb91f972ea8c0b1c39637fc00d7b997ef..24c361d3072aaef88252be7649e2c61840a5254b 100644 --- a/FaceRecogAttendance/FaceRecogAttendance/View/Base.lproj/Main.storyboard +++ b/FaceRecogAttendance/FaceRecogAttendance/View/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="MF4-3F-e2i"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="MF4-3F-e2i"> <device id="retina6_1" orientation="portrait" appearance="light"/> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/> <capability name="Named colors" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> @@ -93,7 +93,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SelectModuleCell" id="duJ-Le-O7j"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="duJ-Le-O7j" id="hDW-Ct-8Yz"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/> @@ -509,7 +509,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="StudentCell" id="n4a-vH-GUk"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="n4a-vH-GUk" id="uMI-qc-Ehj"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/> @@ -541,7 +541,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ModuleCell" id="lmx-Pj-mNT"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="lmx-Pj-mNT" id="kAw-1Q-htj"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/> @@ -579,7 +579,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SessionCell" id="Paf-9O-dD0"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Paf-9O-dD0" id="kPi-rh-lS0"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/> @@ -617,7 +617,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AttendanceCell" id="1B1-XZ-txl"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="1B1-XZ-txl" id="cJo-Sh-3pD"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/> @@ -839,7 +839,7 @@ </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="kwU-XT-yCf" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="5343" y="587"/> + <point key="canvasLocation" x="5380" y="848"/> </scene> <!--Sessions--> <scene sceneID="1rz-1N-nEt"> @@ -851,7 +851,7 @@ <color key="backgroundColor" systemColor="systemBackgroundColor"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SelectSessionCell" id="94i-wo-gXx"> - <rect key="frame" x="0.0" y="28" width="414" height="43.5"/> + <rect key="frame" x="0.0" y="24.5" width="414" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="94i-wo-gXx" id="yxV-Vc-pGt"> <rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>