As I am trying to run the application with the vision Pro, I receive following error:
ar_image_tracking_provider_t <0x303d45340>: Failed to set up image tracking with error: No images were supplied.
i did add images in Assets under a “ref” folder. so normally it should work
this is my function
import Foundation
import RealityKit
import ARKit
import RealityKitContent
var arkitSession = ARKitSession()
@MainActor class ARKitViewModel: ObservableObject{
private let session = ARKitSession()
private let imageTracking = ImageTrackingProvider(referenceImages: ReferenceImage.loadReferenceImages(inGroupNamed: "ref"))
var entityMap : [UUID: ModelEntity] = [:]
func runSession() async {
Task {
do {
try await arkitSession.run([imageTracking])
} catch {
print("Error: \(error)")
}
}
}
var material = SimpleMaterial()
var rootEntity = Entity()
func updateImage(_ anchor: ImageAnchor) {
if entityMap[anchor.id] == nil {
let entity = ModelEntity(mesh: .generateSphere(radius: 0.05))
entityMap[anchor.id] = entity
rootEntity.addChild(entity)
entity.transform = Transform(matrix: anchor.originFromAnchorTransform)
}
}
func processUpdates() async {
for await _ in imageTracking.anchorUpdates{
print("test")
}
}
}
i don't know why it failed to set up and basically i am trying to use this code to detect an object ,static one? exemple of these photos:
You have to put images under a ref.arresourcegroup
folder (which has an adhoc json
file that created automatically), not under a regular ref
folder. To do that, create you ref
folder in Assets using contextual menu (do not specify .arresourcegroup
extension, this folder will receive it automatically):
Place your 480
x480
reference images in this folder and adjust their real-world size in the Inspector. You must use high-contrast, well-discernible, RGB-only (no Alpha-transparency) images. Also, avoid gradients and single-solid-colors in your reference images. Try to use colors that have an ideal contrast in black-and-white version of this image. Try not to use repetitive patterns like stripes or polka dots.