Can SceneKit be used with RoomPlan

We have an App that does something similar to RoomPlan. We use SceneKit to draw all the wall lines. We have noticed that RoomPlan has trouble detecting walls around 7 inches or shorter. Our app has tools to deal with this. It seems the difference in time to capture the walls of a room between our app and the RoomPlan demo app is negligible. But we could save time in our app with auto detection of all the other things like windows, doors, openings, cabinets, etc.

Are the lines you see drawn in the RoomPlan demo App SCNNodes?

If so will you ever be able to call .addNode() inside the RoomPlan framework?

If not, does RoomPlan use SpriteKit to draw?

We use an ARSCNView to keep track of all the lines in our app. Changing that member to an instance of RoomCaptureView seems like a non starter.

Starting a new RoomCaptureSession when we're ready to scan for objects other than walls wipes all the wall lines we've previously captured.

Thanks,

Mike

Answered by jmousseau in 716580022

As far as I can tell, RoomPlan visualizes the lines with RealityKit. Instead of using RoomCaptureView, you can run a RoomCaptureSession and add SCNNodes for each of the CapturedRoom's completed edge surfaces. One tricky aspect is you'll have to assign the RoomCaptureSession's arSession to your ARSCNView inside the captureSession(_:didStartWith:) delegate method. This is because RoomPlan owns the underlying ARSession instance.

I too have an app that uses SceneKit with ARKit to frame pictures and lay them out in galleries in a room. I would hope to use my SCNNodes seamlessly with RoomPlan. I'm very interested in the answers to this question.

Accepted Answer

As far as I can tell, RoomPlan visualizes the lines with RealityKit. Instead of using RoomCaptureView, you can run a RoomCaptureSession and add SCNNodes for each of the CapturedRoom's completed edge surfaces. One tricky aspect is you'll have to assign the RoomCaptureSession's arSession to your ARSCNView inside the captureSession(_:didStartWith:) delegate method. This is because RoomPlan owns the underlying ARSession instance.

My understanding is that if you want access to the RoomPlan session you need to use the data api rather than the RoomCaptureView. You create a RoomCaptureSession and hand that over to an ARSCNView and listen to all the callbacks from the RoomCaptureSessionDelegate. It will update you with a new version of the room as it finds it. It's up to you to then build the room from the data it gives you. This was the conversation I had with the apple engineer this morning, but I've yet to try it.

I just got it to work with this code

 private var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration()
  var arSceneView: ARSCNView!
  var session:RoomCaptureSession!

    override func viewDidLoad() {
        super.viewDidLoad()
        arSceneView = ARSCNView.init(frame: self.view.bounds)
        self.view.addSubview(arSceneView)
        roomCaptureSessionConfig.isCoachingEnabled = true
        session = RoomCaptureSession()
        session.delegate = self
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
         session.run(configuration: roomCaptureSessionConfig)
    }

     func captureSession(_ session: RoomCaptureSession, didStartWith configuration: RoomCaptureSession.Configuration){
         arSceneView.session = session.arSession
    }

I was able to get it to work using a fresh ARKit project from Xcode 14 Beta 2 and what was presented at WWDC like so:

import UIKit
import RealityKit
import RoomPlan
import ARKit

class ViewController: UIViewController {

    var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration()
    @IBOutlet var arView: ARView!

//    var previewVisualizer: Visualizer!

    lazy var captureSession: RoomCaptureSession = {
        let captureSession = RoomCaptureSession()
        arView.session = captureSession.arSession
        return captureSession
    }()
   
    override func viewDidLoad() {
        super.viewDidLoad()
        captureSession.delegate = self
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        captureSession.run(configuration: roomCaptureSessionConfig)
    }
}

extension ViewController: RoomCaptureSessionDelegate {

    func captureSession(_ session: RoomCaptureSession,
                        didUpdate room: CapturedRoom) {
        print(room)
//        previewVisualizer.update(model: room)
    }

    func captureSession(_ session: RoomCaptureSession,
                        didProvide instruction: RoomCaptureSession.Instruction) {
        print(instruction)
  //    previewVisualizer.provide(instruction)
    }
}

That will really fill up your console pretty quickly and turn your phone into a nice hand warmer if you're not careful. :-)

Does anyone have a Roomplan file output that they would share? I am working on something for the construction industry and would love to see the output. Preferred as a .USD (not USDZ) if possible. Thanks Nate (Ontario, Canada)

Can SceneKit be used with RoomPlan
 
 
Q