dige hat geschrieben:@Stevie63: Du hast hier so nebenbei erwähnt das Du mit dem XBox Kinect Sensor arbeitest.
Hast Du es schon geschafft direkt mit PB auf den Sensor zuzugreifen? Leider gibt es das
Microsoft Kinect SDK noch nicht und auch keinen VB/PB Wrapper für das OpenNI Framework.
Und was genau machst Du mit dem Teil? Ich will es für Gestensteuerung nutzen...
Hi,
um auf die Kinect zugreifen zu können, gibt es verschiedene Schnittstellen. Zwei der bekanntesten sind die API von OpenNI (wie du oben schon genannt hast) und einmal die API von codelaboratories. Die OpenNI ist eine sehr umfangreiche C/C++ - Bibliothek, die auch schon das Tracking enthält. Die lib von codelaboratories ist dagegen schon minimalistisch. Über einen wrap lässt sich sehr bequem auf die Kinect zugreifen, dh. man kann a) das normale Kamerabild und b) die Tiefenbilder "abgreifen".
Ich benutze die Kinect zuallererst für "Laborzwecke", d.h. ich bereite Aufgaben und Übungen für unser neues Medienlabor vor, welches sich zur Zeit im Aufbau befindet. Mein erstes "konkretes" Übungsbeispiel ist die Gestensteuerung für Armagetron, welche auch schon ganz gut funktioniert. Zur Zeit arbeit ich daran, Kinect-Bilder übers web zu übertragen. Funktioniert auch schon, aber noch ohne Kompression (Kompression muß aber sein, denn bei 25 frames pro Sekunde mit ca 300k für ein 8bit-Graustufenbild braucht man entweder eine gute Bandbreite oder eine gute Kompression). Weitere Übungen (hauptsächlich in Form von einfachen Spielen mit Gestensteuerung befindet sich in Planung).
Als Code lege ich den wrapper der codelaboratories bei. Achtung: die dll von codelaboratories ist in 32bit, also mit pb32 arbeiten.
Vielleicht schaffe ich es, im Laufe des Jahres eine Kinect-Lib (inkl. Tracking und ImageProcessing) in PB fertigzustellen. Wer Interesse hat, kann sich ja bei mir melden (aber zur Zeit noch alles ohne Gewähr).
Ach, ich vergaß: ohne die Autowin-Lib und das lib2pb-Tool von ts-soft hätte ich das Ganze nicht geschafft! Vielen Dank an ts-soft

