Created
December 2, 2019 13:17
-
-
Save anupamchugh/1814a976ad5c45bd06d039d15fead5e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func processImages() | |
{ | |
guard self.modelData.count > 0 else{ | |
return | |
} | |
var observation : VNFeaturePrintObservation? | |
var sourceObservation : VNFeaturePrintObservation? | |
sourceObservation = featureprintObservationForImage(image: UIImage(named: sourceImage)!) | |
var tempData = modelData | |
tempData = modelData.enumerated().map { (i,m) in | |
var model = m | |
if let uiimage = UIImage(named: model.imageName){ | |
observation = featureprintObservationForImage(image: uiimage) | |
do{ | |
var distance = Float(0) | |
if let sourceObservation = sourceObservation{ | |
try observation?.computeDistance(&distance, to: sourceObservation) | |
model.distance = "\(distance)" | |
} | |
}catch{ | |
print("errror occurred..") | |
} | |
} | |
return model | |
} | |
modelData = tempData.sorted(by: {Float($0.distance)! < Float($1.distance)!}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment