Post

Replies

Boosts

Views

Activity

Reply to Barcode Detection Enterprise API
struct BarcodeView: View { @Environment(AppModel.self) var appModel @State private var root = Entity() @State private var arKitSession = ARKitSession() var body: some View { RealityView { content, attachments in content.add(root) if let barcodeAttachment = attachments.entity(for: "testView") { barcodeAttachment.position = [0, 1, -1] root.addChild(barcodeAttachment) } } placeholder: { ProgressView() } attachments: { Attachment(id: "testView") { Text("Looking for barcodes") .bold() .font(.largeTitle) } } .task { guard BarcodeDetectionProvider.isSupported else { print("Barcode detection is not supported") return } await arKitSession.requestAuthorization(for: [.cameraAccess, .worldSensing]) let barcodeDetection = BarcodeDetectionProvider(symbologies: [.code128, .code39, .code93, .ean8, .ean13, .qr, .upce]) do { try await arKitSession.run([barcodeDetection]) for await update in barcodeDetection.anchorUpdates { switch update.event { case .added: print("New barcode detected: \(update.anchor.payloadString ?? "")") case .updated: print("Barcode updated: \(update.anchor.payloadString ?? "")") case .removed: print("Barcode removed: \(update.anchor.payloadString ?? "")") } } } catch { print("Error running ARKit session: \(error.localizedDescription)") } } } }
Oct ’24
Reply to Barcode Detection Enterprise API
@Vision Pro Engineer Thanks for responding. I did remove that code after posting this, and that did not make a difference. I also made sure my Vision Pro was updated to 2.0.1. I'm using the standard template for an immersive space app and this is the code to launch my barcode immersive space. There's nothing missing in this part of the implementation is there? import SwiftUI @main struct Enterprise3App: App { @State private var appModel = AppModel() @State private var avPlayerViewModel = AVPlayerViewModel() var body: some Scene { WindowGroup { if avPlayerViewModel.isPlaying { AVPlayerView(viewModel: avPlayerViewModel) } else { ContentView() .environment(appModel) } } ImmersiveSpace(id: appModel.immersiveSpaceID2) { BarcodeView() .environment(appModel) .onAppear { appModel.immersiveSpaceState = .open } .onDisappear { appModel.immersiveSpaceState = .closed } } .immersionStyle(selection: .constant(.mixed), in: .mixed) } }
Oct ’24
Reply to Barcode Detection Enterprise API
My entitlements look great, and there is no issue at compile time with them matching up to what's in the portal. I've confirmed that the Enterprise.license file is included in the target membership for the project. I've even gone so far as to create an additional project from the Xcode template, used .mixed immersionStyle, and copy the code from the example directly into ImmersiveView.swift. I still get that error message and the app absolutely does not pick up and type of bar code. I've added all the available symbologies, and tried scanning both QR codes and barcodes on the back of an iPhone box and also a standard UPC code, to no avail. It really seems that the code published (https://developer.apple.com/documentation/visionos/locating-and-decoding-barcodes-in-3d-space) to attempt barcode scanning is missing something in order to get it to work properly. @team_hcs have you gotten barcode scanning to work yet?
Oct ’24
Reply to Barcode Detection Enterprise API
Unfortunately the link that you sent I get an "Unauthorized Access" page when clicking on it, even when signed in with the account holder role. I can confirm that I am using an immersive space. I've even replaced the barcode detection .task with the task from this sample code (https://developer.apple.com/documentation/visionos/setting-up-access-to-arkit-data) and I have no problem detecting planes in the await update in planeData.anchorUpdates code block. Is there any chance something is wrong with my Enterprise.license file that would cause this? Also, you mentioned that you've ran my code and it seems to be working just fine. Can you confirm you see the same message that I do in the console when running barcode detection? The ar_barcode_detection_provider_t <0x303ee4a20>: Failed to run provider with transient error code: 1 message?
Oct ’24