Skip to content

Commit

Permalink
updated threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
mmitrevs committed Apr 14, 2018
1 parent 216d67e commit 4149d12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Binary file not shown.
14 changes: 8 additions & 6 deletions WhiskyClub/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ class ViewController: UIViewController {
}

let photoSourcePicker = UIAlertController()
let takePhoto = UIAlertAction(title: "Take Photo", style: .default) { [unowned self] _ in
let takePhoto = UIAlertAction(title: "Take Photo", style: .default) {
[unowned self] _ in
self.presentPhotoPicker(sourceType: .camera)
}
let choosePhoto = UIAlertAction(title: "Choose Photo", style: .default) { [unowned self] _ in
let choosePhoto = UIAlertAction(title: "Choose Photo", style: .default) {
[unowned self] _ in
self.presentPhotoPicker(sourceType: .photoLibrary)
}

Expand Down Expand Up @@ -89,7 +91,6 @@ class ViewController: UIViewController {
// MARK: - Whisky classification

func classifyImage(for image: UIImage, localThreshold: Double = 0.0) {

detectedWhisky.text = "Detecting whisky..."

let failure = { (error: Error) in
Expand All @@ -102,8 +103,9 @@ class ViewController: UIViewController {
failure: failure) { classifiedImages in

var topClassification = ""

if classifiedImages.images.count > 0 && classifiedImages.images[0].classifiers.count > 0 && classifiedImages.images[0].classifiers[0].classes.count > 0 {
if classifiedImages.images.count > 0
&& classifiedImages.images[0].classifiers.count > 0
&& classifiedImages.images[0].classifiers[0].classes.count > 0 {
topClassification = classifiedImages.images[0].classifiers[0].classes[0].className
}

Expand Down Expand Up @@ -140,6 +142,6 @@ extension ViewController: UIImagePickerControllerDelegate, UINavigationControlle
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
imageView.contentMode = UIViewContentMode.scaleAspectFit
imageView.image = image
classifyImage(for: image, localThreshold: 0.2)
classifyImage(for: image, localThreshold: 0.51)
}
}

0 comments on commit 4149d12

Please sign in to comment.