StandardCyborg / StandardCyborgCocoa

Everything you need for 3D scanning on iOS
https://www.standardcyborg.com
Other
143 stars 49 forks source link

Alternate path to save .ply files #30

Closed scottldouglas60 closed 1 year ago

scottldouglas60 commented 1 year ago

Love this code - Thanks to the team at StandardCyborg for releasing to the public. I have the example app compiling and working nicely.

  1. When the save button is pressed two .ply files are saved in the container in the app. I ALSO to save the two same files to a documents directory. I grep'd the complete installation folder for .ply etc and nothing pops up. Are the methods to write out the .ply files buried somewhere. Apologies but I saw this code in a previous release earlier this year, or in the readme.

let plyFile = documentsURL!.appendingPathComponent("myScan.ply") previewVC?.pointCloud?.writeToPLY(atPath: plyFile.path)

I did find this function which I think I could wire to a button but in a previous issue members report that this method is not working correctly

scene.writeToGLTF(atPath: sceneGltfURL.path)

So how would I save out these files in the Documents folder.

Thanks for all the help!

SD

aaptho commented 1 year ago

Have you verified that previewVC and pointCloud are non-nil? If you change those ? to !, does it crash?

How are you looking in the installation folder? Downloading the app container via the Xcode organizer?

scottldouglas60 commented 1 year ago

Hi aaptho!!!!

I have found the .ply files! When I use Xcode to download the container and view contents. The .ply reside in /tmp/SCMeshTexturing-xxxx where the xxx is placed by numbers generated at I expect compile/run time.

Im able to set my copy path to tmp, and copy files out to the Phones user Documents Folder.

print("Pressed Export Button") let temporaryFolderURL = URL(fileURLWithPath: NSTemporaryDirectory()) print("tmp folder is =",temporaryFolderURL)

tmp folder is = file:///private/var/mobile/Containers/Data/Application/9EE52650-19B6-4028-8F31-2ED882B4EFAD/tmp/

I am stuck how to set the path to the SCMeshTexturing-x folder if name changes all the time. Any help to a newbie Xcode developer is much appreciated.!!

Screen Shot 2022-12-11 at 1 03 26 PM

aaptho commented 1 year ago

Those tmp/SCMeshTexturing-{uuid} files are only used during scanning for generating a textured mesh, not for saving the point cloud. The point cloud should already be in the app’s Documents directory when you used

let plyFile = documentsURL!.appendingPathComponent("myScan.ply”)

Does Documents/myScan.ply exist in this case?

While iOS does have a system-wide Documents directory accessible with the Files app, your app can’t directly write to that one. Instead, each app’s documents directory is “containerized”, so it’s specific to that app.

See here for how to prompt the user to export a copy of the file to the shared Documents directory in Files, or to make your app’s Documents directory show up within Files on the device. https://stackoverflow.com/a/46457518

scottldouglas60 commented 1 year ago

Absolutely crushed it. I added this code to the saveScene function and it wrote out a .ply.

SWEET !!!!!1 scene.pointCloud?.writeToPLY(atPath: scenePlyURL.path)