7 #include "../../../include/librealsense2/rs.hpp" 8 #include "../../../include/librealsense2/rsutil.h" 12 jclass intrinsic_class = env->GetObjectClass(intrinsic);
13 jfieldID width_field = env->GetFieldID(intrinsic_class,
"mWidth",
"I");
14 jfieldID height_field = env->GetFieldID(intrinsic_class,
"mHeight",
"I");
15 jfieldID ppx_field = env->GetFieldID(intrinsic_class,
"mPpx",
"F");
16 jfieldID ppy_field = env->GetFieldID(intrinsic_class,
"mPpy",
"F");
17 jfieldID fx_field = env->GetFieldID(intrinsic_class,
"mFx",
"F");
18 jfieldID fy_field = env->GetFieldID(intrinsic_class,
"mFy",
"F");
19 jfieldID model_field = env->GetFieldID(intrinsic_class,
"mModelValue",
"I");
20 jfieldID coeff_field = env->GetFieldID(intrinsic_class,
"mCoeffs",
"[F");
22 intrinsics.
width = env->GetIntField(intrinsic, width_field);
23 intrinsics.
height = env->GetIntField(intrinsic, height_field);
24 intrinsics.
ppx = env->GetFloatField(intrinsic, ppx_field);
25 intrinsics.
ppy = env->GetFloatField(intrinsic, ppy_field);
26 intrinsics.
fx = env->GetFloatField(intrinsic, fx_field);
27 intrinsics.
fy = env->GetFloatField(intrinsic, fy_field);
30 jobject coeffsObject = env->GetObjectField(intrinsic, coeff_field);
31 jfloatArray* coeffsArray =
reinterpret_cast<jfloatArray *
>(&coeffsObject);
32 jfloat *
coeffs = env->GetFloatArrayElements(*coeffsArray,
NULL);
33 memcpy(intrinsics.
coeffs, coeffs, 5 *
sizeof(
float));
34 env->ReleaseFloatArrayElements(*coeffsArray, coeffs, 0);
42 jclass extrinsic_class = env->GetObjectClass(extrinsic);
44 jfieldID rotation_field = env->GetFieldID(extrinsic_class,
"mRotation",
"[F");
45 jobject rotationObject = env->GetObjectField(extrinsic, rotation_field);
46 jfloatArray* rotationArray =
reinterpret_cast<jfloatArray *
>(&rotationObject);
47 jfloat *
rotation = env->GetFloatArrayElements(*rotationArray,
NULL);
48 memcpy(extrinsics.
rotation, rotation, 9 *
sizeof(
float));
49 env->ReleaseFloatArrayElements(*rotationArray, rotation, 0);
51 jfieldID translation_field = env->GetFieldID(extrinsic_class,
"mTranslation",
"[F");
52 jobject translationObject = env->GetObjectField(extrinsic, translation_field);
53 jfloatArray* translationArray =
reinterpret_cast<jfloatArray *
>(&translationObject);
54 jfloat * translation = env->GetFloatArrayElements(*translationArray,
NULL);
55 memcpy(extrinsics.
translation, translation, 3 *
sizeof(
float));
56 env->ReleaseFloatArrayElements(*translationArray, translation, 0);
61 extern "C" JNIEXPORT
void JNICALL
63 jobject pixel_2D, jobject intrinsic,
66 jclass point_3D_class = env->GetObjectClass(point_3D);
67 jfieldID point_x_field = env->GetFieldID(point_3D_class,
"mX",
"F");
68 jfieldID point_y_field = env->GetFieldID(point_3D_class,
"mY",
"F");
69 jfieldID point_z_field = env->GetFieldID(point_3D_class,
"mZ",
"F");
71 point[0] = env->GetFloatField(point_3D, point_x_field);
72 point[1] = env->GetFloatField(point_3D, point_y_field);
73 point[2] = env->GetFloatField(point_3D, point_z_field);
79 float pixel[2] = {0.
f, 0.f};
84 jclass pixel_2D_class = env->GetObjectClass(pixel_2D);
85 jfieldID pixel_x_field = env->GetFieldID(pixel_2D_class,
"mX",
"F");
86 jfieldID pixel_y_field = env->GetFieldID(pixel_2D_class,
"mY",
"F");
87 env->SetFloatField(pixel_2D, pixel_x_field, pixel[0]);
88 env->SetFloatField(pixel_2D, pixel_y_field, pixel[1]);
91 extern "C" JNIEXPORT
void JNICALL
93 jobject point_3D, jobject intrinsic,
94 jobject pixel_2D, jfloat
depth) {
97 jclass pixel_2D_class = env->GetObjectClass(pixel_2D);
98 jfieldID pixel_x_field = env->GetFieldID(pixel_2D_class,
"mX",
"F");
99 jfieldID pixel_y_field = env->GetFieldID(pixel_2D_class,
"mY",
"F");
101 pixel[0] = env->GetFloatField(pixel_2D, pixel_x_field);
102 pixel[1] = env->GetFloatField(pixel_2D, pixel_y_field);
108 float point[3] = {0.f, 0.f, 0.f};
113 jclass point_3D_class = env->GetObjectClass(point_3D);
114 jfieldID point_x_field = env->GetFieldID(point_3D_class,
"mX",
"F");
115 jfieldID point_y_field = env->GetFieldID(point_3D_class,
"mY",
"F");
116 jfieldID point_z_field = env->GetFieldID(point_3D_class,
"mZ",
"F");
117 env->SetFloatField(point_3D, point_x_field, point[0]);
118 env->SetFloatField(point_3D, point_y_field, point[1]);
119 env->SetFloatField(point_3D, point_z_field, point[2]);
122 extern "C" JNIEXPORT
void JNICALL
124 jobject to_point_3D, jobject extrinsic,
125 jobject from_point_3D) {
127 jclass point_3D_class = env->GetObjectClass(from_point_3D);
128 jfieldID point_x_field = env->GetFieldID(point_3D_class,
"mX",
"F");
129 jfieldID point_y_field = env->GetFieldID(point_3D_class,
"mY",
"F");
130 jfieldID point_z_field = env->GetFieldID(point_3D_class,
"mZ",
"F");
132 from_point[0] = env->GetFloatField(from_point_3D, point_x_field);
133 from_point[1] = env->GetFloatField(from_point_3D, point_y_field);
134 from_point[2] = env->GetFloatField(from_point_3D, point_z_field);
140 float to_point[3] = {0.f, 0.f, 0.f};
146 jclass to_point_3D_class = env->GetObjectClass(to_point_3D);
147 jfieldID to_point_x_field = env->GetFieldID(to_point_3D_class,
"mX",
"F");
148 jfieldID to_point_y_field = env->GetFieldID(to_point_3D_class,
"mY",
"F");
149 jfieldID to_point_z_field = env->GetFieldID(to_point_3D_class,
"mZ",
"F");
150 env->SetFloatField(to_point_3D, to_point_x_field, to_point[0]);
151 env->SetFloatField(to_point_3D, to_point_y_field, to_point[1]);
152 env->SetFloatField(to_point_3D, to_point_z_field, to_point[2]);
155 extern "C" JNIEXPORT
void JNICALL
157 jobject fov, jobject intrinsic) {
161 float fov_cpp[2] = {0.f, 0.f};
165 jclass fov_class = env->GetObjectClass(fov);
166 jfieldID fov_x_field = env->GetFieldID(fov_class,
"mFovX",
"F");
167 jfieldID fov_y_field = env->GetFieldID(fov_class,
"mFovY",
"F");
168 env->SetFloatField(fov, fov_x_field, fov_cpp[0]);
169 env->SetFloatField(fov, fov_y_field, fov_cpp[1]);
172 extern "C" JNIEXPORT
void JNICALL
174 jobject toPixel, jlong depthFrameHandle, jfloat depthScale,
175 jfloat depthMin, jfloat depthMax,
176 jobject depthIntrinsic, jobject otherIntrinsic,
177 jobject otherToDepth, jobject depthToOther,
182 float to_pixel[2] = {0.f, 0.f};
195 jclass from_pixel_class = env->GetObjectClass(fromPixel);
196 jfieldID from_pixel_x_field = env->GetFieldID(from_pixel_class,
"mX",
"F");
197 jfieldID from_pixel_y_field = env->GetFieldID(from_pixel_class,
"mY",
"F");
199 from_pixel[0] = env->GetFloatField(fromPixel, from_pixel_x_field);
200 from_pixel[1] = env->GetFloatField(fromPixel, from_pixel_y_field);
204 &depth_intrinsics, &other_intrinsics, &other_to_depth_extrinsics, &depth_to_other_extrinsics, from_pixel);
207 jclass to_pixel_class = env->GetObjectClass(toPixel);
208 jfieldID to_pixel_x_field = env->GetFieldID(to_pixel_class,
"mX",
"F");
209 jfieldID to_pixel_y_field = env->GetFieldID(to_pixel_class,
"mY",
"F");
210 env->SetFloatField(toPixel, to_pixel_x_field, to_pixel[0]);
211 env->SetFloatField(toPixel, to_pixel_y_field, to_pixel[1]);
static void rs2_transform_point_to_point(float to_point[3], const struct rs2_extrinsics *extrin, const float from_point[3])
::realsense_legacy_msgs::extrinsics_< std::allocator< void > > extrinsics
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Utils_nDeprojectPixelToPoint(JNIEnv *env, jclass type, jobject point_3D, jobject intrinsic, jobject pixel_2D, jfloat depth)
rs2_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
static void rs2_fov(const struct rs2_intrinsics *intrin, float to_fov[2])
GLint GLint GLsizei GLsizei GLsizei depth
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Utils_nProject2dPixelToDepthPixel(JNIEnv *env, jclass type, jobject toPixel, jlong depthFrameHandle, jfloat depthScale, jfloat depthMin, jfloat depthMax, jobject depthIntrinsic, jobject otherIntrinsic, jobject otherToDepth, jobject depthToOther, jobject fromPixel)
GLint GLenum GLint const GLfloat * coeffs
static void rs2_deproject_pixel_to_point(float point[3], const struct rs2_intrinsics *intrin, const float pixel[2], float depth)
rs2_intrinsics intrinsic_jobject2rs(JNIEnv *env, jobject intrinsic)
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Utils_nProjectPointToPixel(JNIEnv *env, jclass type, jobject pixel_2D, jobject intrinsic, jobject point_3D)
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Utils_nGetFov(JNIEnv *env, jclass type, jobject fov, jobject intrinsic)
JNIEXPORT void JNICALL Java_com_intel_realsense_librealsense_Utils_nTransformPointToPoint(JNIEnv *env, jclass type, jobject to_point_3D, jobject extrinsic, jobject from_point_3D)
static void rs2_project_point_to_pixel(float pixel[2], const struct rs2_intrinsics *intrin, const float point[3])
static void rs2_project_color_pixel_to_depth_pixel(float to_pixel[2], const uint16_t *data, float depth_scale, float depth_min, float depth_max, const struct rs2_intrinsics *depth_intrin, const struct rs2_intrinsics *color_intrin, const struct rs2_extrinsics *color_to_depth, const struct rs2_extrinsics *depth_to_color, const float from_pixel[2])
rs2_extrinsics extrinsic_jobject2rs(JNIEnv *env, jobject extrinsic)
struct rs2_frame rs2_frame
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)