Building a New iPad App


#21

Hi @anthony.monaco

Thanks for your excellent reply.

For depth query with save as video I will describe soon.

At the moment I am troubling with to save the “Mesh.obj” file into the local device.
As you said above writeToFile:options:error: function. I already do that but it’s not saving the file properly. It’s saving the empty folder.

Actually it giving an error like - NSUnderlyingError=0x280e76dc0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}

My Swift code is below-

@objc func saveMesh()
{
let documentsDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
let filePath = URL(fileURLWithPath: documentsDirectoryPath).appendingPathComponent("").absoluteString

    do{
       try meshRef?.write(toFile: filePath)

    } catch{
         print("Failed to read text from \(filePath)")
    }

    let fileURL = URL(fileURLWithPath: filePath)
    if documentInteractionController == nil {
        documentInteractionController = UIDocumentInteractionController(url: fileURL)
    } else {
        documentInteractionController?.url = fileURL
    }

    if let lastObject = navigationItem.rightBarButtonItems?.last {
        documentInteractionController?.presentOpenInMenu(from: lastObject, animated: true)
    }
}

Thanks & Regards,
Puneet


#22

I think the issue lies with the above line: https://stackoverflow.com/questions/52481321/swift-4-0-unable-to-create-empty-text-file-in-ios?rq=1


#23

Thank you @anthony.monaco for your reply.

@jim_selikoff & @anthony.monaco
Now, I already play with Structure SDK and get to know more about the same.

So, here is my first scenario-

First, I want to Capture a room with RGBA Color & Depth after that I want to save the Mesh(including RGBA+Depth) locally on device. Something like Structure App.

So, Now I am creating a new Project for the above Scenario but I am facing set up problems-

Problems-
I want to developed in Swift language. When I created the Bridge Header file and Import the SDK. It’s always gives me the error like-

  1. Header file not found.
  2. command precompileswiftbridgingheader failed with a nonzero exit code
    3.After Importing "#import “Structure.h” " into the Header file also it’s says “Structure.h” Not Found.

Overall It’s giving the error related to the Header Bridging file. I already set up the previous project and set up after lot of fixing but this time it’s not compiling.

I already do lot of googling but not get any success to solve it.

Do you have any suggestions?
I already follow - “Guide to setting up a Swift project

https://stackoverflow.com/questions/46690619/build-fails-with-command-failed-with-a-nonzero-exit-code

https://stackoverflow.com/questions/52387452/command-compileswift-failed-with-a-nonzero-exit-code-in-xcode-10?rq=1

Thanks.
Best
Puneet


#24

Maybe this tutorial will help you out: https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift


#25

Hi @jim_selikoff , Hi @anthony.monaco,

I have worked on RGBA app with Depth. I have done RGBA & depth but depth gives me nan value when I don’t have depth(Debug Message - shift: 1033 depth: 303.8cm & shift: 2047 depth: nan).
How Can I fix the nan value?
Also, how can I capture this RGBA Image with depth and save it?

I wish you a nice weekend.

Best,
Puneet


#26

Hello All,

After rendering the imageFromPixels with
func sensorDidOutputDepthFrame( _ depthFrame:STDepthFrame!)
I am trying to capture the RGBA scene, even I ported the selectCaptureFormat from the scanner sample to see if that was it.

But It’s crashed on:-
func enterScanningState() {

    // This can happen if the UI did not get updated quickly enough.
    if !_slamState.cameraPoseInitializer!.lastOutput.hasValidPose.boolValue {
        print("Warning: not accepting to enter into scanning state since the initial pose is not valid.")
        return
    } } 

and gives the error-
error: Unexpectedly found nil while unwrapping an Optional value

Can someone help me to capture and save it?

Best
Puneet