extern "C" JNIEXPORT jfloat JNICALL Java_com_intel_realsense_librealsense_Options_nGetValue(JNIEnv *env, jclass type, jlong handle, jint option) { rs2_error* e = NULL; float rv = rs2_get_option(reinterpret_cast<const rs2_options *>(handle), static_cast<rs2_option>(option), &e); handle_error(env, e); return rv; }
float URealSenseOption::QueryValue() { rs2::error_ref e; Value = rs2_get_option(RsOptions, (rs2_option)Type, &e); if (!e.success()) { REALSENSE_ERR(TEXT("rs2_get_option failed: %s"), *uestr(e.get_message())); } return Value; }
// The number of meters represented by a single depth unit float get_depth_unit_value(const rs2_device* const dev) { rs2_error* e = 0; rs2_sensor_list* sensor_list = rs2_query_sensors(dev, &e); check_error(e); int num_of_sensors = rs2_get_sensors_count(sensor_list, &e); check_error(e); float depth_scale = 0; int is_depth_sensor_found = 0; int i; for (i = 0; i < num_of_sensors; ++i) { rs2_sensor* sensor = rs2_create_sensor(sensor_list, i, &e); check_error(e); // Check if the given sensor can be extended to depth sensor interface is_depth_sensor_found = rs2_is_sensor_extendable_to(sensor, RS2_EXTENSION_DEPTH_SENSOR, &e); check_error(e); if (1 == is_depth_sensor_found) { depth_scale = rs2_get_option(sensor, RS2_OPTION_DEPTH_UNITS, &e); check_error(e); rs2_delete_sensor(sensor); break; } rs2_delete_sensor(sensor); } rs2_delete_sensor_list(sensor_list); if (0 == is_depth_sensor_found) { printf("Depth sensor not found!\n"); exit(EXIT_FAILURE); } return depth_scale; }