5 Replies Latest reply on Dec 20, 2017 9:12 AM by KFindlater

    Good way to save and load device intrinsics?

    KFindlater

      If I capture data with a realsense device, and later want to load images from the dataset (which may have been modified/saved with opencv)  is there a good way with Librealsense v1 (legacy one) to serialize/save the device intrinsics/extrinsics to file and load them along with the dataset for re-running/post-processing and having all the rs::intrinsic objects readily available?

       

      Anyone done this yet, or does the API have a neat way to handle this kind of thing?

       

      edit: the specific use-case for why I need the intrinsics is to call the  rs::intrinsics::deproject( rs::float2 px, float depth)  function on old data without a live connection to a realsense camera (where i'd normally have the intrinsics easily available) or perhaps you DO have a live camera connected, but it's not the same camera (either type, or just has slightly different intrinsics so the values will be different).

        • 1. Re: Good way to save and load device intrinsics?
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello KFindlater,

          Thank you for your interest on Intel® RealSense™ Technology.

          For future references, your ticket number is 03162709. Please keep this number handy in case you are asked for it.

          Actually, there is no "good" way to save and load intrinsics. The librealsense API does not provide a native mechanism to achieve this. 

          One approach is to save the intrinsics into a .json file and save the file in the same directory as the image file.
           
          Otherwise, you can use ROS to somehow capture the stream and intrinsics into a ROS Bag file. But this can get very complex and will require a lot of work.
           
          In other words, there is no easy way to do this.

          I hope you find this information useful.

          Please do not hesitate to contact us again if you need further assistance.
             
          Thank you for your patience and understanding on this matter.
             
          Best regards.
             
          Josh B.
          Intel Customer Support.

          • 2. Re: Good way to save and load device intrinsics?
            KFindlater

            Hi Josh,

             

            Thanks for the info.

             

            I dug around in the source code a bit..

             

            Seeing as the rs::intrinsics appears to be a struct, is it not possible to save the object ("serialize" it) and use an output filestream ( using ios::base::binary options to preserve the format exactly) into some random binary object (lets call it a .bin file) and it can be loaded by reading it back and copying it into a new rs::intrinsic struct object in the program which is re-running data?

             

            the ROS nodes and bag recording do not have access to the intrinsics either...

             

            This is a possibly useful tool/idea for the librealsense devs, if you could pass it along for me!

            • 3. Re: Good way to save and load device intrinsics?
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hello KFindlater,
               
              Thank you for your reply.
               
              I will pass your suggestion to the development team.
               
              On the meantime, our suggestion is to continue using Librealsense and to code any mechanism you may need in order to accomplish your goal for your specific situation.
               
              Please, let us know if further assistance is required or if we can close this case.
               
              We will be looking forward for your reply.
               
              Best regards,
               
              Josh B.
              Intel Customer Support

              • 4. Re: Good way to save and load device intrinsics?
                KFindlater

                You may close this support case. I will do what I can until/if librealsense gets a native way to save/load intrinsics for the purpose of re-running datasets. Thanks!

                • 5. Re: Good way to save and load device intrinsics?
                  KFindlater

                  If anyone is interested, I have successfully serialized and saved the intrinsics to disk. they are simple data-type structs, so a memcpy to a char* array and using ofstream to write the file (and ifstream to read it back) does indeed work, and reversing is also very simple as well.

                   

                  haven't done super-deep testing yet but the initial results are promising.