EXPORT void *initWebCapture(const char *outPath) { struct inputCfg cfg = { IN_WEBCAM, 1}; char *fname = NULL; int i = 0; fname = malloc(MAX_LEN); void *ctx = NULL; for(i = 0;!ctx;i++) { *fname = '\0'; get_devicename(fname, i); if(*fname == 0) { fprintf(stderr, "Please Attach Webcam device\n"); break; } ctx = init_capture(fname, outPath, &cfg); if (!ctx) { fprintf(stderr, "Error while configuring Input %s\n",fname); } } free(fname); return ctx; }
int main(int argc, char *argv[]) { pcap_t *handle; if (argc != 2) { print_usage(argv[0]); return 2; } init_capture(argv[1], &handle); pcap_loop(handle, -1, got_packet, NULL); pcap_close(handle); return 0; }
EXPORT void *initRtmpCapture(const char *inPath, const char *outPath) { struct inputCfg cfg = { IN_STREAM, 1}; //dont know 1 or 0 return init_capture(inPath, outPath, &cfg); }
int main(void) { struct sigaction sigact; int r = 1; r = libusb_init(NULL); if (r < 0) { fprintf(stderr, "failed to initialise libusb\n"); exit(1); } r = find_dpfp_device(); if (r < 0) { fprintf(stderr, "Could not find/open device\n"); goto out; } r = libusb_claim_interface(devh, 0); if (r < 0) { fprintf(stderr, "usb_claim_interface error %d %s\n", r, strerror(-r)); goto out; } printf("claimed interface\n"); r = print_f0_data(); if (r < 0) goto out_release; r = do_init(); if (r < 0) goto out_deinit; /* async from here onwards */ sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); r = pthread_create(&poll_thread, NULL, poll_thread_main, NULL); if (r) goto out_deinit; r = alloc_transfers(); if (r < 0) { request_exit(1); pthread_join(poll_thread, NULL); goto out_deinit; } r = init_capture(); if (r < 0) { request_exit(1); pthread_join(poll_thread, NULL); goto out_deinit; } while (!do_exit) { pthread_mutex_lock(&exit_cond_lock); pthread_cond_wait(&exit_cond, &exit_cond_lock); pthread_mutex_unlock(&exit_cond_lock); } printf("shutting down...\n"); pthread_join(poll_thread, NULL); r = libusb_cancel_transfer(irq_transfer); if (r < 0) { request_exit(1); goto out_deinit; } r = libusb_cancel_transfer(img_transfer); if (r < 0) { request_exit(1); goto out_deinit; } while (img_transfer || irq_transfer) if (libusb_handle_events(NULL) < 0) break; if (do_exit == 1) r = 0; else r = 1; out_deinit: libusb_free_transfer(img_transfer); libusb_free_transfer(irq_transfer); set_mode(0); set_hwstat(0x80); out_release: libusb_release_interface(devh, 0); out: libusb_close(devh); libusb_exit(NULL); return r >= 0 ? r : -r; }
/* * Main entry point: */ int MAIN(int argc, char **argv) { // First print GPL information: printf("%s %s [%s] Copyright (C) 2017 basil\n", PROGRAM_NAME_LONG, PROGRAM_VERSION, PLATFORM); puts("License GPLv3+: GNU GPL version 3 or later " "<http://gnu.org/licenses/gpl.html>."); puts("This is free software: you are free to change and redistribute it."); puts("There is NO WARRANTY, to the extent permitted by law."); putchar('\n'); // Process options: options_init(argc, argv); // Initialise various components (order is important!). log_init(); trace("changing to home directory %s", PROGRAM_DIR); chdir_home(); trace("installing files (if required)"); install_files(); trace("initialising user configuration"); config_init(); trace("initialising tunnel management"); tunnel_init(); // Initialise the sockets library (if required on this platform). trace("initialising sockets"); init_sockets(); // Get number of threads. int num_threads = (options_get()->seen_num_threads? options_get()->val_num_threads: NUM_THREADS_DEFAULT); if (num_threads < 1 || num_threads > NUM_THREADS_MAX) { error("unable to spawn %d threads; expected a number within the " "range 1..%u", num_threads, NUM_THREADS_MAX); } // Create configuration server thread. trace("launching configuration server thread"); if (thread_lock_init(&config_lock)) { error("unable to initialise global configuration lock"); } thread_t config_thread; if (!options_get()->seen_no_ui && thread_create(&config_thread, configuration_thread, NULL) != 0) { error("unable to create configuration server thread"); } // Open the packet capture/injection device driver. trace("initialising packet capture"); if (!options_get()->seen_no_capture) { init_capture(); } // Open the tunnels. trace("initialising tunnels"); tunnel_file_read(); tunnel_open(); // Go to sleep if we are not capturing packets. while (options_get()->seen_no_capture) { sleeptime(UINT64_MAX); } // Start worker threads. for (int i = 1; i < num_threads; i++) { thread_t work_thread; if (thread_create(&work_thread, worker_thread, NULL) != 0) { error("unable to create worker thread"); } } worker_thread((void *)0); return EXIT_SUCCESS; }
int main(int argc, char **argv) { struct ctx ctx = { }; int key; CvPoint last_center; last_center.x = 0; last_center.y = 0; int threshold_x = 50; int threshold_y = 50; init_capture(&ctx); init_windows(); init_ctx(&ctx); do { ctx.image = cvQueryFrame(ctx.capture); filter_and_threshold(&ctx); find_contour(&ctx); find_convex_hull(&ctx); find_fingers(&ctx); display(&ctx); //cvWriteFrame(ctx.writer, ctx.image); //printf("num: %d rad: %d def: %d x: %d y: %d\n", ctx.num_fingers, ctx.hand_radius, ctx.num_defects, ctx.hand_center.x, ctx.hand_center.y); if(ctx.num_fingers && ctx.hand_radius) { if(!last_center.x) { last_center = ctx.hand_center; } else { //Check If Position changed if( abs(ctx.hand_center.x - last_center.x) > threshold_x ) { if( ctx.hand_center.x - last_center.x > 0 ) { printf("move left\n"); } else { printf("move right\n"); } } if( abs(ctx.hand_center.y - last_center.y) > threshold_y ) { if( ctx.hand_center.y - last_center.y > 0 ) { printf("move down\n"); } else { printf("move up\n"); } } last_center = ctx.hand_center; } } key = cvWaitKey(1); } while (key != 'q'); return 0; }