int KinectControl::initDevice(unsigned int _user_device_number) { printf("KinectControl. initing the device.\n"); user_device_number = _user_device_number; if (freenect_open_device(f_ctx, &f_dev, user_device_number) < 0) { this->errorCode = 4; errorString = "Could not open device"; printf("%s\n", errorString.c_str()); freenect_shutdown(f_ctx); return this->errorCode; } else { printf("Kinect device opened.\n"); isInited = true; } int res; res = pthread_create(&freenect_thread, NULL, freenect_threadfunc, NULL); if (res) { errorString = "pthread_create failed"; printf("%s\n",errorString.c_str()); freenect_shutdown(f_ctx); this->errorCode = 5; return this->errorCode; } else { printf("Kinect thread created.\n"); } return res; }
int main(int argc, char **argv) { init_cv_buffers(); context = init_kinect(); if (context == NULL) { return 1; } if (freenect_open_device(context, &device, 0) < 0) { printf("could not open device\n"); freenect_shutdown(context); return 1; } int capture_loop_failed = pthread_create(&kinect_thread, NULL, capture_loop, NULL); if (capture_loop_failed) { printf("pthread_create failed\n"); freenect_shutdown(context); return 1; } handle_sigint(); graphics_loop(argc, argv); pthread_join(kinect_thread, NULL); printf("thanks for shooting down quads!\n"); }
int main( int argc, char **argv ) { //depth_gl = (uint8_t*)malloc(640*480*3); if( freenect_init( &f_context, NULL ) < 0 ) { printf( "Freenect initialization failed.\n" ); return 1; } freenect_set_log_level( f_context, FREENECT_LOG_DEBUG ); freenect_select_subdevices( f_context, ( freenect_device_flags )( FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA ) ); if( freenect_num_devices ( f_context ) < 1 ) { printf( "No devices found. Shutting down...\n" ); freenect_shutdown( f_context ); return 1; } if( freenect_open_device( f_context, &f_device, 0 ) <0 ) { printf( "Couldn't open device. Shutting down...\n" ); freenect_shutdown( f_context ); return 1; } if( pthread_create( &f_thread, NULL, f_threadfunc, NULL ) ) { printf( "Thread creation failed. Shutting down...\n" ); freenect_shutdown( f_context ); return 1; } glutInit( &argc, argv ); gl_threadfunc( NULL ); return 0; }
int main(int argc, char **argv) { int res; depth_mid = (uint8_t*)malloc(640*480*3); depth_front = (uint8_t*)malloc(640*480*3); rgb_back = (uint8_t*)malloc(640*480*3); rgb_mid = (uint8_t*)malloc(640*480*3); rgb_front = (uint8_t*)malloc(640*480*3); printf("Kinect camera test\n"); int i; for (i=0; i<2048; i++) { float v = i/2048.0; v = powf(v, 3)* 6; t_gamma[i] = v*6*256; } g_argc = argc; g_argv = argv; if (freenect_init(&f_ctx, NULL) < 0) { printf("freenect_init() failed\n"); return 1; } freenect_set_log_level(f_ctx, FREENECT_LOG_DEBUG); freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); int nr_devices = freenect_num_devices (f_ctx); printf ("Number of devices found: %d\n", nr_devices); int user_device_number = 0; if (argc > 1) user_device_number = atoi(argv[1]); if (nr_devices < 1) { freenect_shutdown(f_ctx); return 1; } if (freenect_open_device(f_ctx, &f_dev, user_device_number) < 0) { printf("Could not open device\n"); freenect_shutdown(f_ctx); return 1; } res = pthread_create(&freenect_thread, NULL, freenect_threadfunc, NULL); if (res) { printf("pthread_create failed\n"); freenect_shutdown(f_ctx); return 1; } // OS X requires GLUT to run on the main thread gl_threadfunc(NULL); return 0; }
int main() { freenect_context *f_ctx; freenect_device *f_dev; if (freenect_init(&f_ctx, NULL) < 0) { fprintf(stderr, "freenect_init() failed\n"); return 1; } freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); if (freenect_num_devices(f_ctx) < 1) { fprintf(stderr, "no devices found\n"); freenect_shutdown(f_ctx); return 1; } if (freenect_open_device(f_ctx, &f_dev, 0) < 0) { fprintf(stderr, "can't open device\n"); freenect_shutdown(f_ctx); return 1; } depth_image = image_create(640, 480); freenect_set_led(f_dev, LED_GREEN); freenect_set_depth_callback(f_dev, capture_depth_image); freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); freenect_start_depth(f_dev); if (signal(SIGINT, handle_interrupt) == SIG_IGN) { signal(SIGINT, SIG_IGN); } if (signal(SIGTERM, handle_interrupt) == SIG_IGN) { signal(SIGTERM, SIG_IGN); } fprintf(stdout, "\x1B[2J"); while (running && freenect_process_events(f_ctx) >= 0) { struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); fprintf(stdout, "\x1B[1;1H"); draw_depth_image(stdout, w.ws_col, w.ws_row - 1); } freenect_stop_depth(f_dev); freenect_set_led(f_dev, LED_OFF); freenect_close_device(f_dev); freenect_shutdown(f_ctx); image_destroy(depth_image); return 0; }
bool Kinect::setup() { if(ctx) { printf("Error: the freenect context has been setup already.\n"); return false; } if(freenect_init(&ctx, NULL) < 0) { printf("Error: cannot init libfreenect.\n"); return false; } freenect_set_log_level(ctx, FREENECT_LOG_DEBUG); int ndevices = freenect_num_devices(ctx); if(ndevices < 1) { printf("Error: cannot find a kinect. @todo cleanup mem.\n"); freenect_shutdown(ctx); ctx = NULL; return false; } printf("Number of found kinect devices: %d\n", ndevices); freenect_select_subdevices(ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); //freenect_select_subdevices(ctx, (freenect_device_flags)( FREENECT_DEVICE_CAMERA)); int devnum = 0; if(freenect_open_device(ctx, &device, devnum) < 0) { printf("Error: cannot open device: %d\n", devnum); freenect_shutdown(ctx); ctx = NULL; return false; } freenect_set_user(device, this); uint32_t w = 640; uint32_t h = 480; uint32_t nbytes = w * h * 3; nbytes_rgb = nbytes; rgb_back = new uint8_t[nbytes]; rgb_mid = new uint8_t[nbytes]; rgb_front = new uint8_t[nbytes]; depth_back = new uint8_t[nbytes]; depth_mid = new uint8_t[nbytes]; depth_front = new uint8_t[nbytes]; uv_mutex_lock(&mutex); must_stop = false; uv_mutex_unlock(&mutex); uv_thread_create(&thread, kinect_thread, this); return true; }
int main(int argc, char** argv) { if (freenect_init(&f_ctx, NULL) < 0) { printf("freenect_init() failed\n"); return 1; } freenect_set_log_level(f_ctx, FREENECT_LOG_INFO); freenect_select_subdevices(f_ctx, FREENECT_DEVICE_AUDIO); int nr_devices = freenect_num_devices (f_ctx); printf ("Number of devices found: %d\n", nr_devices); if (nr_devices < 1) { freenect_shutdown(f_ctx); return 1; } int user_device_number = 0; if (freenect_open_device(f_ctx, &f_dev, user_device_number) < 0) { printf("Could not open device\n"); freenect_shutdown(f_ctx); return 1; } state.max_samples = 256 * 60; state.current_idx = 0; state.buffers[0] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); state.buffers[1] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); state.buffers[2] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); state.buffers[3] = (int32_t*)malloc(state.max_samples * sizeof(int32_t)); memset(state.buffers[0], 0, state.max_samples * sizeof(int32_t)); memset(state.buffers[1], 0, state.max_samples * sizeof(int32_t)); memset(state.buffers[2], 0, state.max_samples * sizeof(int32_t)); memset(state.buffers[3], 0, state.max_samples * sizeof(int32_t)); freenect_set_user(f_dev, &state); freenect_set_audio_in_callback(f_dev, in_callback); freenect_start_audio(f_dev); int res = pthread_create(&freenect_thread, NULL, freenect_threadfunc, NULL); if (res) { printf("pthread_create failed\n"); freenect_shutdown(f_ctx); return 1; } ros::init(argc, argv, "kinect_audio"); MicView mv; mv.spin(); return 0; }
void init() { freenect_context *ctx; freenect_device *dev; if (freenect_init(&ctx, 0)) { printf("Error: Cannot get context\n"); return; } if (freenect_open_device(ctx, &dev, 0)) { printf("Error: Cannot get device\n"); return; } freenect_set_depth_format(dev, FREENECT_DEPTH_11BIT); freenect_start_depth(dev); freenect_set_video_format(dev, FREENECT_VIDEO_RGB); freenect_start_video(dev); if (use_ffmpeg) { init_ffmpeg_streams(); freenect_set_depth_callback(dev, depth_cb_ffmpeg); freenect_set_video_callback(dev, rgb_cb_ffmpeg); } else { freenect_set_depth_callback(dev, depth_cb); freenect_set_video_callback(dev, rgb_cb); } while (running && freenect_process_events(ctx) >= 0) snapshot_accel(dev); freenect_stop_depth(dev); freenect_stop_video(dev); freenect_close_device(dev); freenect_shutdown(ctx); }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; } }
static void *init(void *unused) { pending_runloop_tasks_wait_zero(); pthread_mutex_lock(&runloop_lock); while (thread_running && freenect_process_events(ctx) >= 0) { pthread_mutex_unlock(&runloop_lock); // NOTE: This lets you run tasks while process_events isn't running pending_runloop_tasks_wait_zero(); pthread_mutex_lock(&runloop_lock); } // Go through each device, call stop video, close device int i; for (i = 0; i < MAX_KINECTS; ++i) { if (kinects[i]) { freenect_stop_video(kinects[i]->dev); freenect_stop_depth(kinects[i]->dev); freenect_set_user(kinects[i]->dev, NULL); freenect_close_device(kinects[i]->dev); free_buffer_ring(&kinects[i]->video); free_buffer_ring(&kinects[i]->depth); free(kinects[i]); kinects[i] = NULL; } } freenect_shutdown(ctx); pthread_mutex_unlock(&runloop_lock); return NULL; }
void kinect_finish(Kinect* kt){ pthread_mutex_unlock(&G_kt.mutex); freenect_stop_depth(kt->dev); freenect_stop_video(kt->dev); freenect_close_device(kt->dev); freenect_shutdown(kt->ctx); }
KinectControl::KinectControl() { printf("\nKinectControl Init\n"); errorCode = 0; isInited = false; if (kinectControlRef != NULL) { errorCode = 1; errorString = "KinectControl Already Started."; printf("%s.\n",errorString.c_str()); return; } for (int i=0; i<2048; i++) { float v = i/2048.0; v = powf(v, 3)* 6; t_gamma[i] = v*6*256; } kinectControlRef = this; freenect_angle = 0; user_device_number = -1; requested_format = FREENECT_VIDEO_RGB; current_format = FREENECT_VIDEO_RGB; //depth_mid = (uint8_t*)malloc(640*480*3); depth_front = (uint8_t*)malloc(640*480*3); rgb_back = (uint8_t*)malloc(640*480*3); rgb_mid = (uint8_t*)malloc(640*480*3); rgb_front = (uint8_t*)malloc(640*480*3); depth_mid = NULL; memset(depth_front,0,(640*480*3)); memset(rgb_back,0,(640*480*3)); memset(rgb_mid,0,(640*480*3)); memset(rgb_front,0,(640*480*3)); if (freenect_init(&f_ctx, NULL) < 0) { errorCode = 2; errorString = "freenect_init() failed."; printf("%s\n",errorString.c_str()); return; } else { printf("freenect_init() OK\n"); } freenect_set_log_level(f_ctx, FREENECT_LOG_DEBUG); freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); int nr_devices = freenect_num_devices (f_ctx); printf ("Number of devices found: %d\n", nr_devices); // check if there were no device found. if (nr_devices < 0) { freenect_shutdown(f_ctx); errorCode = 3; errorString = "No freenect devices found!"; printf("%s\n", errorString.c_str()); } }
~Freenect() { for(typename std::map<int, T*>::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it) { delete it->second; } m_stop = true; pthread_join(m_thread, NULL); if(freenect_shutdown(m_ctx) != 0) throw std::runtime_error("Cannot cleanup freenect library"); }
bool FreenectGrabber :: disconnectFromDevice() { // Exit requested. m_connected = false; freenect_close_device(f_dev); freenect_shutdown(f_ctx); return true; }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; ofLog(OF_LOG_VERBOSE, "ofxKinect: Context cleared"); } }
void shutdown() { thread_running_ = false; freenect_thread_->join(); if (device_) device_->shutdown(); device_.reset(); freenect_shutdown(driver_); }
~Freenect() { for(DeviceMap::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it) { delete it->second; } m_stop = true; pthread_join(m_thread, NULL); if(freenect_shutdown(m_ctx) < 0){} //FN_WARNING("Freenect did not shutdown in a clean fashion"); }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; ofLogVerbose("ofxKinect") << "context cleared"; } }
void* freenect_threadfunc(void* arg) { while(!die && freenect_process_events(f_ctx) >= 0) { // If we did anything else in the freenect thread, it might go here. } freenect_stop_audio(f_dev); freenect_close_device(f_dev); freenect_shutdown(f_ctx); return NULL; }
int main(int argc, char **argv) { ros::init(argc, argv, "kinect_motor"); freenect_context * context = 0; if (freenect_init(&context, NULL) < 0) { ROS_ERROR("freenect_init() failed"); return 1; } freenect_set_log_level(context, FREENECT_LOG_DEBUG); freenect_select_subdevices(context, (freenect_device_flags)(FREENECT_DEVICE_MOTOR)); int devicesCout = freenect_num_devices (context); ROS_INFO("Number of devices found: %d", devicesCout); if (devicesCout < 1) { freenect_shutdown(context); return 1; } ROS_INFO("Connecting to device: 1"); if (freenect_open_device(context, &device, 0) < 0) { printf("Could not open device\n"); freenect_shutdown(context); return 1; } freenect_set_tilt_degs(device, 0); ros::NodeHandle nodeHandleForAngle; ros::Subscriber angleSubscriber = nodeHandleForAngle.subscribe("angle", 10, Angle); ros::NodeHandle nodeHandleForLed; ros::Subscriber ledSubscriber = nodeHandleForLed.subscribe("led", 10, Led); ros::spin(); freenect_close_device(device); freenect_shutdown(context); return 0; }
int main(int argc, char **argv) { freenect_context *fc; freenect_device *fd; if (freenect_init(&fc, 0) < 0) { printf("failed to init freenect\n"); exit(1); } if (freenect_num_devices(fc) < 1) { printf("no kinect found\n"); freenect_shutdown(fc); exit(1); } if (freenect_open_device(fc, &fd, 0) < 0) { printf("unable to open device 0\n"); freenect_shutdown(fc); exit(1); } double want; while (1) { want = 30.0; freenect_set_tilt_degs(fd, want); freenect_set_led(fd, LED_RED); while (fabs(freenect_get_tilt_degs(freenect_get_tilt_state(fd)) - want) > 1) { freenect_update_tilt_state(fd); usleep(1000); } want = -30.0; freenect_set_tilt_degs(fd, want); freenect_set_led(fd, LED_GREEN); while (fabs(freenect_get_tilt_degs(freenect_get_tilt_state(fd)) - want) > 1) { freenect_update_tilt_state(fd); usleep(1000); } } freenect_close_device(fd); freenect_shutdown(fc); exit(0); }
int main(int argc, char** argv) { ros::init(argc, argv, "kinect_audio"); freenect_context * contex; if (freenect_init(&contex, NULL) < 0) { printf("freenect_init() failed\n"); return 1; } freenect_set_log_level(contex, FREENECT_LOG_SPEW); freenect_select_subdevices(contex, FREENECT_DEVICE_AUDIO); int nr_devices = freenect_num_devices(contex); printf ("Number of devices found: %d\n", nr_devices); if (nr_devices < 1) { freenect_shutdown(contex); return 1; } freenect_device * device; int deviceNumber = 0; if (freenect_open_device(contex, &device, deviceNumber) < 0) { printf("Could not open device\n"); freenect_shutdown(contex); return 1; } freenect_set_audio_in_callback(device, callback); freenect_start_audio(device); signal(SIGINT, cleanup); audioPublisher = ros::NodeHandle().advertise<kinect_audio::audio>("audio", 10); while(!die && freenect_process_events(contex) >= 0) { // If we did anything else, it might go here. // Alternately, we might split off another thread // to do this loop while the main thread did something // interesting. } freenect_shutdown(contex); return 0; }
int KinectFreenect::stop() { die = 1; freenect_stop_depth(f_dev); freenect_stop_video(f_dev); freenect_close_device(f_dev); freenect_shutdown(f_ctx); pthread_join(fnkt_thread, NULL); return 0; }
Kinect::~Kinect() { printf("Error: need to free buffers.\n"); uv_mutex_lock(&mutex); must_stop = true; uv_mutex_unlock(&mutex); uv_thread_join(&thread); if(ctx) { freenect_close_device(device); freenect_shutdown(ctx); ctx = NULL; } uv_mutex_destroy(&mutex); has_new_rgb = false; has_new_depth = false; if(depth_back) { delete[] depth_back; } if(depth_mid) { delete[] depth_mid; } if(depth_front) { delete[] depth_front; } depth_back = NULL; depth_mid = NULL; depth_front = NULL; if(rgb_back) { delete[] rgb_back; } if(rgb_mid) { delete[] rgb_mid; } if(rgb_front) { delete[] rgb_front; } rgb_back = NULL; rgb_mid = NULL; rgb_front = NULL; device = NULL; }
//---------------------------------------------------------------------------------------------------------------------- void KinectInterface::shutDownKinect() { /// stop the processing thread m_process->setInActive(); /// stop the video and depth callbacks freenect_stop_depth(m_dev); freenect_stop_video(m_dev); // close down our devices freenect_close_device(m_dev); freenect_shutdown(m_ctx); }
void *freenect_threadfunc(void *arg) { int accelCount = 0; freenect_set_tilt_degs(f_dev,freenect_angle); freenect_set_led(f_dev,LED_RED); freenect_set_depth_callback(f_dev, depth_cb); freenect_set_video_callback(f_dev, rgb_cb); freenect_set_video_mode(f_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, current_format)); freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); freenect_set_video_buffer(f_dev, rgb_back); freenect_start_depth(f_dev); freenect_start_video(f_dev); printf("'w' - tilt up, 's' - level, 'x' - tilt down, '0'-'6' - select LED mode, '+' & '-' - change IR intensity \n"); printf("'f' - change video format, 'm' - mirror video, 'o' - rotate video with accelerometer \n"); printf("'e' - auto exposure, 'b' - white balance, 'r' - raw color, 'n' - near mode (K4W only) \n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output if (accelCount++ >= 2000) { accelCount = 0; freenect_raw_tilt_state* state; freenect_update_tilt_state(f_dev); state = freenect_get_tilt_state(f_dev); double dx,dy,dz; freenect_get_mks_accel(state, &dx, &dy, &dz); printf("\r raw acceleration: %4d %4d %4d mks acceleration: %4f %4f %4f", state->accelerometer_x, state->accelerometer_y, state->accelerometer_z, dx, dy, dz); fflush(stdout); } if (requested_format != current_format) { freenect_stop_video(f_dev); freenect_set_video_mode(f_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, requested_format)); freenect_start_video(f_dev); current_format = requested_format; } } printf("\nshutting down streams...\n"); freenect_stop_depth(f_dev); freenect_stop_video(f_dev); freenect_close_device(f_dev); freenect_shutdown(f_ctx); printf("-- done!\n"); return NULL; }
void *freenect_threadfunc(void *arg) { printf("Freenect thread\n"); int accelCount = 0; //freenect_set_tilt_degs(f_dev,freenect_angle); //freenect_set_led(f_dev,LED_RED); freenect_set_depth_callback(f_dev, depth_cb); freenect_set_video_callback(f_dev, rgb_cb); freenect_set_video_mode(f_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, current_format)); freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT)); freenect_set_video_buffer(f_dev, rgb_back); freenect_start_depth(f_dev); freenect_start_video(f_dev); printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format\n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output if (accelCount++ >= 2000) { accelCount = 0; //freenect_raw_tilt_state* state; //freenect_update_tilt_state(f_dev); //state = freenect_get_tilt_state(f_dev); double dx,dy,dz; //freenect_get_mks_accel(state, &dx, &dy, &dz); //printf("\r raw acceleration: %4d %4d %4d mks acceleration: %4f %4f %4f", state->accelerometer_x, state->accelerometer_y, state->accelerometer_z, dx, dy, dz); fflush(stdout); } if (requested_format != current_format) { freenect_stop_video(f_dev); freenect_set_video_mode(f_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, requested_format)); freenect_start_video(f_dev); current_format = requested_format; } } printf("\nshutting down streams...\n"); freenect_stop_depth(f_dev); freenect_stop_video(f_dev); freenect_close_device(f_dev); freenect_shutdown(f_ctx); printf("-- done!\n"); return NULL; }
/* Function: mdlTerminate ===================================================== * Abstract: * In this function, you should perform any actions that are necessary * at the termination of a simulation. For example, if memory was * allocated in mdlStart, this is the place to free it. */ static void mdlTerminate(SimStruct *S) { SS_SimMode mode= ssGetSimMode(S); if(mode==0) { printf("Term\n"); kinRunning= 0; freenect_stop_depth(kinDev); freenect_stop_video(kinDev); freenect_close_device(kinDev); freenect_shutdown(kinCtx); } }
KinectControl::~KinectControl() { printf("Destroying KinectControl.\n"); die = 1; pthread_join(freenect_thread, NULL); freenect_shutdown(f_ctx); free(depth_mid); free(depth_front); free(rgb_back); free(rgb_mid); free(rgb_front); kinectControlRef = NULL; }
/* * Class: org_ensor_robots_sensors_kinect_Driver * Method: nativeShutdown * Signature: ()V */ JNIEXPORT void JNICALL Java_org_ensor_robots_sensors_kinect_Driver_nativeShutdown (JNIEnv *aJNIEnv, jobject aThisObject) { pthread_mutex_lock(&mutex); f_running = 0; pthread_mutex_unlock(&mutex); pthread_join(f_thread, NULL); freenect_shutdown(f_ctx); f_device_count = 0; if (f_devices != NULL) { free(f_devices); f_devices = NULL; } }