HomeiOS Developmentios - Why does VNGenerateOpticalFlowRequest produce an error whereas working on Simulator?

ios – Why does VNGenerateOpticalFlowRequest produce an error whereas working on Simulator?


I am making an attempt to make use of the Imaginative and prescient framework on iOS. Specifically, I am utilizing VNGenerateOpticalFlowRequest as proven in WWDC 2020. I’ve the next Swift code in my app, which I am working on an iPhone 14 in Simulator (with XCode 14.3.1):

//  Circulation.swift

import CoreImage
import Basis
import Imaginative and prescient

func circulation() throws {
    let image1 = CIImage(colour: .blue).cropped(to: .init(x: 0, y: 0, width: 100, top: 100))
    let image2 = CIImage(colour: .blue).cropped(to: .init(x: 0, y: 0, width: 100, top: 100))
    let visionRequest = VNGenerateOpticalFlowRequest(targetedCIImage: image1)
    let requestHandler = VNSequenceRequestHandler()
    strive requestHandler.carry out([visionRequest], on: image2)
}
//  ContentView.swift

import SwiftUI

struct ContentView: View {
    var physique: some View {
        Button("Calculate circulation") {
            strive! circulation()
        }
    }
}

Once I click on on the button in ContentView, I anticipated that the optical circulation between the 2 photos could be calculated. As a substitute, it fails with the deadly error:

2023-07-16 12:51:45.669412-0700 optical-flow-test[5994:125790] [espresso] [Espresso::handle_ex_plan] exception=Espresso exception: "I/O error": Lacking weights path cnn_moflow.espresso.weights standing=-2
optical_flow_test/ContentView.swift:8: Deadly error: 'strive!' expression unexpectedly raised an error: Error Area=com.apple.vis Code=9 "Didn't create movement circulation estimator" UserInfo={NSLocalizedDescription=Didn't create movement circulation estimator}

This doesn’t appear to happen when working the app on an actual system.

(I additionally tried working the code for Constructing a feature-rich app for sports activities evaluation with the supplied pattern video on Simulator, and it seems to be caught on “Loading Board”.)

Why is that this error produced, and the way can I accurately create the optical circulation estimator to work on the Simulator?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments