Librealsense crashes when measuring distance on some camera
I'm using SDK library version 2.55.1 but the same happens on 2.54.
When acquiring frames from depth camera and invoking method com.intel.realsense.librealsense.Utils.project2dPixelToDepthPixel, using some camera pieces the application crashes because of an error on this adjustment function on file src/rs.cpp:
/* Helper inner function (not part of the API) */
void adjust_2D_point_to_boundary(float p[2], int width, int height)
{
if (p[0] < 0) p[0] = 0;
if (p[0] > width) p[0] = (float)width;
if (p[1] < 0) p[1] = 0;
if (p[1] > height) p[1] = (float)height;
}
We're using camera in vertical position so sometimes the rotation and transformation values produces negative (adjusted to zero) or overloaded coordinates; in this case the point is adjusted to width and height causing a segmentation fault: point should be adjusted to width-1 and height-1 in order to stay on frame buffer limit.
can this be fixed on next sdk version? actually I've rebuilt the library with the patch:
/* Helper inner function (not part of the API) */
void adjust_2D_point_to_boundary(float p[2], int width, int height)
{
if (p[0] < 0) p[0] = 0;
if (p[0] >= width) p[0] = (float)width - 1;
if (p[1] < 0) p[1] = 0;
if (p[1] >= height) p[1] = (float)height - 1;
}
and apps do not crashes anymore.
Here is the stack trace of the error:
#00 pc 00000000007eb34c /system/app/ARFlexibilityTest/ARFlexibilityTest.apk!librealsense2.so (rs2_project_color_pixel_to_depth_pixel+776) (BuildId: 07aa2742a238c6a7d2d769e5046ed2ff5e5a6bd0)
#01 pc 00000000007392e0 /system/app/ARFlexibilityTest/ARFlexibilityTest.apk!librealsense2.so (Java_com_intel_realsense_librealsense_Utils_nProject2dPixelToDepthPixel+924) (BuildId: 07aa2742a238c6a7d2d769e5046ed2ff5e5a6bd0)
#02 pc 0000000000222244 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#03 pc 0000000000218be8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#04 pc 0000000000284224 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+216) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#05 pc 00000000003e351c /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+400) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#06 pc 00000000003df570 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+700) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#07 pc 0000000000758b9c /apex/com.android.art/lib64/libart.so (MterpInvokeStaticRange+800) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#08 pc 0000000000203c94 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static_range+20) (BuildId: 4925dbfec35f1037f8ee5dab9b73e87d)
#09 pc 000000000074fd58 /system/app/ARFlexibilityTest/oat/arm64/ARFlexibilityTest.vdex (com.intel.realsense.librealsense.Utils.project2dPixelToDepthPixel+46)
-
Hi Acasalboni84 Thanks very much for the question. If you have developed a fix and would like it to be considered for inclusion in the official SDK then you can submit your solution at the link below as a Pull Request.
-
Please sign in to leave a comment.
Comments
3 comments