int main(int argc, char** argv) { if(!depth_open()) { printf("Unable to open libkipr_link_depth_sensor\n"); return 1; } printf("Press the 'A' button for three seconds to stop\n"); while(a_button() == 0) { if(depth_update()) { int x_center = depth_image_get_width() / 2; int y_center = depth_image_get_height() / 2; int depth_center = get_depth_value(x_center, y_center); printf("Depth at(%d, %d) is %d\n", x_center, y_center, depth_center); msleep(2000); } else { printf("No depth frame image yet\n"); msleep(2000); } } depth_close(); return 0; }
int main () { camera_open(); depth_open(); while(!(a_button_clicked())){ camera_update(); depth_update(); display_clear(); printf("prepare succeeds"); } return 0; }
int main(int argc, char** argv) { if(!depth_open()) { printf("Unable to open libkipr_link_depth_sensor\n"); return 1; } int depth_image_height = -1; int depth_image_width = -1; int mouse_x; int mouse_y; int last_max_depth = 6000 /* mm */; int max_depth; if(set_depth_camera_resolution(DEPTH_CAMERA_RESOLUTION_640_480) == 0) { printf("Failed to set the depth camera resolution to 640 x 480\n"); return 1; } #ifdef CAMERA_IS_UPSIDE_DOWN if(set_depth_camera_orientation(DEPTH_CAMERA_ORIENTATION_UPSIDE_DOWN) == 0) { printf("Failed to set the depth camera orientation\n"); return 1; } #endif printf("Press 'Q' to stop\n"); while(!get_key_state('Q')) { if(depth_update()) { if(depth_image_height == -1) { // initialize the graphics output depth_image_height = depth_image_get_height(); depth_image_width = depth_image_get_width(); graphics_open(depth_image_width, depth_image_height); } get_mouse_position(&mouse_x, &mouse_y); max_depth = 0; // display depth image for(int y = 0; y < depth_image_height; y++) { for(int x = 0; x < depth_image_width; x++) { int depth = get_depth_value(x, y); // save max depth if(depth > max_depth) { max_depth = depth; } // color invalid depth pixel red if((depth != INVALID_COORDINATE) && last_max_depth) { int r; int g; int b; HSVtoRGB(360*0xFF*depth/last_max_depth, &r, &g, &b); graphics_pixel(x, y, r, g, b); } else { graphics_pixel(x, y, 0xFF, 0xFF, 0xFF); } #ifdef SHOW_DEPTH_UNDER_MOUSE if(mouse_x == x && mouse_y == y) { console_clear(); if(depth != INVALID_COORDINATE) { printf("(%d, %d): Depth: %d mm; World coordinate: (%d, %d, %d)\n", x, y, depth, get_world_x(x, y), get_world_y(x, y), get_world_z(x, y)); } else { printf("(%d, %d): No information available\n", x, y); } } #endif } } last_max_depth = max_depth; graphics_update(); } else { printf("No depth image received yet\n"); msleep(2000); } } graphics_close(); depth_close(); return 0; }