Skip to content

[Unstable] LabView Integration #517

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions wrappers/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
INSTALL(FILES libfreenect.hpp
DESTINATION include)

IF(BUILD_EXAMPLES)

set(CMAKE_C_FLAGS "-Wall")

if (WIN32)
Expand Down Expand Up @@ -36,3 +38,5 @@ endif()

install (TARGETS cppview
DESTINATION bin)

ENDIF()
16 changes: 16 additions & 0 deletions wrappers/labview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
######################################################################################
# C Labview Interface
######################################################################################
set_source_files_properties(libfreenect_lv.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})
20 changes: 20 additions & 0 deletions wrappers/labview/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
General information:
These drivers are still very very experimental and while they work, they are not 100% stable. There will probably be problems we haven't discovered yet. Please keep this in mind!

Needed first before this works:
1) Microsoft Visual C++ 2010 Redistributable Package http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84&displaylang=en
2) Windows machine with a (preferably) new version of LabVIEW (8.6+). Older versions untested.
3) 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) Only 11Bit Depth Format and RGB Format work currently. Support for the others is being added soon.
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 in release format
- Only has been tested with 1 Kinect
- 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.
93 changes: 93 additions & 0 deletions wrappers/labview/libfreenect_lv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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 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/get_depth_imaq.vi
Binary file not shown.
Binary file added wrappers/labview/lvlib/VIs/get_image_imaq.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 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.
28 changes: 28 additions & 0 deletions wrappers/labview/lvlib/libfreenect.lvlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<Library LVVersion="8608002">
<Property Name="NI.Lib.Icon" Type="Bin">#'#!!A!!!!)!"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 Name="freenect_rgb_24bit.ctl" Type="VI" URL="../datatypes/freenect_rgb_24bit.ctl"/>
</Item>
<Item Name="dll" Type="Folder">
<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>
<Item Name="imaq" Type="Folder">
<Item Name="get_image_imaq.vi" Type="VI" URL="../VIs/get_image_imaq.vi"/>
<Item Name="get_depth_imaq.vi" Type="VI" URL="../VIs/get_depth_imaq.vi"/>
</Item>
<Item Name="example.vi" Type="VI" URL="../VIs/example.vi"/>
</Library>
Binary file added wrappers/labview/lvlib/pthreadVC2.dll
Binary file not shown.