Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unstable] LabView Integration #517

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Committing initial revisions of the LabView Wrapper Signed-off-by: Ry…
…anGordon <[email protected]>
  • Loading branch information
RyanGordon authored and qdot committed Jan 23, 2011
commit 7feae2b00e3dc1415b92532fafe3eaa435b2d5a8
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ OPTION(BUILD_CPP "Build C++ Library (currently header only)" ON)
OPTION(BUILD_CV "Build OpenCV wrapper" OFF)
OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
OPTION(BUILD_PYTHON "Build Python extension" OFF)
IF(WIN32)
OPTION(BUILD_LABVIEW "Build LabView extension" OFF)
ENDIF()
IF(PROJECT_OS_LINUX)
OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF)
ENDIF(PROJECT_OS_LINUX)
Expand Down Expand Up @@ -137,6 +140,10 @@ IF(BUILD_PYTHON)
add_subdirectory (wrappers/python)
ENDIF()

IF(BUILD_LABVIEW)
add_subdirectory (wrappers/labview)
ENDIF()

######################################################################################
# Extras
######################################################################################
Expand Down
41 changes: 41 additions & 0 deletions wrappers/labview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
######################################################################################
# C Labview Interface
######################################################################################
set_source_files_properties(libfreenect_lv.c PROPERTIES LANGUAGE CXX)
set_source_files_properties(lvdemo.c PROPERTIES LANGUAGE CXX)

add_library (freenect_lv SHARED libfreenect_lv.c)
set_target_properties (freenect_lv PROPERTIES
VERSION ${PROJECT_VER}
SOVERSION ${PROJECT_APIVER})

target_link_libraries (freenect_lv freenect freenect_sync)

install (TARGETS freenect_lv
DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}")
install (FILES "libfreenect_lv.h"
DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})

set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads REQUIRED)

include_directories(${THREADS_PTHREADS_INCLUDE_DIR})

find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${USB_INCLUDE_DIRS})

if (WIN32)
set(MATH_LIB "")
else(WIN32)
set(MATH_LIB "m")
endif()

add_executable(lvdemo lvdemo.c)

target_link_libraries(lvdemo freenect freenect_sync freenect_lv ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})

install (TARGETS lvdemo
DESTINATION bin)
19 changes: 19 additions & 0 deletions wrappers/labview/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
General information:
These drivers are still very very experimental and while they work, they are not stable. I guarantee there will be problems we haven't discovered yet. Please keep this in mind!

Needed first before this works:
1) Windows machine with a (preferably) new version of LabVIEW (8.6+). Older versions untested.
2) inf files (driver files) Please see: http://openkinect.org/wiki/Getting_Started_Windows and follow the Driver Installation instructions. You don't need the dependencies or the other instructions unless you actually want to mess with and compile the code that makes up the dlls.

