Skip to content

Commit f12cca9

Browse files
committed
Merge remote branch 'marcan/master'
Conflicts: .gitignore README.txt
2 parents 3d1b42b + 938a2d5 commit f12cca9

13 files changed

+911
-2
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#ignore thumbnails created by windows
32
Thumbs.db
43
#Ignore files build by Visual Studio
@@ -26,4 +25,5 @@ Thumbs.db
2625
obj/
2726
[Rr]elease*/
2827
_ReSharper*/
29-
[Tt]est[Rr]esult*
28+
[Tt]est[Rr]esult*
29+
build

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PROJECT(libfreenect)
2+
3+
cmake_minimum_required(VERSION 2.6)
4+
5+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Modules/")
6+
7+
set(CMAKE_C_FLAGS "-Wall -O3 -g")
8+
9+
add_subdirectory (lib)
10+
add_subdirectory (examples)

Modules/FindUSB.cmake

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# - Try to find libusb-1.0
2+
# Once done, this will define
3+
#
4+
# USB_FOUND - system has libusb-1.0
5+
# USB_INCLUDE_DIRS - the libusb-1.0 include directories
6+
# USB_LIBRARIES - link these to use libusb-1.0
7+
8+
include(LibFindMacros)
9+
10+
# Dependencies
11+
12+
# Use pkg-config to get hints about paths
13+
libfind_pkg_check_modules(USB_PKGCONF libusb-1.0>=1.0.3)
14+
15+
# Include dir
16+
find_path(USB_INCLUDE_DIR
17+
NAMES libusb.h
18+
PATHS ${USB_PKGCONF_INCLUDE_DIRS}
19+
)
20+
21+
# Finally the library itself
22+
find_library(USB_LIBRARY
23+
NAMES usb-1.0
24+
PATHS ${USB_PKGCONF_LIBRARY_DIRS}
25+
)
26+
27+
# Set the include dir variables and the libraries and let libfind_process do the rest.
28+
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
29+
set(USB_PROCESS_INCLUDES USB_INCLUDE_DIR)
30+
set(USB_PROCESS_LIBS USB_LIBRARY)
31+
libfind_process(USB)

Modules/LibFindMacros.cmake

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
2+
# used for the current package. For this to work, the first parameter must be the
3+
# prefix of the current package, then the prefix of the new package etc, which are
4+
# passed to find_package.
5+
macro (libfind_package PREFIX)
6+
set (LIBFIND_PACKAGE_ARGS ${ARGN})
7+
if (${PREFIX}_FIND_QUIETLY)
8+
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
9+
endif (${PREFIX}_FIND_QUIETLY)
10+
if (${PREFIX}_FIND_REQUIRED)
11+
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
12+
endif (${PREFIX}_FIND_REQUIRED)
13+
find_package(${LIBFIND_PACKAGE_ARGS})
14+
endmacro (libfind_package)
15+
16+
# Damn CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
17+
# where they added pkg_check_modules. Consequently I need to support both in my scripts
18+
# to avoid those deprecated warnings. Here's a helper that does just that.
19+
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
20+
macro (libfind_pkg_check_modules PREFIX PKGNAME)
21+
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
22+
include(UsePkgConfig)
23+
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
24+
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
25+
find_package(PkgConfig)
26+
if (PKG_CONFIG_FOUND)
27+
pkg_check_modules(${PREFIX} ${PKGNAME})
28+
endif (PKG_CONFIG_FOUND)
29+
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
30+
endmacro (libfind_pkg_check_modules)
31+
32+
# Do the final processing once the paths have been detected.
33+
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
34+
# all the variables, each of which contain one include directory.
35+
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
36+
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
37+
# Also handles errors in case library detection was required, etc.
38+
macro (libfind_process PREFIX)
39+
# Skip processing if already processed during this run
40+
if (NOT ${PREFIX}_FOUND)
41+
# Start with the assumption that the library was found
42+
set (${PREFIX}_FOUND TRUE)
43+
44+
# Process all includes and set _FOUND to false if any are missing
45+
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
46+
if (${i})
47+
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
48+
mark_as_advanced(${i})
49+
else (${i})
50+
set (${PREFIX}_FOUND FALSE)
51+
endif (${i})
52+
endforeach (i)
53+
54+
# Process all libraries and set _FOUND to false if any are missing
55+
foreach (i ${${PREFIX}_PROCESS_LIBS})
56+
if (${i})
57+
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
58+
mark_as_advanced(${i})
59+
else (${i})
60+
set (${PREFIX}_FOUND FALSE)
61+
endif (${i})
62+
endforeach (i)
63+
64+
# Print message and/or exit on fatal error
65+
if (${PREFIX}_FOUND)
66+
if (NOT ${PREFIX}_FIND_QUIETLY)
67+
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
68+
endif (NOT ${PREFIX}_FIND_QUIETLY)
69+
else (${PREFIX}_FOUND)
70+
if (${PREFIX}_FIND_REQUIRED)
71+
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
72+
message("${i}=${${i}}")
73+
endforeach (i)
74+
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
75+
endif (${PREFIX}_FIND_REQUIRED)
76+
endif (${PREFIX}_FOUND)
77+
endif (NOT ${PREFIX}_FOUND)
78+
endmacro (libfind_process)
79+
80+
macro(libfind_library PREFIX basename)
81+
set(TMP "")
82+
if(MSVC80)
83+
set(TMP -vc80)
84+
endif(MSVC80)
85+
if(MSVC90)
86+
set(TMP -vc90)
87+
endif(MSVC90)
88+
set(${PREFIX}_LIBNAMES ${basename}${TMP})
89+
if(${ARGC} GREATER 2)
90+
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
91+
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
92+
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
93+
endif(${ARGC} GREATER 2)
94+
find_library(${PREFIX}_LIBRARY
95+
NAMES ${${PREFIX}_LIBNAMES}
96+
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
97+
)
98+
endmacro(libfind_library)
99+

