Items with no label
3335 Discussions

Real Sense R200 Scene Perception Save/Load State

MDamm
Beginner
1,286 Views

Hi,

I am working with the R200 Camera and the RealSense SDK 2016R2.

In the documentation, I found that there is a SaveCurrentState/LoadState function in the Scene Perception Module.

https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?savecurrentstate_pxcsceneperception.html Intel® RealSense™ SDK 2016 R2 Documentation

Now I am wondering what exactly is saved in this state. To be more specific I would like to now, if the BlockMeshingData of the module is saved in the state file.

Also when I try to load a saved state file, the status returns STATUS_ITEM_UNAVAILABLE and my program crashes.

0 Kudos
1 Solution
MartyG
Honored Contributor III
395 Views

I could find little useful documentation on these save and load functions. I think that when the term 'state' is used, it is referring to saving everything rather than just parts of the data.

Regarding your loading error: in the one script reference I could find that mentioned these functions, it says about the loading function:

"This function is only available before calling PXCSenseManager::Init(). The PXCSenseManager::Init() would fail [when loading] If you use a different camera than what was used when SaveCurrentState was called."

Its commentary about the save function is:

"Allows user to Save the current scene perception's state to a file and later supply the file to LoadState() to restore Scene Perception to the saved state."

This information is sourced from the long scene perception script linked below:

https://github.com/getnamo/realsense-ue4/blob/master/Plugins/RealSensePlugin/ThirdParty/RSSDK/Include/pxcsceneperception.h realsense-ue4/pxcsceneperception.h at master · getnamo/realsense-ue4 · GitHub

View solution in original post

5 Replies
MartyG
Honored Contributor III
396 Views

I could find little useful documentation on these save and load functions. I think that when the term 'state' is used, it is referring to saving everything rather than just parts of the data.

Regarding your loading error: in the one script reference I could find that mentioned these functions, it says about the loading function:

"This function is only available before calling PXCSenseManager::Init(). The PXCSenseManager::Init() would fail [when loading] If you use a different camera than what was used when SaveCurrentState was called."

Its commentary about the save function is:

"Allows user to Save the current scene perception's state to a file and later supply the file to LoadState() to restore Scene Perception to the saved state."

This information is sourced from the long scene perception script linked below:

https://github.com/getnamo/realsense-ue4/blob/master/Plugins/RealSensePlugin/ThirdParty/RSSDK/Include/pxcsceneperception.h realsense-ue4/pxcsceneperception.h at master · getnamo/realsense-ue4 · GitHub

MDamm
Beginner
395 Views

Hello MartyG,

thanks for your response. I rearranged my script, so that the LoadState function is called before PXCSenseManager::Init().

Now my application does not crash anymore, but I still get get the same Status Error Code when I execute the LoadState() function.

As you said, documentation on these functions is rare. It is not stated in which fileformat the state is saved.

Maybe the LoadState function does only accept files with the right ending?

0 Kudos
MartyG
Honored Contributor III
395 Views

If the program works until the point when you use the load-file control, I would tend to suspect too that there is a problem in the file path (folder name and file name) that is stopping the file from being found.

Bear in mind that the LoadState instruction may be formatted differently dpeending on whether you are using C++ or C# .

In C++ it might be something like:

pxcStatus PXCAPI LoadState(const pxcCHAR* file) = 0;

And in C# it may be something like:

pxcmStatus PXCAPI LoadState(String file) = 0;

The SaveState instruction would similarly have to be formatted for the language being used.

0 Kudos
MDamm
Beginner
395 Views

Thank you for your help!

I was able to load the state file by simply leaving the string in:

LoadState(String file)

without an file format ending.

When the state is succesfully loaded, I can execute the meshing function of the Scene Perception Module and get the mesh I captured before I saved the state of the module.

In this way it is possible to capture a scene with the Scene Perception Module, draw the mesh in my application, make annotations on the mesh and then save the state of the module.

After that I can restart the application and load the saved state to restore the mesh and its annotations at the right location in the scene.

0 Kudos
MartyG
Honored Contributor III
395 Views

Awesome news! Thanks so much for the detailed feedback. Best of luck with the rest of your project, and please feel free to return to the forum any time that you have further questions.

0 Kudos
Reply