Known issues:
1) RGB image in example.vi isn't being color-converted correctly but works enough to provide as an example. To be diagnosed
2) It is IMPORTANT to make sure the Kinect is turned off (either by pressing the the "stop" button in example.vi or running "stop.vi" or manually removing physical power from the Kinect before working on the code. It's been seen that LabView will close without warning or explanation if these steps are not taken. If LabView crashes when you try and run it, unplug your Kinect physically, wait a few seconds, and plug it back in. Restarting your computer or LabVIEW may also help. Save your work often.

Information:
- The depth frame image in example.vi uses an arbitrary gray-scale false-color rendering. The raw resultant array can be accessed from the vi "get depth frame.vi" included in libfreenect.lvlib. Please see: http://openkinect.org/wiki/Protocol_Documentation for more information
- The RGB frame image in example.vi can be directly accessed from the raw resultant array in "get image frame.vi" included in libfreenect.lvlib. Please see: http://openkinect.org/wiki/Imaging_Information for more information
- The dlls in this project are 32bit compiled with MSVC 2010
- Only have tested 1 sychronous Kinect so far
- Timing is very important to frame rate speed. Please be considerate to cycles when developing algorithms on top of these drivers

If you have problems, email me at [email protected] or find me on irc.freenode.net #openkinect under the RyanGordon alias.
94 changes: 94 additions & 0 deletions wrappers/labview/libfreenect_lv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* This file is part of the OpenKinect Project. http://www.openkinect.org
*
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
* for details.
*
* Ryan Gordon <[email protected]>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include "libfreenect.h"
#include "../c_sync/libfreenect_sync.h"
#include "libfreenect_lv.h"

EXPORT short *freenect_lv_get_depth_frame(int index, freenect_depth_format fmt)
{
short *depth = 0;
unsigned int timestamp;

if(freenect_sync_get_depth((void**)&depth, &timestamp, index, fmt) < 0)
{
return NULL;
}

return depth;
}

EXPORT char *freenect_lv_get_image_frame(int index, freenect_video_format fmt)
{
char *rgb = 0;
unsigned int timestamp;

if(freenect_sync_get_video((void**)&rgb, &timestamp, index, fmt) < 0)
{
return NULL;
}

return rgb;
}

EXPORT int freenect_lv_set_tilt_degs(int angle, int index)
{
return freenect_sync_set_tilt_degs(angle, index);
}

EXPORT freenect_raw_tilt_state *freenect_lv_get_tilt_state(int index)
{
freenect_raw_tilt_state *state = 0;

freenect_sync_get_tilt_state(&state, index);

return state;
}

EXPORT void freenect_lv_get_tilt_state_mks(double *dx, double *dy, double *dz, int index)
{
freenect_raw_tilt_state *state = 0;

freenect_sync_get_tilt_state(&state, index);
freenect_get_mks_accel(state, dx, dy, dz);
}

EXPORT void freenect_lv_set_led(freenect_led_options led, int index)
{
freenect_sync_set_led(led, index);
}

EXPORT void freenect_lv_stop()
{
freenect_sync_stop();
}
57 changes: 57 additions & 0 deletions wrappers/labview/libfreenect_lv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This file is part of the OpenKinect Project. http://www.openkinect.org
*
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
* for details.
*
* Ryan Gordon <[email protected]>
*
* 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 LIBFREENECT__LV_H
#define LIBFREENECT_LV_H

#ifdef __cplusplus
extern "C" {
#endif

#include "libfreenect.h"
#include "../c_sync/libfreenect_sync.h"

#ifndef _WIN32
#define EXPORT
#else
#define EXPORT extern "C" __declspec(dllexport)
#endif

EXPORT short *freenect_lv_get_depth_frame(int index, freenect_depth_format fmt);
EXPORT char *freenect_lv_get_image_frame(int index, freenect_video_format fmt);
EXPORT int freenect_lv_set_tilt_degs(int angle, int index);
EXPORT freenect_raw_tilt_state *freenect_lv_get_tilt_state(int index);
EXPORT void freenect_lv_get_tilt_state_mks(double *dx, double *dy, double *dz, int index);
EXPORT void freenect_lv_set_led(freenect_led_options led, int index);
EXPORT void freenect_lv_stop();

#ifdef __cplusplus
}
#endif

#endif //
Binary file added wrappers/labview/lvlib/VIs/example.vi
Binary file not shown.
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/get depth frame.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/get image frame.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/get tilt state mks.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/get tilt state.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/set led.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/set tilt degs.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/stop.vi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added wrappers/labview/lvlib/freenect.dll
Binary file not shown.
Binary file added wrappers/labview/lvlib/freenect_lv.dll
Binary file not shown.
Binary file added wrappers/labview/lvlib/freenect_sync.dll
Binary file not shown.
21 changes: 21 additions & 0 deletions wrappers/labview/lvlib/libfreenect.lvlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='UTF-8'?>
<Library LVVersion="8608001">
<Property Name="NI.Lib.Icon" Type="Bin">#'#!!1!!!!)!"1!&amp;!!!-!%!!!@````]!!!!"!!%!!!+G!!!*Q(C=\:9\DB."%)&lt;`:4&gt;9E@E'S#*T7&amp;=Q#9%T3ZSALG#=L&lt;2#=LI3$EJ;2%$G!TCR%)(4CD&lt;X&amp;8S&amp;Y?NWYXWA(1M*"!(6LHH]V68VO;=^MF4N5LJ1&gt;]L5;[./LXNM&gt;%?]7[`8X:J38^&gt;0\@:"@,X&gt;^M;\%`(H]\OON`^0[O0YZ,&lt;(\PK``[4WHZ22\(#=X!M(PG0E'*]]DD/[_3'R;^E(Y4Y_\VJ]XO*6?*[email protected];XR/@0'``YX]`0OL@H[/\8O-X@(8S(@#(44J4?2(BC1@OO+G%OE20^%20^%20^%!0^%!0^%!0&gt;%&gt;X&gt;%&gt;X&gt;%&gt;X&gt;%-X&gt;%-X&gt;%-X^$L1B3ZUI&lt;-K3@/E56)U+:"-"E8*)?&amp;*?"+?B)&gt;&lt;*4Q*4]+4]#1]4&amp;(#E`!E0!F0QE/;%J[%*_&amp;*?")?3F73L!-&gt;HI3(]AJY!J[!*_!*?'CJA#=!#*I&amp;B9-C9#A)"B="4]!4](#JA#@A#8A#HI#(M!+?A#@A#8A#(F,KKE3F+1-&gt;(ML)Y8&amp;Y("[(R_'BN"Q?B]@B=8A=(NL*Y8&amp;Y(!CHI6-="$F*TA4HRO&amp;R?$D*Y8&amp;Y("[(R_%B6*_1VZ5J.'7AQW0Q'$Q'D]&amp;D]&amp;"#"I`"9`!90!90:78Q'$Q'D]&amp;D]."+"I`"9`!9)%:4WMMI:C1;EQT"Y/&amp;4&gt;YP6JR36R/K1WO:6WZ2KGUVN%[FN$L7(LP9QV2[3WO+L,;L;9KENANK85Y.7AV&amp;LIJ:=*GL0=9&gt;P]"7_Q'@Y&amp;"`D1XR15H`TR0V_L^VOJ]VGI^6KJ=6CI&gt;FMJOFUKP&amp;YL/&amp;QK-&amp;A=0QX]9JRM,-@\[7L=M(^T8O&gt;X\T$W`E4:`4TTY=Z:]O,F^=X&amp;Z@8SQ_L\@,.[MPSY^NN]4,H6\X5`&amp;&lt;@3``#OV%PV$XY']9;@1=9RHL7!!!!!!</Property>
<Property Name="NI.Lib.Version" Type="Str">1.0.0.0</Property>
<Item Name="datatypes" Type="Folder">
<Item Name="freenect_depth_format.ctl" Type="VI" URL="../datatypes/freenect_depth_format.ctl"/>
<Item Name="freenect_led_options.ctl" Type="VI" URL="../datatypes/freenect_led_options.ctl"/>
<Item Name="freenect_raw_tilt_state.ctl" Type="VI" URL="../datatypes/freenect_raw_tilt_state.ctl"/>
<Item Name="freenect_tilt_status_code.ctl" Type="VI" URL="../datatypes/freenect_tilt_status_code.ctl"/>
<Item Name="freenect_video_format.ctl" Type="VI" URL="../datatypes/freenect_video_format.ctl"/>
</Item>
<Item Name="freenect_lv.dll" Type="Document" URL="../freenect_lv.dll"/>
<Item Name="get depth frame.vi" Type="VI" URL="../VIs/get depth frame.vi"/>
<Item Name="get image frame.vi" Type="VI" URL="../VIs/get image frame.vi"/>
<Item Name="get tilt state.vi" Type="VI" URL="../VIs/get tilt state.vi"/>
<Item Name="get tilt state mks.vi" Type="VI" URL="../VIs/get tilt state mks.vi"/>
<Item Name="set led.vi" Type="VI" URL="../VIs/set led.vi"/>
<Item Name="set tilt degs.vi" Type="VI" URL="../VIs/set tilt degs.vi"/>
<Item Name="stop.vi" Type="VI" URL="../VIs/stop.vi"/>
<Item Name="example.vi" Type="VI" URL="../VIs/example.vi"/>
</Library>
Binary file added wrappers/labview/lvlib/pthreadVC2.dll
Binary file not shown.