From e1365de85617781e370abdc7ce1ef6d9875d55de Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Mon, 23 Jan 2012 07:41:41 -0800 Subject: [PATCH 01/36] cameras.c: memcpy structs into properly aligned buffers before toggling endianness. The new registration structs are not aligned to 4-byte boundaries in the buffers that we get back from the Kinect. This might have been causing breakage on ARM, where nonaligned access is prohibited. Signed-off-by: Drew Fisher --- src/cameras.c | 132 +++++++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/src/cameras.c b/src/cameras.c index 9f0beb9f..d391a7cd 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -783,56 +783,55 @@ static int freenect_fetch_reg_info(freenect_device *dev) FN_ERROR("freenect_fetch_reg_info: send_cmd read %d bytes (expected 118)\n", res); return -1; } - freenect_reg_info *reg_info_ptr = (freenect_reg_info*)(&reply[2]); - freenect_reg_info *dev_reg_info = &(dev->registration.reg_info); - dev_reg_info->ax = fn_le32s(reg_info_ptr->ax); - dev_reg_info->bx = fn_le32s(reg_info_ptr->bx); - dev_reg_info->cx = fn_le32s(reg_info_ptr->cx); - dev_reg_info->dx = fn_le32s(reg_info_ptr->dx); - dev_reg_info->ay = fn_le32s(reg_info_ptr->ay); - dev_reg_info->by = fn_le32s(reg_info_ptr->by); - dev_reg_info->cy = fn_le32s(reg_info_ptr->cy); - dev_reg_info->dy = fn_le32s(reg_info_ptr->dy); - dev_reg_info->dx_start = fn_le32s(reg_info_ptr->dx_start); - dev_reg_info->dy_start = fn_le32s(reg_info_ptr->dy_start); - dev_reg_info->dx_beta_start = fn_le32s(reg_info_ptr->dx_beta_start); - dev_reg_info->dy_beta_start = fn_le32s(reg_info_ptr->dy_beta_start); - dev_reg_info->dx_beta_inc = fn_le32s(reg_info_ptr->dx_beta_inc); - dev_reg_info->dy_beta_inc = fn_le32s(reg_info_ptr->dy_beta_inc); - dev_reg_info->dxdx_start = fn_le32s(reg_info_ptr->dxdx_start); - dev_reg_info->dxdy_start = fn_le32s(reg_info_ptr->dxdy_start); - dev_reg_info->dydx_start = fn_le32s(reg_info_ptr->dydx_start); - dev_reg_info->dydy_start = fn_le32s(reg_info_ptr->dydy_start); - dev_reg_info->dxdxdx_start = fn_le32s(reg_info_ptr->dxdxdx_start); - dev_reg_info->dydxdx_start = fn_le32s(reg_info_ptr->dydxdx_start); - dev_reg_info->dxdxdy_start = fn_le32s(reg_info_ptr->dxdxdy_start); - dev_reg_info->dydxdy_start = fn_le32s(reg_info_ptr->dydxdy_start); - dev_reg_info->dydydx_start = fn_le32s(reg_info_ptr->dydydx_start); - dev_reg_info->dydydy_start = fn_le32s(reg_info_ptr->dydydy_start); - FN_SPEW("ax: %d\n", dev_reg_info->ax); - FN_SPEW("bx: %d\n", dev_reg_info->bx); - FN_SPEW("cx: %d\n", dev_reg_info->cx); - FN_SPEW("dx: %d\n", dev_reg_info->dx); - FN_SPEW("ay: %d\n", dev_reg_info->ay); - FN_SPEW("by: %d\n", dev_reg_info->by); - FN_SPEW("cy: %d\n", dev_reg_info->cy); - FN_SPEW("dy: %d\n", dev_reg_info->dy); - FN_SPEW("dx_start: %d\n", dev_reg_info->dx_start); - FN_SPEW("dy_start: %d\n", dev_reg_info->dy_start); - FN_SPEW("dx_beta_start: %d\n", dev_reg_info->dx_beta_start); - FN_SPEW("dy_beta_start: %d\n", dev_reg_info->dy_beta_start); - FN_SPEW("dx_beta_inc: %d\n", dev_reg_info->dx_beta_inc); - FN_SPEW("dy_beta_inc: %d\n", dev_reg_info->dy_beta_inc); - FN_SPEW("dxdx_start: %d\n", dev_reg_info->dxdx_start); - FN_SPEW("dxdy_start: %d\n", dev_reg_info->dxdy_start); - FN_SPEW("dydx_start: %d\n", dev_reg_info->dydx_start); - FN_SPEW("dydy_start: %d\n", dev_reg_info->dydy_start); - FN_SPEW("dxdxdx_start: %d\n", dev_reg_info->dxdxdx_start); - FN_SPEW("dydxdx_start: %d\n", dev_reg_info->dydxdx_start); - FN_SPEW("dxdxdy_start: %d\n", dev_reg_info->dxdxdy_start); - FN_SPEW("dydxdy_start: %d\n", dev_reg_info->dydxdy_start); - FN_SPEW("dydydx_start: %d\n", dev_reg_info->dydydx_start); - FN_SPEW("dydydy_start: %d\n", dev_reg_info->dydydy_start); + memcpy(&dev->registration.reg_info, reply + 2, sizeof(dev->registration.reg_info)); + dev->registration.reg_info.ax = fn_le32s(dev->registration.reg_info.ax); + dev->registration.reg_info.bx = fn_le32s(dev->registration.reg_info.bx); + dev->registration.reg_info.cx = fn_le32s(dev->registration.reg_info.cx); + dev->registration.reg_info.dx = fn_le32s(dev->registration.reg_info.dx); + dev->registration.reg_info.ay = fn_le32s(dev->registration.reg_info.ay); + dev->registration.reg_info.by = fn_le32s(dev->registration.reg_info.by); + dev->registration.reg_info.cy = fn_le32s(dev->registration.reg_info.cy); + dev->registration.reg_info.dy = fn_le32s(dev->registration.reg_info.dy); + dev->registration.reg_info.dx_start = fn_le32s(dev->registration.reg_info.dx_start); + dev->registration.reg_info.dy_start = fn_le32s(dev->registration.reg_info.dy_start); + dev->registration.reg_info.dx_beta_start = fn_le32s(dev->registration.reg_info.dx_beta_start); + dev->registration.reg_info.dy_beta_start = fn_le32s(dev->registration.reg_info.dy_beta_start); + dev->registration.reg_info.dx_beta_inc = fn_le32s(dev->registration.reg_info.dx_beta_inc); + dev->registration.reg_info.dy_beta_inc = fn_le32s(dev->registration.reg_info.dy_beta_inc); + dev->registration.reg_info.dxdx_start = fn_le32s(dev->registration.reg_info.dxdx_start); + dev->registration.reg_info.dxdy_start = fn_le32s(dev->registration.reg_info.dxdy_start); + dev->registration.reg_info.dydx_start = fn_le32s(dev->registration.reg_info.dydx_start); + dev->registration.reg_info.dydy_start = fn_le32s(dev->registration.reg_info.dydy_start); + dev->registration.reg_info.dxdxdx_start = fn_le32s(dev->registration.reg_info.dxdxdx_start); + dev->registration.reg_info.dydxdx_start = fn_le32s(dev->registration.reg_info.dydxdx_start); + dev->registration.reg_info.dxdxdy_start = fn_le32s(dev->registration.reg_info.dxdxdy_start); + dev->registration.reg_info.dydxdy_start = fn_le32s(dev->registration.reg_info.dydxdy_start); + dev->registration.reg_info.dydydx_start = fn_le32s(dev->registration.reg_info.dydydx_start); + dev->registration.reg_info.dydydy_start = fn_le32s(dev->registration.reg_info.dydydy_start); + FN_SPEW("ax: %d\n", dev->registration.reg_info.ax); + FN_SPEW("bx: %d\n", dev->registration.reg_info.bx); + FN_SPEW("cx: %d\n", dev->registration.reg_info.cx); + FN_SPEW("dx: %d\n", dev->registration.reg_info.dx); + FN_SPEW("ay: %d\n", dev->registration.reg_info.ay); + FN_SPEW("by: %d\n", dev->registration.reg_info.by); + FN_SPEW("cy: %d\n", dev->registration.reg_info.cy); + FN_SPEW("dy: %d\n", dev->registration.reg_info.dy); + FN_SPEW("dx_start: %d\n", dev->registration.reg_info.dx_start); + FN_SPEW("dy_start: %d\n", dev->registration.reg_info.dy_start); + FN_SPEW("dx_beta_start: %d\n", dev->registration.reg_info.dx_beta_start); + FN_SPEW("dy_beta_start: %d\n", dev->registration.reg_info.dy_beta_start); + FN_SPEW("dx_beta_inc: %d\n", dev->registration.reg_info.dx_beta_inc); + FN_SPEW("dy_beta_inc: %d\n", dev->registration.reg_info.dy_beta_inc); + FN_SPEW("dxdx_start: %d\n", dev->registration.reg_info.dxdx_start); + FN_SPEW("dxdy_start: %d\n", dev->registration.reg_info.dxdy_start); + FN_SPEW("dydx_start: %d\n", dev->registration.reg_info.dydx_start); + FN_SPEW("dydy_start: %d\n", dev->registration.reg_info.dydy_start); + FN_SPEW("dxdxdx_start: %d\n", dev->registration.reg_info.dxdxdx_start); + FN_SPEW("dydxdx_start: %d\n", dev->registration.reg_info.dydxdx_start); + FN_SPEW("dxdxdy_start: %d\n", dev->registration.reg_info.dxdxdy_start); + FN_SPEW("dydxdy_start: %d\n", dev->registration.reg_info.dydxdy_start); + FN_SPEW("dydydx_start: %d\n", dev->registration.reg_info.dydydx_start); + FN_SPEW("dydydy_start: %d\n", dev->registration.reg_info.dydydy_start); /* // NOTE: Not assigned above FN_SPEW("dx_center: %d\n", dev_reg_info->dx_center); @@ -861,10 +860,10 @@ static int freenect_fetch_reg_pad_info(freenect_device *dev) FN_ERROR("freenect_fetch_reg_pad_info: send_cmd read %d bytes (expected 8)\n", res); return -1; } - freenect_reg_pad_info *pad_info_ptr = (freenect_reg_pad_info*)(&reply[2]); - dev->registration.reg_pad_info.start_lines = fn_le16s(pad_info_ptr->start_lines); - dev->registration.reg_pad_info.end_lines = fn_le16s(pad_info_ptr->end_lines); - dev->registration.reg_pad_info.cropping_lines = fn_le16s(pad_info_ptr->cropping_lines); + memcpy(&dev->registration.reg_pad_info, reply+2, sizeof(dev->registration.reg_pad_info)); + dev->registration.reg_pad_info.start_lines = fn_le16s(dev->registration.reg_pad_info.start_lines); + dev->registration.reg_pad_info.end_lines = fn_le16s(dev->registration.reg_pad_info.end_lines); + dev->registration.reg_pad_info.cropping_lines = fn_le16s(dev->registration.reg_pad_info.cropping_lines); FN_SPEW("start_lines: %u\n",dev->registration.reg_pad_info.start_lines); FN_SPEW("end_lines: %u\n",dev->registration.reg_pad_info.end_lines); FN_SPEW("cropping_lines: %u\n",dev->registration.reg_pad_info.cropping_lines); @@ -888,7 +887,9 @@ static int freenect_fetch_reg_const_shift(freenect_device *dev) FN_ERROR("freenect_fetch_reg_const_shift: send_cmd read %d bytes (expected 8)\n", res); return -1; } - uint16_t shift = fn_le16(*((uint16_t*)(reply+2))); + uint16_t shift; + memcpy(&shift, reply+2, sizeof(shift)); + shift = fn_le16(shift); dev->registration.const_shift = (double)shift; FN_SPEW("const_shift: %f\n",dev->registration.const_shift); return 0; @@ -907,17 +908,18 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 322)\n", res); return -1; } + + memcpy(&(dev->registration.zero_plane_info), reply + 94, sizeof(dev->registration.zero_plane_info)); + dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist))))); + dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist))))); + dev->registration.zero_plane_info.reference_distance = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance))))); + dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size))))); + // WTF is all this data? it's way bigger than sizeof(XnFixedParams)... - FN_SPEW("dcmos_emitter_distance: %f\n", *((float*)(reply+94))); - FN_SPEW("dcmos_rcmos_distance: %f\n", *((float*)(reply+98))); - FN_SPEW("reference_distance: %f\n", *((float*)(reply+102))); - FN_SPEW("reference_pixel_size: %f\n", *((float*)(reply+106))); - - // The values are 32-bit floats in little-endian. So: - dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&fn_le32(*((uint32_t*)(reply+94))))); - dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&fn_le32(*((uint32_t*)(reply+98))))); - dev->registration.zero_plane_info.reference_distance = *((float*)(&fn_le32(*((uint32_t*)(reply+102))))); - dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&fn_le32(*((uint32_t*)(reply+106))))); + FN_SPEW("dcmos_emitter_distance: %f\n", dev->registration.zero_plane_info.dcmos_emitter_dist); + FN_SPEW("dcmos_rcmos_distance: %f\n", dev->registration.zero_plane_info.dcmos_rcmos_dist); + FN_SPEW("reference_distance: %f\n", dev->registration.zero_plane_info.reference_distance); + FN_SPEW("reference_pixel_size: %f\n", dev->registration.zero_plane_info.reference_pixel_size); // FIXME: OpenNI seems to use a hardcoded value of 2.4 instead of 2.3 as reported by Kinect dev->registration.zero_plane_info.dcmos_rcmos_dist = 2.4; From 4743a6e02936f7378b4b7b047c75760e93a8646d Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Tue, 24 Jan 2012 14:49:09 +0100 Subject: [PATCH 02/36] C++ wrapper: ignore LIBUSB_ERROR_INTERRUPTED from freenect_process_events() I kept getting errors about "Cannot process freenect events" when trying to start cppview although glview worked perfectly. It turns out libusb kept returning error "interrupted" when starting up, this patch ignores all such errors from libusb. I do not know libusb well enough to be able to tell whether this workaround will cause any problems in special cases. cppview seems to be working, but crashes when pressing ESC or closing the window with the error "pure virtual method called". I'm still investigating that error but I do not think it is related to this patch. Signed-off-by: Joakim Gebart --- wrappers/cpp/libfreenect.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 0a5f637e..b5ecdf16 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -28,8 +28,10 @@ #include #include +#include #include #include +#include namespace Freenect { class Noncopyable { @@ -209,7 +211,20 @@ namespace Freenect { // Do not call directly, thread runs here void operator()() { while(!m_stop) { - if(freenect_process_events(m_ctx) < 0) throw std::runtime_error("Cannot process freenect events"); + int res = freenect_process_events(m_ctx); + if (res < 0) + { + // libusb signals an error has occurred + if (res == LIBUSB_ERROR_INTERRUPTED) + { + // This happens sometimes, it means that a system call in libusb was interrupted somehow (perhaps due to a signal) + // The simple solution seems to be just ignore it. + continue; + } + std::stringstream ss; + ss << "Cannot process freenect events (libusb error code: " << res << ")"; + throw std::runtime_error(ss.str()); + } } } static void *pthread_callback(void *user_data) { From ac6721a678205212378251c4852bcf8614510e22 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 29 Jan 2012 16:27:40 -0800 Subject: [PATCH 03/36] loader.c: memcpy structs into properly aligned buffers before accessing contents Signed-off-by: Drew Fisher --- src/loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/loader.c b/src/loader.c index 7a5e80f4..f946aeb4 100644 --- a/src/loader.c +++ b/src/loader.c @@ -49,14 +49,15 @@ static void dump_cemd_cmd(freenect_context* ctx, cemdloader_command cmd) { static int get_reply(fnusb_dev* dev) { freenect_context* ctx = dev->parent->parent; unsigned char dump[512]; - bootloader_status_code buffer = ((bootloader_status_code*)dump)[0]; + bootloader_status_code buffer; int res; int transferred; - res = fnusb_bulk(dev, 0x81, (unsigned char*)&buffer, 512, &transferred); + res = fnusb_bulk(dev, 0x81, dump, 512, &transferred); if(res != 0 || transferred != sizeof(bootloader_status_code)) { FN_ERROR("Error reading reply: %d\ttransferred: %d (expected %d)\n", res, transferred, (int)(sizeof(bootloader_status_code))); return res; } + memcpy(&buffer, dump, sizeof(bootloader_status_code)); if(fn_le32(buffer.magic) != 0x0a6fe000) { FN_ERROR("Error reading reply: invalid magic %08X\n",buffer.magic); return -1; From bbc109a589a1dd2c229f8bc98536dbc184dd73f9 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 29 Jan 2012 16:28:32 -0800 Subject: [PATCH 04/36] Build on big-endian systems again. On big endian, fn_le32() is actually a function, not an empty preprocessor macro, so we can't take the address of its return value when doing the C equivalent of reinterpret_cast. Signed-off-by: Drew Fisher --- src/cameras.c | 13 +++++++++---- src/freenect_internal.h | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cameras.c b/src/cameras.c index d391a7cd..a078e1d7 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -910,10 +910,15 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) } memcpy(&(dev->registration.zero_plane_info), reply + 94, sizeof(dev->registration.zero_plane_info)); - dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist))))); - dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist))))); - dev->registration.zero_plane_info.reference_distance = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance))))); - dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size))))); + uint32_t temp; + temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist))); + dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&temp)); + temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist))); + dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&temp)); + temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance))); + dev->registration.zero_plane_info.reference_distance = *((float*)(&temp)); + temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size))); + dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&temp)); // WTF is all this data? it's way bigger than sizeof(XnFixedParams)... FN_SPEW("dcmos_emitter_distance: %f\n", dev->registration.zero_plane_info.dcmos_emitter_dist); diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 4e7950ee..d23208aa 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -89,12 +89,16 @@ static inline uint32_t fn_le32(uint32_t d) static inline int16_t fn_le16s(int16_t s) { // reinterpret cast to unsigned, use the normal fn_le16, and then reinterpret cast back - return *((int16_t*)(&fn_le16(*((uint16_t*)(&s))))); + uint16_t temp = (*(uint16_t*)(&s)); + temp = fn_le16(temp); + return *((int16_t*)(&temp)); } static inline int32_t fn_le32s(int32_t s) { // reinterpret cast to unsigned, use the normal fn_le32, and then reinterpret cast back - return *((int32_t*)(&fn_le32(*((uint32_t*)(&s))))); + uint32_t temp = (*(uint32_t*)(&s)); + temp = fn_le32(temp); + return *((int32_t*)(&temp)); } #else #define fn_le16(x) (x) From 416b2505d2d2c04d48bca68850ad22b9a69c8277 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 26 Jan 2012 14:29:35 +0100 Subject: [PATCH 05/36] Hides unexported symbols Mark all non static internal functions with visibility hidden on ELF platform. Declare some internal symbols that were meant to have static linkage as such. On win32 the hidden visibility is no op since it is the default behavior. Signed-off-by: Nicolas Bourdaud --- src/cameras.c | 8 ++++---- src/core.c | 2 +- src/freenect_internal.h | 7 +++++++ src/loader.c | 4 ++-- src/registration.c | 14 +++++++------- src/usb_libusb10.c | 26 +++++++++++++------------- 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/cameras.c b/src/cameras.c index a078e1d7..870be0b1 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -38,7 +38,7 @@ #define RESERVED_TO_FORMAT(reserved) ((reserved) & 0xff) #define video_mode_count 12 -freenect_frame_mode supported_video_modes[video_mode_count] = { +static freenect_frame_mode supported_video_modes[video_mode_count] = { // reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid {MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_RGB}, 1280*1024*3, 1280, 1024, 24, 0, 10, 1 }, {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_RGB}, 640*480*3, 640, 480, 24, 0, 30, 1 }, @@ -61,7 +61,7 @@ freenect_frame_mode supported_video_modes[video_mode_count] = { }; #define depth_mode_count 6 -freenect_frame_mode supported_depth_modes[depth_mode_count] = { +static freenect_frame_mode supported_depth_modes[depth_mode_count] = { // reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_11BIT}, 640*480*2, 640, 480, 11, 5, 30, 1}, {MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_10BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_10BIT}, 640*480*2, 640, 480, 10, 6, 30, 1}, @@ -1323,7 +1323,7 @@ int freenect_set_video_buffer(freenect_device *dev, void *buf) return stream_setbuf(dev->parent, &dev->video, buf); } -int freenect_camera_init(freenect_device *dev) +FN_INTERNAL int freenect_camera_init(freenect_device *dev) { freenect_context *ctx = dev->parent; int res; @@ -1347,7 +1347,7 @@ int freenect_camera_init(freenect_device *dev) return 0; } -int freenect_camera_teardown(freenect_device *dev) +FN_INTERNAL int freenect_camera_teardown(freenect_device *dev) { freenect_context *ctx = dev->parent; int res = 0; diff --git a/src/core.c b/src/core.c index 63374191..d46e7d73 100644 --- a/src/core.c +++ b/src/core.c @@ -260,7 +260,7 @@ FREENECTAPI void freenect_set_log_callback(freenect_context *ctx, freenect_log_c ctx->log_cb = cb; } -void fn_log(freenect_context *ctx, freenect_loglevel level, const char *fmt, ...) +FN_INTERNAL void fn_log(freenect_context *ctx, freenect_loglevel level, const char *fmt, ...) { va_list ap; diff --git a/src/freenect_internal.h b/src/freenect_internal.h index d23208aa..a68a9996 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -36,6 +36,13 @@ #include "libfreenect-audio.h" #endif +#ifdef __ELF__ +#define FN_INTERNAL __attribute__ ((visibility ("hidden"))) +#else +#define FN_INTERNAL +#endif + + typedef void (*fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len); #include "usb_libusb10.h" diff --git a/src/loader.c b/src/loader.c index f946aeb4..f5bf0585 100644 --- a/src/loader.c +++ b/src/loader.c @@ -120,7 +120,7 @@ static int check_version_string(fnusb_dev* dev) { return res; } -int upload_firmware(fnusb_dev* dev) { +FN_INTERNAL int upload_firmware(fnusb_dev* dev) { freenect_context* ctx = dev->parent->parent; bootloader_command bootcmd; memset(&bootcmd, 0, sizeof(bootcmd)); @@ -248,7 +248,7 @@ int upload_firmware(fnusb_dev* dev) { return 0; } -int upload_cemd_data(fnusb_dev* dev) { +FN_INTERNAL int upload_cemd_data(fnusb_dev* dev) { // Now we upload the CEMD data. freenect_context* ctx = dev->parent->parent; cemdloader_command cemdcmd; diff --git a/src/registration.c b/src/registration.c index 7c6f2e08..072b7043 100644 --- a/src/registration.c +++ b/src/registration.c @@ -74,7 +74,7 @@ static void freenect_init_depth_to_rgb(int32_t* depth_to_rgb, freenect_zero_plan } // unrolled inner loop of the 11-bit unpacker -inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame) +static inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame) { uint16_t baseMask = 0x7FF; @@ -101,7 +101,7 @@ inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame) } // apply registration data to a single packed frame -int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm) +FN_INTERNAL int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm) { freenect_registration* reg = &(dev->registration); // set output buffer to zero using pointer-sized memory access (~ 30-40% faster than memset) @@ -169,7 +169,7 @@ int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uin } // Same as freenect_apply_registration, but don't bother aligning to the RGB image -int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm) +FN_INTERNAL int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm) { freenect_registration* reg = &(dev->registration); uint16_t unpack[8]; @@ -289,9 +289,9 @@ static void freenect_init_registration_table(int32_t (*registration_table)[2], f } // These are just constants. -double parameter_coefficient = 4; -double shift_scale = 10; -double pixel_size_factor = 1; +static double parameter_coefficient = 4; +static double shift_scale = 10; +static double pixel_size_factor = 1; /// convert raw shift value to metric depth (in mm) static uint16_t freenect_raw_to_mm(uint16_t raw, freenect_registration* reg) @@ -332,7 +332,7 @@ void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, doub /// Allocate and fill registration tables /// This function should be called every time a new video (not depth!) mode is /// activated. -int freenect_init_registration(freenect_device* dev) +FN_INTERNAL int freenect_init_registration(freenect_device* dev) { freenect_registration* reg = &(dev->registration); diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index b53d6f89..190d685e 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -33,7 +33,7 @@ #include "freenect_internal.h" #include "loader.h" -int fnusb_num_devices(fnusb_ctx *ctx) +FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) { libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices @@ -56,7 +56,7 @@ int fnusb_num_devices(fnusb_ctx *ctx) return nr; } -int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes** attribute_list) +FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes** attribute_list) { *attribute_list = NULL; // initialize some return value in case the user is careless. libusb_device **devs; @@ -116,7 +116,7 @@ int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attribut return num_cams; } -int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx) +FN_INTERNAL int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx) { int res; if (!usb_ctx) { @@ -137,7 +137,7 @@ int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx) } } -int fnusb_shutdown(fnusb_ctx *ctx) +FN_INTERNAL int fnusb_shutdown(fnusb_ctx *ctx) { //int res; if (ctx->should_free_ctx) { @@ -147,17 +147,17 @@ int fnusb_shutdown(fnusb_ctx *ctx) return 0; } -int fnusb_process_events(fnusb_ctx *ctx) +FN_INTERNAL int fnusb_process_events(fnusb_ctx *ctx) { return libusb_handle_events(ctx->ctx); } -int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout) +FN_INTERNAL int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout) { return libusb_handle_events_timeout(ctx->ctx, timeout); } -int fnusb_open_subdevices(freenect_device *dev, int index) +FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) { freenect_context *ctx = dev->parent; @@ -392,7 +392,7 @@ int fnusb_open_subdevices(freenect_device *dev, int index) } } -int fnusb_close_subdevices(freenect_device *dev) +FN_INTERNAL int fnusb_close_subdevices(freenect_device *dev) { if (dev->usb_cam.dev) { libusb_release_interface(dev->usb_cam.dev, 0); @@ -499,7 +499,7 @@ static void iso_callback(struct libusb_transfer *xfer) } } -int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len) +FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len) { freenect_context *ctx = dev->parent->parent; int ret, i; @@ -537,7 +537,7 @@ int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, in } -int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm) +FN_INTERNAL int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm) { freenect_context *ctx = dev->parent->parent; int i; @@ -568,17 +568,17 @@ int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm) return 0; } -int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength) +FN_INTERNAL int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength) { return libusb_control_transfer(dev->dev, bmRequestType, bRequest, wValue, wIndex, data, wLength, 0); } #ifdef BUILD_AUDIO -int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) { +FN_INTERNAL int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) { return libusb_bulk_transfer(dev->dev, endpoint, data, len, transferred, 0); } -int fnusb_num_interfaces(fnusb_dev *dev) { +FN_INTERNAL int fnusb_num_interfaces(fnusb_dev *dev) { int retval = 0; int res; libusb_device* d = libusb_get_device(dev->dev); From 3d735a89dfc380e8ff346a6815be2b54e4fafdfb Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 19 Jan 2012 12:16:20 +0100 Subject: [PATCH 06/36] Remove libusb.h include from libfreenect.h typedef freenect_usb_context as void, as it is already for win32. That way, we drop the need to have a properly installed developpement files of libusb when we don't use it directly. This fix also partly the problem of discrepancy between the include paths of libusb on freebsd and libusb-1.0 Signed-off-by: Nicolas Bourdaud --- include/libfreenect.h | 8 +------- src/libfreenect.pc.in | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index f0765f6f..7bd2b04d 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -156,13 +156,7 @@ struct _freenect_device; typedef struct _freenect_device freenect_device; /**< Holds device information. */ // usb backend specific section -#ifdef _WIN32 - /* frees Windows users of the burden of specifying the path to */ - typedef void freenect_usb_context; -#else - #include - typedef libusb_context freenect_usb_context; /**< Holds libusb-1.0 specific information */ -#endif +typedef void freenect_usb_context; /**< Holds libusb-1.0 context */ // /// If Win32, export all functions for DLL usage diff --git a/src/libfreenect.pc.in b/src/libfreenect.pc.in index 2e218996..1394cadb 100644 --- a/src/libfreenect.pc.in +++ b/src/libfreenect.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/@PROJECT_INCLUDE_INSTALL_DIR@ Name: @CMAKE_PROJECT_NAME@ Description: Interface to the Microsoft Kinect sensor device. -Requires: libusb-1.0 +Requires.private: libusb-1.0 Version: @PROJECT_APIVER@ Libs: -L${libdir} -lfreenect Cflags: -I${includedir} From 8219750df3a13501626a7f7f54d24afb8e64ec3f Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Thu, 19 Jan 2012 13:24:29 +0100 Subject: [PATCH 07/36] Fix cmake libusb search and fix libusb include Adjust cmake test for libusb library so that the compatible libusb for freebsd can be found. Since freebsd's libusb header are located in a different place from libusb-1.0, the includes in the source code must be adjusted using #include . Actually those new include statements are those that libusb-1.0 really expects to be used (see libusb-1.0.pc cflags to verify this). With this commit, libfreenect is buildable on freebsd. Signed-off-by: Nicolas Bourdaud --- cmake_modules/Findlibusb-1.0.cmake | 6 +++--- src/usb_libusb10.c | 2 +- src/usb_libusb10.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake_modules/Findlibusb-1.0.cmake b/cmake_modules/Findlibusb-1.0.cmake index 405ed516..ec40055a 100644 --- a/cmake_modules/Findlibusb-1.0.cmake +++ b/cmake_modules/Findlibusb-1.0.cmake @@ -49,7 +49,7 @@ if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) find_path(LIBUSB_1_INCLUDE_DIR NAMES - libusb-1.0/libusb.h + libusb.h PATHS /usr/include /usr/local/include @@ -61,7 +61,7 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) find_library(LIBUSB_1_LIBRARY NAMES - usb-1.0 + usb-1.0 usb PATHS /usr/lib /usr/local/lib @@ -95,4 +95,4 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES) -endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) \ No newline at end of file +endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 190d685e..1e29b6d8 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "freenect_internal.h" #include "loader.h" diff --git a/src/usb_libusb10.h b/src/usb_libusb10.h index 62a787a6..f2e0bd73 100644 --- a/src/usb_libusb10.h +++ b/src/usb_libusb10.h @@ -28,7 +28,7 @@ #define USB_LIBUSB10 #include "libfreenect.h" -#include +#include #if defined(__APPLE__) /* From 713c71574afc42d9a48bb621f34f6f8da730ed9b Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 5 Feb 2012 13:13:00 -0800 Subject: [PATCH 08/36] Fix build on Windows after changing includes from to Also obtain struct timeval from the winsock headers. Signed-off-by: Drew Fisher --- CMakeLists.txt | 2 +- include/libfreenect.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcd15c08..bc10ba9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ include_directories(${LIBUSB_1_INCLUDE_DIRS}) if(WIN32) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows") - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/libusb10emu") + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/libusb10emu/libusb-1.0") endif() # Add library project diff --git a/include/libfreenect.h b/include/libfreenect.h index 7bd2b04d..4dfb6b19 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -29,6 +29,13 @@ #include +/* We need struct timeval */ +#ifdef _WIN32 +#include +#else +#include +#endif + #ifdef __cplusplus extern "C" { #endif From 57956559635d679d7f7a1a10d9bc22252246c25b Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 5 Feb 2012 13:17:17 -0800 Subject: [PATCH 09/36] Use unions to perform safe type-punning. Signed-off-by: Drew Fisher --- src/cameras.c | 28 +++++++++++++++++++--------- src/freenect_internal.h | 20 ++++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/cameras.c b/src/cameras.c index 870be0b1..c9179d2a 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -910,15 +910,25 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) } memcpy(&(dev->registration.zero_plane_info), reply + 94, sizeof(dev->registration.zero_plane_info)); - uint32_t temp; - temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist))); - dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&temp)); - temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist))); - dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&temp)); - temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance))); - dev->registration.zero_plane_info.reference_distance = *((float*)(&temp)); - temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size))); - dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&temp)); + union { + uint32_t ui; + float f; + } conversion_union; + conversion_union.f = dev->registration.zero_plane_info.dcmos_emitter_dist; + conversion_union.ui = fn_le32(conversion_union.ui); + dev->registration.zero_plane_info.dcmos_emitter_dist = conversion_union.f; + + conversion_union.f = dev->registration.zero_plane_info.dcmos_rcmos_dist; + conversion_union.ui = fn_le32(conversion_union.ui); + dev->registration.zero_plane_info.dcmos_rcmos_dist = conversion_union.f; + + conversion_union.f = dev->registration.zero_plane_info.reference_distance; + conversion_union.ui = fn_le32(conversion_union.ui); + dev->registration.zero_plane_info.reference_distance = conversion_union.f; + + conversion_union.f = dev->registration.zero_plane_info.reference_pixel_size; + conversion_union.ui = fn_le32(conversion_union.ui); + dev->registration.zero_plane_info.reference_pixel_size = conversion_union.f; // WTF is all this data? it's way bigger than sizeof(XnFixedParams)... FN_SPEW("dcmos_emitter_distance: %f\n", dev->registration.zero_plane_info.dcmos_emitter_dist); diff --git a/src/freenect_internal.h b/src/freenect_internal.h index a68a9996..390e0612 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -96,16 +96,24 @@ static inline uint32_t fn_le32(uint32_t d) static inline int16_t fn_le16s(int16_t s) { // reinterpret cast to unsigned, use the normal fn_le16, and then reinterpret cast back - uint16_t temp = (*(uint16_t*)(&s)); - temp = fn_le16(temp); - return *((int16_t*)(&temp)); + union { + int16_t s; + uint16_t u; + } conversion_union; + conversion_union.s = s; + conversion_union.u = fn_le16(conversion_union.u); + return conversion_union.s; } static inline int32_t fn_le32s(int32_t s) { // reinterpret cast to unsigned, use the normal fn_le32, and then reinterpret cast back - uint32_t temp = (*(uint32_t*)(&s)); - temp = fn_le32(temp); - return *((int32_t*)(&temp)); + union { + int32_t s; + uint32_t u; + } conversion_union; + conversion_union.s = s; + conversion_union.u = fn_le32(conversion_union.u); + return conversion_union.s; } #else #define fn_le16(x) (x) From 071f51e55f565926c2661de7a615619ce229cd7e Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Wed, 7 Mar 2012 21:45:47 -0800 Subject: [PATCH 10/36] Make fakenect work on Windows. We needed platform-specific functions for mkdir(), timers, and we need to open files in binary mode for compatibility. Signed-off-by: Drew Fisher --- fakenect/fakenect.c | 29 +++++++++++++++++++++++++++-- fakenect/record.c | 8 ++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/fakenect/fakenect.c b/fakenect/fakenect.c index a3697ab6..3f8e34b6 100644 --- a/fakenect/fakenect.c +++ b/fakenect/fakenect.c @@ -31,6 +31,9 @@ #include #include #include +#ifdef _WIN32 +#include +#endif #define GRAVITY 9.80665 @@ -54,19 +57,41 @@ static void *user_ptr = NULL; static void sleep_highres(double tm) { +#ifdef _WIN32 + int msec = floor(tm * 1000); + if (msec > 0) { + Sleep(msec); + } +#else int sec = floor(tm); int usec = (tm - sec) * 1000000; if (tm > 0) { sleep(sec); usleep(usec); } +#endif } static double get_time() { +#ifdef _WIN32 + SYSTEMTIME st; + GetSystemTime(&st); + FILETIME ft; + SystemTimeToFileTime(&st, &ft); + ULARGE_INTEGER li; + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + // FILETIME is given as a 64-bit value for the number of 100-nanosecond + // intervals that have passed since Jan 1, 1601 (UTC). The difference between that + // epoch and the POSIX epoch (Jan 1, 1970) is 116444736000000000 such ticks. + uint64_t total_usecs = (li.QuadPart - 116444736000000000L) / 10L; + return (total_usecs / 1000000.); +#else struct timeval cur; gettimeofday(&cur, NULL); return cur.tv_sec + cur.tv_usec / 1000000.; +#endif } static char *one_line(FILE *fp) @@ -107,7 +132,7 @@ static int parse_line(char *type, double *cur_time, unsigned int *timestamp, uns char *file_path = malloc(file_path_size); snprintf(file_path, file_path_size, "%s/%s", input_path, line); // Open file - FILE *cur_fp = fopen(file_path, "r"); + FILE *cur_fp = fopen(file_path, "rb"); if (!cur_fp) { printf("Error: Cannot open file [%s]\n", file_path); exit(1); @@ -136,7 +161,7 @@ static void open_index() int index_path_size = strlen(input_path) + 50; char *index_path = malloc(index_path_size); snprintf(index_path, index_path_size, "%s/INDEX.txt", input_path); - index_fp = fopen(index_path, "r"); + index_fp = fopen(index_path, "rb"); if (!index_fp) { printf("Error: Cannot open file [%s]\n", index_path); exit(1); diff --git a/fakenect/record.c b/fakenect/record.c index e588d0a7..9546995f 100644 --- a/fakenect/record.c +++ b/fakenect/record.c @@ -73,7 +73,7 @@ FILE *open_dump(char type, double cur_time, uint32_t timestamp, int data_size, c sprintf(fn, "%c-%f-%u.%s", type, cur_time, timestamp, extension); fprintf(index_fp, "%s\n", fn); sprintf(fn, "%s/%c-%f-%u.%s", out_dir, type, cur_time, timestamp, extension); - FILE* fp = fopen(fn, "w"); + FILE* fp = fopen(fn, "wb"); if (!fp) { printf("Error: Cannot open file [%s]\n", fn); exit(1); @@ -254,7 +254,7 @@ FILE *open_index(const char *fn) "use a different directory.\n"); return 0; } - fp = fopen(fn, "w"); + fp = fopen(fn, "wb"); if (!fp) { printf("Error: Cannot open file [%s]\n", fn); return 0; @@ -333,7 +333,11 @@ int main(int argc, char **argv) if (rgb_stream) fclose(rgb_stream); fclose(index_fp); } else { +#ifdef _WIN32 + _mkdir(out_dir); +#else mkdir(out_dir, S_IRWXU | S_IRWXG | S_IRWXO); +#endif char *fn = malloc(strlen(out_dir) + 50); sprintf(fn, "%s/INDEX.txt", out_dir); index_fp = open_index(fn); From 6e6015cd996170234252b1ef4470513b3b1afab1 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 28 Feb 2012 14:59:14 +0100 Subject: [PATCH 11/36] examples: call freenect_shutdown() on exit This is mostly useful when using tools like valgrind, which may report possibly lost memory even if the operating systems is going to get it back anyway on the actual process exit. Signed-off-by: Antonio Ospite --- examples/glview.c | 6 +++++- examples/hiview.c | 6 +++++- examples/micview.c | 6 +++++- examples/regview.c | 6 +++++- examples/wavrecord.c | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/examples/glview.c b/examples/glview.c index c7f7dca3..979546de 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -421,17 +421,21 @@ int main(int argc, char **argv) if (argc > 1) user_device_number = atoi(argv[1]); - if (nr_devices < 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; } diff --git a/examples/hiview.c b/examples/hiview.c index 90c74e24..40080099 100644 --- a/examples/hiview.c +++ b/examples/hiview.c @@ -445,17 +445,21 @@ int main(int argc, char **argv) if (argc > 1) user_device_number = atoi(argv[1]); - if (nr_devices < 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; } diff --git a/examples/micview.c b/examples/micview.c index 665664da..280c6d81 100644 --- a/examples/micview.c +++ b/examples/micview.c @@ -161,12 +161,15 @@ int main(int argc, char** argv) { int nr_devices = freenect_num_devices (f_ctx); printf ("Number of devices found: %d\n", nr_devices); - if (nr_devices < 1) + 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; } @@ -188,6 +191,7 @@ int main(int argc, char** argv) { int res = pthread_create(&freenect_thread, NULL, freenect_threadfunc, NULL); if (res) { printf("pthread_create failed\n"); + freenect_shutdown(f_ctx); return 1; } printf("This is the libfreenect microphone waveform viewer. Press 'q' to quit or spacebar to pause/unpause the view.\n"); diff --git a/examples/regview.c b/examples/regview.c index 591b6541..1bd2281c 100644 --- a/examples/regview.c +++ b/examples/regview.c @@ -363,17 +363,21 @@ int main(int argc, char **argv) if (argc > 1) user_device_number = atoi(argv[1]); - if (nr_devices < 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; } diff --git a/examples/wavrecord.c b/examples/wavrecord.c index 0b474164..c7abc697 100644 --- a/examples/wavrecord.c +++ b/examples/wavrecord.c @@ -80,12 +80,15 @@ int main(int argc, char** argv) { int nr_devices = freenect_num_devices (f_ctx); printf ("Number of devices found: %d\n", nr_devices); - if (nr_devices < 1) + 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; } @@ -135,5 +138,6 @@ int main(int argc, char** argv) { fclose(state.logfiles[i]); } + freenect_shutdown(f_ctx); return 0; } From 7205faad0ca6f9bb0a514ab5b1e3bd46f840ba53 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 28 Feb 2012 14:59:15 +0100 Subject: [PATCH 12/36] freenect: avoid leaking the context when fnusb_init() fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maybe this is more a theoretical issue than an actual one, I am not sure in which case fnusb_init() —and hence libusb_init()— is supposed to fail, but let's handle that once I noticed it. Signed-off-by: Antonio Ospite --- src/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index d46e7d73..ecc5942f 100644 --- a/src/core.c +++ b/src/core.c @@ -40,6 +40,8 @@ FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx) { + int res; + *ctx = (freenect_context*)malloc(sizeof(freenect_context)); if (!ctx) return -1; @@ -52,7 +54,12 @@ FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ | FREENECT_DEVICE_AUDIO #endif ); - return fnusb_init(&(*ctx)->usb, usb_ctx); + res = fnusb_init(&(*ctx)->usb, usb_ctx); + if (res < 0) { + free(*ctx); + *ctx = NULL; + } + return res; } FREENECTAPI int freenect_shutdown(freenect_context *ctx) From 05bca9f5d089133083c4c474bddcf6c8ab63bab0 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 28 Feb 2012 14:59:16 +0100 Subject: [PATCH 13/36] freenect: initialize the 'transferred' variable used in bulk transfers This is in order to make the printouts in the error path of the callers of fnusb_bulk() show a saner value when libusb does not touch the variable (i.e. when a transfer fails). Signed-off-by: Antonio Ospite --- src/usb_libusb10.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 1e29b6d8..4a95e02b 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -575,6 +575,7 @@ FN_INTERNAL int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRe #ifdef BUILD_AUDIO FN_INTERNAL int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) { + *transferred = 0; return libusb_bulk_transfer(dev->dev, endpoint, data, len, transferred, 0); } From f8a55ddcfca7a9a03b3adbc0ded4707232113874 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Wed, 22 Feb 2012 18:24:40 +0100 Subject: [PATCH 14/36] Search for threading lib on any platform in c_sync Threading library is necessary for all platform when compiling c_sync wrapper. Moving the search fix the missing library on Linux. Signed-off-by: Nicolas Bourdaud --- wrappers/c_sync/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wrappers/c_sync/CMakeLists.txt b/wrappers/c_sync/CMakeLists.txt index d85256f6..051453f2 100644 --- a/wrappers/c_sync/CMakeLists.txt +++ b/wrappers/c_sync/CMakeLists.txt @@ -3,12 +3,12 @@ ###################################################################################### if (WIN32) set_source_files_properties(libfreenect_sync.c PROPERTIES LANGUAGE CXX) - set(THREADS_USE_PTHREADS_WIN32 true) - find_package(Threads REQUIRED) - include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) endif() +find_package(Threads REQUIRED) +include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) + add_library (freenect_sync SHARED libfreenect_sync.c) add_library (freenect_sync_static STATIC libfreenect_sync.c) set_target_properties (freenect_sync_static PROPERTIES OUTPUT_NAME freenect_sync) @@ -25,4 +25,5 @@ install (TARGETS freenect_sync install (TARGETS freenect_sync_static DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}") install (FILES "libfreenect_sync.h" - DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) \ No newline at end of file + DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR}) + From ad42c6f1f96cb5561a5ca0baec47536d58a006ab Mon Sep 17 00:00:00 2001 From: Nicolas Bourdaud Date: Wed, 22 Feb 2012 18:35:19 +0100 Subject: [PATCH 15/36] Add missing math lib to fakenect Fix the missing dependency of fakenect on the math lib and remove the unecessary one of record. On the way centralizes definition of MATH_LIB since several wrappers and examples uses it. Signed-off-by: Nicolas Bourdaud --- CMakeLists.txt | 6 ++++++ examples/CMakeLists.txt | 6 ------ fakenect/CMakeLists.txt | 3 ++- wrappers/actionscript/CMakeLists.txt | 6 ------ wrappers/cpp/CMakeLists.txt | 6 ------ 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc10ba9a..e7aa066e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,12 @@ if(BUILD_AUDIO) add_definitions(-DBUILD_AUDIO) endif() +if (WIN32) + set(MATH_LIB "") +else(WIN32) + set(MATH_LIB "m") +endif() + ###################################################################################### # CMake ###################################################################################### diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index dc15b79f..13c98fc4 100755 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -58,12 +58,6 @@ else() include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) - if (WIN32) - set(MATH_LIB "") - else(WIN32) - set(MATH_LIB "m") - endif() - target_link_libraries(glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(hiview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) diff --git a/fakenect/CMakeLists.txt b/fakenect/CMakeLists.txt index b9f3adc3..9d6aea8b 100644 --- a/fakenect/CMakeLists.txt +++ b/fakenect/CMakeLists.txt @@ -8,12 +8,13 @@ set_target_properties ( fakenect PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} OUTPUT_NAME freenect) +target_link_libraries(fakenect ${MATH_LIB}) install (TARGETS fakenect DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/fakenect") add_executable(record record.c) -target_link_libraries(record freenect m) +target_link_libraries(record freenect) install (TARGETS record DESTINATION bin) diff --git a/wrappers/actionscript/CMakeLists.txt b/wrappers/actionscript/CMakeLists.txt index a9cd92b9..00c7118e 100755 --- a/wrappers/actionscript/CMakeLists.txt +++ b/wrappers/actionscript/CMakeLists.txt @@ -25,12 +25,6 @@ if(APPLE) set(CMAKE_EXE_LINKER_FLAGS "-framework CoreFoundation -framework IOKit") else(APPLE) find_package(Threads REQUIRED) - if (WIN32) - set(MATH_LIB "") - else(WIN32) - set(MATH_LIB "m") - endif() - endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../wrappers/c_sync) diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index e22ed2f1..bb9c53cb 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -27,12 +27,6 @@ else() include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) - if (WIN32) - set(MATH_LIB "") - else(WIN32) - set(MATH_LIB "m") - endif() - target_link_libraries(cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) endif() From efd073eacfc54a7c028729596858d1618e134b16 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Fri, 16 Mar 2012 16:27:47 -0700 Subject: [PATCH 16/36] windows: libusb-win32 renamed their header; change the include accordingly In libusb-win32 1.2.5.0, the developers changed their header from usb.h to lusb0_usb.h to avoid a name conflict with the WDK usb.h header, which apparently causes issues with MinGW-w64. Signed-off-by: Drew Fisher --- platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h b/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h index 3d9c674b..162899a6 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h @@ -28,7 +28,7 @@ #define LIBUSB_EMULATOR_INTERNAL_H #include "libusbemu_threads.h" -#include +#include #include #include From 9807cfea158110eca04ac0fb98cede8fbea589c6 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Thu, 22 Mar 2012 12:29:02 -0700 Subject: [PATCH 17/36] freenect.pyx: add FREENECT_DEPTH_{MM,REGISTERED} support Signed-off-by: Drew Fisher --- wrappers/python/freenect.pyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wrappers/python/freenect.pyx b/wrappers/python/freenect.pyx index c76ba301..162561f5 100644 --- a/wrappers/python/freenect.pyx +++ b/wrappers/python/freenect.pyx @@ -49,6 +49,8 @@ cdef extern from "libfreenect.h": FREENECT_DEPTH_10BIT FREENECT_DEPTH_11BIT_PACKED FREENECT_DEPTH_10BIT_PACKED + FREENECT_DEPTH_REGISTERED + FREENECT_DEPTH_MM ctypedef enum freenect_led_options: FREENECT_LED_OFF "LED_OFF" @@ -148,6 +150,8 @@ DEPTH_11BIT = FREENECT_DEPTH_11BIT DEPTH_10BIT = FREENECT_DEPTH_10BIT DEPTH_11BIT_PACKED = FREENECT_DEPTH_11BIT_PACKED DEPTH_10BIT_PACKED = FREENECT_DEPTH_10BIT_PACKED +DEPTH_REGISTERED = FREENECT_DEPTH_REGISTERED +DEPTH_MM = FREENECT_DEPTH_MM LED_OFF = FREENECT_LED_OFF LED_GREEN = FREENECT_LED_GREEN LED_RED = FREENECT_LED_RED @@ -476,7 +480,7 @@ def sync_get_depth(index=0, format=DEPTH_11BIT): if out: error_open_device() return - if format == DEPTH_11BIT: + if format in [DEPTH_11BIT, DEPTH_10BIT, DEPTH_MM, DEPTH_REGISTERED]: dims[0], dims[1] = 480, 640 return PyArray_SimpleNewFromData(2, dims, npc.NPY_UINT16, data), timestamp else: From 8160ddd1fa524423e141a52f73047007d7ac23d5 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sat, 24 Mar 2012 18:31:13 -0700 Subject: [PATCH 18/36] audio firmware loader: use the structure of the firmware image format to specify size/addresses Signed-off-by: Drew Fisher --- src/loader.c | 39 +++++++++++++++++++++++++++++++++++---- src/loader.h | 11 +++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/loader.c b/src/loader.c index f5bf0585..0451b1fb 100644 --- a/src/loader.c +++ b/src/loader.c @@ -193,11 +193,37 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { return -errno; } // Now we have an open firmware file handle. - uint32_t addr = 0x00080000; - int read; + firmware_header fwheader; + int read = 0; + read = fread(&fwheader, 1, sizeof(firmware_header), fw); + if (read != sizeof(firmware_header)) { + FN_ERROR("upload_firmware: firmware image too small, has no header?\n"); + fclose(fw); + return -errno; + } + // The file is serialized as little endian. + fwheader.magic = fn_le32(fwheader.magic); + fwheader.ver_major = fn_le16(fwheader.ver_major); + fwheader.ver_minor = fn_le16(fwheader.ver_minor); + fwheader.ver_release = fn_le16(fwheader.ver_release); + fwheader.ver_patch = fn_le16(fwheader.ver_patch); + fwheader.base_addr = fn_le32(fwheader.base_addr); + fwheader.size = fn_le32(fwheader.size); + fwheader.entry_addr = fn_le32(fwheader.entry_addr); + FN_INFO("Found firmware image:\n"); + FN_INFO("\tmagic %08X\n", fwheader.magic); + FN_INFO("\tversion %02d.%02d.%02d.%02d\n", fwheader.ver_major, fwheader.ver_minor, fwheader.ver_release, fwheader.ver_patch); + FN_INFO("\tbase address 0x%08x\n", fwheader.base_addr); + FN_INFO("\tsize 0x%08x\n", fwheader.size); + FN_INFO("\tentry point 0x%08x\n", fwheader.entry_addr); + + rewind(fw); + uint32_t addr = fwheader.base_addr; unsigned char page[0x4000]; + int total_bytes_sent = 0; do { - read = fread(page, 1, 0x4000, fw); + size_t block_size = (0x4000 > fwheader.size - total_bytes_sent) ? fwheader.size - total_bytes_sent : 0x4000; + read = fread(page, 1, block_size, fw); if(read <= 0) { break; } @@ -224,6 +250,7 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { return -1; } bytes_sent += to_send; + total_bytes_sent += to_send; } res = get_reply(dev); addr += (uint32_t)read; @@ -231,11 +258,15 @@ FN_INTERNAL int upload_firmware(fnusb_dev* dev) { } while (read > 0); fclose(fw); fw = NULL; + if (total_bytes_sent != fwheader.size) { + FN_ERROR("upload_firmware: firmware image declared %d bytes, but file only contained %d bytes\n", fwheader.size, total_bytes_sent); + return -1; + } bootcmd.tag = fn_le32(dev->parent->audio_tag); bootcmd.bytes = fn_le32(0); bootcmd.cmd = fn_le32(0x04); - bootcmd.addr = fn_le32(0x00080030); + bootcmd.addr = fn_le32(fwheader.entry_addr); dump_bl_cmd(ctx, bootcmd); res = fnusb_bulk(dev, 1, (unsigned char*)&bootcmd, sizeof(bootcmd), &transferred); if(res != 0 || transferred != sizeof(bootcmd)) { diff --git a/src/loader.h b/src/loader.h index 82782205..dcec08aa 100644 --- a/src/loader.h +++ b/src/loader.h @@ -39,6 +39,17 @@ typedef struct { uint32_t unk; } bootloader_command; +typedef struct { + uint32_t magic; // Magic bytes. 2BL uses 0xF00BACCA, audios uses 0xCA77F00D + uint16_t ver_minor; // The version string has four parts, each a 16-bit little-endian int. + uint16_t ver_major; // Yes, minor comes before major. + uint16_t ver_release; // + uint16_t ver_patch; // + uint32_t base_addr; // Base address of firmware image. 2BL starts at 0x10000, audios starts at 0x80000. + uint32_t size; // Size of firmware image, in bytes + uint32_t entry_addr; // Code entry point (absolute address) +} firmware_header; + typedef struct { uint32_t magic; uint32_t tag; From 6140a46d06c9600b2b0ed52febdbe7b7b91625fa Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sat, 24 Mar 2012 18:34:06 -0700 Subject: [PATCH 19/36] wavrecord.c: initialize sample count to 0 Signed-off-by: Drew Fisher --- examples/wavrecord.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/wavrecord.c b/examples/wavrecord.c index c7abc697..655b39ef 100644 --- a/examples/wavrecord.c +++ b/examples/wavrecord.c @@ -93,6 +93,7 @@ int main(int argc, char** argv) { } capture state; + state.samples = 0; state.logfiles[0] = fopen("channel1.wav", "wb"); state.logfiles[1] = fopen("channel2.wav", "wb"); state.logfiles[2] = fopen("channel3.wav", "wb"); From 16afaf845eabb75c9dd4c0d77ed3330f85027af6 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Thu, 29 Mar 2012 11:55:04 -0700 Subject: [PATCH 20/36] examples: GLUT_INCLUDE_DIRS -> GLUT_INCLUDE_DIR We had misspelled the environment variable in CMakeLists.txt. Reported by Ski-lleR on github. Signed-off-by: Drew Fisher --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 examples/CMakeLists.txt diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt old mode 100755 new mode 100644 index 13c98fc4..506ca9bd --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -56,7 +56,7 @@ else() find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) - include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) + include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) target_link_libraries(glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) From 3ec5265ca37f11df610d668a3d16b304250a9d73 Mon Sep 17 00:00:00 2001 From: Ben Stolovitz Date: Fri, 8 Jun 2012 10:29:43 -0300 Subject: [PATCH 21/36] Added missing dependencies - libtool - automake --- platform/osx/homebrew/libusb-freenect.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/osx/homebrew/libusb-freenect.rb b/platform/osx/homebrew/libusb-freenect.rb index 4d7a101d..63924108 100644 --- a/platform/osx/homebrew/libusb-freenect.rb +++ b/platform/osx/homebrew/libusb-freenect.rb @@ -5,6 +5,10 @@ class LibusbFreenect Date: Mon, 19 Nov 2012 21:19:29 -0500 Subject: [PATCH 22/36] Adding to C++ wrapper a method to access the underlying freenect_device Signed-off-by: Joseph J Dillon josephd --- wrappers/cpp/libfreenect.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 0a5f637e..cb1c1d13 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -132,6 +132,9 @@ namespace Freenect { freenect_resolution getDepthResolution() { return m_depth_resolution; } + const freenect_device *getDevice() { + return m_dev; + } // Do not call directly even in child virtual void VideoCallback(void *video, uint32_t timestamp) = 0; // Do not call directly even in child From 55451aa61f60519fa9c691113820fbb8e985b8f1 Mon Sep 17 00:00:00 2001 From: John Scheible Date: Wed, 28 Nov 2012 23:56:17 -0500 Subject: [PATCH 23/36] FrameMode now implements getFieldOrder() to be compatible with new versions of jna. Signed-off-by: John Scheible johnscheible@gmail.com --- .../main/java/org/openkinect/freenect/FrameMode.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wrappers/java/src/main/java/org/openkinect/freenect/FrameMode.java b/wrappers/java/src/main/java/org/openkinect/freenect/FrameMode.java index b04ea8da..f18aa6f1 100644 --- a/wrappers/java/src/main/java/org/openkinect/freenect/FrameMode.java +++ b/wrappers/java/src/main/java/org/openkinect/freenect/FrameMode.java @@ -25,6 +25,8 @@ package org.openkinect.freenect; import com.sun.jna.Structure; +import java.util.List; +import java.util.Arrays; public class FrameMode extends Structure { /* All fields are public because Structure requires it. @@ -41,6 +43,12 @@ public FrameMode() { valid = 0; } + protected List getFieldOrder() { + return Arrays.asList(new String[] {"reserved", "resolution", "format", + "bytes", "width", "height", "dataBitsPerPixel", + "paddingBitsPerPixel", "framerate", "valid"}); + } + public Resolution getResolution() { return Resolution.fromInt(resolution); } @@ -74,4 +82,4 @@ public boolean isValid() { } public static class ByValue extends FrameMode implements Structure.ByValue { } -} \ No newline at end of file +} From d1d19df8957f8d63a562b310413da15d3e6ef7a1 Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Thu, 6 Dec 2012 12:11:47 +0100 Subject: [PATCH 24/36] handle error case on USB 3.0: control transfer may return 512 bytes Signed-off-by: Florian Echtler --- src/cameras.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cameras.c b/src/cameras.c index c9179d2a..7886a332 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -688,7 +688,8 @@ static int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsigned i do { actual_len = fnusb_control(&dev->usb_cam, 0xc0, 0, 0, 0, ibuf, 0x200); - } while (actual_len == 0); + FN_FLOOD("actual_len: %d\n", actual_len); + } while ((actual_len == 0) || (actual_len == 0x200)); FN_SPEW("Control reply: %d\n", res); if (actual_len < (int)sizeof(*rhdr)) { FN_ERROR("send_cmd: Input control transfer failed (%d)\n", res); From a6c5dd0e91c26c0bfef756cf947bba14a4c9af7c Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Fri, 14 Jun 2013 23:17:00 -0400 Subject: [PATCH 25/36] Removed libusb patch already merged upstream Signed-off-by: Benn Snyder --- README.asciidoc | 35 ++---- platform/osx/homebrew/libfreenect.rb | 4 +- platform/osx/homebrew/libusb-freenect.rb | 23 ---- platform/osx/libusb-osx-kinect.diff | 132 ----------------------- 4 files changed, 8 insertions(+), 186 deletions(-) delete mode 100644 platform/osx/homebrew/libusb-freenect.rb delete mode 100644 platform/osx/libusb-osx-kinect.diff diff --git a/README.asciidoc b/README.asciidoc index 010db285..18e0b34b 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -43,7 +43,7 @@ http://twitter.com/openkinect For the driver, you'll need -- libusb-1.0 >= 1.0.3 (*nix and OS X) +- libusb-1.0 >= 1.0.9 (*nix and OS X) - libusb-win32 (Windows) - Cmake >= 2.6 (All platforms) @@ -73,33 +73,9 @@ To use CMake: ==== OS X -NOTE: AS OF 2010-11-16, WE HAVE UPDATED THIS PATCH. IF YOU HAVE -ALREADY PATCHED, PLEASE REPATCH AND REINSTALL LIBUSB TO GET OS X -WORKING AT FULL 30FPS. - -You will need to pull the matching version of libusb for this -patch. This is NOT v1.0.8, this is a change based off the repo head as -of 2010-10-16. To get a tar.gz with the snapshot of the repo at this -point, hit the link below. - -http://git.libusb.org/?p=libusb.git;a=snapshot;h=7da756e09fd97efad2b35b5cee0e2b2550aac2cb;sf=tgz;js=1 - -Once you've gotten that tarball and unziped it somewhere, patch using -the files in platform/osx/. Just go to the root directory of the -libusb source and run - -patch -p1 < [path_to_OpenKinectRepo]/platform/osx/libusb-osx-kinect.diff - -You need to tell configure to include some necessary frameworks: -./configure LDFLAGS='-framework IOKit -framework CoreFoundation' - -Recompile libusb and put it wherever CMake will look (/usr/local/lib, -/usr/lib, etc...). If you're using a package manager like fink, -macports, or homebrew, I'm going to expect you know what your doing -and can deal with this. If not, see IRC channel. - -OpenGL and GLUT come as prebuilt frameworks with OS X, so that should -do it for requirements. +libusb is available through various package managers +including homebrew and Macports. +OpenGL and GLUT come as prebuilt frameworks. ==== Linux @@ -128,9 +104,10 @@ libfreenect has interface to several languages. Look in the wrappers/ directory for them: - C (using a synchronous API) +- C++ +- C# - python - actionscript -- C# - Java (JNA) === Licensing diff --git a/platform/osx/homebrew/libfreenect.rb b/platform/osx/homebrew/libfreenect.rb index 3685d6ad..48e00b20 100644 --- a/platform/osx/homebrew/libfreenect.rb +++ b/platform/osx/homebrew/libfreenect.rb @@ -6,8 +6,8 @@ class Libfreenect :build def install mkdir "build" diff --git a/platform/osx/homebrew/libusb-freenect.rb b/platform/osx/homebrew/libusb-freenect.rb deleted file mode 100644 index 63924108..00000000 --- a/platform/osx/homebrew/libusb-freenect.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'formula' - -class LibusbFreenect interface))->WritePipeAsync(cInterface->interface, pipeRef, transfer->buffer, - transfer->length, darwin_async_io_callback, itransfer); - } else { -+ itransfer->flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT; -+ - if (is_read) - ret = (*(cInterface->interface))->ReadPipeAsyncTO(cInterface->interface, pipeRef, transfer->buffer, - transfer->length, transfer->timeout, transfer->timeout, -@@ -1171,10 +1173,19 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { - /* are we reading or writing? */ - is_read = transfer->endpoint & LIBUSB_ENDPOINT_IN; - -- /* construct an array of IOUSBIsocFrames */ -- tpriv->isoc_framelist = (IOUSBIsocFrame*) calloc (transfer->num_iso_packets, sizeof(IOUSBIsocFrame)); -- if (!tpriv->isoc_framelist) -- return LIBUSB_ERROR_NO_MEM; -+ /* construct an array of IOUSBIsocFrames, reuse the old one if possible */ -+ if (tpriv->isoc_framelist != NULL && tpriv->num_iso_packets != transfer->num_iso_packets) -+ { -+ free(tpriv->isoc_framelist); -+ tpriv->isoc_framelist = NULL; -+ } -+ if (tpriv->isoc_framelist == NULL) -+ { -+ tpriv->isoc_framelist = (IOUSBIsocFrame*) calloc (transfer->num_iso_packets, sizeof(IOUSBIsocFrame)); -+ tpriv->num_iso_packets = transfer->num_iso_packets; -+ if (!tpriv->isoc_framelist) -+ return LIBUSB_ERROR_NO_MEM; -+ } - - /* copy the frame list from the libusb descriptor (the structures differ only is member order) */ - for (i = 0 ; i < transfer->num_iso_packets ; i++) -@@ -1198,9 +1209,11 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { - - return darwin_to_libusb (kresult); - } -- - /* schedule for a frame a little in the future */ -- frame += 2; -+ frame += 4; -+ -+ if(cInterface->frames[transfer->endpoint] && frame < cInterface->frames[transfer->endpoint]) -+ frame = cInterface->frames[transfer->endpoint]; - - /* submit the request */ - if (is_read) -@@ -1211,6 +1224,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { - kresult = (*(cInterface->interface))->WriteIsochPipeAsync(cInterface->interface, pipeRef, transfer->buffer, frame, - transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback, - itransfer); -+ cInterface->frames[transfer->endpoint] = frame + transfer->num_iso_packets / 8; - - if (kresult != kIOReturnSuccess) { - usbi_err (TRANSFER_CTX (transfer), "isochronous transfer failed (dir: %s): %s", is_read ? "In" : "Out", -@@ -1243,6 +1257,8 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) { - tpriv->req.pData = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE; - tpriv->req.completionTimeout = transfer->timeout; - tpriv->req.noDataTimeout = transfer->timeout; -+ -+ itransfer->flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT; - - /* all transfers in libusb-1.0 are async */ - kresult = (*(dpriv->device))->DeviceRequestAsyncTO(dpriv->device, &(tpriv->req), darwin_async_io_callback, itransfer); -@@ -1358,6 +1374,9 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0) - } - - static int darwin_transfer_status (struct usbi_transfer *itransfer, kern_return_t result) { -+ if (itransfer->flags & USBI_TRANSFER_TIMED_OUT) -+ result = kIOUSBTransactionTimeout; -+ - switch (result) { - case kIOReturnUnderrun: - case kIOReturnSuccess: -@@ -1372,6 +1391,7 @@ static int darwin_transfer_status (struct usbi_transfer *itransfer, kern_return_ - return LIBUSB_TRANSFER_OVERFLOW; - case kIOUSBTransactionTimeout: - usbi_err (ITRANSFER_CTX (itransfer), "transfer error: timed out"); -+ itransfer->flags |= USBI_TRANSFER_TIMED_OUT; - return LIBUSB_TRANSFER_TIMED_OUT; - default: - usbi_err (ITRANSFER_CTX (itransfer), "transfer error: %s (value = 0x%08x)", darwin_error_str (result), result); -diff --git a/libusb/os/darwin_usb.h b/libusb/os/darwin_usb.h -index a71d464..4aadf8c 100644 ---- a/libusb/os/darwin_usb.h -+++ b/libusb/os/darwin_usb.h -@@ -139,6 +139,7 @@ struct darwin_device_handle_priv { - usb_interface_t **interface; - uint8_t num_endpoints; - CFRunLoopSourceRef cfSource; -+ UInt64 frames[256]; - uint8_t endpoint_addrs[USB_MAXENDPOINTS]; - } interfaces[USB_MAXINTERFACES]; - }; -@@ -146,6 +147,7 @@ struct darwin_device_handle_priv { - struct darwin_transfer_priv { - /* Isoc */ - IOUSBIsocFrame *isoc_framelist; -+ size_t num_iso_packets; - - /* Control */ - #if !defined (LIBUSB_NO_TIMEOUT_DEVICE) \ No newline at end of file From 287bc2e7b9b31f6d90e0ca27af7b03e676bf1e6e Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 18 Jun 2013 20:31:25 -0400 Subject: [PATCH 26/36] Removed unused stdbool.h Replaced all include guards with '#pragma once' - fixes #296 Signed-off-by: Benn Snyder --- include/libfreenect-audio.h | 7 +---- include/libfreenect-registration.h | 5 +--- include/libfreenect.h | 6 +--- platform/windows/README.TXT | 10 +++---- .../libusb10emu/libusb-1.0/failguard.h | 5 +--- .../windows/libusb10emu/libusb-1.0/libusb.h | 5 +--- .../libusb-1.0/libusbemu_internal.h | 5 +--- .../libusb-1.0/libusbemu_threads.h | 7 ++--- .../libusb-1.0/libusbemu_threads_win32.h | 5 +--- platform/windows/stdbool.h | 30 ------------------- platform/windows/unistd.h | 5 +--- src/cameras.h | 6 +--- src/freenect_internal.h | 5 +--- src/loader.h | 5 +--- src/registration.h | 5 +--- src/usb_libusb10.c | 1 - src/usb_libusb10.h | 5 +--- wrappers/actionscript/server/as3_jpeg.h | 5 +--- .../actionscript/server/freenect_network.h | 5 +--- wrappers/c_sync/libfreenect_sync.h | 6 ++-- wrappers/opencv/libfreenect_cv.h | 5 +--- 21 files changed, 24 insertions(+), 114 deletions(-) delete mode 100644 platform/windows/stdbool.h diff --git a/include/libfreenect-audio.h b/include/libfreenect-audio.h index 3f2febab..108cf381 100644 --- a/include/libfreenect-audio.h +++ b/include/libfreenect-audio.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBFREENECT_AUDIO_H -#define LIBFREENECT_AUDIO_H +#pragma once #include #include @@ -114,7 +113,3 @@ FREENECTAPI int freenect_stop_audio(freenect_device* dev); #ifdef __cplusplus } #endif - -#endif // - - diff --git a/include/libfreenect-registration.h b/include/libfreenect-registration.h index 2ef5d609..7ad2b5bb 100644 --- a/include/libfreenect-registration.h +++ b/include/libfreenect-registration.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBFREENECT_REGISTRATION_H -#define LIBFREENECT_REGISTRATION_H +#pragma once #include #include @@ -125,5 +124,3 @@ FREENECTAPI void freenect_camera_to_world(freenect_device* dev, #ifdef __cplusplus } #endif - -#endif // LIBFREENECT_REGISTRATION_H diff --git a/include/libfreenect.h b/include/libfreenect.h index 4dfb6b19..13c7c4c5 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBFREENECT_H -#define LIBFREENECT_H +#pragma once #include @@ -618,6 +617,3 @@ FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_fra #ifdef __cplusplus } #endif - -#endif // - diff --git a/platform/windows/README.TXT b/platform/windows/README.TXT index f580e50c..65df1bc0 100644 --- a/platform/windows/README.TXT +++ b/platform/windows/README.TXT @@ -64,12 +64,10 @@ on using the C-compiler to compile .c files (this happens with MSVC versions pri 2010). To work around this, just set the "Compile As" to "Default", click "Apply" and then set it back to "Compile as C++ Code (/TP)", click "Apply" and then "OK". -Another problem is that Visual C++ does not offer the and -headers. However, they are pretty simple to be emulated; the will -actually be a dummy header because C++ already defines the "bool" type semantics, -while the has to simply #include and define the "ssize_t" -type. The implementation of these headers are located at: - "libfreenect\platform\windows" +Another problem is that Visual C++ does not offer . However, it +can be emulated by #include and defining the "ssize_t" type. +The implementation of is located at: + "libfreenect\platform\windows\unistd.h" NOTE: MSVC versions prior to 2010 do not provide the header. An ISO C9x compilant header for such MSVC versions can be found at the wikipedia entry diff --git a/platform/windows/libusb10emu/libusb-1.0/failguard.h b/platform/windows/libusb10emu/libusb-1.0/failguard.h index 3330aca6..da9bea79 100644 --- a/platform/windows/libusb10emu/libusb-1.0/failguard.h +++ b/platform/windows/libusb10emu/libusb-1.0/failguard.h @@ -1,5 +1,4 @@ -#ifndef LIBUSBEMU_FAIL_GUARD_H -#define LIBUSBEMU_FAIL_GUARD_H +#pragma once namespace libusbemu { @@ -12,5 +11,3 @@ namespace libusbemu const bool Abort(); } } - -#endif//LIBUSBEMU_FAIL_GUARD_H diff --git a/platform/windows/libusb10emu/libusb-1.0/libusb.h b/platform/windows/libusb10emu/libusb-1.0/libusb.h index 197e7886..33b32887 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusb.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusb.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBUSB_1_0_INTERFACE_EMULATOR_FOR_LIBUSB_0_1_H -#define LIBUSB_1_0_INTERFACE_EMULATOR_FOR_LIBUSB_0_1_H +#pragma once // This interface emulator requires the libusb-win32 v1.2.2.1 (snapshot) // or later. Prior win32 versions of the library were not conformal to @@ -198,5 +197,3 @@ enum libusb_error #ifdef __cplusplus } #endif - -#endif//LIBUSB_1_0_INTERFACE_EMULATOR_FOR_LIBUSB_0_1_H diff --git a/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h b/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h index 162899a6..1631d1a8 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusbemu_internal.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBUSB_EMULATOR_INTERNAL_H -#define LIBUSB_EMULATOR_INTERNAL_H +#pragma once #include "libusbemu_threads.h" #include @@ -413,5 +412,3 @@ void libusbemu_clear_transfer(transfer_wrapper* wrapper) } } // end of 'namespace libusbemu' - -#endif//LIBUSB_EMULATOR_INTERNAL_H diff --git a/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads.h b/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads.h index c0c83c74..daf03f64 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBUSBEMU_THREAD_INTERFACE_WRAPPER_H -#define LIBUSBEMU_THREAD_INTERFACE_WRAPPER_H +#pragma once // Wrappers for platform-specific thread/synchronization objects: // * Thread @@ -56,6 +55,4 @@ struct RAIIMutex ~RAIIMutex() { m_mutex.Leave(); } }; -}; - -#endif//LIBUSBEMU_THREAD_INTERFACE_WRAPPER_H +} diff --git a/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads_win32.h b/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads_win32.h index 09638a0a..eaf6ba7e 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads_win32.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads_win32.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef LIBUSBEMU_THREAD_INTERFACE_WRAPPER_FOR_WIN32_THREADS_H -#define LIBUSBEMU_THREAD_INTERFACE_WRAPPER_FOR_WIN32_THREADS_H +#pragma once #include #include @@ -320,5 +319,3 @@ struct EventList }; } //end of 'namespace libusbemu' - -#endif//LIBUSBEMU_THREAD_INTERFACE_WRAPPER_FOR_WIN32_THREADS_H diff --git a/platform/windows/stdbool.h b/platform/windows/stdbool.h deleted file mode 100644 index ca5e57dd..00000000 --- a/platform/windows/stdbool.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the OpenKinect Project. http://www.openkinect.org - * - * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file - * for details. - * - * This code is licensed to you under the terms of the Apache License, version - * 2.0, or, at your option, the terms of the GNU General Public License, - * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, - * or the following URLs: - * http://www.apache.org/licenses/LICENSE-2.0 - * http://www.gnu.org/licenses/gpl-2.0.txt - * - * If you redistribute this file in source form, modified or unmodified, you - * may: - * 1) Leave this header intact and distribute it under the same terms, - * accompanying it with the APACHE20 and GPL20 files, or - * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or - * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file - * In all cases you must keep the copyright notice intact and include a copy - * of the CONTRIB file. - * - * Binary distributions must follow the binary distribution requirements of - * either License. - */ - -#ifndef _WINDOWS_STDBOOL_EMULATED_H_ -#define _WINDOWS_STDBOOL_EMULATED_H_ - -#endif//_WINDOWS_STDBOOL_EMULATED_H_ diff --git a/platform/windows/unistd.h b/platform/windows/unistd.h index fa9c9580..25965356 100644 --- a/platform/windows/unistd.h +++ b/platform/windows/unistd.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef _WINDOWS_UNISTD_EMULATED_H_ -#define _WINDOWS_UNISTD_EMULATED_H_ +#pragma once #include @@ -36,5 +35,3 @@ #define _SSIZE_T_ typedef long ssize_t; #endif // _SSIZE_T_ - -#endif//_WINDOWS_UNISTD_EMULATED_H_ diff --git a/src/cameras.h b/src/cameras.h index 7091ed52..a31e23fc 100644 --- a/src/cameras.h +++ b/src/cameras.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef CAMERAS_H -#define CAMERAS_H +#pragma once #include "libfreenect.h" @@ -35,6 +34,3 @@ // camera-specific protocol support. int freenect_camera_init(freenect_device *dev); int freenect_camera_teardown(freenect_device *dev); - -#endif - diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 390e0612..640d23b6 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef FREENECT_INTERNAL_H -#define FREENECT_INTERNAL_H +#pragma once #include @@ -240,5 +239,3 @@ struct _freenect_device { fnusb_dev usb_motor; freenect_raw_tilt_state raw_state; }; - -#endif diff --git a/src/loader.h b/src/loader.h index 82782205..c8c05896 100644 --- a/src/loader.h +++ b/src/loader.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef __LOADER_H__ -#define __LOADER_H__ +#pragma once #include #include "usb_libusb10.h" @@ -56,5 +55,3 @@ typedef struct { int upload_firmware(fnusb_dev* dev); int upload_cemd_data(fnusb_dev* dev); - -#endif //__LOADER_H__ diff --git a/src/registration.h b/src/registration.h index ce09b2dc..7da245c8 100644 --- a/src/registration.h +++ b/src/registration.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef REGISTRATION_H -#define REGISTRATION_H +#pragma once #include "libfreenect.h" @@ -33,5 +32,3 @@ int freenect_init_registration(freenect_device* dev); int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm); int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm); - -#endif diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 4a95e02b..065bf6f6 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -25,7 +25,6 @@ */ #include -#include #include #include #include diff --git a/src/usb_libusb10.h b/src/usb_libusb10.h index f2e0bd73..9133a3c4 100644 --- a/src/usb_libusb10.h +++ b/src/usb_libusb10.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef USB_LIBUSB10 -#define USB_LIBUSB10 +#pragma once #include "libfreenect.h" #include @@ -103,5 +102,3 @@ int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint1 int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred); int fnusb_num_interfaces(fnusb_dev *dev); #endif - -#endif diff --git a/wrappers/actionscript/server/as3_jpeg.h b/wrappers/actionscript/server/as3_jpeg.h index d883a298..57049c5b 100755 --- a/wrappers/actionscript/server/as3_jpeg.h +++ b/wrappers/actionscript/server/as3_jpeg.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef SERVER_JPEG_H -#define SERVER_JPEG_H +#pragma once #ifdef __cplusplus extern "C" { @@ -40,5 +39,3 @@ int RGB_2_JPEG(unsigned char *buffer, unsigned char **compressed, long unsigned #ifdef __cplusplus } #endif - -#endif \ No newline at end of file diff --git a/wrappers/actionscript/server/freenect_network.h b/wrappers/actionscript/server/freenect_network.h index 88b8b9f2..6335a0a7 100755 --- a/wrappers/actionscript/server/freenect_network.h +++ b/wrappers/actionscript/server/freenect_network.h @@ -24,8 +24,7 @@ * either License. */ -#ifndef FREENECT_SERVER_H -#define FREENECT_SERVER_H +#pragma once #ifdef __cplusplus extern "C" { @@ -62,5 +61,3 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif \ No newline at end of file diff --git a/wrappers/c_sync/libfreenect_sync.h b/wrappers/c_sync/libfreenect_sync.h index 35e76c40..923074b5 100644 --- a/wrappers/c_sync/libfreenect_sync.h +++ b/wrappers/c_sync/libfreenect_sync.h @@ -24,8 +24,8 @@ * either License. */ -#ifndef FREENECT_SYNC_H -#define FREENECT_SYNC_H +#pragma once + #include #include @@ -104,5 +104,3 @@ void freenect_sync_stop(void); #ifdef __cplusplus } #endif - -#endif diff --git a/wrappers/opencv/libfreenect_cv.h b/wrappers/opencv/libfreenect_cv.h index a2efcc2c..b73b60c9 100644 --- a/wrappers/opencv/libfreenect_cv.h +++ b/wrappers/opencv/libfreenect_cv.h @@ -1,5 +1,4 @@ -#ifndef FREENECT_CV_H -#define FREENECT_CV_H +#pragma once #ifdef __cplusplus extern "C" { @@ -13,5 +12,3 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif \ No newline at end of file From 8e5d05bd641b85044f27995fdda16a4f34c1a73c Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 18 Jun 2013 20:45:22 -0400 Subject: [PATCH 27/36] Added Kinect for Windows udev rules Signed-off-by: Benn Snyder --- platform/linux/udev/51-kinect.rules | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/linux/udev/51-kinect.rules b/platform/linux/udev/51-kinect.rules index b0f017d5..44c17316 100644 --- a/platform/linux/udev/51-kinect.rules +++ b/platform/linux/udev/51-kinect.rules @@ -1,9 +1,11 @@ # ATTR{product}=="Xbox NUI Motor" SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02b0", MODE="0666" - # ATTR{product}=="Xbox NUI Audio" SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ad", MODE="0666" - # ATTR{product}=="Xbox NUI Camera" SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ae", MODE="0666" +# Kinect for Windows +SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02c2", MODE="0666" +SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02be", MODE="0666" +SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02bf", MODE="0666" From 419b74937de1f27fa246b4438d226c491d9b8f4a Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 18 Jun 2013 20:50:07 -0400 Subject: [PATCH 28/36] Removed Formula now in homebrew Library Signed-off-by: Benn Snyder --- platform/osx/homebrew/libfreenect.rb | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 platform/osx/homebrew/libfreenect.rb diff --git a/platform/osx/homebrew/libfreenect.rb b/platform/osx/homebrew/libfreenect.rb deleted file mode 100644 index 48e00b20..00000000 --- a/platform/osx/homebrew/libfreenect.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'formula' - -class Libfreenect :build - - def install - mkdir "build" - cd "build" - system "cmake .. #{std_cmake_parameters}" - system "make install" - end -end From 89ccc40d366381631097705302ad661295d47919 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 18 Jun 2013 20:57:54 -0400 Subject: [PATCH 29/36] Fixed fprintf format warnings Signed-off-by: Benn Snyder --- examples/regtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/regtest.c b/examples/regtest.c index ecae9be7..9bfe7fd5 100644 --- a/examples/regtest.c +++ b/examples/regtest.c @@ -43,13 +43,13 @@ FILE *open_dump(const char *filename) void dump_depth(FILE *fp, void *data, unsigned int width, unsigned int height) { - fprintf(fp, "P5 %d %d 65535\n", width, height); + fprintf(fp, "P5 %u %u 65535\n", width, height); fwrite(data, width * height * 2, 1, fp); } void dump_rgb(FILE *fp, void *data, unsigned int width, unsigned int height) { - fprintf(fp, "P6 %d %d 255\n", width, height); + fprintf(fp, "P6 %u %u 255\n", width, height); fwrite(data, width * height * 3, 1, fp); } From 1ddb0faeb6bc6deae50b0f098ae8005a0e403597 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Thu, 27 Jun 2013 22:48:07 -0400 Subject: [PATCH 30/36] camera-flags: initial commit Signed-off-by: Benn Snyder --- examples/glview.c | 17 +++- include/libfreenect.h | 23 +++++ src/CMakeLists.txt | 4 +- src/cameras.c | 117 +------------------------- src/flags.c | 191 ++++++++++++++++++++++++++++++++++++++++++ src/flags.h | 38 +++++++++ 6 files changed, 271 insertions(+), 119 deletions(-) create mode 100644 src/flags.c create mode 100644 src/flags.h diff --git a/examples/glview.c b/examples/glview.c index 979546de..caf7dd56 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -179,6 +179,21 @@ void keyPressed(unsigned char key, int x, int y) freenect_angle = -30; } } + if (key == 'e') { + static freenect_flag_value auto_exposure = FREENECT_ON; + freenect_set_flag(f_dev, FREENECT_AUTO_EXPOSURE, auto_exposure); + auto_exposure = !auto_exposure; + } + if (key == 'b') { + static freenect_flag_value white_balance = FREENECT_ON; + freenect_set_flag(f_dev, FREENECT_AUTO_WHITE_BALANCE, white_balance); + white_balance = !white_balance; + } + if (key == 'r') { + static freenect_flag_value raw_color = FREENECT_ON; + freenect_set_flag(f_dev, FREENECT_RAW_COLOR, raw_color); + raw_color = !raw_color; + } if (key == '1') { freenect_set_led(f_dev,LED_GREEN); } @@ -348,7 +363,7 @@ void *freenect_threadfunc(void *arg) 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"); + printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format, 'e' - auto exposure, 'b' - white balance, r - raw color\n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output diff --git a/include/libfreenect.h b/include/libfreenect.h index 13c7c4c5..381d286e 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -106,6 +106,19 @@ typedef enum { FREENECT_DEPTH_DUMMY = 2147483647, /**< Dummy value to force enum to be 32 bits wide */ } freenect_depth_format; +/// Enumeration of flags to toggle features with freenect_set_flag() +typedef enum { + FREENECT_AUTO_EXPOSURE = 1 << 14, + FREENECT_AUTO_WHITE_BALANCE = 1 << 1, + FREENECT_RAW_COLOR = 1 << 4, +} freenect_flag; + +/// Possible values for setting each `freenect_flag` +typedef enum { + FREENECT_ON = 1, + FREENECT_OFF = 0, +} freenect_flag_value; + /// Structure to give information about the width, height, bitrate, /// framerate, and buffer size of a frame in a particular mode, as /// well as the total number of bytes needed to hold a single frame. @@ -614,6 +627,16 @@ FREENECTAPI freenect_frame_mode freenect_find_depth_mode(freenect_resolution res */ FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_frame_mode mode); +/** + * Enables or disables the specified flag. + * + * @param flag Feature to set + * @param value `FREENECT_ON` or `FREENECT_OFF` + * + * @return 0 on success, < 0 if error + */ +FREENECTAPI int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value); + #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e70b6e73..e248ec45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,10 +8,10 @@ set(CMAKE_C_FLAGS "-Wall") include_directories(${LIBUSB_1_INCLUDE_DIRS}) IF(WIN32) - LIST(APPEND SRC core.c tilt.c cameras.c usb_libusb10.c registration.c ../platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp ../platform/windows/libusb10emu/libusb-1.0/failguard.cpp) + LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c ../platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp ../platform/windows/libusb10emu/libusb-1.0/failguard.cpp) set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX) ELSE(WIN32) - LIST(APPEND SRC core.c tilt.c cameras.c usb_libusb10.c registration.c) + LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c) ENDIF(WIN32) IF(BUILD_AUDIO) diff --git a/src/cameras.c b/src/cameras.c index 7886a332..0b4fd1a7 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -32,6 +32,7 @@ #include "freenect_internal.h" #include "registration.h" #include "cameras.h" +#include "flags.h" #define MAKE_RESERVED(res, fmt) (uint32_t)(((res & 0xff) << 8) | (((fmt & 0xff)))) #define RESERVED_TO_RESOLUTION(reserved) (freenect_resolution)((reserved >> 8) & 0xff) @@ -650,122 +651,6 @@ static void video_process(freenect_device *dev, uint8_t *pkt, int len) dev->video_cb(dev, dev->video.proc_buf, dev->video.timestamp); } -typedef struct { - uint8_t magic[2]; - uint16_t len; - uint16_t cmd; - uint16_t tag; -} cam_hdr; - -static int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsigned int cmd_len, void *replybuf, int reply_len) -{ - freenect_context *ctx = dev->parent; - int res, actual_len; - uint8_t obuf[0x400]; - uint8_t ibuf[0x200]; - cam_hdr *chdr = (cam_hdr*)obuf; - cam_hdr *rhdr = (cam_hdr*)ibuf; - - if (cmd_len & 1 || cmd_len > (0x400 - sizeof(*chdr))) { - FN_ERROR("send_cmd: Invalid command length (0x%x)\n", cmd_len); - return -1; - } - - chdr->magic[0] = 0x47; - chdr->magic[1] = 0x4d; - chdr->cmd = fn_le16(cmd); - chdr->tag = fn_le16(dev->cam_tag); - chdr->len = fn_le16(cmd_len / 2); - - memcpy(obuf+sizeof(*chdr), cmdbuf, cmd_len); - - res = fnusb_control(&dev->usb_cam, 0x40, 0, 0, 0, obuf, cmd_len + sizeof(*chdr)); - FN_SPEW("Control cmd=%04x tag=%04x len=%04x: %d\n", cmd, dev->cam_tag, cmd_len, res); - if (res < 0) { - FN_ERROR("send_cmd: Output control transfer failed (%d)\n", res); - return res; - } - - do { - actual_len = fnusb_control(&dev->usb_cam, 0xc0, 0, 0, 0, ibuf, 0x200); - FN_FLOOD("actual_len: %d\n", actual_len); - } while ((actual_len == 0) || (actual_len == 0x200)); - FN_SPEW("Control reply: %d\n", res); - if (actual_len < (int)sizeof(*rhdr)) { - FN_ERROR("send_cmd: Input control transfer failed (%d)\n", res); - return res; - } - actual_len -= sizeof(*rhdr); - - if (rhdr->magic[0] != 0x52 || rhdr->magic[1] != 0x42) { - FN_ERROR("send_cmd: Bad magic %02x %02x\n", rhdr->magic[0], rhdr->magic[1]); - return -1; - } - if (rhdr->cmd != chdr->cmd) { - FN_ERROR("send_cmd: Bad cmd %02x != %02x\n", rhdr->cmd, chdr->cmd); - return -1; - } - if (rhdr->tag != chdr->tag) { - FN_ERROR("send_cmd: Bad tag %04x != %04x\n", rhdr->tag, chdr->tag); - return -1; - } - if (fn_le16(rhdr->len) != (actual_len/2)) { - FN_ERROR("send_cmd: Bad len %04x != %04x\n", fn_le16(rhdr->len), (int)(actual_len/2)); - return -1; - } - - if (actual_len > reply_len) { - FN_WARNING("send_cmd: Data buffer is %d bytes long, but got %d bytes\n", reply_len, actual_len); - memcpy(replybuf, ibuf+sizeof(*rhdr), reply_len); - } else { - memcpy(replybuf, ibuf+sizeof(*rhdr), actual_len); - } - - dev->cam_tag++; - - return actual_len; -} - -static int write_register(freenect_device *dev, uint16_t reg, uint16_t data) -{ - freenect_context *ctx = dev->parent; - uint16_t reply[2]; - uint16_t cmd[2]; - int res; - - cmd[0] = fn_le16(reg); - cmd[1] = fn_le16(data); - - FN_DEBUG("Write Reg 0x%04x <= 0x%02x\n", reg, data); - res = send_cmd(dev, 0x03, cmd, 4, reply, 4); - if (res < 0) - return res; - if (res != 2) { - FN_WARNING("send_cmd returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); - } - return 0; -} - -// This function is here for completeness. We don't actually use it for anything right now. -static uint16_t read_register(freenect_device *dev, uint16_t reg) -{ - freenect_context *ctx = dev->parent; - uint16_t reply[2]; - uint16_t cmd; - int res; - - cmd = fn_le16(reg); - - FN_DEBUG("Read Reg 0x%04x =>\n", reg); - res = send_cmd(dev, 0x02, &cmd, 2, reply, 4); - if (res < 0) - FN_ERROR("read_register: send_cmd() failed: %d\n", res); - if (res != 4) - FN_WARNING("send_cmd returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); - - return reply[1]; -} - static int freenect_fetch_reg_info(freenect_device *dev) { freenect_context *ctx = dev->parent; diff --git a/src/flags.c b/src/flags.c new file mode 100644 index 00000000..780e2421 --- /dev/null +++ b/src/flags.c @@ -0,0 +1,191 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2010-2011 individual OpenKinect contributors. See the CONTRIB + * file for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + +#include // for memcpy +#include "freenect_internal.h" +#include "flags.h" + + +// freenect_set_flag is the only function exposed in libfreenect.h +// The rest are available internally via #include flags.h + + +int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) +{ + uint16_t reg = read_cmos_register(dev, 0x0106); + if (reg < 0) + return reg; + if (value == FREENECT_ON) + reg |= flag; + else + reg &= ~flag; + return write_cmos_register(dev, 0x0106, reg); +} + +typedef struct { + uint8_t magic[2]; + uint16_t len; + uint16_t cmd; + uint16_t tag; +} cam_hdr; + +FN_INTERNAL int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsigned int cmd_len, void *replybuf, int reply_len) +{ + freenect_context *ctx = dev->parent; + int res, actual_len; + uint8_t obuf[0x400]; + uint8_t ibuf[0x200]; + cam_hdr *chdr = (cam_hdr*)obuf; + cam_hdr *rhdr = (cam_hdr*)ibuf; + + if (cmd_len & 1 || cmd_len > (0x400 - sizeof(*chdr))) { + FN_ERROR("send_cmd: Invalid command length (0x%x)\n", cmd_len); + return -1; + } + + chdr->magic[0] = 0x47; + chdr->magic[1] = 0x4d; + chdr->cmd = fn_le16(cmd); + chdr->tag = fn_le16(dev->cam_tag); + chdr->len = fn_le16(cmd_len / 2); + + memcpy(obuf+sizeof(*chdr), cmdbuf, cmd_len); + + res = fnusb_control(&dev->usb_cam, 0x40, 0, 0, 0, obuf, cmd_len + sizeof(*chdr)); + FN_SPEW("send_cmd: cmd=%04x tag=%04x len=%04x: %d\n", cmd, dev->cam_tag, cmd_len, res); + if (res < 0) { + FN_ERROR("send_cmd: Output control transfer failed (%d)\n", res); + return res; + } + + do { + actual_len = fnusb_control(&dev->usb_cam, 0xc0, 0, 0, 0, ibuf, 0x200); + FN_FLOOD("send_cmd: actual length = %d\n", actual_len); + } while ((actual_len == 0) || (actual_len == 0x200)); + FN_SPEW("Control reply: %d\n", res); + if (actual_len < (int)sizeof(*rhdr)) { + FN_ERROR("send_cmd: Input control transfer failed (%d)\n", res); + return res; + } + actual_len -= sizeof(*rhdr); + + if (rhdr->magic[0] != 0x52 || rhdr->magic[1] != 0x42) { + FN_ERROR("send_cmd: Bad magic %02x %02x\n", rhdr->magic[0], rhdr->magic[1]); + return -1; + } + if (rhdr->cmd != chdr->cmd) { + FN_ERROR("send_cmd: Bad cmd %02x != %02x\n", rhdr->cmd, chdr->cmd); + return -1; + } + if (rhdr->tag != chdr->tag) { + FN_ERROR("send_cmd: Bad tag %04x != %04x\n", rhdr->tag, chdr->tag); + return -1; + } + if (fn_le16(rhdr->len) != (actual_len/2)) { + FN_ERROR("send_cmd: Bad len %04x != %04x\n", fn_le16(rhdr->len), (int)(actual_len/2)); + return -1; + } + + if (actual_len > reply_len) { + FN_WARNING("send_cmd: Data buffer is %d bytes long, but got %d bytes\n", reply_len, actual_len); + memcpy(replybuf, ibuf+sizeof(*rhdr), reply_len); + } else { + memcpy(replybuf, ibuf+sizeof(*rhdr), actual_len); + } + + dev->cam_tag++; + + return actual_len; +} + +FN_INTERNAL uint16_t read_register(freenect_device *dev, uint16_t reg) +{ + freenect_context *ctx = dev->parent; + uint16_t reply[2]; + uint16_t cmd; + int res; + + cmd = fn_le16(reg); + + FN_DEBUG("read_register: 0x%04x =>\n", reg); + res = send_cmd(dev, 0x02, &cmd, 2, reply, 4); + if (res < 0) + FN_ERROR("read_register: send_cmd() failed: %d\n", res); + if (res != 4) + FN_WARNING("read_register: send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); + + return reply[1]; +} + +FN_INTERNAL int write_register(freenect_device *dev, uint16_t reg, uint16_t data) +{ + freenect_context *ctx = dev->parent; + uint16_t reply[2]; + uint16_t cmd[2]; + int res; + + cmd[0] = fn_le16(reg); + cmd[1] = fn_le16(data); + + FN_DEBUG("write_register: 0x%04x <= 0x%02x\n", reg, data); + res = send_cmd(dev, 0x03, cmd, 4, reply, 4); + if (res < 0) + return res; + if (res != 2) { + FN_WARNING("send_cmd() returned %d [%04x %04x], 0000 expected\n", res, reply[0], reply[1]); + } + return 0; +} + +FN_INTERNAL uint16_t read_cmos_register(freenect_device *dev, uint16_t reg) +{ + freenect_context *ctx = dev->parent; + uint16_t replybuf[0x200]; + uint16_t cmdbuf[3]; + cmdbuf[0] = 1; + cmdbuf[1] = reg & 0x7fff; + cmdbuf[2] = 0; + int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); + if (res < 0) { + FN_ERROR("read_cmos_register: send_cmd() returned %d\n", res); + return res; + } + return replybuf[2]; +} + +FN_INTERNAL int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t value) +{ + freenect_context *ctx = dev->parent; + uint16_t replybuf[0x200]; + uint16_t cmdbuf[3]; + cmdbuf[0] = 1; + cmdbuf[1] = reg | 0x8000; + cmdbuf[2] = value; + int res = send_cmd(dev, 0x95, cmdbuf, 6, replybuf, 6); + if (res < 0) + FN_ERROR("read_cmos_register: send_cmd() returned %d\n", res); + return res; +} diff --git a/src/flags.h b/src/flags.h new file mode 100644 index 00000000..87e401df --- /dev/null +++ b/src/flags.h @@ -0,0 +1,38 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2010-2011 individual OpenKinect contributors. See the CONTRIB + * file for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + +#pragma once + +#include "libfreenect.h" + + +int send_cmd(freenect_device *dev, uint16_t cmd, void *cmdbuf, unsigned int cmd_len, void *replybuf, int reply_len); + +uint16_t read_register(freenect_device *dev, uint16_t reg); +int write_register(freenect_device *dev, uint16_t reg, uint16_t data); + +uint16_t read_cmos_register(freenect_device *dev, uint16_t reg); +int write_cmos_register(freenect_device *dev, uint16_t reg, uint16_t value); From 37758b2fb516a66d630a703885d937d1994d844b Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Sun, 30 Jun 2013 13:01:51 -0400 Subject: [PATCH 31/36] camera-flags: added depth and video mirror Signed-off-by: Benn Snyder --- examples/glview.c | 9 ++++++++- include/libfreenect.h | 12 ++++++++---- src/flags.c | 3 +++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/glview.c b/examples/glview.c index caf7dd56..f2edcf1b 100644 --- a/examples/glview.c +++ b/examples/glview.c @@ -194,6 +194,12 @@ void keyPressed(unsigned char key, int x, int y) freenect_set_flag(f_dev, FREENECT_RAW_COLOR, raw_color); raw_color = !raw_color; } + if (key == 'm') { + static freenect_flag_value mirror = FREENECT_ON; + freenect_set_flag(f_dev, FREENECT_MIRROR_DEPTH, mirror); + freenect_set_flag(f_dev, FREENECT_MIRROR_VIDEO, mirror); + mirror = !mirror; + } if (key == '1') { freenect_set_led(f_dev,LED_GREEN); } @@ -363,7 +369,8 @@ void *freenect_threadfunc(void *arg) 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, 'e' - auto exposure, 'b' - white balance, r - raw color\n"); + printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode, 'f'-video format\n"); + printf("'e' - auto exposure, 'b' - white balance, 'r' - raw color, 'm' - mirror\n"); while (!die && freenect_process_events(f_ctx) >= 0) { //Throttle the text output diff --git a/include/libfreenect.h b/include/libfreenect.h index 381d286e..55ac3279 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -108,15 +108,19 @@ typedef enum { /// Enumeration of flags to toggle features with freenect_set_flag() typedef enum { - FREENECT_AUTO_EXPOSURE = 1 << 14, + // values written to the CMOS register + FREENECT_AUTO_EXPOSURE = 1 << 14, FREENECT_AUTO_WHITE_BALANCE = 1 << 1, - FREENECT_RAW_COLOR = 1 << 4, + FREENECT_RAW_COLOR = 1 << 4, + // registers to be written with 0 or 1 + FREENECT_MIRROR_DEPTH = 0x0017, + FREENECT_MIRROR_VIDEO = 0x0047, } freenect_flag; /// Possible values for setting each `freenect_flag` typedef enum { - FREENECT_ON = 1, FREENECT_OFF = 0, + FREENECT_ON = 1, } freenect_flag_value; /// Structure to give information about the width, height, bitrate, @@ -631,7 +635,7 @@ FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_fra * Enables or disables the specified flag. * * @param flag Feature to set - * @param value `FREENECT_ON` or `FREENECT_OFF` + * @param value `FREENECT_OFF` or `FREENECT_ON` * * @return 0 on success, < 0 if error */ diff --git a/src/flags.c b/src/flags.c index 780e2421..85c6d0e0 100644 --- a/src/flags.c +++ b/src/flags.c @@ -35,6 +35,9 @@ int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value) { + if (flag == FREENECT_MIRROR_DEPTH || flag == FREENECT_MIRROR_VIDEO) + return write_register(dev, flag, value); + uint16_t reg = read_cmos_register(dev, 0x0106); if (reg < 0) return reg; From baa489a863712d930831b41040bf607f2857857d Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Wed, 10 Jul 2013 21:57:54 -0400 Subject: [PATCH 32/36] as3-bom: Support uncompressed depth Signed-off-by: Benn Snyder --- wrappers/actionscript/server/as3-server.c | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/wrappers/actionscript/server/as3-server.c b/wrappers/actionscript/server/as3-server.c index 8b79103d..ac5b476e 100755 --- a/wrappers/actionscript/server/as3-server.c +++ b/wrappers/actionscript/server/as3-server.c @@ -123,17 +123,29 @@ void sendDepth(){ depth = tmp_depth; } - for (i=0; i< depth_mode.width * depth_mode.height; i++) { - buf_depth[4 * i + 0] = 0x00; - buf_depth[4 * i + 1] = 0x00; - buf_depth[4 * i + 2] = 0x00; - buf_depth[4 * i + 3] = 0xFF; + for (i=0; i< depth_mode.width * depth_mode.height; i++) { + if(_depth_compression != 0) { + buf_depth[3 * i + 0] = 0x00; + buf_depth[3 * i + 1] = 0x00; + buf_depth[3 * i + 2] = 0x00; + } else { + buf_depth[4 * i + 0] = 0x00; + buf_depth[4 * i + 1] = 0x00; + buf_depth[4 * i + 2] = 0x00; + buf_depth[4 * i + 3] = 0xFF; + } if(depth[i] < _max_depth && depth[i] > _min_depth){ unsigned char l = 0xFF - ((depth[i] - _min_depth) & 0xFF); - buf_depth[4 * i + 0] = l; - buf_depth[4 * i + 1] = l; - buf_depth[4 * i + 2] = l; - buf_depth[4 * i + 3] = 0xFF; + if(_depth_compression != 0) { + buf_depth[3 * i + 0] = l; + buf_depth[3 * i + 1] = l; + buf_depth[3 * i + 2] = l; + } else { + buf_depth[4 * i + 0] = l; + buf_depth[4 * i + 1] = l; + buf_depth[4 * i + 2] = l; + buf_depth[4 * i + 3] = 0xFF; + } } } if(_depth_compression != 0) { From 955af59d324ea73890118ee2ee56814a7303b830 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Tue, 16 Jul 2013 18:46:55 -0400 Subject: [PATCH 33/36] Changed all GL-related INCLUDE_DIRS to INCLUDE_DIR Fixes #320 Signed-off-by: Benn Snyder --- examples/CMakeLists.txt | 2 +- wrappers/cpp/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 506ca9bd..3ae566e8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -56,7 +56,7 @@ else() find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) - include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) + include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) target_link_libraries(glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) target_link_libraries(regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index bb9c53cb..ff8469f7 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -25,7 +25,7 @@ else() find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) - include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS}) + include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS}) target_link_libraries(cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB}) endif() From 3ef82585695605d40be9bd0a1dc4a882fbb3a4af Mon Sep 17 00:00:00 2001 From: Yannis Gravezas Date: Tue, 23 Apr 2013 14:35:33 +0300 Subject: [PATCH 34/36] Kinect for Windows and Xbox 360 Model 1473 support This patch does auto detection of all three models and disables motor subdevice for the 2 newer ones. It also adds a function to test for the presence of the motor and audio devices on newer models. Signed-off-by: Yannis Gravezas (wizgrav) --- include/libfreenect.h | 9 ++++ .../windows/libusb10emu/libusb-1.0/libusb.h | 1 + .../libusb10emu/libusb-1.0/libusbemu.cpp | 11 +++++ src/cameras.c | 6 +-- src/core.c | 4 ++ src/freenect_internal.h | 3 ++ src/tilt.c | 8 ++++ src/usb_libusb10.c | 42 ++++++++++++++++--- 8 files changed, 75 insertions(+), 9 deletions(-) diff --git a/include/libfreenect.h b/include/libfreenect.h index 13c7c4c5..1648a756 100644 --- a/include/libfreenect.h +++ b/include/libfreenect.h @@ -302,6 +302,15 @@ FREENECTAPI int freenect_supported_subdevices(void); */ FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs); +/** + * Returns the devices that are enabled after calls to freenect_open_device() + * On newer kinects the motor and audio are automatically disabled for now + * + * @param ctx Context to set future subdevice selection for + * @return Flags representing the subdevices that were actually opened (see freenect_device_flags) + */ +FREENECTAPI freenect_device_flags freenect_enabled_subdevices(freenect_context *ctx); + /** * Opens a kinect device via a context. Index specifies the index of * the device on the current state of the bus. Bus resets may cause diff --git a/platform/windows/libusb10emu/libusb-1.0/libusb.h b/platform/windows/libusb10emu/libusb-1.0/libusb.h index 33b32887..38c3c1a9 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusb.h +++ b/platform/windows/libusb10emu/libusb-1.0/libusb.h @@ -77,6 +77,7 @@ int libusb_get_string_descriptor(libusb_device_handle *dev_handle, uint8_t desc_ int libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle, uint8_t desc_index, unsigned char *data, int length); int libusb_set_configuration(libusb_device_handle *dev, int configuration); +int libusb_set_interface_alt_setting(libusb_device_handle *dev,int interface_number,int alternate_setting); int libusb_claim_interface(libusb_device_handle* dev, int interface_number); int libusb_release_interface(libusb_device_handle* dev, int interface_number); diff --git a/platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp b/platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp index af39ff68..79361e1f 100644 --- a/platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp +++ b/platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp @@ -302,6 +302,17 @@ int libusb_set_configuration(libusb_device_handle *dev, int configuration) return 0; } +int libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number,int alternate_setting){ + RAIIMutex lock (dev->dev->ctx->mutex); + if (0 != usb_set_altinterface(dev->handle, alternate_setting)) + { + LIBUSBEMU_ERROR_LIBUSBWIN32(); + return(LIBUSB_ERROR_OTHER); + } + + return(0); +} + int libusb_claim_interface(libusb_device_handle* dev, int interface_number) { RAIIMutex lock (dev->dev->ctx->mutex); diff --git a/src/cameras.c b/src/cameras.c index 7886a332..0483c2ed 100644 --- a/src/cameras.c +++ b/src/cameras.c @@ -904,9 +904,9 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev) uint16_t cmd[5] = {0}; // Offset is the only field in this command, and it's 0 int res; - res = send_cmd(dev, 0x04, cmd, 10, reply, 322); //OPCODE_GET_FIXED_PARAMS = 4, - if (res != 322) { - FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 322)\n", res); + res = send_cmd(dev, 0x04, cmd, 10, reply, ctx->zero_plane_res); //OPCODE_GET_FIXED_PARAMS = 4, + if (res != ctx->zero_plane_res) { + FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected %d)\n", res,ctx->zero_plane_res); return -1; } diff --git a/src/core.c b/src/core.c index ecc5942f..305c9e18 100644 --- a/src/core.c +++ b/src/core.c @@ -148,6 +148,10 @@ FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_devi )); } +FREENECTAPI freenect_device_flags freenect_enabled_subdevices(freenect_context *ctx) { + return ctx->enabled_subdevices; +} + FREENECTAPI int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index) { int res; diff --git a/src/freenect_internal.h b/src/freenect_internal.h index 640d23b6..8df4ee22 100644 --- a/src/freenect_internal.h +++ b/src/freenect_internal.h @@ -52,6 +52,7 @@ struct _freenect_context { fnusb_ctx usb; freenect_device_flags enabled_subdevices; freenect_device *first; + int zero_plane_res; }; #define LL_FATAL FREENECT_LOG_FATAL @@ -131,6 +132,8 @@ static inline int32_t fn_le32s(int32_t s) #define PID_NUI_AUDIO 0x02ad #define PID_NUI_CAMERA 0x02ae #define PID_NUI_MOTOR 0x02b0 +#define PID_K4W_CAMERA 0x02bf +#define PID_K4W_AUDIO 0x02be typedef struct { int running; diff --git a/src/tilt.c b/src/tilt.c index 1a466499..8852e768 100644 --- a/src/tilt.c +++ b/src/tilt.c @@ -47,6 +47,8 @@ freenect_raw_tilt_state* freenect_get_tilt_state(freenect_device *dev) int freenect_update_tilt_state(freenect_device *dev) { freenect_context *ctx = dev->parent; + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) + return 0; uint8_t buf[10]; uint16_t ux, uy, uz; int ret = fnusb_control(&dev->usb_motor, 0xC0, 0x32, 0x0, 0x0, buf, 10); @@ -70,6 +72,9 @@ int freenect_update_tilt_state(freenect_device *dev) int freenect_set_tilt_degs(freenect_device *dev, double angle) { + freenect_context *ctx = dev->parent; + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) + return 0; int ret; uint8_t empty[0x1]; @@ -82,6 +87,9 @@ int freenect_set_tilt_degs(freenect_device *dev, double angle) int freenect_set_led(freenect_device *dev, freenect_led_options option) { + freenect_context *ctx = dev->parent; + if(!(ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR)) + return 0; int ret; uint8_t empty[0x1]; ret = fnusb_control(&dev->usb_motor, 0x40, 0x06, (uint16_t)option, 0x0, empty, 0x0); diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 065bf6f6..451d2012 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -47,7 +47,7 @@ FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx) int r = libusb_get_device_descriptor (devs[i], &desc); if (r < 0) continue; - if (desc.idVendor == VID_MICROSOFT && desc.idProduct == PID_NUI_CAMERA) + if (desc.idVendor == VID_MICROSOFT && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) nr++; } libusb_free_device_list (devs, 1); @@ -76,7 +76,7 @@ FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_dev int r = libusb_get_device_descriptor (devs[i], &desc); if (r < 0) continue; - if (desc.idVendor == VID_MICROSOFT && desc.idProduct == PID_NUI_CAMERA) { + if (desc.idVendor == VID_MICROSOFT && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) { // Verify that a serial number exists to query. If not, don't touch the device. if (desc.iSerialNumber == 0) { continue; @@ -188,9 +188,9 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) if (desc.idVendor != VID_MICROSOFT) continue; - + res = 0; // Search for the camera - if ((ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA) && !dev->usb_cam.dev && desc.idProduct == PID_NUI_CAMERA) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_CAMERA) && !dev->usb_cam.dev && (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA)) { // If the index given by the user matches our camera index if (nr_cam == index) { res = libusb_open (devs[i], &dev->usb_cam.dev); @@ -199,6 +199,15 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_cam.dev = NULL; break; } + if(desc.idProduct == PID_K4W_CAMERA || desc.bcdDevice != fn_le32(267)){ + /* Not the old kinect so we only set up the camera*/ + ctx->enabled_subdevices = FREENECT_DEVICE_CAMERA; + ctx->zero_plane_res = 334; + }else{ + /* The good old kinect that tilts and tweets */ + ctx->zero_plane_res = 322; + } + #ifndef _WIN32 // Detach an existing kernel driver for the device res = libusb_kernel_driver_active(dev->usb_cam.dev, 0); @@ -219,12 +228,33 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) dev->usb_cam.dev = NULL; break; } + if(desc.idProduct == PID_K4W_CAMERA){ + res = libusb_set_interface_alt_setting(dev->usb_cam.dev, 0, 1); + if (res != 0) { + FN_ERROR("Failed to set alternate interface #1 for K4W: %d\n", res); + libusb_close(dev->usb_cam.dev); + dev->usb_cam.dev = NULL; + break; + } + + } } else { nr_cam++; } } - + } + + if(ctx->enabled_subdevices == FREENECT_DEVICE_CAMERA || res < 0) cnt = 0; + // Search for the motor + + for (i = 0; i < cnt; i++) { + int r = libusb_get_device_descriptor (devs[i], &desc); + if (r < 0) + continue; + + if (desc.idVendor != VID_MICROSOFT) + continue; if ((ctx->enabled_subdevices & FREENECT_DEVICE_MOTOR) && !dev->usb_motor.dev && desc.idProduct == PID_NUI_MOTOR) { // If the index given by the user matches our camera index if (nr_mot == index) { @@ -249,7 +279,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index) #ifdef BUILD_AUDIO // TODO: check that the firmware has already been loaded; if not, upload firmware. // Search for the audio - if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && desc.idProduct == PID_NUI_AUDIO) { + if ((ctx->enabled_subdevices & FREENECT_DEVICE_AUDIO) && !dev->usb_audio.dev && (desc.idProduct == PID_NUI_AUDIO || desc.idProduct == PID_K4W_AUDIO)) { // If the index given by the user matches our audio index if (nr_audio == index) { res = libusb_open (devs[i], &dev->usb_audio.dev); From 5eed1f061da229aab600471a4a85e83844151af9 Mon Sep 17 00:00:00 2001 From: Benn Snyder Date: Thu, 8 Aug 2013 18:09:53 -0400 Subject: [PATCH 35/36] Update CMake version for v0.2.0 Signed-off-by: Benn Snyder --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7aa066e..272a410f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ cmake_minimum_required(VERSION 2.6) PROJECT(libfreenect) set (PROJECT_VER_MAJOR 0) -set (PROJECT_VER_MINOR 1) -set (PROJECT_VER_PATCH 2) +set (PROJECT_VER_MINOR 2) +set (PROJECT_VER_PATCH 0) set (PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set (PROJECT_APIVER From 6198bcd469625cf7e10f2cddc7868b030e137249 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 21 Sep 2013 19:52:56 -0400 Subject: [PATCH 36/36] Update CONTRIB for v0.2.0 --- CONTRIB | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIB b/CONTRIB index 9ae22e61..1ec7cc47 100644 --- a/CONTRIB +++ b/CONTRIB @@ -5,6 +5,8 @@ Alex Weiss Andrew Antonio Ospite arnebe +Benn Snyder +Ben Stolovitz Brandyn A. White Chris J (cryptk) David García Garzón @@ -18,7 +20,10 @@ Francois Coulombe Gabor Szarka Hector Martin James Harris +Joakim Gebart Jochen Kerdels +John Scheible +josephd Josh Grunzweig Joshua Blake Juan Carlos del Valle @@ -30,6 +35,7 @@ Kyle Machulis Marcos Paulo Berteli Slomp Mark Renouf Melonee Wise +Nicolas Bourdaud Peter Kropf Radu Bogdan Rusu Rich Mattes @@ -42,4 +48,5 @@ Thomas Roefer Tim Niemueller Tully Foote Vincent Le Ligeour +Yannis Gravezas Yaroslav Halchenko