How to run a depth estimation with a custom stereo camera and intrinsincs, extrinsincs parameters

Hello,
I did a code to copy custom intrinsincs to a color camera proto but I have issues doing the image copying part.
I need to copy my input image into my output proto but I don’t know how to do that so I tried with opencv but maybe their is an easier way, please help me. (This code compile but no image is sent. Yes there is L and R because I use a stereo camera)

This is my code to get the color camera proto and send a modified color camera proto, my issue is in the Copy image section of the code :

#include "TX.hpp"
#include <memory>
#include <utility>
#include "engine/core/assert.hpp"
#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/camera.hpp"
#include "messages/math.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"

namespace isaac {
void TX::start() {
  tickOnMessage(rx_inLcam());
}

void TX::tick() {
//Extrinsincs
  Pose3d extrinsics;
  double qq[4] = {0,0,0,0};
  extrinsics.rotation = SO3<double>::FromQuaternion(Quaterniond(qq));
  extrinsics.translation = Vector3d(0.06,0,0);
  const auto ext = tx_extrinsics().initProto();
  ToProto(extrinsics, ext);
  tx_extrinsics().publish();

//Intrinsincs
  auto outL = tx_outLcam().initProto();
  auto outR = tx_outRcam().initProto();
  // Pinhole
  auto pinholeL = outL.initPinhole();
  ToProto(Vector2d(3147.54098361, 3160.49382716), pinholeL.getFocal());//1280*12/4.86 & 960*12/3.66  Foc len [8.525929042561033e+02,8.549701455135702e+02]
  ToProto(Vector2d(519.4719202793973, 693.0736876181506), pinholeL.getCenter());//principal point [6.930736876181506e+02,5.194719202793973e+02]
  pinholeL.setCols(1280);
  pinholeL.setRows(960);
  auto pinholeR = outR.initPinhole();
  ToProto(Vector2d(3147.54098361, 3160.49382716), pinholeR.getFocal());//theoric :1280*12/4.86 & 960*12/3.66  Pratic : [8.525929042561033e+02,8.549701455135702e+02]
  ToProto(Vector2d(519.4719202793973, 693.0736876181506), pinholeR.getCenter());//principal point [6.930736876181506e+02,5.194719202793973e+02]
  pinholeR.setCols(1280);
  pinholeR.setRows(960);
  // Distortion
  auto distortionL = outL.initDistortion();
  auto distortionR = outR.initDistortion();
  distortionL.setModel(DistortionProto::DistortionModel::BROWN);
  distortionR.setModel(DistortionProto::DistortionModel::BROWN);
  Vector5d disto;
  disto << 0.035, 0.035, 0, 0, 0;
  ToProto(disto, distortionL.getCoefficients());
  ToProto(disto, distortionR.getCoefficients());
  //Color
  outL.setColorSpace(ColorCameraProto::ColorSpace::RGB);
  outR.setColorSpace(ColorCameraProto::ColorSpace::RGB);
  //Get Image
  auto inL= rx_inLcam().getProto();
  auto inR = rx_inRcam().getProto();
  ImageConstView3ub inLcam;
  ImageConstView3ub inRcam;
  bool okL = FromProto(inL.getImage(), rx_inLcam().buffers(), inLcam);  ASSERT(okL, "Failed to deserialize the input image L");
  bool okR = FromProto(inR.getImage(), rx_inRcam().buffers(), inRcam);  ASSERT(okR, "Failed to deserialize the input image R");
  //Copy Image
  const size_t rows = inLcam.rows();
  const size_t cols = inLcam.cols();
  Image3ub outLcam(rows, cols);
  Image3ub outRcam(rows, cols);
  cv::Mat imageL =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inLcam.data().pointer())));
  cv::Mat imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inRcam.data().pointer())));
  cv::Mat outLcam_image =  imageL.clone();
  cv::Mat outRcam_image =  imageR.clone();
  
  //  NEED A outLcam = outLcam_image; FUNCTION HERE, PLEASE HELP ME WITH THIS LINE 

  //Publish CamProto
  ToProto(std::move(outLcam), outL.getImage(), tx_outLcam().buffers());
  ToProto(std::move(outRcam), outR.getImage(), tx_outRcam().buffers());
  tx_outLcam().publish(rx_inLcam().acqtime());
  tx_outRcam().publish(rx_inRcam().acqtime());
  

  
  LOG_INFO("OK \n");
}

}  // namespace isaac

