skip to Main Content

For the past few days I’ve tried creating a photogrammetry command line app in Xcode. But I keep getting an error when I try to run the code.

The error I get is the following:

[Photogrammetry] queueNextProcessingBatchIfNeeded(): Already running a job... not starting new one.

I’ve searched on Google but I can’t find anyone who has experienced the same issue.

The code I’m using is the following:

import Foundation
import RealityKit

let inputFolderUrl = URL(fileURLWithPath: "/Users/username/Desktop/AirForce", isDirectory: true)
let session = try! PhotogrammetrySession(input: inputFolderUrl, configuration: PhotogrammetrySession.Configuration())

try! session.process(requests: [.modelFile(url: URL(fileURLWithPath: "/Users/username/Desktop/MyModel.usdz"), detail: .preview)])

My system:
MacBook Air (M1, 2020)
macOS Monterey 12.0.1 (21A559)
Xcode Version 13.2.1 (13C100)

2

Answers


  1. Use my code. It works. If you need more details on photogrammetry, read my Medium post.

    import Cocoa
    import RealityKit
    
    struct Photogrammetry {
    
        typealias Config = PhotogrammetrySession.Configuration
        typealias Request = PhotogrammetrySession.Request
        var inputFolder = "/Users/swift/Desktop/WildBoar"
        var outputFile = "/Users/swift/Desktop/wildBoar.usdz"
        var detail: Request.Detail = .medium
    
        fileprivate func running() {
            var config = PhotogrammetrySession.Configuration()
            config.featureSensitivity = .normal
            config.isObjectMaskingEnabled = true
            config.sampleOrdering = .unordered
    
            let inputFolderURL = URL(fileURLWithPath: inputFolder, 
                                         isDirectory: true)
    
            var optionalSession: PhotogrammetrySession? = nil
    
            do {
                optionalSession = try PhotogrammetrySession(
                                                 input: inputFolderURL,
                                         configuration: config)        
            } catch {
                print("ERROR")
                Foundation.exit(1)
            }
    
            guard let session = optionalSession 
            else { Foundation.exit(1) }
    
            withExtendedLifetime(session) {
                do {
                    let request = PhotogrammetrySession.Request
                       .modelFile(url: URL(fileURLWithPath: outputFile),
                               detail: detail)
                    try session.process(requests: [request])
                    RunLoop.main.run()
                } catch {
                    print("ERROR")
                    Foundation.exit(1)
                }
            }
        }
    }
    
    Login or Signup to reply.
  2. Hello I had the same problem I solved it by adding a single line.
    RunLoop.main.run()

    import Foundation
    import RealityKit
    
    let inputFolderURL =  URL(fileURLWithPath: "/Users/saibalaji/Desktop/ObjectCapture/ObjectCapture/Images/camera",isDirectory: true)
    let outputURL = URL(fileURLWithPath: "/Users/saibalaji/Desktop/ObjectCapture/ObjectCapture/Camera.usdz")
    
    let session = try! PhotogrammetrySession(input: inputFolderURL, configuration: PhotogrammetrySession.Configuration())
    let request = PhotogrammetrySession.Request.modelFile(url: outputURL, detail: .medium)
    try!  session.process(requests: [request])
            RunLoop.main.run()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search