!!
cu, stevie63
Code: Alles auswählen
; Import-File created by Lib2PBImport
; Libname: CLNUIDevice.lib
; include <stdint.h>
;
; typedef uint8_t BYTE;
; typedef uint16_t WORD;
; typedef uint32_t DWORD;
; typedef uint64_t QWORD;
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; //
; // This library is part of CL NUI SDK
; // It allows the use of Microsoft Kinect cameras in your own applications
; //
; // For updates And file downloads go To: http://codelaboratories.com/get/kinect
; //
; // Copyright 2010 (c) Code Laboratories, Inc. All rights reserved.
; //
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; #pragma once
; #include <windows.h>
;
; #define Import(type) extern "C" __declspec(dllimport)## type __cdecl
;
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; // NUIDevice API
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; Import(int) GetNUIDeviceCount();
; Import(PCHAR) GetNUIDeviceSerial(int index);
;
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; // CLNUIMotor API
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; // Motor instance type
; typedef void *CLNUIMotor;
;
; // Library initialization
; Import(CLNUIMotor) CreateNUIMotor(PCHAR serial);
; Import(bool) DestroyNUIMotor(CLNUIMotor mot);
;
; // Motor control
; Import(bool) SetNUIMotorPosition(CLNUIMotor mot, SHORT position);
;
; // Get accelerometer Data
; Import(bool) GetNUIMotorAccelerometer(CLNUIMotor mot, SHORT &x, SHORT &y, SHORT &z);
;
; Import(bool) SetNUIMotorLED(CLNUIMotor mot, BYTE value);
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; // CLNUICamera API
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; // Camera instance type
; typedef void *CLNUICamera;
;
; // Library initialization
; Import(CLNUICamera) CreateNUICamera(PCHAR serial);
; Import(bool) DestroyNUICamera(CLNUICamera cam);
;
; // Camera capture control
; Import(bool) StartNUICamera(CLNUICamera cam);
; Import(bool) StopNUICamera(CLNUICamera cam);
;
; // Camera video frame image Data retrieval
; Import(bool) GetNUICameraColorFrameRAW(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
; Import(bool) GetNUICameraColorFrameRGB24(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
; Import(bool) GetNUICameraColorFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
;
; // Camera depth frame image Data retrieval
; Import(bool) GetNUICameraDepthFrameRAW(CLNUICamera cam, PUSHORT pData, int waitTimeout = 2000);
; Import(bool) GetNUICameraDepthFrameCorrected12(CLNUICamera cam, PUSHORT pData, int waitTimeout = 2000);
; Import(bool) GetNUICameraDepthFrameCorrected8(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
; Import(bool) GetNUICameraDepthFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EnableExplicit
ImportC "CLNUIDevice.lib"
; ================================================================
; *Data: .a (1 Byte, 0-255), *camera: void *
; Import(bool) GetNUICameraDepthFrameCorrected8(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
GetNUICameraDepthFrameCorrected8.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraDepthFrameCorrected8"
; ================================================================
; *pData: .u (2 Byte, 0-65535)
; Import(bool) GetNUICameraDepthFrameCorrected12(CLNUICamera cam, PUSHORT pData, int waitTimeout = 2000);
GetNUICameraDepthFrameCorrected12.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraDepthFrameCorrected12"
; ================================================================
; *pData: .l (32 Bit unsigned)
; Import(bool) GetNUICameraDepthFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
GetNUICameraDepthFrameRGB32.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraDepthFrameRGB32"
; ================================================================
; *pData: .u (2 Byte, 0-65535)
; Import(bool) GetNUICameraDepthFrameRAW(CLNUICamera cam, PUSHORT pData, int waitTimeout = 2000);
GetNUICameraDepthFrameRAW.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraDepthFrameRAW"
; ================================================================
; *pData: .l (32 Bit unsigned)
; Import(bool) GetNUICameraColorFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
GetNUICameraColorFrameRGB32.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraColorFrameRGB32"
; ================================================================
; *Data: .a (1 Byte, 0-255), *camera: void *
; Import(bool) GetNUICameraColorFrameRGB24(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
GetNUICameraColorFrameRGB24.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraColorFrameRGB24"
; ================================================================
; Import(bool) GetNUICameraColorFrameRAW(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
GetNUICameraColorFrameRAW.l(*camera, *pData, waitTimeout.l) As "_GetNUICameraColorFrameRAW"
; ================================================================
; Import(bool) StopNUICamera(CLNUICamera cam);
StopNUICamera.l(*camera) As "_StopNUICamera"
; ================================================================
; Import(bool) StartNUICamera(CLNUICamera cam);
StartNUICamera.l(*camera) As "_StartNUICamera"
; ================================================================
; Import(bool) DestroyNUICamera(CLNUICamera cam);
DestroyNUICamera.l(*camera) As "_DestroyNUICamera"
; ================================================================
; Import(CLNUICamera) CreateNUICamera(PCHAR serial);
CreateNUICamera.l(*serial) As "_CreateNUICamera"
; ================================================================
; Import(bool) SetNUIMotorLED(CLNUIMotor mot, BYTE value);
SetNUIMotorLED.l(*motor,value.a ) As "_SetNUIMotorLED"
; ================================================================
; Import(bool) SetNUIMotorPosition(CLNUIMotor mot, SHORT position);
SetNUIMotorPosition.l(*motor,position.w) As "_SetNUIMotorPosition"
; ================================================================
; Import(bool) GetNUIMotorAccelerometer(CLNUIMotor mot, SHORT &x, SHORT &y, SHORT &z);
GetNUIMotorAccelerometer.l(*motor,*x,*y,*z) As "_GetNUIMotorAccelerometer"
; ================================================================
; Import(bool) DestroyNUIMotor(CLNUIMotor mot);
DestroyNUIMotor.l(*motor) As "_DestroyNUIMotor"
; ================================================================
; Import(CLNUIMotor) CreateNUIMotor(PCHAR serial);
CreateNUIMotor.i(*serial) As "_CreateNUIMotor"
; ================================================================
; Import(PCHAR) GetNUIDeviceSerial(int index);
GetNUIDeviceSerial.i(index.l) As "_GetNUIDeviceSerial"
; ================================================================
; Import(int) GetNUIDeviceCount();
GetNUIDeviceCount.l() As "_GetNUIDeviceCount"
; ================================================================
EndImport
Kann sein, daß beim Wrapper noch der eine oder andere Bug ist (ich habe noch nicht alle Funktionen getestet, da ich hauptsächlich das Kamerabild, das 24bit-Tiefenbild und 8bit-Tiefenbild benutze.).