For example the following code convert a RGB image into Grey and work perfectly :

#include "RGB2GREY.hpp"
#include <memory>
#include <utility>
#include "engine/core/assert.hpp"
#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/camera.hpp"
#include "messages/math.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"

namespace isaac {
namespace opencv {

void RGB2GREY::start() {
  tickOnMessage(rx_input_image());
}

void RGB2GREY::tick() {

  auto input = rx_input_image().getProto();
  ImageConstView3ub input_image;
  bool ok = FromProto(input.getImage(), rx_input_image().buffers(), input_image);
  ASSERT(ok, "Failed to deserialize the input image");

  const size_t rows = input_image.rows();
  const size_t cols = input_image.cols();
  Image1ub output_image(rows, cols);
  cv::Mat image =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(input_image.data().pointer())));
	
  cv::Mat gradient = cv::Mat(rows, cols, CV_8U, static_cast<void*>(output_image.data().pointer()));
  cv::cvtColor(image, gradient, cv::COLOR_RGB2GRAY);


  auto output = tx_output_image().initProto();

  auto in_pinhole = input.getPinhole();
  const Vector2d focal = FromProto(in_pinhole.getFocal());
  const Vector2d center = FromProto(in_pinhole.getCenter());

  auto out_pinhole = output.initPinhole();
  ToProto(focal, out_pinhole.getFocal());
  ToProto(center, out_pinhole.getCenter());
  out_pinhole.setCols(in_pinhole.getCols());
  out_pinhole.setRows(in_pinhole.getRows());

  if (input.hasDistortion()) {
    auto in_distortion = input.getDistortion();
    auto out_distortion = output.initDistortion();
    auto distortion_coeff = FromProto(in_distortion.getCoefficients());
    out_distortion.setModel(in_distortion.getModel());
    ToProto(distortion_coeff, out_distortion.getCoefficients());
  }

  output.setColorSpace(ColorCameraProto::ColorSpace::GRAYSCALE);
  ToProto(std::move(output_image), output.getImage(), tx_output_image().buffers());
  tx_output_image().publish(rx_input_image().acqtime());
}

}  // namespace opencv
}  // namespace isaac

I tried adding this lines :

  //Copy Image
  const size_t rows = inLcam.rows();
  const size_t cols = inLcam.cols();
  Image3ub outLcam(rows, cols);
  Image3ub outRcam(rows, cols);
  cv::Mat in_imageL =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inLcam.data().pointer())));
  cv::Mat in_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inRcam.data().pointer())));
  cv::Mat out_imageL =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(outLcam.data().pointer())));
  cv::Mat out_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(outRcam.data().pointer())));
  in_imageL.copyTo(out_imageL);
  in_imageR.copyTo(out_imageR);

I also modified my .hpp so it can receive the color camera proto but now I get the following error :
2020-08-05 17:54:51.694 PANIC ./engine/alice/hooks/message_hook.hpp@199: No message available

this is my .cpp :

#include "TX.hpp"

#include <memory>
#include <utility>

#include "engine/core/assert.hpp"

#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/camera.hpp"
#include "messages/math.hpp"

#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
namespace isaac {
void TX::start() {
  tickOnMessage(rx_inLcam());
}

void TX::tick() {
//Extrinsincs
  Pose3d extrinsics;
  double qq[4] = {0,0,0,0};
  extrinsics.rotation = SO3<double>::FromQuaternion(Quaterniond(qq));
  extrinsics.translation = Vector3d(0.06,0,0);
  const auto ext = tx_extrinsics().initProto();
  ToProto(extrinsics, ext);
  tx_extrinsics().publish();

//Intrinsincs
  auto outL = tx_outLcam().initProto();
  auto outR = tx_outRcam().initProto();
  // Pinhole
  auto pinholeL = outL.initPinhole();
  ToProto(Vector2d(3147.54098361, 3160.49382716), pinholeL.getFocal());//1280*12/4.86 & 960*12/3.66  Foc len [8.525929042561033e+02,8.549701455135702e+02]
  ToProto(Vector2d(519.4719202793973, 693.0736876181506), pinholeL.getCenter());//principal point [6.930736876181506e+02,5.194719202793973e+02]
  pinholeL.setCols(1280);
  pinholeL.setRows(960);
  auto pinholeR = outR.initPinhole();
  ToProto(Vector2d(3147.54098361, 3160.49382716), pinholeR.getFocal());//theoric :1280*12/4.86 & 960*12/3.66  Pratic : [8.525929042561033e+02,8.549701455135702e+02]
  ToProto(Vector2d(519.4719202793973, 693.0736876181506), pinholeR.getCenter());//principal point [6.930736876181506e+02,5.194719202793973e+02]
  pinholeR.setCols(1280);
  pinholeR.setRows(960);
  // Distortion
  auto distortionL = outL.initDistortion();
  auto distortionR = outR.initDistortion();
  distortionL.setModel(DistortionProto::DistortionModel::BROWN);
  distortionR.setModel(DistortionProto::DistortionModel::BROWN);
  Vector5d disto;
  disto << 0.035, 0.035, 0, 0, 0;
  ToProto(disto, distortionL.getCoefficients());
  ToProto(disto, distortionR.getCoefficients());
  //Color
  outL.setColorSpace(ColorCameraProto::ColorSpace::RGB);
  outR.setColorSpace(ColorCameraProto::ColorSpace::RGB);
  //Get Image
  auto inL= rx_inLcam().getProto();
  auto inR = rx_inRcam().getProto();
  ImageConstView3ub inLcam;
  ImageConstView3ub inRcam;
  bool okL = FromProto(inL.getImage(), rx_inLcam().buffers(), inLcam);  ASSERT(okL, "Failed to deserialize the input image L");
  bool okR = FromProto(inR.getImage(), rx_inRcam().buffers(), inRcam);  ASSERT(okR, "Failed to deserialize the input image R");
  //Copy Image
  const size_t rows = inLcam.rows();
  const size_t cols = inLcam.cols();
  Image3ub outLcam(rows, cols);
  Image3ub outRcam(rows, cols);
  cv::Mat in_imageL =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inLcam.data().pointer())));
  cv::Mat in_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inRcam.data().pointer())));
  
  cv::Mat out_imageL =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(outLcam.data().pointer())));
  cv::Mat out_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(outRcam.data().pointer())));
  
  in_imageL.copyTo(out_imageL);
  in_imageR.copyTo(out_imageR);
  
  //Publish CamProto
  ToProto(std::move(outLcam), outL.getImage(), tx_outLcam().buffers());
  ToProto(std::move(outRcam), outR.getImage(), tx_outRcam().buffers());
  tx_outLcam().publish(rx_inLcam().acqtime());
  tx_outRcam().publish(rx_inRcam().acqtime());
  
  LOG_INFO("OK \n");
}

}  // namespace isaac

This is my .hpp :

#pragma once

#include <string>

#include "engine/alice/alice_codelet.hpp"
#include "engine/core/image/image.hpp"
#include "messages/camera.capnp.h"


namespace isaac {

// A simple C++ codelet that sends pings periodically
class TX : public alice::Codelet {
 public:
  // Has whatever needs to be run in the beginning of the program
  void start() override;
  // Has whatever needs to be run repeatedly
  void tick() override;
 

 ISAAC_PROTO_RX(ColorCameraProto, inLcam);
 ISAAC_PROTO_RX(ColorCameraProto, inRcam);

  ISAAC_PROTO_TX(Pose3dProto, extrinsics);
  ISAAC_PROTO_TX(ColorCameraProto, outRcam);
  ISAAC_PROTO_TX(ColorCameraProto, outLcam);
};

}  // namespace isaac

ISAAC_ALICE_REGISTER_CODELET(isaac::TX);

