Posts

Post not yet marked as solved
0 Replies
444 Views
I try to fix focus length for iPad camera, and get camera intrinsic value. But fx, fy of camera intrinsics is varied. Are fx and fy varied normal? iOS version is 13.5.1 AVCaptureConnection *conn = [dataOutput connectionWithMediaType:AVMediaTypeVideo]; if (conn.isCameraIntrinsicMatrixDeliverySupported) {       [conn setCameraIntrinsicMatrixDeliveryEnabled: true]; } (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { 		CFTypeRef intrinsics_data_ref = CMGetAttachment(sampleBuffer,                           kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix,                           nil);   	NSData *intrinsics_data = (__bridge NSData *)intrinsics_data_ref;   	matrix_float3x3 *intrinsics_3x3 = (matrix_float3x3 *)intrinsics_data.bytes;   	float fx = intrinsics_3x3->columns[0][0];   	float fy = intrinsics_3x3->columns[1][1];   	float cx = intrinsics_3x3->columns[2][0];   	float cy = intrinsics_3x3->columns[2][1];   	NSLog(@"output: fx= %f, fy= %f, cx= %f, cy= %f", fx, fy, cx, cy); }
Posted Last updated
.
Post not yet marked as solved
0 Replies
398 Views
I download usdz by urlsession in my code:let url = URL(string: "download usdz url") let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let destinationUrl = documentsUrl.appendingPathComponent(url!.lastPathComponent) let session = URLSession(configuration: URLSessionConfiguration.default, delegate: nil, delegateQueue: nil) var request = URLRequest(url: url!) request.httpMethod = "GET" let downloadTask = session.downloadTask(with: request, completionHandler: { (location:URL?, response:URLResponse?, error:Error?) -> Void in let fileManager = FileManager.default try! fileManager.moveItem(atPath: location!.path, toPath: destinationUrl.path) do { let testEntity = try Entity.load(contentsOf: destinationUrl) // Error } catch { print("\(error.localizedDescription)") } }) downloadTask.resume()but this code is error:let testEntity = try Entity.load(contentsOf: destinationUrl)
Posted Last updated
.
Post not yet marked as solved
0 Replies
383 Views
I want to create a place virtually object animation for ar app.such as https://developer.apple.com/documentation/arkit/placing_objects_and_handling_3d_interaction?language=objcI want to replace the square with animation.So I create animation by the Reality Composer and export file(.reality).then I load this file by Xcode. var entity: Entity? override func viewDidLoad() { super.viewDidLoad() arView.debugOptions = [.showPhysics] arView.session.delegate = self let object = try! Entity.load(named: "object_animation") self.entity = object let anchor = AnchorEntity() anchor.addChild(object) arView.scene.addAnchor(root) } func session(_ session: ARSession, didUpdate frame: ARFrame) { let bounds = self.arView.bounds let screenCenter = CGPoint(x: bounds.midX, y: bounds.midY) guard let query = self.arView.makeRaycastQuery(from: screenCenter, allowing: .estimatedPlane, alignment: .horizontal), let result = self.arView.session.raycast(query).first else { self.entity?.isEnabled = false return } self.entity?.isEnabled = true self.entity!.transform = Transform(matrix: result.worldTransform) }then, I build this app, the animation object position is wrong.
Posted Last updated
.