RoomPlan

RSS for tag

Create parametric 3D scans of rooms and room-defining objects.

Posts under RoomPlan tag

200 Posts

Post

Replies

Boosts

Views

Activity

Room plan ceiling scans and model placement
Hello, I am trying to make an app that involves room scanning and then placing of imaginary objects in the room. I had two questions about the specifics behind this. Is it possible for Roomplan to include the ceiling when scanning the room? Is it possible to place objects in AR while Room plan is running, or is it necessary to wait until after the scan is done?
1
1
1k
Jun ’24
Where can "SystemVersion.bundle" be found?
This is one of the files being looked for during initialization of the RoomPlan WWDC Demo package but it cannot be found since moving to IOS 18.0. it is not anyrhere since the upgrade. Reference is 2024-06-18 16:03:36.871062-0500 RoomPlanExampleApp[860:159744] [loading] Unable to create bundle at URL (file:///System/Library/CoreServices/SystemVersion.bundle): does not exist or not a directory (0)
10
0
1.4k
Jun ’24
Access RoomPlan API from Objective-C
Is it possible to access the RoomPlan API from Objective-C? I cannot figure out how to include the RoomPlan framework into some legacy Objective-C code I have. I can include the RoomPlan.h header but it still does not recognize any of the API classes. I also could not figure out if there was a way to use RoomPlan-Swift.h to expose the API to the Objective-C code.
1
0
1.1k
Jun ’24
2D or 3D indoor mapping app in iOS
Hello! I want to create an indoor mapping application in Swift, using the LiDAR scanner. I searched among frameworks and I found that ARKit, RealityKit and RoomPlan would be useful. Which is the proper way to create a 2D indoor mapping app? And which is the proper way to create a 3D indoor mapping app? Are there any modifications I have to make on my code in order to have both?
1
0
1k
Jun ’24
RoomPlan: How to track rooms across a CapturedStructure.init(from:) call?
I'd like to be able to associate some data with each CapturedRoom scan and maintain those associations when CapturedRooms are combined in a CapturedStructure. For example, in the delegate method captureView(didPresent:error:), I'd like to associate external data with the CapturedRoom. That's easy enough to do with a Swift dictionary, using the CapturedRoom's identifier as the key to the associated data. However, when I assemble a list of CapturedRooms into a CapturedStructure using StructureBuilder.init(from:), the rooms in the output CapturedStructure have different identifiers so their associations to the external data are lost. Is there any way to track or identify CapturedRoom objects that are input into a StructureBuilder to the rooms in the CapturedStructure output? I looked for something like a "userdata" property on a CapturedRoom that might be preserved, but couldn't find one. And since the room identifiers change when they are built into a CapturedStructure, I don't see an obvious way to do this.
3
1
1.1k
Jun ’24
StructureBuilder with modified CapturedRooms
My goal is to modify CapturedRooms and load them back into the StructureBuilder to generate a new CapturedStructure. Since CapturedRooms cannot be modified directly I stored them as JSON, modified the parameters (e.g. switching object categories) and serialized them back into a CapturedRoom object. So far so good, the object is loaded correctly. But when i put them into the capturedStructure() all the original parts of the CapturedRoom are used. As some of you may have already noticed there is an undocumented CoreModel stored in CapturedRooms when you export them in JSON-format. It seems that the structure builder only uses this CoreModel to compose the output. So here my question to the forum: Does anybody know a way to edit a CapturedRoom so the StructureBuilder respects those changes and composes a new structure including those changes?
1
1
696
May ’24
Room not to scale
Hello, I am working on an AR application to visualize a life-size room. I am working with Unity 2023.3, Apple ARKIT XR Plugin 6.0.0-pre.8 and a 2021 5th gen iPad. First I scan a room with roomplan to get a usdz file. I open it with Blender to make sure I have the right data (I do) and I export it to fbx to use it in Unity. Then I import the fbx to Unity and I use it as a prefab to instantiate it when I click on a detected floor. I build my application in Unity, then in Xcode to use it on my iPad. But when the room is displayed, it is way too small. I tried adding a slider to scale up the room's gameobject and I added a plugin to visualize my Unity scene in my built application. The room is scalling up in the Unity scene but not in the application. Does anyone ever had this issue and if so how did you fix that? Best regards, Angel Garcia
0
0
655
May ’24
StructureBuilder Trajectory issues during merging
In larger scenes, I need to record motion trajectories. RoomCaptureSession always starts from (0,0,0), and I use the last tracked point as the offset value to connect multiple trajectory points, just like StructureBuilder merging models But when StructureBuilder merged, it eliminated some of the models, which would make the trajectory points I saved lose accuracy, and I cannot know how much scene size was specifically eliminated between them Is there any way you can help me?
0
1
646
May ’24
CapturedStructure encoding failure issue
invalidValue(-nan, Swift.EncodingError.Context(codingPath: [CapturedVolumeCodingKeys(stringValue: "rooms", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CapturedVolumeCodingKeys(stringValue: "openings", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "dimensions", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "Unable to encode Float.nan directly in JSON.", underlyingError: nil)) Why does this exception occur during encoding? All scan data is CapturedRoom and has not been modified
0
0
544
May ’24
Trying to use ARView session's currentFrame camera transforms to identify wall corners in capturedImage
I am trying to determine the corners of a RoomPlan-detected wall using the information available in the ARView session's frame, but can't quite figure out what I'm doing wrong. The corners appear to be correct relative to each other, but the wall appears too large when I render it. (I'm also not sure I'm handling the image rotation correctly either, which may be compounding my problem). Here is the code I currently have, along with a sample image, and the resulting image when I pass it through the perspective filter. it is close but isn't cropping the walls and floors correctly. func captureSession(_ session: RoomCaptureSession, didChange room: CapturedRoom) { for surface in room.walls { if let frame = self.arView.session.currentFrame { var image: CGImage? = nil VTCreateCGImageFromCVPixelBuffer(frame.capturedImage, options: nil, imageOut: &image) let wallTransform = surface.transform let cameraTransform = frame.camera.transform let intrinsics = frame.camera.intrinsics let projectionMatrix = frame.camera.projectionMatrix let width = surface.dimensions.y let height = surface.dimensions.x let inverseCameraTransform = simd_inverse(cameraTransform) let wallTopRight = simd_float4(width/2, height/2, 0, 1) let wallTopLeft = simd_float4(-width/2, height/2, 0, 1) let wallBottomRight = simd_float4(width/2, -height/2, 0, 1) let wallBottomLeft = simd_float4(-width/2, -height/2, 0, 1) let worldTopRight = wallTransform * wallTopRight let worldTopLeft = wallTransform * wallTopLeft let worldBottomRight = wallTransform * wallBottomRight let worldBottomLeft = wallTransform * wallBottomLeft let cameraTopRight = projectionMatrix * inverseCameraTransform * worldTopRight let cameraTopLeft = projectionMatrix * inverseCameraTransform * worldTopLeft let cameraBottomRight = projectionMatrix * inverseCameraTransform * worldBottomRight let cameraBottomLeft = projectionMatrix * inverseCameraTransform * worldBottomLeft let imageTopRight = intrinsics * simd_float3(cameraTopRight.x / cameraTopRight.w, cameraTopRight.y / cameraTopRight.w, cameraTopRight.z / cameraTopRight.w) let imageTopLeft = intrinsics * simd_float3(cameraTopLeft.x / cameraTopLeft.w, cameraTopLeft.y / cameraTopLeft.w, cameraTopLeft.z / cameraTopLeft.w) let imageBottomRight = intrinsics * simd_float3(cameraBottomRight.x / cameraBottomRight.w, cameraBottomRight.y / cameraBottomRight.w, cameraBottomRight.z / cameraBottomRight.w) let imageBottomLeft = intrinsics * simd_float3(cameraBottomLeft.x / cameraBottomLeft.w, cameraBottomLeft.y / cameraBottomLeft.w, cameraBottomLeft.z / cameraBottomLeft.w) let topRight = CGPoint(x: CGFloat(imageTopRight.x), y: CGFloat(imageTopRight.y)) let topLeft = CGPoint(x: CGFloat(imageTopLeft.x), y: CGFloat(imageTopLeft.y)) let bottomRight = CGPoint(x: CGFloat(imageBottomRight.x), y: CGFloat(imageBottomRight.y)) let bottomLeft = CGPoint(x: CGFloat(imageBottomLeft.x), y: CGFloat(imageBottomLeft.y)) if let image { let filter = CIFilter.perspectiveCorrection() filter.inputImage = CIImage(image: UIImage(cgImage: image)) filter.topRight = topRight filter.topLeft = topLeft filter.bottomRight = bottomRight filter.bottomLeft = bottomLeft let transformedImage = filter.outputImage if let transformedImage { let context = CIContext() if let outputImage = context.createCGImage(transformedImage, from: transformedImage.extent) { let wall = Wall(id: surface.identifier, image: outputImage, surface: surface) self.walls.append(wall) } } } } } }
0
0
673
Apr ’24
Lidar Accuracy
I am using Lidar to measure the distance between the target point and the iPhone Pro. I am getting the correct distance only if I am greater than 70 cm away from the target point. I need that value to be accurate for distances below 70 cm as well. Is there any coding level issue or It's Lidar's limitations?
0
1
1.2k
Apr ’24
Having issue with two ar session togather
I have the following issue regarding running 2 AR service. I am trying to develop an app for my masters thesis. Case 1: I first scan the room using the roomplan api. Then I stop the roomplan api session and start the realitykit session. When the realitykit session starts, the camera is not showing anything but black screen. Case 2: When I had the issue with case one, I tried a seperate test app where I had 2 seperate screen for roomplan api and realitykit. There is no relation. but as soon as I introduced roomplan api, realitykit stopped working, having the same black screen as above. There might be any states that changed by the roomplan api, that's why realitykit is not able to access the camera. Let me know if you have any idea about it or any sample. I am using the following stack: Xcode - Latest; Swiftui; latest os in mac mini and iphone
2
1
1.2k
Apr ’24
RoomPlan- Getting error for ceiling Height and floor Height from CapturedRoom.
RoomPlan- Getting error for ceiling Height and floor Height from CapturedRoom. I am using RoomPlan version-2 Framework to scan houses. I need ceilingHeight and floorHeight. I am parsing the data of CapturedRoom successfully into Json and getting all keys and their value except "coreModel" of type: (RSFloorPlan) value. Does Apple support coreModel: RSFloorPlan yet? In "coreModel" key, there are some keys values of ceilingHeight and floorHeight. In the last I am getting encoded string as value of key "coreModel". CoreModel: qkgdxIDMaicOkpwW1I/h/V4C.........................7nCom3Lpu0CM= I will really appreciate your hard work.
2
0
882
Mar ’24
How can I prevent objects from aligning in RoomPlan?
I am making an app with RoomPlan using the official sample code. A model of the room is generated as it is scanned, and when the scan is complete, chairs and other objects are aligned parallel to the desk. I wanted to stop this behavior, so I decided to use the option beautifyObjects. import UIKit import RoomPlan class RoomCaptureViewController: UIViewController, RoomCaptureViewDelegate, RoomCaptureSessionDelegate { @IBOutlet var exportButton: UIButton? @IBOutlet var doneButton: UIBarButtonItem? @IBOutlet var cancelButton: UIBarButtonItem? @IBOutlet var activityIndicator: UIActivityIndicatorView? private var isScanning: Bool = false private var roomCaptureView: RoomCaptureView! private var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration() private var roomBuilder: RoomBuilder! private var processedResult: CapturedRoom? private var finalResults: CapturedRoom? override func viewDidLoad() { super.viewDidLoad() // Set up after loading the view. setupRoomBuilder() setupRoomCaptureView() activityIndicator?.stopAnimating() } private func setupRoomBuilder() { let beautifyObjectsEnabled = UserDefaults.standard.bool(forKey: "beautifyObjectsEnabled") if beautifyObjectsEnabled { roomBuilder = RoomBuilder(options: [.beautifyObjects]) } else { roomBuilder = RoomBuilder(options: []) } } private func setupRoomCaptureView() { roomCaptureView = RoomCaptureView(frame: view.bounds) roomCaptureView.captureSession.delegate = self roomCaptureView.delegate = self view.insertSubview(roomCaptureView, at: 0) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) startSession() } override func viewWillDisappear(_ flag: Bool) { super.viewWillDisappear(flag) stopSession() } private func startSession() { isScanning = true roomCaptureView?.captureSession.run(configuration: roomCaptureSessionConfig) setActiveNavBar() } private func stopSession() { isScanning = false roomCaptureView?.captureSession.stop() setCompleteNavBar() } // Decide to post-process and show the final results. func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { Task { do { let capturedRoom = try await roomBuilder.capturedRoom(from: roomDataForProcessing) DispatchQueue.main.async { self.finalResults = capturedRoom self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } } catch { print("Error processing room data: \(error.localizedDescription)") } } return true } // Access the final post-processed results. func captureView(didPresent processedResult: CapturedRoom, error: Error?) { finalResults = processedResult self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } @IBAction func doneScanning(_ sender: UIBarButtonItem) { if isScanning { stopSession() } else { cancelScanning(sender) } self.exportButton?.isEnabled = false self.activityIndicator?.startAnimating() } @IBAction func cancelScanning(_ sender: UIBarButtonItem) { navigationController?.dismiss(animated: true) } // Export the USDZ output by specifying the `.parametric` export option. // Alternatively, `.mesh` exports a nonparametric file and `.all` // exports both in a single USDZ. @IBAction func exportResults(_ sender: UIButton) { let destinationFolderURL = FileManager.default.temporaryDirectory.appending(path: "Export") let destinationURL = destinationFolderURL.appending(path: "Room.usdz") let capturedRoomURL = destinationFolderURL.appending(path: "Room.json") do { try FileManager.default.createDirectory(at: destinationFolderURL, withIntermediateDirectories: true) let jsonEncoder = JSONEncoder() let jsonData = try jsonEncoder.encode(finalResults) try jsonData.write(to: capturedRoomURL) try finalResults?.export(to: destinationURL, exportOptions: .parametric) let activityVC = UIActivityViewController(activityItems: [destinationFolderURL], applicationActivities: nil) activityVC.modalPresentationStyle = .popover present(activityVC, animated: true, completion: nil) if let popOver = activityVC.popoverPresentationController { popOver.sourceView = self.exportButton } } catch { print("Error = \(error)") } } private func setActiveNavBar() { UIView.animate(withDuration: 1.0, animations: { self.cancelButton?.tintColor = .white self.doneButton?.tintColor = .white self.exportButton?.alpha = 0.0 }, completion: { complete in self.exportButton?.isHidden = true }) } private func setCompleteNavBar() { self.exportButton?.isHidden = false UIView.animate(withDuration: 1.0) { self.cancelButton?.tintColor = .systemBlue self.doneButton?.tintColor = .systemBlue self.exportButton?.alpha = 1.0 } } } The func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) is mainly changed. I have confirmed in the debugger that the roomBuilder options are changed according to the buttons in the UI. Anyone who knows more about the behavior of this option, please give me an advice.
0
0
757
Mar ’24
Trouble encoding CapturedRoomData with JSONEncoder (used to work)
Hello, I used to be able to encode CapturedRoomData using JSONEncoder with the code below: // Encode CapturedRoomData func encodeRoomData(_ roomData: CapturedRoomData) -> Data? { print("#ECRD1 - Data: \(roomData)") do { let encodedRoom = try JSONEncoder().encode(roomData) print("#ECRD2 - Encoded: \(encodedRoom.description)") return encodedRoom } catch { print("#ECRD3 - Failed with error: \(error)") } return nil } A few weeks ago I noticed this approach is no longer working. The encoding fails and I get the following error printed: #ECRD3 - Failed with error: invalidValue(RoomPlan.CapturedRoomData, Swift.EncodingError.Context(codingPath: [], debugDescription: "Invalid data", underlyingError: nil)) Can anyone help me find the root of this problem? For reference, here’s what the printed CapturedRoomData looks like (with the keyframes omitted): #ECRD1 - Data: CapturedRoomData(keyframes: [...], coreAsset: <RSAsset: 0x283988bd0>, arFrameReferenceOriginTransform: simd_float4x4([[0.9995456, 0.0, 0.030147359, 0.0], [0.0, 1.0, 0.0, 0.0], [-0.030147359, 0.0, 0.9995456, 0.0], [0.38664898, 0.93699455, 0.38685757, 1.0]]))
0
0
600
Mar ’24
RoomPlanUsdz getting morphed
start the session and took a scan everything looks perfect in the 3d while taking but after completing the scan, the 3d model that is presented on the screen is getting morphed within 4 sec gap . first it shows the correct one after 4 to 5 sec the usdz is getting morphed like all the straight walls are transforming into curved and if i have one walls getting some 2 to 3 walls with overlapping. not able to know why it is getting morphed like that. All I do was presenting the 3d model on the screen from the delegate method should Present - func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { print("shouldPresentdelegate") if let error = error { print("shouldPresent error::",error) } return true } first it shows correct next in 4 to 5 sec its again reloads to another 3d form which is not correct at all . is there any reason behind this. can anyone please help me with this. your help is appreciated. Thankyou.
1
0
734
Mar ’24
Room plan ceiling scans and model placement
Hello, I am trying to make an app that involves room scanning and then placing of imaginary objects in the room. I had two questions about the specifics behind this. Is it possible for Roomplan to include the ceiling when scanning the room? Is it possible to place objects in AR while Room plan is running, or is it necessary to wait until after the scan is done?
Replies
1
Boosts
1
Views
1k
Activity
Jun ’24
Where can "SystemVersion.bundle" be found?
This is one of the files being looked for during initialization of the RoomPlan WWDC Demo package but it cannot be found since moving to IOS 18.0. it is not anyrhere since the upgrade. Reference is 2024-06-18 16:03:36.871062-0500 RoomPlanExampleApp[860:159744] [loading] Unable to create bundle at URL (file:///System/Library/CoreServices/SystemVersion.bundle): does not exist or not a directory (0)
Replies
10
Boosts
0
Views
1.4k
Activity
Jun ’24
Access RoomPlan API from Objective-C
Is it possible to access the RoomPlan API from Objective-C? I cannot figure out how to include the RoomPlan framework into some legacy Objective-C code I have. I can include the RoomPlan.h header but it still does not recognize any of the API classes. I also could not figure out if there was a way to use RoomPlan-Swift.h to expose the API to the Objective-C code.
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’24
2D or 3D indoor mapping app in iOS
Hello! I want to create an indoor mapping application in Swift, using the LiDAR scanner. I searched among frameworks and I found that ARKit, RealityKit and RoomPlan would be useful. Which is the proper way to create a 2D indoor mapping app? And which is the proper way to create a 3D indoor mapping app? Are there any modifications I have to make on my code in order to have both?
Replies
1
Boosts
0
Views
1k
Activity
Jun ’24
RoomPlan: How to track rooms across a CapturedStructure.init(from:) call?
I'd like to be able to associate some data with each CapturedRoom scan and maintain those associations when CapturedRooms are combined in a CapturedStructure. For example, in the delegate method captureView(didPresent:error:), I'd like to associate external data with the CapturedRoom. That's easy enough to do with a Swift dictionary, using the CapturedRoom's identifier as the key to the associated data. However, when I assemble a list of CapturedRooms into a CapturedStructure using StructureBuilder.init(from:), the rooms in the output CapturedStructure have different identifiers so their associations to the external data are lost. Is there any way to track or identify CapturedRoom objects that are input into a StructureBuilder to the rooms in the CapturedStructure output? I looked for something like a "userdata" property on a CapturedRoom that might be preserved, but couldn't find one. And since the room identifiers change when they are built into a CapturedStructure, I don't see an obvious way to do this.
Replies
3
Boosts
1
Views
1.1k
Activity
Jun ’24
CapturedRoom.coreModel?
It has been awhile since I looked at RoomPlan. I noticed when I was poking at the CapturedRoom, that there is binary data called coreModel... Does anyone know what this is? Is this related to ModelProvider? Thanks in advance.
Replies
1
Boosts
0
Views
752
Activity
May ’24
StructureBuilder with modified CapturedRooms
My goal is to modify CapturedRooms and load them back into the StructureBuilder to generate a new CapturedStructure. Since CapturedRooms cannot be modified directly I stored them as JSON, modified the parameters (e.g. switching object categories) and serialized them back into a CapturedRoom object. So far so good, the object is loaded correctly. But when i put them into the capturedStructure() all the original parts of the CapturedRoom are used. As some of you may have already noticed there is an undocumented CoreModel stored in CapturedRooms when you export them in JSON-format. It seems that the structure builder only uses this CoreModel to compose the output. So here my question to the forum: Does anybody know a way to edit a CapturedRoom so the StructureBuilder respects those changes and composes a new structure including those changes?
Replies
1
Boosts
1
Views
696
Activity
May ’24
Room not to scale
Hello, I am working on an AR application to visualize a life-size room. I am working with Unity 2023.3, Apple ARKIT XR Plugin 6.0.0-pre.8 and a 2021 5th gen iPad. First I scan a room with roomplan to get a usdz file. I open it with Blender to make sure I have the right data (I do) and I export it to fbx to use it in Unity. Then I import the fbx to Unity and I use it as a prefab to instantiate it when I click on a detected floor. I build my application in Unity, then in Xcode to use it on my iPad. But when the room is displayed, it is way too small. I tried adding a slider to scale up the room's gameobject and I added a plugin to visualize my Unity scene in my built application. The room is scalling up in the Unity scene but not in the application. Does anyone ever had this issue and if so how did you fix that? Best regards, Angel Garcia
Replies
0
Boosts
0
Views
655
Activity
May ’24
StructureBuilder Trajectory issues during merging
In larger scenes, I need to record motion trajectories. RoomCaptureSession always starts from (0,0,0), and I use the last tracked point as the offset value to connect multiple trajectory points, just like StructureBuilder merging models But when StructureBuilder merged, it eliminated some of the models, which would make the trajectory points I saved lose accuracy, and I cannot know how much scene size was specifically eliminated between them Is there any way you can help me?
Replies
0
Boosts
1
Views
646
Activity
May ’24
CapturedStructure encoding failure issue
invalidValue(-nan, Swift.EncodingError.Context(codingPath: [CapturedVolumeCodingKeys(stringValue: "rooms", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CapturedVolumeCodingKeys(stringValue: "openings", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "dimensions", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "Unable to encode Float.nan directly in JSON.", underlyingError: nil)) Why does this exception occur during encoding? All scan data is CapturedRoom and has not been modified
Replies
0
Boosts
0
Views
544
Activity
May ’24
Will RoomPlan work on iPhones without lidar?
If my app utilized the RoomPlan api to create a parametric representation of the room, would it open on iPhones that don’t have lidars? I‘m aware the iPhone models that are equipped with lidar are iPhone 12 Pro & Pro Max, iPhone 13 Pro & Pro Max, iPhone 14 Pro & Pro Max, and iPhone 15 Pro & Pro Max.
Replies
1
Boosts
1
Views
859
Activity
May ’24
Trying to use ARView session's currentFrame camera transforms to identify wall corners in capturedImage
I am trying to determine the corners of a RoomPlan-detected wall using the information available in the ARView session's frame, but can't quite figure out what I'm doing wrong. The corners appear to be correct relative to each other, but the wall appears too large when I render it. (I'm also not sure I'm handling the image rotation correctly either, which may be compounding my problem). Here is the code I currently have, along with a sample image, and the resulting image when I pass it through the perspective filter. it is close but isn't cropping the walls and floors correctly. func captureSession(_ session: RoomCaptureSession, didChange room: CapturedRoom) { for surface in room.walls { if let frame = self.arView.session.currentFrame { var image: CGImage? = nil VTCreateCGImageFromCVPixelBuffer(frame.capturedImage, options: nil, imageOut: &image) let wallTransform = surface.transform let cameraTransform = frame.camera.transform let intrinsics = frame.camera.intrinsics let projectionMatrix = frame.camera.projectionMatrix let width = surface.dimensions.y let height = surface.dimensions.x let inverseCameraTransform = simd_inverse(cameraTransform) let wallTopRight = simd_float4(width/2, height/2, 0, 1) let wallTopLeft = simd_float4(-width/2, height/2, 0, 1) let wallBottomRight = simd_float4(width/2, -height/2, 0, 1) let wallBottomLeft = simd_float4(-width/2, -height/2, 0, 1) let worldTopRight = wallTransform * wallTopRight let worldTopLeft = wallTransform * wallTopLeft let worldBottomRight = wallTransform * wallBottomRight let worldBottomLeft = wallTransform * wallBottomLeft let cameraTopRight = projectionMatrix * inverseCameraTransform * worldTopRight let cameraTopLeft = projectionMatrix * inverseCameraTransform * worldTopLeft let cameraBottomRight = projectionMatrix * inverseCameraTransform * worldBottomRight let cameraBottomLeft = projectionMatrix * inverseCameraTransform * worldBottomLeft let imageTopRight = intrinsics * simd_float3(cameraTopRight.x / cameraTopRight.w, cameraTopRight.y / cameraTopRight.w, cameraTopRight.z / cameraTopRight.w) let imageTopLeft = intrinsics * simd_float3(cameraTopLeft.x / cameraTopLeft.w, cameraTopLeft.y / cameraTopLeft.w, cameraTopLeft.z / cameraTopLeft.w) let imageBottomRight = intrinsics * simd_float3(cameraBottomRight.x / cameraBottomRight.w, cameraBottomRight.y / cameraBottomRight.w, cameraBottomRight.z / cameraBottomRight.w) let imageBottomLeft = intrinsics * simd_float3(cameraBottomLeft.x / cameraBottomLeft.w, cameraBottomLeft.y / cameraBottomLeft.w, cameraBottomLeft.z / cameraBottomLeft.w) let topRight = CGPoint(x: CGFloat(imageTopRight.x), y: CGFloat(imageTopRight.y)) let topLeft = CGPoint(x: CGFloat(imageTopLeft.x), y: CGFloat(imageTopLeft.y)) let bottomRight = CGPoint(x: CGFloat(imageBottomRight.x), y: CGFloat(imageBottomRight.y)) let bottomLeft = CGPoint(x: CGFloat(imageBottomLeft.x), y: CGFloat(imageBottomLeft.y)) if let image { let filter = CIFilter.perspectiveCorrection() filter.inputImage = CIImage(image: UIImage(cgImage: image)) filter.topRight = topRight filter.topLeft = topLeft filter.bottomRight = bottomRight filter.bottomLeft = bottomLeft let transformedImage = filter.outputImage if let transformedImage { let context = CIContext() if let outputImage = context.createCGImage(transformedImage, from: transformedImage.extent) { let wall = Wall(id: surface.identifier, image: outputImage, surface: surface) self.walls.append(wall) } } } } } }
Replies
0
Boosts
0
Views
673
Activity
Apr ’24
Lidar Accuracy
I am using Lidar to measure the distance between the target point and the iPhone Pro. I am getting the correct distance only if I am greater than 70 cm away from the target point. I need that value to be accurate for distances below 70 cm as well. Is there any coding level issue or It's Lidar's limitations?
Replies
0
Boosts
1
Views
1.2k
Activity
Apr ’24
Having issue with two ar session togather
I have the following issue regarding running 2 AR service. I am trying to develop an app for my masters thesis. Case 1: I first scan the room using the roomplan api. Then I stop the roomplan api session and start the realitykit session. When the realitykit session starts, the camera is not showing anything but black screen. Case 2: When I had the issue with case one, I tried a seperate test app where I had 2 seperate screen for roomplan api and realitykit. There is no relation. but as soon as I introduced roomplan api, realitykit stopped working, having the same black screen as above. There might be any states that changed by the roomplan api, that's why realitykit is not able to access the camera. Let me know if you have any idea about it or any sample. I am using the following stack: Xcode - Latest; Swiftui; latest os in mac mini and iphone
Replies
2
Boosts
1
Views
1.2k
Activity
Apr ’24
WWDC2022-10127: setup previewVisualizer
Following along with video from here https://developer.apple.com/videos/play/wwdc2022/10127/?time=410 At 6:50 mark we set up setup previewVisualizer, but we're not actually shown the implementation of this type. I think it would be helpful as I am having a hard time showing white visualizing lines that appear when scanning.
Replies
0
Boosts
0
Views
664
Activity
Mar ’24
RoomPlan- Getting error for ceiling Height and floor Height from CapturedRoom.
RoomPlan- Getting error for ceiling Height and floor Height from CapturedRoom. I am using RoomPlan version-2 Framework to scan houses. I need ceilingHeight and floorHeight. I am parsing the data of CapturedRoom successfully into Json and getting all keys and their value except "coreModel" of type: (RSFloorPlan) value. Does Apple support coreModel: RSFloorPlan yet? In "coreModel" key, there are some keys values of ceilingHeight and floorHeight. In the last I am getting encoded string as value of key "coreModel". CoreModel: qkgdxIDMaicOkpwW1I/h/V4C.........................7nCom3Lpu0CM= I will really appreciate your hard work.
Replies
2
Boosts
0
Views
882
Activity
Mar ’24
How can I prevent objects from aligning in RoomPlan?
I am making an app with RoomPlan using the official sample code. A model of the room is generated as it is scanned, and when the scan is complete, chairs and other objects are aligned parallel to the desk. I wanted to stop this behavior, so I decided to use the option beautifyObjects. import UIKit import RoomPlan class RoomCaptureViewController: UIViewController, RoomCaptureViewDelegate, RoomCaptureSessionDelegate { @IBOutlet var exportButton: UIButton? @IBOutlet var doneButton: UIBarButtonItem? @IBOutlet var cancelButton: UIBarButtonItem? @IBOutlet var activityIndicator: UIActivityIndicatorView? private var isScanning: Bool = false private var roomCaptureView: RoomCaptureView! private var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration() private var roomBuilder: RoomBuilder! private var processedResult: CapturedRoom? private var finalResults: CapturedRoom? override func viewDidLoad() { super.viewDidLoad() // Set up after loading the view. setupRoomBuilder() setupRoomCaptureView() activityIndicator?.stopAnimating() } private func setupRoomBuilder() { let beautifyObjectsEnabled = UserDefaults.standard.bool(forKey: "beautifyObjectsEnabled") if beautifyObjectsEnabled { roomBuilder = RoomBuilder(options: [.beautifyObjects]) } else { roomBuilder = RoomBuilder(options: []) } } private func setupRoomCaptureView() { roomCaptureView = RoomCaptureView(frame: view.bounds) roomCaptureView.captureSession.delegate = self roomCaptureView.delegate = self view.insertSubview(roomCaptureView, at: 0) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) startSession() } override func viewWillDisappear(_ flag: Bool) { super.viewWillDisappear(flag) stopSession() } private func startSession() { isScanning = true roomCaptureView?.captureSession.run(configuration: roomCaptureSessionConfig) setActiveNavBar() } private func stopSession() { isScanning = false roomCaptureView?.captureSession.stop() setCompleteNavBar() } // Decide to post-process and show the final results. func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { Task { do { let capturedRoom = try await roomBuilder.capturedRoom(from: roomDataForProcessing) DispatchQueue.main.async { self.finalResults = capturedRoom self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } } catch { print("Error processing room data: \(error.localizedDescription)") } } return true } // Access the final post-processed results. func captureView(didPresent processedResult: CapturedRoom, error: Error?) { finalResults = processedResult self.exportButton?.isEnabled = true self.activityIndicator?.stopAnimating() } @IBAction func doneScanning(_ sender: UIBarButtonItem) { if isScanning { stopSession() } else { cancelScanning(sender) } self.exportButton?.isEnabled = false self.activityIndicator?.startAnimating() } @IBAction func cancelScanning(_ sender: UIBarButtonItem) { navigationController?.dismiss(animated: true) } // Export the USDZ output by specifying the `.parametric` export option. // Alternatively, `.mesh` exports a nonparametric file and `.all` // exports both in a single USDZ. @IBAction func exportResults(_ sender: UIButton) { let destinationFolderURL = FileManager.default.temporaryDirectory.appending(path: "Export") let destinationURL = destinationFolderURL.appending(path: "Room.usdz") let capturedRoomURL = destinationFolderURL.appending(path: "Room.json") do { try FileManager.default.createDirectory(at: destinationFolderURL, withIntermediateDirectories: true) let jsonEncoder = JSONEncoder() let jsonData = try jsonEncoder.encode(finalResults) try jsonData.write(to: capturedRoomURL) try finalResults?.export(to: destinationURL, exportOptions: .parametric) let activityVC = UIActivityViewController(activityItems: [destinationFolderURL], applicationActivities: nil) activityVC.modalPresentationStyle = .popover present(activityVC, animated: true, completion: nil) if let popOver = activityVC.popoverPresentationController { popOver.sourceView = self.exportButton } } catch { print("Error = \(error)") } } private func setActiveNavBar() { UIView.animate(withDuration: 1.0, animations: { self.cancelButton?.tintColor = .white self.doneButton?.tintColor = .white self.exportButton?.alpha = 0.0 }, completion: { complete in self.exportButton?.isHidden = true }) } private func setCompleteNavBar() { self.exportButton?.isHidden = false UIView.animate(withDuration: 1.0) { self.cancelButton?.tintColor = .systemBlue self.doneButton?.tintColor = .systemBlue self.exportButton?.alpha = 1.0 } } } The func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) is mainly changed. I have confirmed in the debugger that the roomBuilder options are changed according to the buttons in the UI. Anyone who knows more about the behavior of this option, please give me an advice.
Replies
0
Boosts
0
Views
757
Activity
Mar ’24
Trouble encoding CapturedRoomData with JSONEncoder (used to work)
Hello, I used to be able to encode CapturedRoomData using JSONEncoder with the code below: // Encode CapturedRoomData func encodeRoomData(_ roomData: CapturedRoomData) -> Data? { print("#ECRD1 - Data: \(roomData)") do { let encodedRoom = try JSONEncoder().encode(roomData) print("#ECRD2 - Encoded: \(encodedRoom.description)") return encodedRoom } catch { print("#ECRD3 - Failed with error: \(error)") } return nil } A few weeks ago I noticed this approach is no longer working. The encoding fails and I get the following error printed: #ECRD3 - Failed with error: invalidValue(RoomPlan.CapturedRoomData, Swift.EncodingError.Context(codingPath: [], debugDescription: "Invalid data", underlyingError: nil)) Can anyone help me find the root of this problem? For reference, here’s what the printed CapturedRoomData looks like (with the keyframes omitted): #ECRD1 - Data: CapturedRoomData(keyframes: [...], coreAsset: <RSAsset: 0x283988bd0>, arFrameReferenceOriginTransform: simd_float4x4([[0.9995456, 0.0, 0.030147359, 0.0], [0.0, 1.0, 0.0, 0.0], [-0.030147359, 0.0, 0.9995456, 0.0], [0.38664898, 0.93699455, 0.38685757, 1.0]]))
Replies
0
Boosts
0
Views
600
Activity
Mar ’24
RoomPlanUsdz getting morphed
start the session and took a scan everything looks perfect in the 3d while taking but after completing the scan, the 3d model that is presented on the screen is getting morphed within 4 sec gap . first it shows the correct one after 4 to 5 sec the usdz is getting morphed like all the straight walls are transforming into curved and if i have one walls getting some 2 to 3 walls with overlapping. not able to know why it is getting morphed like that. All I do was presenting the 3d model on the screen from the delegate method should Present - func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { print("shouldPresentdelegate") if let error = error { print("shouldPresent error::",error) } return true } first it shows correct next in 4 to 5 sec its again reloads to another 3d form which is not correct at all . is there any reason behind this. can anyone please help me with this. your help is appreciated. Thankyou.
Replies
1
Boosts
0
Views
734
Activity
Mar ’24
[RSCaptureSession] RSError: kRSError_Runtime_DriftDetection: 4
During scanning, I got this error and scanning process immediately quips without any output. I wonder what this error means and what caused it. Thanks.
Replies
1
Boosts
0
Views
1k
Activity
Mar ’24