This is my JSON :

{
  "name": "stereo_matching_depth",
  "modules": [
    "//apps/samples/stereo_matching_depth:tx",
    "//packages/stereo_depth:coarse_to_fine",
    "//packages/perception",
    "sensors:v4l2_camera",
    "deepstream",
    "message_generators",
    "viewers",
    "deepstream",
    "sight"
  ],
  "graph": {
    "nodes": [
          {
          "name": "TXn",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "TX",
            "type": "isaac::TX"
          }
          ]
      },
      {
          "name": "input_images",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "pipeline",
            "type": "isaac::deepstream::Pipeline"
          }
          ]
      },
      {
        "name": "compute",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "crop1",
            "type": "isaac::perception::CropAndDownsampleCuda"
          },
	  {
            "name": "crop2",
            "type": "isaac::perception::CropAndDownsampleCuda"
          }
        ]
      },
      {
          "name": "depth_visualization",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
              {
                  "name": "isaac.viewers.DepthCameraViewer",
                  "type": "isaac::viewers::DepthCameraViewer"
              }
          ]
      },
      {
          "name": "depth_estimation",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
              {
                  "name": "isaac.stereo_depth.CoarseToFineStereoDepth",
                  "type": "isaac::stereo_depth::CoarseToFineStereoDepth"
              }
          ]
      },
             {
        "name": "publishing",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "viewer1",
            "type": "isaac::viewers::ColorCameraViewer"
          },
          {
            "name": "viewer2",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	 {
            "name": "viewer3",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	  {
            "name": "viewer4",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	  	  {
            "name": "viewer5",
            "type": "isaac::viewers::ColorCameraViewer"
          },
          {
            "name": "viewer1_widget",
            "type": "isaac::sight::SightWidget"
          },
          {
            "name": "viewer2_widget",
            "type": "isaac::sight::SightWidget"
          },
          {
            "name": "viewer3_widget",
            "type": "isaac::sight::SightWidget"
          },
	  {
            "name": "viewer4_widget",
            "type": "isaac::sight::SightWidget"
          },
	  {
            "name": "viewer5_widget",
            "type": "isaac::sight::SightWidget"
          }		  
        ]
      }
      
  ],
  "edges": [
         {
        "source": "input_images/pipeline/acquired_image",
        "target": "compute/crop1/input_image"
      },
      {
        "source": "input_images/pipeline/acquired_image",
        "target": "compute/crop2/input_image"
      },
       {
          "source": "compute/crop1/output_image",
          "target": "TXn/TX/inLcam"
      },
       {
          "source": "compute/crop2/output_image",
          "target": "TXn/TX/inRcam"
      },
      {
          "source": "TXn/TX/outLcam",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/left_image"
      },
      {
          "source": "TXn/TX/outRcam",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/right_image"
      },
      {
          "source": "TXn/TX/extrinsics",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/extrinsics"
      },
      {
          "source": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/left_depth_image",
          "target": "depth_visualization/isaac.viewers.DepthCameraViewer/depth_listener"
      },
      {
        "source": "compute/crop1/output_image",
        "target": "publishing/viewer1/color_listener"
      },
      {
       "source": "compute/crop2/output_image",
        "target": "publishing/viewer2/color_listener"
      },
      {
        "source": "input_images/pipeline/acquired_image",
        "target": "publishing/viewer3/color_listener"
      },
      {
        "source": "TXn/TX/outLcam",
        "target": "publishing/viewer4/color_listener"
      },
      {
        "source": "TXn/TX/outRcam",
        "target": "publishing/viewer5/color_listener"
      }
    ]
  },
  "config": {
    "depth_estimation": {
      "isaac.stereo_depth.CoarseToFineStereoDepth": {
        "min_depth": 0.0,
        "max_depth": 20.0,
        "baseline" : 0.06
      }
    },
    "depth_visualization": {
      "isaac.viewers.DepthCameraViewer": {
        "max_visualization_depth": 20.0,
        "camera_name" : "left_camera"
      }
    },
    "input_images": {
       "pipeline": {
        "pipeline": "gst-launch-1.0 -v v4l2src device=/dev/video0  ! avdec_mjpeg ! videoconvert ! video/x-raw,format=RGB,height=960,wight=2560,framerate=30/1 ! appsink name = acquired_image "
       }
    },
    "compute": {
      "crop1": {
        "crop_start": [0, 0],
        "crop_size": [960, 1280]
       },
      "crop2": {
        "crop_start": [0, 1280],
        "crop_size": [960, 1280]
       }
      },
      "publishing": {
      "viewer1_widget": {
        "title": "Viewer: Video Left",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer1/Color"
          }
        ]
      },
      "viewer2_widget": {
        "title": "Viewer: Video Right",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer2/Color"
          }
        ]
      },
       "viewer3_widget": {
        "title": "Viewer: Acquis ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer3/Color"
          }
        ]
      },
            "viewer4_widget": {
        "title": "Viewer: Post L ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer4/Color"
          }
        ]
      },
             "viewer5_widget": {
        "title": "Viewer: Post R ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer5/Color"
          }
        ]
      }
    },
    "websight": {
      "WebsightServer": {
        "port": 3000,
        "ui_config": {
          "windows": {
            "Depth": {
              "renderer": "2d",
              "channels": [
                {
                  "name": "stereo_matching_depth/depth_visualization/isaac.viewers.DepthCameraViewer/Depth"
                }
              ]
            }
          }
        }
      }
    }
  }
}