README.txt

+45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
1+
== Marcan's Readme
2+
3+
Horribly hacky first take at a Kinect Camera driver. Does RGB and Depth.
4+
5+
main.c implements a simple OpenGL visualization. Hopefully it should be mostly
6+
self-explanatory... You pretty much just open the USB device, call
7+
cams_init(dev, depthimg, rgbimg), and your depthimg and rgbimg callbacks get
8+
called as libusb processes events.
9+
10+
TODO:
11+
- TONS of cleanup. I mean LOTS.
12+
- Determine exactly what the inits do
13+
- Bayer to RGB conversion that doesn't suck
14+
- Integrate support for the servo and accelerometer (which have already been
15+
reverse engineered)
16+
17+
BIG TODO: audio. The audio chip (the Marvell) requires firmware and more init
18+
and does a TON of stuff including the crypto authentication to prove that it is
19+
an original Kinect and not a clone. Who knows what this thing does to the
20+
incoming audio. This should be interesting to look at.
21+
22+
23+
Libfreenect is Copyright (C) 2010 Hector Martin "marcan" <[email protected]>
24+
25+
This code is licensed to you under the terms of the GNU GPL, version 2 or
26+
version 3; see:
27+
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
28+
http://www.gnu.org/licenses/gpl-3.0.txt
29+
30+
Credits:
31+
32+
Adafruit, for providing the USB logs that I used to work out the initialization
33+
sequence and data format.
34+
35+
bushing, for trying to provide USB logs, although he got preempted by Adafruit ;)
36+
37+
A few other people who provided hints and encouragement along the way, you know
38+
who you are!
39+
40+
== Josh Blake's Readme
41+
142
OpenKinect project
243

344
Copyright (c) 2010 Joshua Blake and other contributors
445

546
The folder INF contains Windows drivers. Plug in Kinect and during the driver installation browse to the proper folder. The drivers were generated via libusbdotnet tools and are distributed under their own licenses.
647

748
The rest of the project is distributed under the Apache 2 license.
49+
50+
== qDot's Readme
51+
52+
I'm a code janitor!

examples/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include_directories (${CMAKE_SOURCE_DIR}/include)
2+
link_directories (${CMAKE_BINARY_DIR}/lib)
3+
4+
find_package(Threads REQUIRED)
5+
find_package(OpenGL REQUIRED)
6+
find_package(GLU REQUIRED)
7+
find_package(GLUT REQUIRED)
8+
9+
find_package(USB REQUIRED)
10+
include_directories(${USB_INCLUDE_DIRS})
11+
12+
add_executable(glview glview.c)
13+
find_library (PTHREAD pthread)
14+
target_link_libraries(glview freenect GL GLU glut m)

0 commit comments

Comments
 (0)