Post

Replies

Boosts

Views

Activity

compareDistance in Vision not working as expected
Hi, When using VNFeaturePrintObservation and then computing the distance using two images, the values that it returns varies heavily. When two identical images (same image file) is inputted into function (below) that I have used to compare the images, the distance does not return 0 while it is expected to, since they are identical images. Also, what is the upper limit of computeDistance? I am trying to find the percentage similarity between the two images. (Of course, this cannot be done unless the issue above is resolved). Code that I have used is below func featureprintObservationForImage(image: UIImage) -> VNFeaturePrintObservation? {     let requestHandler = VNImageRequestHandler(cgImage: image.cgImage!, options: [:])     let request = VNGenerateImageFeaturePrintRequest()     request.usesCPUOnly = true // Simulator Testing     do {       try requestHandler.perform([request])       return request.results?.first as? VNFeaturePrintObservation     } catch {       print("Vision Error: \(error)")       return nil     }   }   func compare(origImg: UIImage, drawnImg: UIImage) -> Float? {     let oImgObservation = featureprintObservationForImage(image: origImg)     let dImgObservation = featureprintObservationForImage(image: drawnImg)     if let oImgObservation = oImgObservation {       if let dImgObservation = dImgObservation {         var distance: Float = -1         do {           try oImgObservation.computeDistance(&distance, to: dImgObservation)         } catch {           fatalError("Failed to Compute Distance")         }         if distance == -1 {           return nil         } else {           return distance         }       } else {         print("Drawn Image Observation found Nil")       }     } else {       print("Original Image Observation found Nil")     }     return nil   } Thanks for all the help!
4
1
2.3k
Dec ’22
Bundle.main.url returning nil
Hi, I have added an audio asset into my .swiftpm file in a folder called “Audios”, and have tried getting it by the following methods Bundle.main.url(forResource: "Completed", withExtension: "mp3") Bundle.main.url(forResource: "Completed", withExtension: "mp3", subdirectory: "AppData") However, it still returns nil for both methods. I have also tried deleting and adding the file back but to no avail. I would greatly appreciate any help! Thanks.
1
0
4.2k
Apr ’22
How will the project be ran?
From the Swift Student Challenge section, it states that, Your Swift Playgrounds app project must be built with and run on Swift Playgrounds 4.0.2 on iPadOS 15.4 or Xcode 13.3 on macOS 12.3. If it runs on iPadOS, it must be optimized to display properly on all models of iPad Pro.  By running on all models of iPad Pro, does it mean running the app using the Xcode Simulator set to iPad Pro/Directly running the app on Swift Playgrounds on iPad Pro? Thanks!
2
0
1.1k
Apr ’22
MacOS Bootloop
After updating to the latest beta of MacOS Big Sur (Public Beta), my Mac entered a boot loop. When First Aiding my Main Apple SSD, an error “snapshot fsroot tree corruptions are not repaired they will go away when the snapshot are deleted.” There was also an error, "Cross Check: Mismatch between extent ref entry reference count (1) and calculated fsroot entry reference count (0) for extent (0x1930163 + 1)" Many orphan files were found too. After first aid has completed, the First Aid restored to the original state.
0
0
593
Oct ’20
UISwipeGestureRecognizer does not work with swipeGesture.direction = .right
For the UISwipeGestureRecognizer, when I use direction = .left, it works. However, when I use direction = .right, it does not work // swipeGesture is the UISwipeGestureRecognizer if (swipeGesture.direction = .right) { // Code does not run } else if (swipeGesture.direction = .left) { // Code runs } Does anyone have any idea why this happens?
5
0
1.2k
Aug ’20