This is my BUILD :

load("//engine/build:isaac.bzl", "isaac_app", "isaac_cc_module")

isaac_cc_module(
    name = "tx",
    srcs = [
        "TX.cpp",
    ],
    hdrs = [
        "TX.hpp",
    ],
    visibility = ["//visibility:public"],
    deps = [
      "//engine/core/math",
      "//engine/core/image",
	"//third_party:opencv",
      ],
)

isaac_app(
    name = "stereo_matching_depth",
    modules = [
	"//apps/samples/stereo_matching_depth:tx",
        "//packages/stereo_depth:coarse_to_fine",
	"//packages/message_generators",
	"//packages/perception",
        "viewers",
        "sensors:v4l2_camera",
	"sight",
	"deepstream",
    ],
)

Thank you !

The error come from the fact that I was trying to get the 2 protos in the same code so I sliced my code into 3 parts : extinsincs, Right intrinsincs and left intrinsincs and now it work perfectly !

With this code I was able to run a depth estimation with a custom stereo camera, custom Intrinsincs and custom Extrinsincs parameters.

Thanks for looking at this post !
PS: I can send the full project if someone need it :D

This is the the code to modify the Right Intrinsincs :

#include "INTR.hpp"
#include <memory>
#include <utility>
#include "engine/core/assert.hpp"
#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/camera.hpp"
#include "messages/math.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
namespace isaac {
void INTR::start() {tickOnMessage(rx_inRcam());}
void INTR::tick() {
//Intrinsincs
  auto outR = tx_outRcam().initProto();
  // Pinhole
  auto pinholeR = outR.initPinhole();
  ToProto(Vector2d(3147.54098361, 3160.49382716), pinholeR.getFocal());//theoric :1280*12/4.86 & 960*12/3.66  Pratic : [8.525929042561033e+02,8.549701455135702e+02]
  ToProto(Vector2d(519.4719202793973, 693.0736876181506), pinholeR.getCenter());//principal point [6.930736876181506e+02,5.194719202793973e+02]
  pinholeR.setCols(1280);
  pinholeR.setRows(960);
  // Distortion
  auto distortionR = outR.initDistortion();
  distortionR.setModel(DistortionProto::DistortionModel::BROWN);
  Vector5d disto;
  disto << 0.035, 0.035, 0, 0, 0;
  ToProto(disto, distortionR.getCoefficients());
  //Color
  outR.setColorSpace(ColorCameraProto::ColorSpace::RGB);
  //Get Image
  auto inR = rx_inRcam().getProto();
  ImageConstView3ub inRcam;
  bool okR = FromProto(inR.getImage(), rx_inRcam().buffers(), inRcam);  ASSERT(okR, "Failed to deserialize the input image R");
  //Copy Image
  const size_t rows = inRcam.rows();
  const size_t cols = inRcam.cols();
  Image3ub outRcam(rows, cols);
  cv::Mat in_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(inRcam.data().pointer())));
  cv::Mat out_imageR =  cv::Mat(rows, cols, CV_8UC3, const_cast<void*>(static_cast<const void*>(outRcam.data().pointer())));
  in_imageR.copyTo(out_imageR);
  //Publish CamProto
  ToProto(std::move(outRcam), outR.getImage(), tx_outRcam().buffers());
  tx_outRcam().publish(rx_inRcam().acqtime());
  //End
  //LOG_INFO("INTR OK \n");
}

}  // namespace isaac

