Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgbd::registerDepth segfault when depth resolution > rgb resolution #3761

Open
4 tasks done
NickLaurenson-Visionick opened this issue Jun 12, 2024 · 0 comments
Open
4 tasks done

Comments

@NickLaurenson-Visionick
Copy link

NickLaurenson-Visionick commented Jun 12, 2024

System information (version)
  • OpenCV => 4.10.0
  • Operating System / Platform => ubuntu 22.04
  • Compiler => g++-11
Detailed description

cv::rgbd::registerDepth segfault in case the depth resolution is greater than the rgb resolution.

This is caused by a wrong argument used in the contructor here, and could be fixed as follow:

--- a/modules/rgbd/src/depth_registration.cpp
+++ b/modules/rgbd/src/depth_registration.cpp
@@ -146,7 +146,7 @@ namespace rgbd
         // Apply the initial projection to the input depth
         Mat_<Point3f> transformedCloud;
         {
-            Mat_<Point3f> point_tmp(outputImagePlaneSize,Point3f(0.,0.,0.));
+            Mat_<Point3f> point_tmp(unregisteredDepth.size(),Point3f(0.,0.,0.));
 
             for(int j = 0; j < unregisteredDepth.rows; ++j)
             {
Steps to reproduce
#include <opencv2/opencv.hpp>
#include <opencv2/rgbd.hpp>

int main() {
  // Example of a 1000x1000 depth image we want to register into a 600x600 color image

  // Define the intrinsic matrices
  cv::Matx33d intrinsics_depth(100, 0, 500, 0, 100, 500, 0, 0, 1);
  cv::Matx33d intrinsics_color(100, 0, 300, 0, 100, 300, 0, 0, 1);
  cv::Mat dist_coef_color; // Empty distortion coefficients
  cv::Matx44d extrinsics = cv::Matx44d::eye();

  // Create a depth image with resolution 1000x1000
  cv::Mat depth(1000, 1000, CV_64F);

  // Define the output resolution
  int width = 300;
  int height = 300;

  // Register depth
  cv::Mat registered_depth(cv::Size(width, height), CV_64F);

  cv::rgbd::registerDepth(intrinsics_depth,
                          intrinsics_color,
                          dist_coef_color,
                          extrinsics,
                          depth,
                          cv::Size(width, height),
                          registered_depth,
                          false // Depth dilation
  );

  return 0;
}
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant