1 Reply Latest reply on Mar 24, 2018 1:33 AM by MartyG

    About the First Steps to a Simpler RealSense source code

    even

      Hi MartyG:

           

           Can you provide the source code for the First Steps to a Simpler RealSense?

       

      Thank you!

        • 1. Re: About the First Steps to a Simpler RealSense source code
          MartyG

          Apparently there is not a pre-made ource code file associated with the article.  It looks like a guide where you put the script together yourself step by step by adding bits in order to better teach you how it works.  I will try to assemble a complete script below, but I'd recommend still following the guide to learn what each section of code does.

           

          I've included the code up til the point in the article where the author uses the word [/source], which I take to mean the end of the source code.  There are a couple of extra parts below that where the author adds extra functions, but with no indicator of where these new code blocks should slot into the script, I will leave it up to your experimentation to find out the correct places where those bits go in the script.

           

          ******************************

           

          #pragma once

           

          #include

          #include

          #include "information.h"

          #include "hpp/rs_context.hpp"

           

          using namespace std;

          using namespace rs2;

           

          using cameras_t = vector<shared_ptr>;

          using iterator = cameras_t::iterator;

          using const_iterator = cameras_t::const_iterator;

           

          class cameras

          {

          public:

            cameras() {}

            ~cameras() {}

          }

           

          class camera

          {

          public:

            explicit camera(const device dev) : information_(make_shared(dev)) {}

           

            ~camera()

            {

            }

           

            shared_ptr get_information() const

            {

              return information_;

            }

           

          private:

            shared_ptr information_;

          };

           

          class information

          {

          public:

          explicit information(const device device) : device_(device) {}

          ~information()

          {

          }

           

          const char* name() const

          {

            return get_info(RS2_CAMERA_INFO_NAME);

          }

           

          const char* serial_number() const

          {

            return get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

          }

           

          const char* port() const

          {

            return get_info(RS2_CAMERA_INFO_PHYSICAL_PORT);

          }

           

          const char* firmware_version() const

          {

            return get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);

          }

           

          const char* debug_opCode() const

          {

            return get_info(RS2_CAMERA_INFO_DEBUG_OP_CODE);

          }

           

          const char* advanced_mode() const

          {

            return get_info(RS2_CAMERA_INFO_ADVANCED_MODE);

          }

           

          const char* product_id() const

          {

            return get_info(RS2_CAMERA_INFO_PRODUCT_ID);

          }

           

          const char* camera_locked() const

          {

            return get_info(RS2_CAMERA_INFO_CAMERA_LOCKED);

          }

           

          string dump_diagnostic() const

          {

            string text = "\nDevice Name: ";

            text += name();

            text += "\n Serial number: ";

            text += serial_number();

            text += "\n Port: ";

            text += port();

            text += "\n Firmware version: ";

            text += firmware_version();

            text += "\n Debug op code: ";

            text += debug_opCode();

            text += "\n Advanced Mode: ";

            text += advanced_mode();

            text += "\n Product id: ";

            text += product_id();

            text += "\n Camera locked: ";

            text += camera_locked();

            return text;

          }

           

          private:

            const char* get_info(const rs2_camera_info info) const

            {

              if (!device_.supports(info))

              {

                return "Not supported";

              }

              return device_.get_info(info);

            }

            device device_;

          };