diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 00000000..cbe85d7c --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,68 @@ +Change Log: +----------- + +OpenNI 2.2.0: + - Added getDepthColorSyncEnabled API + - Merge pull request #7: Driver path resolution based on the shared library location See https://github.com/OpenNI/OpenNI2/pull/7 for details (thanks Tomoto) + - Build: Rename Redist dir to Packaging + - Build: Remove all warnings during build. Treat all warnings as errors. + - Bug Fix: Failed to use after OpenCL was initialized + - Rewrote the android make files to proper standards + - Fix Linux identification (apparently -std=c1x defines only __linux and not linux) + - PS1080 Bug Fix: handle file system lock when uploading only in supporting firmwares + - PS1080: Add NESA unlimited to BIST + - PS1080: improved hardware name detection + - PS1080: IR stream now also supports RGB888 + - Bug Fix: Visual Sutdio 2008 wasn't supported + - Add a typedef: OniGrayscale8Pixel + - Make sure device is still open when closing a stream that uses it. + - Add support for Capri devices + - New Java Wrappers + - New Java sample: SimpleViewer.java + - Support WIX 3.6 and up + - Kinect: wrong error code returned when trying to change video mode while streaming + - invoke() method signature was updated - data is no longer const + - PrimeSense: move common properties (PS1080 and Capri) to PrimeSense.h + - PS1080: add new property for turning on hardware frame sync, with no OpenNI checks + - New pixel format: YUYV. PS1080 now supports it (on newer firmwares) + - PS1080: add lots of debug commands + - ReleaseVersion script: don't fail if output file exists (overwrite it) + - PS1080: add new file type (vendor data) + +OpenNI 2.1.0: + - API change: each event now has its own addListener()/removeListener() methods. A listener object can now be added only once. + - Support for Mac OSX + - Support for Linux on Arm + - Support for Android (native only) + - Kinect: implementing convertDepthToColorCoordinates() + - Kinect: implementing CameraSettings + - Kinect Bug Fix: can now switch between color and IR streams + - Kinect Bug Fix: wrong mirror value was returned + - PS1080 Bug Fix: trying to open more than 8 devices will crash + - PS1080 Bug Fix: on Linux 64-bit, color frames are sometimes corrupt + - PS1080 Bug Fix: a potential crash with older firmwares + - NiViewer now browses whenever a recording is started + - NiViewer: added 'i' key for toggling image-registration (also added current status in the status bar) + - Minor memory leak fixes + - EventBasedRead Sample Bug Fix: will not get device events + - EventBasedRead Sample now prints the list of connected devices and every change that occurs + - Recordings are now also compatible with OpenNI 1.x and NiTE 1.x + - Potential starvation bug fix when application takes much time handling events + - Log file now closes on shutdown(), and a new one is created on initialize() + - SimpleRead is now the default project in the VS solution (thanks eranws) + - Bug Fix: did not support Visual Studio 2008 and older + - Bug Fix: did not support Visual Studio 2012 and newer + - Bug Fix: did not support Visual Studio Express (thanks rh-galaxy) + - NiViewer Bug Fix: Mirror did not change IR state + - Kinect: providing Kinect for Windows PID and VID in the device info struct + - ONI files: providing driver name in the device info struct + - Bug Fix: ReleaseVersion script did not work on 32-bit machines + - Linux Bug Fix: log timestamps did not start from 0. + +OpenNI 2.0.0: + - Brand new API (see documentation) + - Algorithms API were removed, and are now part of middleware libraries (such as NiTE) + - New deployment model - private copy to each application (see documentation) + - Added support for turning off Auto Exposure and Auto White Balance of the color CMOS in PS1080 devices + - Built-in support for Kinect devices via the Kinect SDK (Windows only) + - Added support for translating a depth pixel to color map coordinates diff --git a/Config/OpenNI2/Drivers/PS1080.ini b/Config/OpenNI2/Drivers/PS1080.ini index 737c41de..b519f9c3 100644 --- a/Config/OpenNI2/Drivers/PS1080.ini +++ b/Config/OpenNI2/Drivers/PS1080.ini @@ -101,7 +101,7 @@ ;Enabled=1 [Image] -; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only) +; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only), 205 - YUYV ;OutputFormat=200 ; Is stream mirrored. 0 - Off, 1 - On @@ -113,7 +113,7 @@ ; Frames per second (default is 30) ;FPS=30 -; Input format. 0 - BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER +; Input format. 0 - BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER, 7 - Uncompressed YUYV ;InputFormat=5 ; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. diff --git a/Include/Driver/OniDriverAPI.h b/Include/Driver/OniDriverAPI.h index a1ee7519..8552f9db 100644 --- a/Include/Driver/OniDriverAPI.h +++ b/Include/Driver/OniDriverAPI.h @@ -47,7 +47,7 @@ class StreamBase virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} - virtual OniStatus invoke(int /*commandId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} virtual OniStatus start() = 0; @@ -88,7 +88,7 @@ class DeviceBase virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} - virtual OniStatus invoke(int /*commandId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} @@ -254,7 +254,7 @@ ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase pDevice->notifyAllProperties(); \ } \ ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ - const void* data, int dataSize) \ + void* data, int dataSize) \ { \ return pDevice->invoke(commandId, data, dataSize); \ } \ @@ -297,7 +297,7 @@ ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase pStream->notifyAllProperties(); \ } \ ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ - const void* data, int dataSize) \ + void* data, int dataSize) \ { \ return pStream->invoke(commandId, data, dataSize); \ } \ diff --git a/Include/OniCAPI.h b/Include/OniCAPI.h index 341f7171..f2840d5a 100644 --- a/Include/OniCAPI.h +++ b/Include/OniCAPI.h @@ -84,7 +84,7 @@ ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, /** Check if the property is supported by the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId); /** Invoke an internal functionality of the device. */ -ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, const void* data, int dataSize); +ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void* data, int dataSize); /** Check if a command is supported, for invoke */ ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId); @@ -118,7 +118,7 @@ ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, /** Check if the property is supported the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId); /** Invoke an internal functionality of the stream. */ -ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, const void* data, int dataSize); +ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void* data, int dataSize); /** Check if a command is supported, for invoke */ ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId); // handle registration of pixel diff --git a/Include/OniCEnums.h b/Include/OniCEnums.h index cde92c41..affce9a1 100644 --- a/Include/OniCEnums.h +++ b/Include/OniCEnums.h @@ -58,6 +58,7 @@ typedef enum ONI_PIXEL_FORMAT_GRAY8 = 202, ONI_PIXEL_FORMAT_GRAY16 = 203, ONI_PIXEL_FORMAT_JPEG = 204, + ONI_PIXEL_FORMAT_YUYV = 205, } OniPixelFormat; typedef enum diff --git a/Include/OniEnums.h b/Include/OniEnums.h index fa591f5a..018f2227 100644 --- a/Include/OniEnums.h +++ b/Include/OniEnums.h @@ -61,6 +61,7 @@ typedef enum PIXEL_FORMAT_GRAY8 = 202, PIXEL_FORMAT_GRAY16 = 203, PIXEL_FORMAT_JPEG = 204, + PIXEL_FORMAT_YUYV = 205, } PixelFormat; typedef enum diff --git a/Include/OniVersion.h b/Include/OniVersion.h index 9c1fc180..1b9bccb8 100644 --- a/Include/OniVersion.h +++ b/Include/OniVersion.h @@ -23,7 +23,7 @@ #define ONI_VERSION_MAJOR 2 #define ONI_VERSION_MINOR 2 #define ONI_VERSION_MAINTENANCE 0 -#define ONI_VERSION_BUILD 3 +#define ONI_VERSION_BUILD 7 /** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ #define ONI_BRIEF_VERSION_STRING \ diff --git a/Include/OpenNI.h b/Include/OpenNI.h index 4df62935..661b6d3c 100644 --- a/Include/OpenNI.h +++ b/Include/OpenNI.h @@ -1096,7 +1096,7 @@ class VideoStream @returns Status code indicating success or failure of this operation. */ template - Status invoke(int commandId, const T& value) + Status invoke(int commandId, T& value) { return invoke(commandId, &value, sizeof(T)); } @@ -1505,7 +1505,7 @@ class Device @param [in] dataSize size of the buffer passed in @c data. @returns Status code indicating success or failure of this operation. */ - Status invoke(int commandId, const void* data, int dataSize) + Status invoke(int commandId, void* data, int dataSize) { return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize); } @@ -1520,7 +1520,7 @@ class Device @returns Status code indicating success or failure of this operation. */ template - Status invoke(int propertyId, const T& value) + Status invoke(int propertyId, T& value) { return invoke(propertyId, &value, sizeof(T)); } diff --git a/Include/PS1080.h b/Include/PS1080.h index cff12f82..8e26725a 100644 --- a/Include/PS1080.h +++ b/Include/PS1080.h @@ -36,6 +36,7 @@ * E0 - device commands * 00 - common stream properties * 10 - depth stream properties + * 20 - color stream properties */ enum { @@ -57,9 +58,31 @@ enum XN_MODULE_PROPERTY_SERIAL_NUMBER = 0x1080F006, // "ID" /** XnVersions */ XN_MODULE_PROPERTY_VERSION = 0x1080F007, // "Version" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_FRAME_SYNC = 0x1080F008, + /** Boolean */ + XN_MODULE_PROPERTY_HOST_TIMESTAMPS = 0x1080FF77, // "HostTimestamps" + /** Boolean */ + XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN = 0x1080FF78, // "CloseStreamsOnShutdown" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_INTERVAL = 0x1080FF7F, // "FirmwareLogInterval" + /** Boolean */ + XN_MODULE_PROPERTY_PRINT_FIRMWARE_LOG = 0x1080FF80, // "FirmwareLogPrint" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_FILTER = 0x1080FF81, // "FirmwareLogFilter" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG = 0x1080FF82, // "FirmwareLog" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL = 0x1080FF83, // "FirmwareCPUInterval" + /** String */ + XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME = 0x1080FF7A, // "PhysicalDeviceName" + /** String */ + XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA = 0x1080FF7B, // "VendorSpecificData" + /** String */ + XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING = 0x1080FF7C, // "SensorPlatformString" /*******************************************************************/ - /* Device commands (activated via SetProperty) */ + /* Device commands (activated via SetProperty/GetProperty) */ /*******************************************************************/ /** XnInnerParam */ @@ -74,7 +97,32 @@ enum XN_MODULE_PROPERTY_AHB = 0x1080E005, // "AHB" /** XnLedState */ XN_MODULE_PROPERTY_LED_STATE = 0x1080E006, // "LedState" - + /** XnCmosBlankingUnits */ + XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS = 0x1080FF74, // "CmosBlankingUnits" + /** XnCmosBlankingTime */ + XN_MODULE_PROPERTY_CMOS_BLANKING_TIME = 0x1080FF75, // "CmosBlankingTime" + /** XnFlashFileList */ + XN_MODULE_PROPERTY_FILE_LIST = 0x1080FF84, // "FileList" + /** XnParamFlashData */ + XN_MODULE_PROPERTY_FLASH_CHUNK = 0x1080FF85, // "FlashChunk" + XN_MODULE_PROPERTY_FILE = 0x1080FF86, // "FlashFile" + /** Integer */ + XN_MODULE_PROPERTY_DELETE_FILE = 0x1080FF87, // "DeleteFile" + XN_MODULE_PROPERTY_FILE_ATTRIBUTES = 0x1080FF88, // "FileAttributes" + XN_MODULE_PROPERTY_TEC_SET_POINT = 0x1080FF89, // "TecSetPoint" + XN_MODULE_PROPERTY_TEC_STATUS = 0x1080FF8A, // "TecStatus" + XN_MODULE_PROPERTY_TEC_FAST_CONVERGENCE_STATUS = 0x1080FF8B, // "TecFastConvergenceStatus" + XN_MODULE_PROPERTY_EMITTER_SET_POINT = 0x1080FF8C, // "EmitterSetPoint" + XN_MODULE_PROPERTY_EMITTER_STATUS = 0x1080FF8D, // "EmitterStatus" + XN_MODULE_PROPERTY_I2C = 0x1080FF8E, // "I2C" + /** Integer */ + XN_MODULE_PROPERTY_BIST = 0x1080FF8F, // "BIST" + /** XnProjectorFaultData */ + XN_MODULE_PROPERTY_PROJECTOR_FAULT = 0x1080FF90, // "ProjectorFault" + /** Boolean */ + XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" /*******************************************************************/ /* Common stream properties */ @@ -125,6 +173,20 @@ enum XN_STREAM_PROPERTY_D2S_TABLE = 0x10801011, // "D2S" XN_STREAM_PROPERTY_DEPTH_SENSOR_CALIBRATION_INFO = 0x10801012, + /** Boolean */ + XN_STREAM_PROPERTY_GMC_MODE = 0x1080FF44, // "GmcMode" + /** Boolean */ + XN_STREAM_PROPERTY_GMC_DEBUG = 0x1080FF45, // "GmcDebug" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION = 0x1080FF46, // "WavelengthCorrection" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION_DEBUG = 0x1080FF47, // "WavelengthCorrectionDebug" + + /*******************************************************************/ + /* Color stream properties */ + /*******************************************************************/ + /** Integer */ + XN_STREAM_PROPERTY_FLICKER = 0x10802001, // "Flicker" }; typedef enum @@ -189,7 +251,7 @@ typedef enum XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, - XN_IO_IMAGE_FORMAT_UNCOMPRESSED_GRAY8 = 7, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUYV = 7, } XnIOImageFormats; typedef enum @@ -236,6 +298,119 @@ enum XN_ERROR_STATE_DEVICE_OVERHEAT = 2, }; +typedef enum XnFirmwareCroppingMode +{ + XN_FIRMWARE_CROPPING_MODE_DISABLED = 0, + XN_FIRMWARE_CROPPING_MODE_NORMAL = 1, + XN_FIRMWARE_CROPPING_MODE_INCREASED_FPS = 2, +} XnFirmwareCroppingMode; + +typedef enum +{ + XnLogFilterDebug = 0x0001, + XnLogFilterInfo = 0x0002, + XnLogFilterError = 0x0004, + XnLogFilterProtocol = 0x0008, + XnLogFilterAssert = 0x0010, + XnLogFilterConfig = 0x0020, + XnLogFilterFrameSync = 0x0040, + XnLogFilterAGC = 0x0080, + XnLogFilterTelems = 0x0100, + + XnLogFilterAll = 0xFFFF +} XnLogFilter; + +typedef enum +{ + XnFileAttributeReadOnly = 0x8000 +} XnFilePossibleAttributes; + +typedef enum +{ + XnFlashFileTypeFileTable = 0x00, + XnFlashFileTypeScratchFile = 0x01, + XnFlashFileTypeBootSector = 0x02, + XnFlashFileTypeBootManager = 0x03, + XnFlashFileTypeCodeDownloader = 0x04, + XnFlashFileTypeMonitor = 0x05, + XnFlashFileTypeApplication = 0x06, + XnFlashFileTypeFixedParams = 0x07, + XnFlashFileTypeDescriptors = 0x08, + XnFlashFileTypeDefaultParams = 0x09, + XnFlashFileTypeImageCmos = 0x0A, + XnFlashFileTypeDepthCmos = 0x0B, + XnFlashFileTypeAlgorithmParams = 0x0C, + XnFlashFileTypeReferenceQVGA = 0x0D, + XnFlashFileTypeReferenceVGA = 0x0E, + XnFlashFileTypeMaintenance = 0x0F, + XnFlashFileTypeDebugParams = 0x10, + XnFlashFileTypePrimeProcessor = 0x11, + XnFlashFileTypeGainControl = 0x12, + XnFlashFileTypeRegistartionParams = 0x13, + XnFlashFileTypeIDParams = 0x14, + XnFlashFileTypeSensorTECParams = 0x15, + XnFlashFileTypeSensorAPCParams = 0x16, + XnFlashFileTypeSensorProjectorFaultParams = 0x17, + XnFlashFileTypeProductionFile = 0x18, + XnFlashFileTypeUpgradeInProgress = 0x19, + XnFlashFileTypeWavelengthCorrection = 0x1A, + XnFlashFileTypeGMCReferenceOffset = 0x1B, + XnFlashFileTypeSensorNESAParams = 0x1C, + XnFlashFileTypeSensorFault = 0x1D, + XnFlashFileTypeVendorData = 0x1E, +} XnFlashFileType; + +typedef enum XnBistType +{ + //Auto tests + XN_BIST_IMAGE_CMOS = 1 << 0, + XN_BIST_IR_CMOS = 1 << 1, + XN_BIST_POTENTIOMETER = 1 << 2, + XN_BIST_FLASH = 1 << 3, + XN_BIST_FULL_FLASH = 1 << 4, + XN_BIST_PROJECTOR_TEST_MASK = 1 << 5, + XN_BIST_TEC_TEST_MASK = 1 << 6, + + // Manual tests + XN_BIST_NESA_TEST_MASK = 1 << 7, + XN_BIST_NESA_UNLIMITED_TEST_MASK = 1 << 8, + + // Mask of all the auto tests + XN_BIST_ALL = (0xFFFFFFFF & ~XN_BIST_NESA_TEST_MASK & ~XN_BIST_NESA_UNLIMITED_TEST_MASK), + +} XnBistType; + +typedef enum XnBistError +{ + XN_BIST_RAM_TEST_FAILURE = 1 << 0, + XN_BIST_IR_CMOS_CONTROL_BUS_FAILURE = 1 << 1, + XN_BIST_IR_CMOS_DATA_BUS_FAILURE = 1 << 2, + XN_BIST_IR_CMOS_BAD_VERSION = 1 << 3, + XN_BIST_IR_CMOS_RESET_FAILUE = 1 << 4, + XN_BIST_IR_CMOS_TRIGGER_FAILURE = 1 << 5, + XN_BIST_IR_CMOS_STROBE_FAILURE = 1 << 6, + XN_BIST_COLOR_CMOS_CONTROL_BUS_FAILURE = 1 << 7, + XN_BIST_COLOR_CMOS_DATA_BUS_FAILURE = 1 << 8, + XN_BIST_COLOR_CMOS_BAD_VERSION = 1 << 9, + XN_BIST_COLOR_CMOS_RESET_FAILUE = 1 << 10, + XN_BIST_FLASH_WRITE_LINE_FAILURE = 1 << 11, + XN_BIST_FLASH_TEST_FAILURE = 1 << 12, + XN_BIST_POTENTIOMETER_CONTROL_BUS_FAILURE = 1 << 13, + XN_BIST_POTENTIOMETER_FAILURE = 1 << 14, + XN_BIST_AUDIO_TEST_FAILURE = 1 << 15, + XN_BIST_PROJECTOR_TEST_LD_FAIL = 1 << 16, + XN_BIST_PROJECTOR_TEST_LD_FAILSAFE_TRIG_FAIL = 1 << 17, + XN_BIST_PROJECTOR_TEST_FAILSAFE_HIGH_FAIL = 1 << 18, + XN_BIST_PROJECTOR_TEST_FAILSAFE_LOW_FAIL = 1 << 19, + XN_TEC_TEST_HEATER_CROSSED = 1 << 20, + XN_TEC_TEST_HEATER_DISCONNETED = 1 << 21, + XN_TEC_TEST_TEC_CROSSED = 1 << 22, + XN_TEC_TEST_TEC_FAULT = 1 << 23, +} XnBistError; + +#define XN_IO_MAX_I2C_BUFFER_SIZE 10 +#define XN_MAX_LOG_SIZE (6*1024) + #pragma pack (push, 1) typedef struct XnSDKVersion @@ -305,6 +480,131 @@ typedef struct XnLedState uint16_t nState; } XnLedState; +typedef struct XnCmosBlankingTime +{ + XnCMOSType nCmosID; + float nTimeInMilliseconds; + uint16_t nNumberOfFrames; +} XnCmosBlankingTime; + +typedef struct XnCmosBlankingUnits +{ + XnCMOSType nCmosID; + uint16_t nUnits; + uint16_t nNumberOfFrames; +} XnCmosBlankingUnits; + +typedef struct XnI2CWriteData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nWriteSize; +} XnI2CWriteData; + +typedef struct XnI2CReadData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nReadSize; + uint16_t nWriteSize; +} XnI2CReadData; + +typedef struct XnTecData +{ + uint16_t m_SetPointVoltage; + uint16_t m_CompensationVoltage; + uint16_t m_TecDutyCycle; //duty cycle on heater/cooler + uint16_t m_HeatMode; //TRUE - heat, FALSE - cool + int32_t m_ProportionalError; + int32_t m_IntegralError; + int32_t m_DerivativeError; + uint16_t m_ScanMode; //0 - crude, 1 - precise +} XnTecData; + +typedef struct XnTecFastConvergenceData +{ + int16_t m_SetPointTemperature; // set point temperature in celsius, + // scaled by factor of 100 (extra precision) + int16_t m_MeasuredTemperature; // measured temperature in celsius, + // scaled by factor of 100 (extra precision) + int32_t m_ProportionalError; // proportional error in system clocks + int32_t m_IntegralError; // integral error in system clocks + int32_t m_DerivativeError; // derivative error in system clocks + uint16_t m_ScanMode; // 0 - initial, 1 - crude, 2 - precise + uint16_t m_HeatMode; // 0 - idle, 1 - heat, 2 - cool + uint16_t m_TecDutyCycle; // duty cycle on heater/cooler in percents + uint16_t m_TemperatureRange; // 0 - cool, 1 - room, 2 - warm +} XnTecFastConvergenceData; + +typedef struct XnEmitterData +{ + uint16_t m_State; //idle, calibrating + uint16_t m_SetPointVoltage; //this is what should be written to the XML + uint16_t m_SetPointClocks; //target cross duty cycle + uint16_t m_PD_Reading; //current cross duty cycle in system clocks(high time) + uint16_t m_EmitterSet; //duty cycle on emitter set in system clocks (high time). + uint16_t m_EmitterSettingLogic; //TRUE = positive logic, FALSE = negative logic + uint16_t m_LightMeasureLogic; //TRUE - positive logic, FALSE - negative logic + uint16_t m_IsAPCEnabled; + uint16_t m_EmitterSetStepSize; // in MilliVolts + uint16_t m_ApcTolerance; // in system clocks (only valid up till v5.2) + uint16_t m_SubClocking; //in system clocks (only valid from v5.3) + uint16_t m_Precision; // (only valid from v5.3) +} XnEmitterData; + +typedef struct +{ + uint16_t nId; + uint16_t nAttribs; +} XnFileAttributes; + +typedef struct +{ + uint32_t nOffset; + const char* strFileName; + uint16_t nAttributes; +} XnParamFileData; + +typedef struct +{ + uint32_t nOffset; + uint32_t nSize; + unsigned char* pData; +} XnParamFlashData; + +typedef struct { + uint16_t nId; + uint16_t nType; + uint32_t nVersion; + uint32_t nOffset; + uint32_t nSize; + uint16_t nCrc; + uint16_t nAttributes; + uint16_t nReserve; +} XnFlashFile; + +typedef struct +{ + XnFlashFile* pFiles; + uint16_t nFiles; +} XnFlashFileList; + +typedef struct XnProjectorFaultData +{ + uint16_t nMinThreshold; + uint16_t nMaxThreshold; + int32_t bProjectorFaultEvent; +} XnProjectorFaultData; + +typedef struct XnBist +{ + uint32_t nTestsMask; + uint32_t nFailures; +} XnBist; + #pragma pack (pop) #endif //_PS1080_H_ \ No newline at end of file diff --git a/Include/PSLink.h b/Include/PSLink.h new file mode 100644 index 00000000..dfd87a51 --- /dev/null +++ b/Include/PSLink.h @@ -0,0 +1,129 @@ +#ifndef __XN_PRIME_CLIENT_PROPS_H__ +#define __XN_PRIME_CLIENT_PROPS_H__ + +#include + +enum +{ + /**** Device properties ****/ + /* (XnDetailedVersion) */ + LINK_PROP_FW_VERSION = 0x12000001, // "FWVersion" + /* Int */ + LINK_PROP_VERSIONS_INFO_COUNT = 0x12000002, // "VersionsInfoCount" + /* General - array - XnComponentVersion * count elements */ + LINK_PROP_VERSIONS_INFO = 0x12000003, // "VersionsInfo" + /* General. XnPropUploadFile. Set only. */ + LINK_PROP_UPLOAD_FILE = 0x12000006, // "UploadFile" + /* General. XnPropDownloadFile. Set only. */ + LINK_PROP_DOWNLOAD_FILE = 0x12000007, // "DownloadFile" + /* Int - 0 means off, 1 means on. */ + LINK_PROP_EMITTER_ACTIVE = 0x12000008, // "EmitterActive" + /* Int - 0 means off, 1 means on. */ + LINK_PROP_FW_LOG = 0x12000009, // "FWLog" + /* String */ + LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" + /* Real */ + LINK_PROP_DEPTH_SCALE = 0x1200000b, // "DepthScale" + /* Int */ + LINK_PROP_FORMAT_ZONE = 0x1200000f, // "FormatZone" + /* String */ + LINK_PROP_SERIAL_NUMBER = 0x12000010, // "ID" + + /**** Stream properties ****/ + /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ + LINK_PROP_PIXEL_FORMAT = 0x12001001, // "PixelFormat" + /* Int. 0 - None, 1 - 8z, 2 - 16z, 3 - 24z, 4 - 6-bit, 5 - 10-bit, 6 - 11-bit, 7 - 12-bit */ + LINK_PROP_COMPRESSION = 0x12001002, // "Compression" + + /**** Depth Stream properties ****/ + /* Int */ + LINK_PROP_MAX_SHIFT = 0x12002001, // "MaxShift" + /* Int */ + LINK_PROP_ZERO_PLANE_DISTANCE = 0x12002002, // "ZPD" + /* Int */ + LINK_PROP_CONST_SHIFT = 0x12002003, // "ConstShift" + /* Int */ + LINK_PROP_PARAM_COEFF = 0x12002004, // "ParamCoeff" + /* Int */ + LINK_PROP_SHIFT_SCALE = 0x12002005, // "ShiftScale" + /* Real */ + LINK_PROP_ZERO_PLANE_PIXEL_SIZE = 0x12002006, // "ZPPS" + /* Real */ + LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE = 0x12002007, // "ZPOPS" + /* Real */ + LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE = 0x12002008, // "LDDIS" + /* General - array - MaxShift * XnDepthPixel elements */ + LINK_PROP_SHIFT_TO_DEPTH_TABLE = 0x12002009, // "S2D" + /* General - array - MaxDepth * uint16_t elements */ + LINK_PROP_DEPTH_TO_SHIFT_TABLE = 0x1200200a, // "D2S" +}; + + +#pragma pack (push, 1) + +#define XN_MAX_VERSION_MODIFIER_LENGTH 16 +typedef struct XnDetailedVersion +{ + uint8_t m_nMajor; + uint8_t m_nMinor; + uint16_t m_nMaintenance; + uint32_t m_nBuild; + char m_strModifier[XN_MAX_VERSION_MODIFIER_LENGTH]; +} XnDetailedVersion; + +typedef struct XnPropReadAHB +{ + uint32_t m_nAddress; + uint32_t m_nBitOffset; //Offset in bits of value to read within address + uint32_t m_nBitWidth; //Width in bits of value to read + uint32_t m_nValue; //Output parameter - the value that was actually read +} XnPropReadAHB; + +typedef struct XnPropWriteAHB +{ + uint32_t m_nAddress; + uint32_t m_nValue; + uint32_t m_nBitOffset; //Offset in bits of value to write within address + uint32_t m_nBitWidth; //Width in bits of value to write +} XnPropWriteAHB; + +typedef struct XnPropReadI2C +{ + uint32_t m_nDeviceID; + uint32_t m_nAddressSize; + uint32_t m_nValueSize; + uint32_t m_nAddress; + uint32_t m_nValue; //Output parameter - the value that was actually read +} XnPropReadI2C; + +typedef struct XnPropWriteI2C +{ + uint32_t m_nDeviceID; + uint32_t m_nAddressSize; + uint32_t m_nValueSize; + uint32_t m_nAddress; + uint32_t m_nValue; + uint32_t m_nMask; +} XnPropWriteI2C; + +typedef struct XnPropUploadFile +{ + char* m_nFileName; + uint32_t m_nbOverrideFactorySettings; +} XnPropUploadFile; + +typedef struct XnPropDownloadFile +{ + uint16_t m_nZone; + char* m_nStrFirmwareFileName; + char* m_nStrTargetFile; +} XnPropDownloadFile; + +typedef struct XnPropFormatZone +{ + uint8_t m_nZone; +} XnPropFormatZone; + +#pragma pack (pop) + +#endif //__XN_PRIME_CLIENT_PROPS_H__ diff --git a/Include/PrimeSense.h b/Include/PrimeSense.h new file mode 100644 index 00000000..369ed104 --- /dev/null +++ b/Include/PrimeSense.h @@ -0,0 +1,94 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef _PRIME_SENSE_H_ +#define _PRIME_SENSE_H_ + +#include + +#define PS_USB_VENDOR_ID 0x1D27 +#define PS_NAME "PrimeSense" + +/** +* Additional properties for PrimeSense devices +* +* @remarks +* properties structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* 00 - common stream properties +* 10 - depth stream properties +* E0 - device commands +* F0 - device properties +*/ +enum +{ + // Device Properties + PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType +}; + +/** +* Additional commands for PrimeSense devices +* +* @remarks +* Commands structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* E0 - device commands +*/ +enum +{ + // Device Commands + PS_COMMAND_AHB_READ = 0x1d27E001, // XnCommandAHB + PS_COMMAND_AHB_WRITE = 0x1d27E002, // XnCommandAHB + PS_COMMAND_I2C_READ = 0x1d27E003, // XnCommandI2C + PS_COMMAND_I2C_WRITE = 0x1d27E004, // XnCommandI2C + PS_COMMAND_SOFT_RESET = 0x1d27E005, // no arguments + PS_COMMAND_POWER_RESET = 0x1d27E006, // no arguments +}; + +typedef enum XnUsbInterfaceType +{ + PS_USB_INTERFACE_DONT_CARE = 0, + PS_USB_INTERFACE_ISO_ENDPOINTS = 1, + PS_USB_INTERFACE_BULK_ENDPOINTS = 2, +} XnUsbInterfaceType; + +#pragma pack (push, 1) + +typedef struct XnCommandAHB +{ + uint32_t m_nAddress; // Address of this register + uint32_t m_nBitOffset; // Offset of the field in bits within address + uint32_t m_nBitWidth; // Width of the field in bits + uint32_t m_nValue; // For read requests, this is where the actual value will be filled. For write requests, the value to write. +} XnCommandAHB; + +typedef struct XnCommandI2C +{ + uint32_t m_nDeviceID; // Device to communicate with + uint32_t m_nAddressSize; // Size of the address, in bytes (1-4) + uint32_t m_nAddress; // Address + uint32_t m_nValueSize; // Size of the value, in bytes (1-4) + uint32_t m_nMask; // For write request - a mask to be applied to the value. For read requests - ignored. + uint32_t m_nValue; // For write request - the value to be written. For read requests - the place where the actual value is written to +} XnCommandI2C; + +#pragma pack (pop) + +#endif //_PRIME_SENSE_H_ \ No newline at end of file diff --git a/Makefile b/Makefile index 36edc574..3074a756 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,14 @@ DEPTH_UTILS = Source/DepthUtils ALL_DRIVERS = \ Source/Drivers/DummyDevice \ Source/Drivers/PS1080 \ + Source/Drivers/PSLink \ Source/Drivers/OniFile +# list all wrappers +ALL_WRAPPERS = \ + Wrappers/java/OpenNI.jni \ + Wrappers/java/OpenNI.java + # list all tools ALL_TOOLS = @@ -34,6 +40,7 @@ ALL_CORE_PROJS = \ $(OPENNI) \ $(DEPTH_UTILS) \ $(ALL_DRIVERS) \ + $(ALL_WRAPPERS) \ $(ALL_TOOLS) # list all samples @@ -43,7 +50,11 @@ CORE_SAMPLES = \ Samples/MultipleStreamRead \ Samples/MWClosestPoint \ Samples/MWClosestPointApp - + +# list all java samples +JAVA_SAMPLES = \ + Samples/SimpleViewer.java + ifeq "$(GLUT_SUPPORTED)" "1" ALL_TOOLS += \ Source/Tools/NiViewer @@ -59,7 +70,8 @@ else endif ALL_SAMPLES = \ - $(CORE_SAMPLES) + $(CORE_SAMPLES) \ + $(JAVA_SAMPLES) # list all projects that are build ALL_BUILD_PROJS = \ @@ -96,9 +108,12 @@ $(foreach proj,$(ALL_PROJS),$(eval $(call CREATE_PROJ_TARGET,$(proj)))) # additional dependencies $(OPENNI): $(XNLIB) +Wrappers/java/OpenNI.jni: $(OPENNI) $(XNLIB) + Source/Drivers/DummyDevice: $(OPENNI) $(XNLIB) Source/Drivers/RawDevice: $(OPENNI) $(XNLIB) Source/Drivers/PS1080: $(OPENNI) $(XNLIB) $(DEPTH_UTILS) +Source/Drivers/PSLink: $(OPENNI) $(XNLIB) Source/Drivers/OniFile: $(OPENNI) $(XNLIB) Source/Tools/NiViewer: $(OPENNI) $(XNLIB) @@ -112,6 +127,7 @@ Samples/MWClosestPointApp: $(OPENNI) Samples/MWClosestPoint Samples/SimpleViewer: $(OPENNI) Samples/MultiDepthViewer: $(OPENNI) Samples/ClosestPointViewer: $(OPENNI) Samples/MWClosestPoint +Samples/SimpleViewer.java: Wrappers/java/OpenNI.java # clean is cleaning all projects clean: $(ALL_PROJS_CLEAN) diff --git a/OpenNI.sln b/OpenNI.sln index 4a28beec..4fb20302 100644 --- a/OpenNI.sln +++ b/OpenNI.sln @@ -83,6 +83,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultipleStreamRead", "Sampl EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Install", "Packaging\Install\Install.wixproj", "{BAEB9C48-562C-4D56-A6CD-18932265480A}" ProjectSection(ProjectDependencies) = postProject + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63} = {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63} {E636BACA-795F-41CF-BC52-14C727BF014E} = {E636BACA-795F-41CF-BC52-14C727BF014E} EndProjectSection EndProject @@ -93,6 +94,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Kinect", "Source\Drivers\Ki EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DepthUtils", "Source\DepthUtils\DepthUtils.vcxproj", "{72D595BB-8C52-449B-91DB-0E9F6AEABBBB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSLink", "Source\Drivers\PSLink\PSLink\PSLink.vcxproj", "{5B74F010-8B79-46B5-B906-C2B56CDB3386}" + ProjectSection(ProjectDependencies) = postProject + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD} = {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD} + {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} = {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LinkProtoLib", "Source\Drivers\PSLink\LinkProtoLib\LinkProtoLib.vcxproj", "{96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}" + ProjectSection(ProjectDependencies) = postProject + {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} = {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSLinkConsole", "Source\Drivers\PSLink\PSLinkConsole\PSLinkConsole.vcxproj", "{D39A4248-3985-41DE-AFD5-AEC58D29291F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wrappers", "Wrappers", "{9FCEE1ED-B0D9-46D7-A014-98FBDD0EF6A9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenNI.jni", "Wrappers\java\OpenNI.jni\OpenNI.jni.vcxproj", "{1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}" + ProjectSection(ProjectDependencies) = postProject + {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} = {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -241,6 +262,38 @@ Global {72D595BB-8C52-449B-91DB-0E9F6AEABBBB}.Release|x64.Build.0 = Release|x64 {72D595BB-8C52-449B-91DB-0E9F6AEABBBB}.Release|x86.ActiveCfg = Release|Win32 {72D595BB-8C52-449B-91DB-0E9F6AEABBBB}.Release|x86.Build.0 = Release|Win32 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Debug|x64.ActiveCfg = Debug|x64 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Debug|x64.Build.0 = Debug|x64 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Debug|x86.ActiveCfg = Debug|Win32 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Debug|x86.Build.0 = Debug|Win32 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x64.ActiveCfg = Release|x64 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x64.Build.0 = Release|x64 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x86.ActiveCfg = Release|Win32 + {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x86.Build.0 = Release|Win32 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Debug|x64.ActiveCfg = Debug|x64 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Debug|x64.Build.0 = Debug|x64 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Debug|x86.ActiveCfg = Debug|Win32 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Debug|x86.Build.0 = Debug|Win32 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Release|x64.ActiveCfg = Release|x64 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Release|x64.Build.0 = Release|x64 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Release|x86.ActiveCfg = Release|Win32 + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD}.Release|x86.Build.0 = Release|Win32 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Debug|x64.ActiveCfg = Debug|x64 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Debug|x64.Build.0 = Debug|x64 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Debug|x86.ActiveCfg = Debug|Win32 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Debug|x86.Build.0 = Debug|Win32 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Release|x64.ActiveCfg = Release|x64 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Release|x64.Build.0 = Release|x64 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Release|x86.ActiveCfg = Release|Win32 + {D39A4248-3985-41DE-AFD5-AEC58D29291F}.Release|x86.Build.0 = Release|Win32 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Debug|x64.ActiveCfg = Debug|x64 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Debug|x64.Build.0 = Debug|x64 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Debug|x86.ActiveCfg = Debug|Win32 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Debug|x86.Build.0 = Debug|Win32 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Release|x64.ActiveCfg = Release|x64 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Release|x64.Build.0 = Release|x64 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Release|x86.ActiveCfg = Release|Win32 + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -259,6 +312,10 @@ Global {31F0F25B-A84A-48AC-9716-5DF9137F3855} = {238D091D-1A85-4A61-9DCD-483768C51804} {15ECC029-90DE-4D1D-B00A-4A8E647D8C24} = {238D091D-1A85-4A61-9DCD-483768C51804} {E636BACA-795F-41CF-BC52-14C727BF014E} = {238D091D-1A85-4A61-9DCD-483768C51804} + {5B74F010-8B79-46B5-B906-C2B56CDB3386} = {238D091D-1A85-4A61-9DCD-483768C51804} + {96447E8B-AB23-4A4F-9FB3-7705C10AD4BD} = {238D091D-1A85-4A61-9DCD-483768C51804} {BDA3BF24-550A-4BF9-83E5-0056134EED40} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} + {D39A4248-3985-41DE-AFD5-AEC58D29291F} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} + {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63} = {9FCEE1ED-B0D9-46D7-A014-98FBDD0EF6A9} EndGlobalSection EndGlobal diff --git a/Packaging/Install/Includes/Variables.wxi b/Packaging/Install/Includes/Variables.wxi index 65af4368..39a32a9e 100644 --- a/Packaging/Install/Includes/Variables.wxi +++ b/Packaging/Install/Includes/Variables.wxi @@ -8,7 +8,7 @@ - + diff --git a/Packaging/Install/Install.wixproj b/Packaging/Install/Install.wixproj index f95411d5..008198cb 100644 --- a/Packaging/Install/Install.wixproj +++ b/Packaging/Install/Install.wixproj @@ -138,6 +138,14 @@ Binaries;Content;Satellites INSTALLLOCATION + + PrimeClient + {5b74f010-8b79-46b5-b906-c2b56cdb3386} + True + True + Binaries;Content;Satellites + INSTALLLOCATION + NiViewer {bda3bf24-550a-4bf9-83e5-0056134eed40} @@ -146,6 +154,14 @@ Binaries;Content;Satellites INSTALLLOCATION + + PrimeConsole + {d39a4248-3985-41de-afd5-aec58d29291f} + True + True + Binaries;Content;Satellites + INSTALLLOCATION + XnLib {72d595bb-8c52-449b-91db-0e9f6aeaf5bb} diff --git a/Packaging/Install/Install.wxs b/Packaging/Install/Install.wxs index 8631fd00..fd0bf102 100644 --- a/Packaging/Install/Install.wxs +++ b/Packaging/Install/Install.wxs @@ -114,6 +114,8 @@ + + diff --git a/Packaging/Linux/install.sh b/Packaging/Linux/install.sh index 5fdbcd9a..2243c9d6 100755 --- a/Packaging/Linux/install.sh +++ b/Packaging/Linux/install.sh @@ -29,26 +29,16 @@ if [ `whoami` != root ]; then exit fi -if [ "`uname -s`" != "Darwin" ]; then - # Install UDEV rules for USB device - echo '# Make primesense device mount with writing permissions (default is read only for unknown devices) - SUBSYSTEM=="usb", ATTR{idProduct}=="0200", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="0300", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="0401", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="0500", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="0600", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="0601", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="1280", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="2100", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="2200", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" - SUBSYSTEM=="usb", ATTR{idProduct}=="f9db", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video"' > /etc/udev/rules.d/557-primesense-usb.rules -fi - ORIG_PATH=`pwd` cd `dirname $0` SCRIPT_PATH=`pwd` cd $ORIG_PATH +if [ "`uname -s`" != "Darwin" ]; then + # Install UDEV rules for USB device + cp ${SCRIPT_PATH}/primesense-usb.rules /etc/udev/rules.d/557-primesense-usb.rules +fi + OUT_FILE="$SCRIPT_PATH/OpenNIDevEnvironment" echo "export OPENNI2_INCLUDE=$SCRIPT_PATH/Include" > $OUT_FILE diff --git a/Packaging/Linux/primesense-usb.rules b/Packaging/Linux/primesense-usb.rules new file mode 100644 index 00000000..fe8cbe0f --- /dev/null +++ b/Packaging/Linux/primesense-usb.rules @@ -0,0 +1,13 @@ +# Make primesense device mount with writing permissions (default is read only for unknown devices) +SUBSYSTEM=="usb", ATTR{idProduct}=="0200", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="0300", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="0401", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="0500", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="0600", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="0601", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="1250", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="1260", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="1270", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="1280", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="1290", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="f9db", ATTR{idVendor}=="1d27", MODE:="0666", OWNER:="root", GROUP:="video" \ No newline at end of file diff --git a/Packaging/Redist.py b/Packaging/Redist.py index e60adf42..8748fe26 100755 --- a/Packaging/Redist.py +++ b/Packaging/Redist.py @@ -59,18 +59,20 @@ def get_reg_values(reg_key, value_list): pass return tuple(values) - class OS: #def __init__(): def setConfiguration(self, config): self.config = config def getExportedDrivers(self): - return ['PS1080', 'OniFile'] + return ['PS1080', 'PSLink', 'OniFile'] def getExportedTools(self): - return ['NiViewer'] + return ['NiViewer', 'PSLinkConsole'] def getExportedSamples(self): - return ['ClosestPointViewer', 'EventBasedRead', 'MultiDepthViewer', 'MultipleStreamRead', 'MWClosestPoint', 'MWClosestPointApp', 'SimpleRead', 'SimpleViewer'] + return ['ClosestPointViewer', 'EventBasedRead', 'MultiDepthViewer', 'MultipleStreamRead', 'MWClosestPoint', 'MWClosestPointApp', 'SimpleRead', 'SimpleViewer', 'SimpleViewer.java', 'org.openni.Samples.SimpleViewer'] + def prepare(self): + return + def cleanOutput(self): # Delete the redist directory and create it again if os.path.isdir(self.config.output_dir): @@ -187,6 +189,19 @@ def __init__(self): self.VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] self.PROJECT_SLN = "OpenNI.sln" + def prepare(self): + # java wrapper + os.chdir(os.path.join('Wrappers', 'java', 'OpenNI.java')) + subprocess.call(['Build.bat']) + os.chdir(os.path.join('..', '..', '..')) + + # java samples + for sample in self.getExportedSamples(): + if sample.endswith('.java'): + os.chdir(os.path.join('Samples', sample)) + subprocess.call(['Build.bat']) + os.chdir(os.path.join('..', '..')) + def getExportedDrivers(self): drivers = OS.getExportedDrivers(self) drivers.append('Kinect') @@ -199,7 +214,7 @@ def copyOpenNI(self, where): binDir = self.getBinDir() for r, d, f in os.walk(binDir): for file in f: - if not self.isIllegalBinFile(file) and (file.startswith('OpenNI') and not file.endswith('.lib')): + if not self.isIllegalBinFile(file) and ((file.startswith('OpenNI') and not file.endswith('.lib')) or (file == "org.openni.jar")): shutil.copy(r+'/'+file, where) # Copy the OpenNI driver binaries @@ -355,21 +370,32 @@ def compile(self, configuration, platform, compilationMode): print(compilationMode + ', RC: %d'%rc) if rc == 0: os.remove(outfile) - + return rc def isBaseDirValid(self, dir): if os.path.isdir(dir) and os.path.exists(dir+'/OpenNI.sln'): return True return False + def isIllegalSampleFile(self, file): return file.endswith('.user') or file == 'Makefile' or file == 'Android.mk' + def isIllegalBinFile(self, file): - return not file.endswith('.exe') and not file.endswith('.dll') and not file.endswith('.pdb') and not file.endswith('.lib') or (not self.config.supplyTools and file == 'XnLib.lib') + return not file.endswith('.exe') and \ + not file.endswith('.dll') and \ + not file.endswith('.pdb') and \ + not file.endswith('.jar') and \ + not file.endswith('.bat') and \ + not file.endswith('.lib') \ + or file == 'DepthUtils.lib' or file == 'LinkProtoLib.lib' or (not self.config.supplyTools and file == 'XnLib.lib') + def isIllegalBinDriverFile(self, file): return not any(file.startswith(driver) for driver in self.getExportedDrivers()) or file.endswith('.lib') + def isIllegalToolFile(self, file): return not any(file.startswith(tool) for tool in self.getExportedTools()) or file.endswith('.lib') + def isIllegalSampleBinFile(self, file): return not any(file.startswith(sample) for sample in self.getExportedSamples()) @@ -384,7 +410,7 @@ def copyOpenNI(self, where): binDir = self.getBinDir() for r, d, f in os.walk(binDir): for file in f: - if not self.isIllegalBinFile(file) and file.startswith('libOpenNI'): + if not self.isIllegalBinFile(file) and (file.startswith('libOpenNI') or file == 'org.openni.jar'): shutil.copy(r+'/'+file, where) # Copy the OpenNI driver binaries @@ -550,14 +576,20 @@ def isBaseDirValid(self, dir): if os.path.isdir(dir) and os.path.exists(dir+'/Makefile'): return True return False + def isIllegalBinFile(self, file): - return False + #TODO: currently implemented on a Blacklist basis, consider changing this. + return file == 'libDepthUtils.a' or file == 'libLinkProtoLib.a' or (not self.config.supplyTools and file == 'libXnLib.a') + def isIllegalBinDriverFile(self, file): return not any(file=="lib"+driver+".so" for driver in self.getExportedDrivers()) + def isIllegalSampleFile(self, file): return any(file.endswith(ext) for ext in ['.vcxproj', '.vcxproj.filters', 'Android.mk']) + def isIllegalToolFile(self, file): return not any(file.startswith(tool) for tool in self.getExportedTools()) + def isIllegalSampleBinFile(self, file): return not any((file.startswith(sample) or file.startswith('lib'+sample)) for sample in self.getExportedSamples()) @@ -697,6 +729,7 @@ def Redist(myConfig): sys.exit(2) # Create file structure + myOS.prepare() myOS.createGeneralFiles() myOS.createRedist() myOS.createInclude() diff --git a/Packaging/ReleaseVersion.py b/Packaging/ReleaseVersion.py index a2d3253a..3b51bdcf 100755 --- a/Packaging/ReleaseVersion.py +++ b/Packaging/ReleaseVersion.py @@ -102,7 +102,7 @@ def get_reg_values(reg_key, value_list): print 'Build failed!' sys.exit(3) - outFile = 'Final/' + outputDir + '.tar' + outFile = finalDir + '/' + outputDir + '.tar' shutil.move(buildDir + '/libs/armeabi-v7a', outputDir) @@ -111,11 +111,7 @@ def get_reg_values(reg_key, value_list): shutil.copy('../Config/PS1080.ini', outputDir) print('Creating archive ' + outFile) - - rc = subprocess.call(['tar', '-cf', outFile, outputDir]) - if rc != 0: - print 'Tar failed!' - sys.exit(3) + subprocess.check_call(['tar', '-cf', outFile, outputDir]) elif platform.system() == 'Windows': import win32con,pywintypes,win32api,platform @@ -133,16 +129,17 @@ def get_reg_values(reg_key, value_list): VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] PROJECT_SLN = "..\OpenNI.sln" - outfile = origDir+'/build.Release.'+plat+'.txt' - devenv_cmd = '\"'+VS_INST_DIR + 'devenv\" '+PROJECT_SLN + ' /Project Install /Rebuild "Release|'+plat+'\" /out '+outfile + bulidLog = origDir+'/build.Release.'+plat+'.txt' + devenv_cmd = '\"'+VS_INST_DIR + 'devenv\" '+PROJECT_SLN + ' /Project Install /Rebuild "Release|'+plat+'\" /out '+bulidLog print(devenv_cmd) - rc = subprocess.call(devenv_cmd, close_fds=True) - if rc == 0: - os.remove(outfile) - else: - print "Error" + subprocess.check_call(devenv_cmd, close_fds=True) + os.remove(bulidLog) + + outFile = 'OpenNI-Windows-' + plat + '-' + strVersion + '.msi' + if os.path.exists(os.path.join(finalDir, outFile)): + os.remove(os.path.join(finalDir, outFile)) - shutil.move('Install/bin/' + plat + '/en-us/OpenNI-Windows-' + plat + '-' + strVersion + '.msi', finalDir) + shutil.move('Install/bin/' + plat + '/en-us/' + outFile, finalDir) elif platform.system() == 'Linux' or platform.system() == 'Darwin': import Redist @@ -175,16 +172,13 @@ def get_reg_values(reg_key, value_list): Redist.Redist(config) # Copy install script - shutil.copy('Linux/install.sh', config.output_dir + '/install.sh') - + shutil.copy('Linux/install.sh', config.output_dir) + shutil.copy('Linux/primesense-usb.rules', config.output_dir) + # Create archive print('Creating archive ' + outFile) - - archiveCmd = 'tar -cjf ' + outFile + ' ' + dirName + '/*' - rc = os.system(archiveCmd) - - if rc != 0: - print('Could not create archive' + outFile) + subprocess.check_call(['tar', '-cjf', outFile, dirName]) + else: print "Unknown OS" sys.exit(2) diff --git a/Packaging/UpdateVersion.py b/Packaging/UpdateVersion.py index bc5d2c42..532daf11 100755 --- a/Packaging/UpdateVersion.py +++ b/Packaging/UpdateVersion.py @@ -28,7 +28,7 @@ VERSION_MAJOR = 2 VERSION_MINOR = 2 VERSION_MAINTENANCE = 0 -VERSION_BUILD = 3 +VERSION_BUILD = 7 class UpdateVersion: def main(self): diff --git a/README b/README index bac45bed..e2c525e9 100644 --- a/README +++ b/README @@ -16,6 +16,10 @@ Windows - PyWin32 From: http://sourceforge.net/projects/pywin32/files/pywin32/ Please make sure you download the version that matches your exact python version. +- JDK 6.0 + From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html + You must also define an environment variable called "JAVA_HOME" that points to the JDK installation directory. + For example: set JAVA_HOME=c:\Program Files (x86)\Java\jdk1.6.0_32 - WIX 3.5 From: http://wix.codeplex.com/releases/view/60102 - Doxygen @@ -37,6 +41,15 @@ Linux From: http://sourceforge.net/projects/libusb/files/libusb-1.0/ Or via apt: sudo apt-get install libusb-1.0-0-dev +- JDK 6.0 + From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html + Or via apt: + Ubuntu 10.x: + sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" + sudo apt-get update + sudo apt-get install sun-java6-jdk + Ubuntu 12.x: + sudo apt-get install openjdk-6-jdk - FreeGLUT3 From: http://freeglut.sourceforge.net/index.php#download Or via apt: diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index a1ac8e3f..619f9c80 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,5 @@ -OpenNI 2.2.0 Build 3 -February 12 2013 +OpenNI 2.2.0 Build 7 +March 21 2013 Minimum Requirements: --------------------- @@ -26,51 +26,3 @@ Notes: support the rpath option, the samples cannot start as is. To solve this, do one of the following: - Copy OpenNI libraries (libOpenNI2.so, libPS1080.so and libOniFile.so) to /system/lib (requires root) - or - - run `export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH` before starting the native executeable - -Change Log: ------------ - -OpenNI 2.2.0: - - Added getDepthColorSyncEnabled API - - Merge pull request #7: Driver path resolution based on the shared library location See https://github.com/OpenNI/OpenNI2/pull/7 for details (thanks Tomoto) - - Build: Rename Redist dir to Packaging - - Build: Remove all warnings during build. Treat all warnings as errors. - - Bug Fix: Failed to use after OpenCL was initialized - -OpenNI 2.1.0: - - API change: each event now has its own addListener()/removeListener() methods. A listener object can now be added only once. - - Support for Mac OSX - - Support for Linux on Arm - - Support for Android (native only) - - Kinect: implementing convertDepthToColorCoordinates() - - Kinect: implementing CameraSettings - - Kinect Bug Fix: can now switch between color and IR streams - - Kinect Bug Fix: wrong mirror value was returned - - PS1080 Bug Fix: trying to open more than 8 devices will crash - - PS1080 Bug Fix: on Linux 64-bit, color frames are sometimes corrupt - - PS1080 Bug Fix: a potential crash with older firmwares - - NiViewer now browses whenever a recording is started - - NiViewer: added 'i' key for toggling image-registration (also added current status in the status bar) - - Minor memory leak fixes - - EventBasedRead Sample Bug Fix: will not get device events - - EventBasedRead Sample now prints the list of connected devices and every change that occurs - - Recordings are now also compatible with OpenNI 1.x and NiTE 1.x - - Potential starvation bug fix when application takes much time handling events - - Log file now closes on shutdown(), and a new one is created on initialize() - - SimpleRead is now the default project in the VS solution (thanks eranws) - - Bug Fix: did not support Visual Studio 2008 and older - - Bug Fix: did not support Visual Studio 2012 and newer - - Bug Fix: did not support Visual Studio Express (thanks rh-galaxy) - - NiViewer Bug Fix: Mirror did not change IR state - - Kinect: providing Kinect for Windows PID and VID in the device info struct - - ONI files: providing driver name in the device info struct - - Bug Fix: ReleaseVersion script did not work on 32-bit machines - - Linux Bug Fix: log timestamps did not start from 0. - -OpenNI 2.0.0: - - Brand new API (see documentation) - - Algorithms API were removed, and are now part of middleware libraries (such as NiTE) - - New deployment model - private copy to each application (see documentation) - - Added support for turning off Auto Exposure and Auto White Balance of the color CMOS in PS1080 devices - - Built-in support for Kinect devices via the Kinect SDK (Windows only) - - Added support for translating a depth pixel to color map coordinates diff --git a/Samples/SimpleViewer.java/Build.bat b/Samples/SimpleViewer.java/Build.bat new file mode 100644 index 00000000..3365e032 --- /dev/null +++ b/Samples/SimpleViewer.java/Build.bat @@ -0,0 +1 @@ +@%0\..\..\..\ThirdParty\PSCommon\BuildSystem\BuildJavaWindows.py "%1" "%0\..\..\..\Bin" src\org\openni\Samples\SimpleViewer org.openni.Samples.SimpleViewer org.openni.jar;jogl.jar;gluegen-rt.jar org.openni.Samples.SimpleViewer.SimpleViewerApplication diff --git a/Samples/SimpleViewer.java/Makefile b/Samples/SimpleViewer.java/Makefile new file mode 100644 index 00000000..bfcea5b9 --- /dev/null +++ b/Samples/SimpleViewer.java/Makefile @@ -0,0 +1,12 @@ +include ../../ThirdParty/PSCommon/BuildSystem/CommonDefs.mak + +BIN_DIR = ../../Bin + +SRC_FILES = \ + src/org/openni/Samples/SimpleViewer/*.java + +JAR_NAME = org.openni.Samples.SimpleViewer +USED_JARS = org.openni +MAIN_CLASS = org.openni.Samples.SimpleViewer.SimpleViewerApplication + +include ../../ThirdParty/PSCommon/BuildSystem/CommonJavaMakefile diff --git a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java new file mode 100644 index 00000000..8ba594f8 --- /dev/null +++ b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java @@ -0,0 +1,135 @@ +package org.openni.Samples.SimpleViewer; + +import java.awt.*; +import java.awt.image.*; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import org.openni.*; + + +public class SimpleViewer extends Component + implements VideoStream.NewFrameListener { + + float mHistogram[]; + int[] mImagePixels; + VideoStream mVideoStream; + VideoFrameRef mLastFrame; + BufferedImage mBufferedImage; + + public SimpleViewer() { + } + + public void setStream(VideoStream videoStream) { + if (mLastFrame != null) { + mLastFrame.release(); + mLastFrame = null; + } + + if (mVideoStream != null) { + mVideoStream.removeNewFrameListener(this); + } + + mVideoStream = videoStream; + + if (mVideoStream != null) { + mVideoStream.addNewFrameListener(this); + } + } + + public void paint(Graphics g) { + if (mLastFrame == null) { + return; + } + + int width = mLastFrame.getWidth(); + int height = mLastFrame.getHeight(); + + // make sure we have enough room + if (mBufferedImage == null || mBufferedImage.getWidth() != width || mBufferedImage.getHeight() != height) { + mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + } + + mBufferedImage.setRGB(0, 0, width, height, mImagePixels, 0, width); + g.drawImage(mBufferedImage, 0, 0, null); + } + + public void onFrameReady(VideoStream stream) { + if (mLastFrame != null) { + mLastFrame.release(); + mLastFrame = null; + } + + mLastFrame = mVideoStream.readFrame(); + ByteBuffer frameData = mLastFrame.getData().order(ByteOrder.LITTLE_ENDIAN); + + // make sure we have enough room + if (mImagePixels == null || mImagePixels.length < mLastFrame.getWidth() * mLastFrame.getHeight()) { + mImagePixels = new int[mLastFrame.getWidth() * mLastFrame.getHeight()]; + } + + switch (mLastFrame.getVideoMode().getPixelFormat()) + { + case DEPTH_1_MM: + case DEPTH_100_UM: + case SHIFT_9_2: + case SHIFT_9_3: + calcHist(frameData); + frameData.rewind(); + int pos = 0; + while(frameData.remaining() > 0) { + short depth = frameData.getShort(); + short pixel = (short)mHistogram[depth]; + mImagePixels[pos] = 0xFF000000 | (pixel << 16) | (pixel << 8); + pos++; + } + break; + case RGB888: + pos = 0; + while (frameData.remaining() > 0) { + int red = (int)frameData.get() & 0xFF; + int green = (int)frameData.get() & 0xFF; + int blue = (int)frameData.get() & 0xFF; + mImagePixels[pos] = 0xFF000000 | (red << 16) | (green << 8) | blue; + pos++; + } + break; + default: + // don't know how to draw + mLastFrame.release(); + mLastFrame = null; + } + + repaint(); + } + + private void calcHist(ByteBuffer depthBuffer) { + // make sure we have enough room + if (mHistogram == null || mHistogram.length < mVideoStream.getMaxPixelValue()) { + mHistogram = new float[mVideoStream.getMaxPixelValue()]; + } + + // reset + for (int i = 0; i < mHistogram.length; ++i) + mHistogram[i] = 0; + + int points = 0; + while (depthBuffer.remaining() > 0) { + int depth = depthBuffer.getShort() & 0xFFFF; + if (depth != 0) { + mHistogram[depth]++; + points++; + } + } + + for (int i = 1; i < mHistogram.length; i++) { + mHistogram[i] += mHistogram[i - 1]; + } + + if (points > 0) { + for (int i = 1; i < mHistogram.length; i++) { + mHistogram[i] = (int) (256 * (1.0f - (mHistogram[i] / (float) points))); + } + } + } +} diff --git a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java new file mode 100755 index 00000000..19c09b5a --- /dev/null +++ b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java @@ -0,0 +1,206 @@ +package org.openni.Samples.SimpleViewer; + +import org.openni.*; +import java.awt.AWTEvent; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JOptionPane; + +public class SimpleViewerApplication implements ItemListener { + + private JFrame mFrame; + private JPanel mPanel; + private SimpleViewer mViewer; + private boolean mShouldRun = true; + private Device mDevice; + private VideoStream mVideoStream; + private ArrayList mDeviceSensors; + private ArrayList mSupportedModes; + + private JComboBox mComboBoxStreams; + private JComboBox mComboBoxVideoModes; + + public SimpleViewerApplication(Device device) { + mDevice = device; + + mFrame = new JFrame("OpenNI Simple Viewer"); + mPanel = new JPanel(); + mViewer = new SimpleViewer(); + + // register to key events + mFrame.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent arg0) {} + + @Override + public void keyReleased(KeyEvent arg0) {} + + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) { + mShouldRun = false; + } + } + }); + + // register to closing event + mFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + mShouldRun = false; + } + }); + + mComboBoxStreams = new JComboBox(); + mComboBoxVideoModes = new JComboBox(); + + mComboBoxStreams.addItem(""); + mDeviceSensors = new ArrayList(); + + if (device.getSensorInfo(SensorType.COLOR) != null) { + mDeviceSensors.add(SensorType.COLOR); + mComboBoxStreams.addItem("Color"); + } + + if (device.getSensorInfo(SensorType.DEPTH) != null) { + mDeviceSensors.add(SensorType.DEPTH); + mComboBoxStreams.addItem("Depth"); + } + + mComboBoxStreams.addItemListener(this); + mComboBoxVideoModes.addItemListener(this); + mViewer.setSize(800,600); + + mPanel.add("West", mComboBoxStreams); + mPanel.add("East", mComboBoxVideoModes); + mFrame.add("North", mPanel); + mFrame.add("Center", mViewer); + mFrame.setSize(800, 600 + mPanel.getHeight()); + mFrame.setVisible(true); + } + + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.DESELECTED) + return; + + if (e.getSource() == mComboBoxStreams) { + selectedStreamChanged(); + } else if (e.getSource() == mComboBoxVideoModes) { + selectedVideoModeChanged(); + } + } + + void selectedStreamChanged() { + + if (mVideoStream != null) { + mVideoStream.stop(); + mViewer.setStream(null); + mVideoStream.destroy(); + mVideoStream = null; + } + + int sensorIndex = mComboBoxStreams.getSelectedIndex() - 1; + if (sensorIndex == -1) { + return; + } + + SensorType type = mDeviceSensors.get(sensorIndex); + + mVideoStream = VideoStream.create(mDevice, type); + List supportedModes = mVideoStream.getSensorInfo().getSupportedVideoModes(); + mSupportedModes = new ArrayList(); + + // now only keeo the ones that our application supports + for (VideoMode mode : supportedModes) { + switch (mode.getPixelFormat()) { + case DEPTH_1_MM: + case DEPTH_100_UM: + case SHIFT_9_2: + case SHIFT_9_3: + case RGB888: + mSupportedModes.add(mode); + break; + } + } + + // and add them to combo box + mComboBoxVideoModes.removeAllItems(); + mComboBoxVideoModes.addItem("