So I tried actually initialize different PhotogrammetrySessions but they do not run in parallel. I get this error [Photogrammetry] queueNextProcessingBatchIfNeeded(): Already running a job... not starting new one.
Here is my code :
class Pictures23d {
func loop(group: DispatchGroup, _ jobNumber: Int? = nil) {
var session: PhotogrammetrySession?
print("run \(Date())")
group.enter()
print("group enter for job \(String(describing: jobNumber))")
DispatchQueue(label: "\(jobNumber ?? 0)").async { [weak self] in
guard let self = self else { return }
let configuration = self.makeConfiguration()
do {
session = try PhotogrammetrySession(input: self.processingConf.inputFolderUrl,
configuration: configuration)
self.delegate?.processingStarted()
} catch {
Foundation.exit(1)
}
guard let session = session else {
Foundation.exit(1)
}
let waiter = self.waiter(group: group, session: session)
// Compiler may deinitialize these objects since they may appear to be
// unused. This keeps them from being deallocated until they exit.
withExtendedLifetime((session, waiter)) {
// Run the main process call on the request, then enter the main run
// loop until you get the published completion event or error.
do {
let requests = self.makeRequests()
if requests.isEmpty {
Foundation.exit(1)
}
try session.process(requests: requests)
RunLoop.current.run()
} catch {
Foundation.exit(1)
}
}
}
}
and from another class this is how I run it:
let group = DispatchGroup()
var index = 0
for conf in list {
let picture23dsession = Pictures23d(processingConf: conf)
picture23dsession.loop(group: group, index + 1000)
index += 1
// Everything went fine
let loadResult = String(describing: picture23dsession.lodResults)
}
group.wait()