This is for the Extrinsincs :

#include "EXT.hpp"
#include <memory>
#include <utility>
#include "engine/core/assert.hpp"
#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/camera.hpp"
#include "messages/math.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
namespace isaac {
void EXT::start() {tickOnMessage(rx_inLcam());}
void EXT::tick() {
//Extrinsincs
  Pose3d extrinsics;
  double qq[4] = {0,0,0,0};
  extrinsics.rotation = SO3<double>::FromQuaternion(Quaterniond(qq));
  extrinsics.translation = Vector3d(0.06,0,0);
  const auto ext = tx_extrinsics().initProto();
  ToProto(extrinsics, ext);
  tx_extrinsics().publish();
 // LOG_INFO("EXT OK \n");
}
}  // namespace isaac

And this is the JSON :

{
  "name": "stereo_matching_depth",
  "modules": [
    "//apps/samples/stereo_matching_depth:intext",
    "//packages/stereo_depth:coarse_to_fine",
    "//packages/perception",
    "sensors:v4l2_camera",
    "deepstream",
    "message_generators",
    "viewers",
    "deepstream",
    "sight"
  ],
  "graph": {
    "nodes": [
          {
          "name": "INTLn",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "INTL",
            "type": "isaac::INTL"
          }
          ]
      },
       {
          "name": "INTRn",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "INTR",
            "type": "isaac::INTR"
          }
          ]
      },
      {
          "name": "EXTn",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "EXT",
            "type": "isaac::EXT"
          }
          ]
      },
      {
          "name": "input_images",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
	  {
            "name": "pipeline",
            "type": "isaac::deepstream::Pipeline"
          }
          ]
      },
      {
        "name": "compute",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "crop1",
            "type": "isaac::perception::CropAndDownsampleCuda"
          },
	  {
            "name": "crop2",
            "type": "isaac::perception::CropAndDownsampleCuda"
          }
        ]
      },
      {
          "name": "depth_visualization",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
              {
                  "name": "isaac.viewers.DepthCameraViewer",
                  "type": "isaac::viewers::DepthCameraViewer"
              }
          ]
      },
      {
          "name": "depth_estimation",
          "components": [
              {
                  "name": "isaac.alice.MessageLedger",
                  "type": "isaac::alice::MessageLedger"
              },
              {
                  "name": "isaac.stereo_depth.CoarseToFineStereoDepth",
                  "type": "isaac::stereo_depth::CoarseToFineStereoDepth"
              }
          ]
      },
             {
        "name": "publishing",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "viewer1",
            "type": "isaac::viewers::ColorCameraViewer"
          },
          {
            "name": "viewer2",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	 {
            "name": "viewer3",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	  {
            "name": "viewer4",
            "type": "isaac::viewers::ColorCameraViewer"
          },
	  	  {
            "name": "viewer5",
            "type": "isaac::viewers::ColorCameraViewer"
          },
          {
            "name": "viewer1_widget",
            "type": "isaac::sight::SightWidget"
          },
          {
            "name": "viewer2_widget",
            "type": "isaac::sight::SightWidget"
          },
          {
            "name": "viewer3_widget",
            "type": "isaac::sight::SightWidget"
          },
	  {
            "name": "viewer4_widget",
            "type": "isaac::sight::SightWidget"
          },
	  {
            "name": "viewer5_widget",
            "type": "isaac::sight::SightWidget"
          }		  
        ]
      }
      
  ],
  "edges": [
         {
        "source": "input_images/pipeline/acquired_image",
        "target": "compute/crop1/input_image"
      },
      {
        "source": "input_images/pipeline/acquired_image",
        "target": "compute/crop2/input_image"
      },
       {
          "source": "compute/crop1/output_image",
          "target": "INTLn/INTL/inLcam"
      },
       {
          "source": "compute/crop2/output_image",
          "target": "INTRn/INTR/inRcam"
      },
      {
          "source": "compute/crop2/output_image",
          "target": "EXTn/EXT/inLcam"
      },
      {
          "source": "INTLn/INTL/outLcam",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/left_image"
      },
      {
          "source": "INTRn/INTR/outRcam",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/right_image"
      },
      {
          "source": "EXTn/EXT/extrinsics",
          "target": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/extrinsics"
      },
      {
          "source": "depth_estimation/isaac.stereo_depth.CoarseToFineStereoDepth/left_depth_image",
          "target": "depth_visualization/isaac.viewers.DepthCameraViewer/depth_listener"
      },
     
      {
        "source": "compute/crop1/output_image",
        "target": "publishing/viewer1/color_listener"
      },
      {
       "source": "compute/crop2/output_image",
        "target": "publishing/viewer2/color_listener"
      },
      {
        "source": "input_images/pipeline/acquired_image",
        "target": "publishing/viewer3/color_listener"
      },
      {
        "source": "INTLn/INTL/outLcam",
        "target": "publishing/viewer4/color_listener"
      },
       {
        "source": "INTRn/INTR/outRcam",
        "target": "publishing/viewer5/color_listener"
      }
    ]
  },
  "config": {
    "depth_estimation": {
      "isaac.stereo_depth.CoarseToFineStereoDepth": {
        "min_depth": 0.0,
        "max_depth": 20.0,
        "baseline" : 0.06
      }
    },
    "depth_visualization": {
      "isaac.viewers.DepthCameraViewer": {
        "max_visualization_depth": 20.0,
        "camera_name" : "left_camera"
      }
    },
    "input_images": {
       "pipeline": {
        "pipeline": "gst-launch-1.0 -v v4l2src device=/dev/video0  ! avdec_mjpeg ! videoconvert ! video/x-raw,format=RGB,height=960,wight=2560,framerate=30/1 ! appsink name = acquired_image "
       }
    },
    "compute": {
      "crop1": {
        "crop_start": [0, 0],
        "crop_size": [960, 1280]
       },
      "crop2": {
        "crop_start": [0, 1280],
        "crop_size": [960, 1280]
       }
      },
      "publishing": {
      "viewer1_widget": {
        "title": "Viewer: Video Left",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer1/Color"
          }
        ]
      },
      "viewer2_widget": {
        "title": "Viewer: Video Right",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer2/Color"
          }
        ]
      },
       "viewer3_widget": {
        "title": "Viewer: Acquis ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer3/Color"
          }
        ]
      },
            "viewer4_widget": {
        "title": "Viewer: Post L ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer4/Color"
          }
        ]
      },
             "viewer5_widget": {
        "title": "Viewer: Post R ",
        "type": "2d",
        "channels": [
          {
            "name": "publishing/viewer5/Color"
          }
        ]
      }
    },
    "websight": {
      "WebsightServer": {
        "port": 3000,
        "ui_config": {
          "windows": {
            "Depth": {
              "renderer": "2d",
              "channels": [
                {
                  "name": "stereo_matching_depth/depth_visualization/isaac.viewers.DepthCameraViewer/Depth"
                }
              ]
            }
          }
        }
      }
    }
  }
}

Hi @Planktos,

I think you can have both left and right messages in same script. I was facing a similar issue but seemed to work after synchronizing the messages during intialization. So in your case it might be:

void TX::start() {
  tickOnMessage(rx_inLcam());
  synchronize(rx_inLcam(), rx_inRcam());
}
2 Likes

Thank you @david.yu,
this is a great idea ! This will make my code so much shorter and easier to modify !

1 Like