Post

Replies

Boosts

Views

Activity

Reply to Barcode Detection Enterprise API
We have identified the issue. In our case it was a malformated entitlements file. We opened in a editor and made sure it looks like this: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.developer.arkit.barcode-detection.allow</key> <true/> </dict> </plist> However, I get the failure from the OP starter: ar_barcode_detection_provider_t <0x300d82130>: Failed to run provider with transient error code: 1 Though Barcode Scanning itself works (confiremd with QR)
Dec ’24
Reply to Barcode Detection Enterprise API
I would like to add more details. This is how my App looks like import ARKit @main struct MyApp: App { @State var session = ARKitSession() @State var immersionState: ImmersionStyle = .mixed var body: some Scene { WindowGroup { MyContentView() } ImmersiveSpace(id: "appSpace") { ImmersiveView() }.immersionStyle(selection: $immersionState, in: .mixed) } struct MyContentView: View { @Environment(\.openImmersiveSpace) private var openImmersiveSpace var body: some View { Button("Start ARKit experience") { Task { await openImmersiveSpace(id: "appSpace") } } } } } And my ImmersiveView with the barcode detection: // ImmersiveView.swift // VisionProHelloWorld // // Created by Development User on 26.07.24. // import SwiftUI import RealityKit import ARKit import Combine struct ImmersiveView: View { @State private var arkitSession = ARKitSession() @State private var root = Entity() @State private var fadeCompleteSubscriptions: Set<AnyCancellable> = [] var body: some View { RealityView { content in content.add(root) } .task { // Check if barcode detection is supported; otherwise handle this case. guard BarcodeDetectionProvider.isSupported else { return } // Specify the symbologies you want to detect. let barcodeDetection = BarcodeDetectionProvider(symbologies: [.code128, .qr, .upce, .ean13, .ean8]) do { try await arkitSession.requestAuthorization(for: [.worldSensing]) try await arkitSession.run([barcodeDetection]) print("Barcode scanning started") for await update in barcodeDetection.anchorUpdates where update.event == .added { let anchor = update.anchor // Play an animation to indicate the system detected a barcode. playAnimation(for: anchor) // Use the anchor's decoded contents and symbology to take action. print( """ Payload: \(anchor.payloadString ?? "") Symbology: \(anchor.symbology) """) } } catch { // Handle the error. print(error) } } } // Define this function in ImmersiveView. func playAnimation(for anchor: BarcodeAnchor) { guard let scene = root.scene else { return } // Create a plane sized to match the barcode. let extent = anchor.extent let entity = ModelEntity(mesh: .generatePlane(width: extent.x, depth: extent.z), materials: [UnlitMaterial(color: .green)]) entity.components.set(OpacityComponent(opacity: 0)) // Position the plane over the barcode. entity.transform = Transform(matrix: anchor.originFromAnchorTransform) root.addChild(entity) // Fade the plane in and out. do { let duration = 0.5 let fadeIn = try AnimationResource.generate(with: FromToByAnimation<Float>( from: 0, to: 1.0, duration: duration, isAdditive: true, bindTarget: .opacity) ) let fadeOut = try AnimationResource.generate(with: FromToByAnimation<Float>( from: 1.0, to: 0, duration: duration, isAdditive: true, bindTarget: .opacity)) let fadeAnimation = try AnimationResource.sequence(with: [fadeIn, fadeOut]) _ = scene.subscribe(to: AnimationEvents.PlaybackCompleted.self, on: entity, { _ in // Remove the plane after the animation completes. entity.removeFromParent() }).store(in: &fadeCompleteSubscriptions) entity.playAnimation(fadeAnimation) } catch { print("Error") } } } And here is the output from the log: Unfortunately now barcode is detected neither qr, nor another.
Nov ’24
Reply to Barcode Detection Enterprise API
I am also trying to use the Barcode Detection API. The code for me is running. World sensing is Authorized and I can see that the barcode detection task is tarted However, Barcodes are not being recognized. I am wondering if this could be caused by my AVP beging on visionOS 2.2 Beta 3 ?
Nov ’24