Closed kuls14 closed 4 years ago
You can try the following in the project's playground:
var names = ["blurred_architecture1.bmp", "compressed_architecture1.jpg", "blurred_architecture_2.bmp", "compressed_architecture_2.jpg"]
let similarImages = imageHashing.similarImages(withProvider: .pHash) { () -> OSTuple<NSString, NSData>? in
if names.count > 0 {
let name = names.removeFirst()
let url = Bundle.main.urlForImageResource(NSImage.Name(name))!
let data = try! Data(contentsOf: url)
return OSTuple<NSString, NSData>(first: name as NSString, andSecond: data as NSData)
} else {
return nil
}
}
print("Images", similarImages)
Thanks.
I want to use Concurrent, stream-based similarity search for finding similar images from all images in the phone gallery but I cannot understand how to do that. I have tried to use an array-based method but that takes too long to get all the image data in an array and causes memory management issues. If anyone knows this please help me.