int main(int argc, char* argv[]) { set_key_handler(); astra_initialize(); astra_streamsetconnection_t sensor; astra_streamset_open("device/default", &sensor); astra_reader_t reader; astra_reader_create(sensor, &reader); astra_depthstream_t depthStream; astra_reader_get_depthstream(reader, &depthStream); float hFov, vFov; astra_depthstream_get_hfov(depthStream, &hFov); astra_depthstream_get_vfov(depthStream, &vFov); printf("depth sensor -- hFov: %f radians vFov: %f radians\n", hFov, vFov); astra_stream_start(depthStream); astra_frame_index_t lastFrameIndex = -1; do { astra_temp_update(); astra_reader_frame_t frame; astra_status_t rc = astra_reader_open_frame(reader, 0, &frame); if (rc == ASTRA_STATUS_SUCCESS) { astra_depthframe_t depthFrame; astra_frame_get_depthframe(frame, &depthFrame); astra_frame_index_t newFrameIndex; astra_depthframe_get_frameindex(depthFrame, &newFrameIndex); if (lastFrameIndex == newFrameIndex) { printf("duplicate frame index: %d\n", lastFrameIndex); } lastFrameIndex = newFrameIndex; print_depth(depthFrame); astra_reader_close_frame(&frame); } } while (shouldContinue); astra_reader_destroy(&reader); astra_streamset_close(&sensor); astra_terminate(); }
virtual void on_frame_ready(astra::StreamReader& reader, astra::Frame& frame) override { const astra::DepthFrame depthFrame = frame.get<astra::DepthFrame>(); if (depthFrame.is_valid()) { print_depth(depthFrame, reader.stream<astra::DepthStream>().coordinateMapper()); check_fps(); } }
static void try_expand(struct torture_context *tctx, const struct ndr_interface_table *iface, int opnum, DATA_BLOB *base_in, int insert_ofs, int depth) { DATA_BLOB stub_in, stub_out; int n; NTSTATUS status; struct dcerpc_pipe *p = NULL; reopen(tctx, &p, iface); /* work out how much to expand to get a non fault */ for (n=0;n<2000;n++) { stub_in = data_blob(NULL, base_in->length + n); data_blob_clear(&stub_in); memcpy(stub_in.data, base_in->data, insert_ofs); memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs); status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out); if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); printf("expand by %d gives %s\n", n, nt_errstr(status)); if (n >= 4) { test_ptr_scan(tctx, iface, opnum, &stub_in, insert_ofs, insert_ofs+n, depth+1); } return; } else { #if 0 print_depth(depth); printf("expand by %d gives fault %s\n", n, dcerpc_errstr(tctx, p->last_fault_code)); #endif } if (p->last_fault_code == 5) { reopen(tctx, &p, iface); } } talloc_free(p); }
static void print_mime_struct (GMimeStream *stream, GMimeObject *part, int depth) { GMimeMultipart *multipart; GMimeMessagePart *mpart; GMimeContentType *type; GMimeObject *subpart; GMimeObject *body; GMimeMessage *msg; int i, n; print_depth (stream, depth); type = g_mime_object_get_content_type (part); g_mime_stream_printf (stream, "Content-Type: %s/%s\n", g_mime_content_type_get_media_type (type), g_mime_content_type_get_media_subtype (type)); if (GMIME_IS_MULTIPART (part)) { multipart = (GMimeMultipart *) part; n = g_mime_multipart_get_count (multipart); for (i = 0; i < n; i++) { subpart = g_mime_multipart_get_part (multipart, i); print_mime_struct (stream, subpart, depth + 1); } } else if (GMIME_IS_MESSAGE_PART (part)) { mpart = (GMimeMessagePart *) part; msg = g_mime_message_part_get_message (mpart); if (msg != NULL) { body = g_mime_message_get_mime_part (msg); print_mime_struct (stream, body, depth + 1); } } }
static void test_ptr_scan(struct torture_context *tctx, const struct ndr_interface_table *iface, int opnum, DATA_BLOB *base_in, int min_ofs, int max_ofs, int depth) { DATA_BLOB stub_in, stub_out; int ofs; NTSTATUS status; struct dcerpc_pipe *p = NULL; reopen(tctx, &p, iface); stub_in = data_blob(NULL, base_in->length); memcpy(stub_in.data, base_in->data, base_in->length); /* work out which elements are pointers */ for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) { SIVAL(stub_in.data, ofs, 1); status = dcerpc_request(p, NULL, opnum, tctx, &stub_in, &stub_out); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); printf("possible ptr at ofs %d - fault %s\n", ofs-min_ofs, dcerpc_errstr(tctx, p->last_fault_code)); if (p->last_fault_code == 5) { reopen(tctx, &p, iface); } if (depth == 0) { try_expand(tctx, iface, opnum, &stub_in, ofs+4, depth+1); } else { try_expand(tctx, iface, opnum, &stub_in, max_ofs, depth+1); } SIVAL(stub_in.data, ofs, 0); continue; } SIVAL(stub_in.data, ofs, 0); } talloc_free(p); }
static void print_current_result(struct engine_result res) { mtx_lock(&game_mutex); mtx_lock(&stdout_mutex); if (is_xboard) { printf("%u ", res.depth); if (res.sresult.value < - mate_value) printf("%d ", -100000 - (res.sresult.value + max_value) / 2); else if (res.sresult.value > mate_value) printf("%d ", 100000 + (max_value - res.sresult.value) / 2); else printf("%d ", res.sresult.value); printf("%ju ", res.time_spent); printf("%ju ", res.sresult.node_count); } else if (is_uci) { printf("info depth %u ", res.depth); printf("seldepth %u ", res.sresult.selective_depth); if (res.sresult.value < - mate_value) printf("score mate -%d ", (res.sresult.value + max_value) / 2); else if (res.sresult.value > mate_value) printf("score mate %d ", (max_value - res.sresult.value) / 2); else printf("score cp %d ", res.sresult.value); printf("nodes %ju ", res.sresult.node_count); } else { if (res.first) print_result_header(); putchar(' '); print_depth(res); putchar('\t'); printf("%ju.%.2ju", res.time_spent / 100, res.time_spent % 100); putchar('\t'); if (res.sresult.value < - mate_value) printf("-#%d", (res.sresult.value + max_value) / 2); else if (res.sresult.value > mate_value) printf("#%d", (max_value - res.sresult.value) / 2); else print_centipawns(res.sresult.value); putchar('\t'); if (verbose) print_verbose_search_info(res); (void) print_nice_count(res.sresult.node_count); printf("N\t"); (void) print_nice_count(res.sresult.qnode_count); printf("N\t"); } if (is_uci) printf("pv "); print_move_path(game, res.pv, conf->move_not); putchar('\n'); mtx_unlock(&stdout_mutex); mtx_unlock(&game_mutex); }