diff --git a/Bin/SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2 b/Bin/SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2 new file mode 100644 index 0000000..8a860f3 Binary files /dev/null and b/Bin/SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2 differ diff --git a/Bin/SensorKinect093-Bin-Linux-x86-v5.1.2.1.tar.bz2 b/Bin/SensorKinect093-Bin-Linux-x86-v5.1.2.1.tar.bz2 new file mode 100644 index 0000000..d5575b9 Binary files /dev/null and b/Bin/SensorKinect093-Bin-Linux-x86-v5.1.2.1.tar.bz2 differ diff --git a/Bin/SensorKinect093-Bin-MacOSX-v5.1.2.1.tar.bz2 b/Bin/SensorKinect093-Bin-MacOSX-v5.1.2.1.tar.bz2 new file mode 100644 index 0000000..2e804d2 Binary files /dev/null and b/Bin/SensorKinect093-Bin-MacOSX-v5.1.2.1.tar.bz2 differ diff --git a/Bin/SensorKinect093-Bin-Win32-v5.1.2.1.msi b/Bin/SensorKinect093-Bin-Win32-v5.1.2.1.msi new file mode 100644 index 0000000..53564d8 Binary files /dev/null and b/Bin/SensorKinect093-Bin-Win32-v5.1.2.1.msi differ diff --git a/Bin/SensorKinect093-Bin-Win64-v5.1.2.1.msi b/Bin/SensorKinect093-Bin-Win64-v5.1.2.1.msi new file mode 100644 index 0000000..38ea810 Binary files /dev/null and b/Bin/SensorKinect093-Bin-Win64-v5.1.2.1.msi differ diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..2a5fb04 --- /dev/null +++ b/CHANGES @@ -0,0 +1,193 @@ +Detailed Change log: +-------------------- + +Version 5.1.2.1 (Unstable version - May 15th 2012) +-------------------------------------------------- + * Redist: fix identification of ARM. + * Adding support for new command: get usb core type. Also add different USB handling for different cores. + * Remove annoying (and misleading) warning messages from the log. + * Starting with firmware 5.7.0 - add the platform string to the firmware version (to support different platforms running the same FW version). + * Improved the hardware version information. + * Bug Fix: changing resolution might cause a crash when working without a server. + * Adding "Lean Init" mode which only gets version (no other FW queries). + * Adding -safe option to command console. If applied, lean init is used and chances of failing to open sensor are dramatically reduced. + * Bug Fix: If upload file fails, file remains open by process. + * Fix printing values during upload. + * Starting with 5.6.9 - check if image is supported using fixed params (instead of VSync ugly patch). Also moved fixed params to be part of SensorFirmware class. + * BIST: host now always performs soft reset before running BIST. + * Allowing AHB operations. + * Bug Fix: device is always opened on interface 0 (should be ISO on x86 and BULK on ARM). + * Added support to convert the uncompressed bayer image format into RGB24. + * Added the 720p & 1280x960 image resolutions in the Xiron.ini and GlobalDefaults.ini files. + * Added support for real uncompressed bayer image format. + * ARM depth defaults are now QQ and 12-bit. + * Allowing an application to provide buffers for map streams (instead of using the shared memory). + * Add some logs to the server session. + * Audio buffer (shared memory) and indexes are now owned by stream (and not the device). + * Workaround a FW bug which returns a preset with FPS 0 (causes DirectShow filter to crash). + * Using new data containers (XnListT, XnHashT, XnEventT). + * Added new server property: "ServerLogFile" (string) for getting log file name. + * Fix some static analysis warnings. + * Fix some minor, rare, never-gonna-happen, memory leaks. + * Moving "service discovery" into one location - takes place during init (instead of as part of the get version command). + * Adding support for FW 5.3.29 (like previous, with the get presets opcode). + * Adding a warning log when trying to set a non-supported mode. + * Bug Fix: enumerating for image caused soft-reset of the device when server is off. This is problematic if working from different contexts and this device is streaming in another context. + * Bug Fix: image resolution possible values were hard-coded, even when taking presets from FW. + * Fixed some bugs in the software registration: + 1) The start/end padding code was removed. It was not really necessary and caused the result to be incorrect. + 2) In the depth-to-shift table calculation, the distance between the cameras was truncated from bad float/int conversions. + 3) Removed the code which stops building the registration table if the max Y was reached. The correct solution is not to stop the loop, but to mark the values as invalid. + 4) Enabled software registration to also work in QVGA 30 mode. + * Using USB connection event instead of old single callback. + * Bug Fix: corrupt memory if resolution is changed *after* a frame was received but not read by application yet (#1950) + * Shifts map is stored as part of the frame. + * Added 12-bit depth processor. + * Optimizations for Arm Cortex A8 (neon). + * Adding interface for general i2c operations. + * Update device frequency whenever a stream is opened (frequency might change on setting to specific mode). + * Added a property "HostTimestamps" for making the code create timestamps according to host clock and disregard firmware timestamps. + * Added support for the Depth@QVGA and IR@VGA mode in FW 5.6 and above. + * Added support for QQVGA Depth. + * Now, when opening sensor without reset (for enumeration purposes), also not setting interface. + * Adding the 'CloseRange' property to the depth stream (supported by FW 5.6) + +Version 5.1.0.41 (Stable version - Dec 28th 2011) +------------------------------------------------- + * No code changes, build is based on latest OpenNI. + +Version 5.1.0.25 (Unstable version - Dec 18th 2011) +--------------------------------------------------- + * Bug Fix: server-client didn't always work due to an uninitialized member. + * Installer bug fix: versions were compared by string instead of by number. + * Added Support for FW 5.5: + 1) Support product ID 0601. + 2) ISO and BULK interfaces are now switched. + 3) AudioGenerator is no longer supported. + * Enumeration Bug Fix: From now on, a generator will not return on enumeration if one already exists from the same device. + * Android: makefiles now match ndk v7. + * Bug Fix: client-server did not pass timestamp correct in the NewDataAvailbale event, causing FrameSync to malfunction. + * Bug Fix: Enumeration for ImageGenerator could cause a crash. + * Default UsbInterface is now BULK on Arm (for performance reasons) and ISO on all other platforms. + * Default Image format is now uncompressed in ISO, and compressed in BULK. + * Server (Multiprocess) is not on by default on Arm. + * BC Bug fix: XnVInitStreamPropertiesInternal::IsProperty did not function correctly. + * BC Bug Fix: XnVDepthRepresentation would not set correct Y resolution. + * Added support for FW 5.6 (no audio) + * Added Android support to open source. + * Temporary patch for MacOSX: Cache the device path's since running enum on the MAC takes several seconds! + +Version 5.0.5.1 (Unstable version - Nov 17th 2011) +-------------------------------------------------- + * Removed support for very old 2.0 devices. + * Linux: XnSensorServer dependency was missing. + * Bug Fix: AllowMultiUsers property was not handled correctly. + +Version 5.0.4.4 (Unstable version - Nov 7th 2011) +------------------------------------------------- + * Added YUV input in high res for FW 5.3.28 and above. + * Added grayscale 8 input format. + * Added automatic setting of input format, and automatic checking of modes. + * Updated to newer common makefiles + * Sensor client-server on windows: Allow starting server and client in different sessions (requires a special setting in GlobalDefaults.ini, as this causes things not to work properly if running on a machine with UAC on). + * Changed Engine changed to Sensor in the final installation files. + * Renamed Linux-x86 to "Linux" (supports x86, x64, Arm and MacOSX). + * Allow better cross compiling. + * Bug Fix: old XNS files would not set their IsGenerating property (and so it is left FALSE, even if node has frames). + * Updated the value of the UsbInterface property once endpoints are opened. + +Version 5.0.4.3 (Stable version - Sep 18th 2011) +------------------------------------------------ + * Some minor windows installer UI fix (title position). + * Fixed buffer overflow bugs in the software registration. + * Support for firmware 5.4.x: New TEC and extended serial number commands. + * On newer FWs (5.4+) high-res image output does not always have to be bayer so this rule will only be enforced on older versions. + * Preliminary Android Support. + * Preliminary ARM Support. + * Win32: Added the /MP (MultiProcess Compiling) flag to all projects to save build time. + * Bug Fix: Image Generator always said it supports JPEG (without checking the sensor itself). + * Fix a memory leak (about 180 bytes per generator). + +Version 5.0.3.4 (Stable version - Jul 5th 2011) +----------------------------------------------- + * Windows Redist: Support for 64-bit systems. + * Control mutex is now per sensor and not global to all sensors. + +Version 5.0.3.3 (Stable version - Jul 5th 2011) +----------------------------------------------- + * Linux: Allow installation to a different directory (for cross-compilation mainly). + * Workaround firmware bug: if no depth, IR timestamps are corrupt. Use host clock for timestamps instead. + * Bug Fix: unregistering USB event callback when destroying sensor to prevent crash when unplugging device. + * XnExportedSensorDevice now only enumerates devices that weren't created in the context yet. + +Version 5.0.2.3 (Stable version - May 3rd 2011) +----------------------------------------------- + * Fixed use of deprecated CreateProductionTree(). + * Bug Fix: playing XNS files in applications using deprecated API might cause memory leaks. + * Bug Fix: serial number was in hex format instead of decimal one. + * Make sure SensorV2 nodes will only use SensorV2 device (up to now they only checked it's a PrimeSense device). + +Version 5.0.1.33 (Unstable version - Apr 18th 2011) +--------------------------------------------------- + * CE4100: adding support in makefiles, redist and install. + * CE4100: default is now BULK with compressed formats. + +Version 5.0.1.32 (Unstable version - Apr 11th 2011) +--------------------------------------------------- + * Fixing log prints of resolutions (-1 appeared as MAX_UINT64...) to the resolution name. + * Linux Bug Fix: Server creates two log files, one in the client folder and one in /var/log/primesense/XnSensorServer + * Fixed a memory leak when rewinding old XNS files. + * Win32: WIX installer (replacing NSIS) + * Fixed wrong version in XnDeviceFile + +Version 5.0.1.31 (Stable version - Apr 11th 2011) +------------------------------------------------- + * Fix BULK timeout - it was too small... + * Bug Fix: IR only works in QVGA... + * Added 64bit support for the installers. + * Fix wrong uses of the XN_IS_STATUS_OK macro (value is evaluated twice). + * Adding support for MJPEG pass-through. + * Adding initial support for new CMOS interfaces + * Adding initial JPEG support + * Fix for UAC installer problems. + * Fixed uninstall without OpenNI. + * Set minimum OpenNI version check in the installer. + * Fix seeking to first frame in old XNS files. + * Bug Fix: Client would fail to connect if trying to connect while server is shutting down. + * Improving the timestamps algorithm. + * performance improvement when enumerating for image nodes - a sensor should only be checked once. + * improving error message for setting grayscale8 in low resolutions. + * Improve thread-safety when starting server + * Bug Fix: a crash when trying to open a non-existing XNS file. + * Bug Fix: a potential crash if Init of depth generator fails. + * Sensor now supports the Device Identification capability. + * Server: fixing a deadlock problem between closing a stream and getting new data from it. This was done by splitting the sensor lock into two locks: one for changes on the sensor and one for changing the stream collection. + * MultiProcess Bug Fix: the lock on a sensor didn't exist, so nothing was synchronized. + * ImageGenerator now also changes InputFormat when changing resolution if needed (when switching from hi-res to normal & vice versa). + * Adding frame IDs to Audio (just counting) + * restoring defaults to QVGA. + * Add support for sensors with no image CMOS. + * Updated low-bandwidth USB devices buffer information. + * Added the Asus WAVI auto-detection for Win32. + * Low bandwidth devices now use bigger USB delays. + * New defaults are now VGA, uncompressed. + * Initial support for low-band devices: + 1. Image, IR and audio does not enumerate. + 2. Defaults changed to QVGA, compressed. + +Version 5.0.0.25 (Unstable version - Jan 6th 2011) +-------------------------------------------------- + * Bug fix: infinite loop in server when a client tries to disconnect and streams can't be closed (usb timeout for example). + * Added MacOSX platform support. + * Added the unstable README file. + * Removed useless win32 prerequisites... + * Fixing audio to work properly in the client-server model. + * Server Bug Fix: a potential dead lock was solved. + * Sensor Server now supports multiple sensors. + * Refactored server to a better design, which should decrease deadlocks and make code more readable. + * Adding support for enumerating and opening different sensors. + * Bug Fix: GetStringProperty would always return XN_STATUS_ERROR. + +Version 5.0.0.24 (Stable version - Dec 8th 2010) +------------------------------------------------ + * Initial release... \ No newline at end of file diff --git a/Data/GlobalDefaults.ini b/Data/GlobalDefaultsKinect.ini similarity index 77% rename from Data/GlobalDefaults.ini rename to Data/GlobalDefaultsKinect.ini index 8fecee9..eee0d2c 100644 --- a/Data/GlobalDefaults.ini +++ b/Data/GlobalDefaultsKinect.ini @@ -1,6 +1,6 @@ [Core] ; 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -LogLevel=0 +LogLevel=3 ; leave empty for nothing (default). ALL - all masks LogMasks=ALL ; 0 - No (default), 1 - Yes @@ -17,9 +17,12 @@ LogWriteToFile=1 ;---------------- Server Default Configuration ------------------- [Server] -; Use a server to access sensor. 0 - No (single application), 1 - Yes (multiple applications, default) +; Use a server to access sensor. 0 - No (single application), 1 - Yes (multiple applications). Default: Arm - 0, other platforms - 1. Not supported on Mac. ;EnableMultiProcess=0 +; When multi process is enabled, allows server and client running in different sessions. 0 - No (default), 1 - Yes +;EnableMultiUsers=0 + ; The timeout in which a server goes down if no client is connected, in milliseconds ;ServerNoClientsTimeout=10000 @@ -38,6 +41,9 @@ LogWriteToFile=1 ; Stream Data Timestamps. 0 - milliseconds, 1 - microseconds (default) ;HighResTimestamps=1 +; Stream Data Timestamps Source. 0 - Firmware (default), 1 - Host +;HostTimestamps=0 + ; A filter for the firmware log. Default is determined by firmware. ;FirmwareLogFilter=0 @@ -53,17 +59,17 @@ LogWriteToFile=1 ; Is APC enabled. 0 - Off, 1 - On (default) ;APCEnabled=1 -; USB interface to be used. 0 - FW Default (default), 1 - ISO endpoints, 2 - BULK endpoints +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints, 2 - BULK endpoints. Default: Arm - 2, other platforms - 1 ;UsbInterface=2 [Depth] -; Output format. 0 - Shift values, 1 - 12-bit depth values (default) +; Output format. 0 - Shift values, 1 - depth values (default) ;OutputFormat=1 ; Is stream mirrored. 0 - Off, 1 - On ;Mirror=1 -; 0 - QVGA (default), 1 - VGA +; 0 - QVGA, 1 - VGA, 4 - QQVGA. Default: Arm - 4, other platforms - 0 ;Resolution=1 ; Frames per second (default is 30) @@ -75,8 +81,8 @@ LogWriteToFile=1 ; Max depth cutoff. 0-10000 mm (default is 10000) ;MaxDepthValue=10000 -; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression (default), 3 - Packed 11-bit -InputFormat=3 +; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression, 3 - Packed 11-bit, 4 - Packed 12-bit. Default: Arm - 4, other platforms - 3 +;InputFormat=1 ; Registration. 0 - Off (default), 1 - On ;Registration=1 @@ -93,6 +99,9 @@ InputFormat=3 ; Gain. 0-50 (0 - Auto, 1 - Min., 50 - Max.). Default value is set by firmware. ;Gain=0 +; Close Range Mode. 0 - Off (default), 1 - On +;CloseRange=0 + ; GMC Mode. 0 - Off, 1 - On (default) ;GMCMode=0 @@ -130,14 +139,14 @@ InputFormat=3 ; Is stream mirrored. 0 - Off, 1 - On ;Mirror=1 -; 0 - QVGA (default), 1 - VGA, 2- SXGA (1.3MP) 3 - UXGA (2.0MP) +; 0 - QVGA (default), 1 - VGA, 2 - SXGA (1.3MP), 3 - UXGA (2.0MP), 14 - 720p, 15 - 1280x960 ;Resolution=1 ; Frames per second (default is 30) ;FPS=30 -; Input format. 0 - BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default), 2 - Jpeg, 5 - Uncompressed YUV422, 6 - Uncompressed 8-bit BAYER -InputFormat=5 +; 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 +;InputFormat=5 ; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. ;Flicker=50 diff --git a/GPL.txt b/GPL.txt index 818433e..94a9ed0 100644 --- a/GPL.txt +++ b/GPL.txt @@ -1,674 +1,674 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Include/XnCommon.h b/Include/XnCommon.h index ef5b9ee..3789ad4 100644 --- a/Include/XnCommon.h +++ b/Include/XnCommon.h @@ -21,10 +21,6 @@ *****************************************************************************/ - - - - #ifndef __XN_COMMON_H__ #define __XN_COMMON_H__ @@ -59,4 +55,4 @@ typedef enum XnPrimeSenseErrorModules #define XN_PS_STATUS_MESSAGE_MAP_END(module) \ XN_STATUS_MESSAGE_MAP_END_FROM(XN_ERROR_GROUP_PRIMESENSE, module) -#endif // __XN_COMMON_H__ \ No newline at end of file +#endif // __XN_COMMON_H__ diff --git a/Include/XnCore.h b/Include/XnCore.h index ea8dd7b..07bee6f 100644 --- a/Include/XnCore.h +++ b/Include/XnCore.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_CORE_H_ #define _XN_CORE_H_ diff --git a/Include/XnDDK.h b/Include/XnDDK.h index e5de4e7..2ed1258 100644 --- a/Include/XnDDK.h +++ b/Include/XnDDK.h @@ -1,36 +1,31 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DDK_H_ #define _XN_DDK_H_ #include #include #include +#include #ifdef __cplusplus #ifdef XN_DDK_EXPORTS @@ -80,4 +75,8 @@ XN_DDK_API XnStatus XnDDKInitFromINIFile(const XnChar* cpINIFileName); */ XN_DDK_API XnStatus XnDDKShutdown(); +XN_DDK_API XnResolutions XnDDKGetResolutionFromXY(XnUInt32 nXRes, XnUInt32 nYRes); +XN_DDK_API XnBool XnDDKGetXYFromResolution(XnResolutions res, XnUInt32* pnXRes, XnUInt32* pnYRes); +XN_DDK_API const XnChar* XnDDKGetResolutionName(XnResolutions res); + #endif //_XN_DDK_H_ diff --git a/Include/XnDDKStatus.h b/Include/XnDDKStatus.h index 658d959..14dfdde 100644 --- a/Include/XnDDKStatus.h +++ b/Include/XnDDKStatus.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DDK_STATUS_H_ #define _XN_DDK_STATUS_H_ diff --git a/Include/XnDevice.h b/Include/XnDevice.h index 7621afd..70b00e7 100644 --- a/Include/XnDevice.h +++ b/Include/XnDevice.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICE_H_ #define _XN_DEVICE_H_ @@ -102,9 +96,22 @@ typedef enum XnStreamsChangeEventType XN_DEVICE_STREAM_DELETED, } XnStreamsChangeEventType; -typedef void (XN_CALLBACK_TYPE* XnDeviceOnStreamsChangedEventHandler)(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie); +typedef struct XnStreamCollectionChangedEventArgs +{ + XnDeviceHandle deviceHandle; + const XnChar* strStreamName; + XnStreamsChangeEventType eventType; +} XnStreamCollectionChangedEventArgs; + +typedef struct XnNewStreamDataEventArgs +{ + XnDeviceHandle deviceHandle; + const XnChar* strStreamName; +} XnNewStreamDataEventArgs; + +typedef void (XN_CALLBACK_TYPE* XnDeviceOnStreamsChangedEventHandler)(const XnStreamCollectionChangedEventArgs& args, void* pCookie); typedef void (XN_CALLBACK_TYPE* XnDeviceOnPropertyChangedEventHandler)(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); -typedef void (XN_CALLBACK_TYPE* XnDeviceOnNewStreamDataEventHandler)(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, void* pCookie); +typedef void (XN_CALLBACK_TYPE* XnDeviceOnNewStreamDataEventHandler)(const XnNewStreamDataEventArgs& args, void* pCookie); //--------------------------------------------------------------------------- // Exported Functions Declaration. Every Device Must Implement Them All! diff --git a/Include/XnDeviceProto.inl b/Include/XnDeviceProto.inl index 4acda35..fc3dd93 100644 --- a/Include/XnDeviceProto.inl +++ b/Include/XnDeviceProto.inl @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ /** * Gets the definition of a device. * @@ -134,9 +130,9 @@ XN_DEVICE_INTERFACE_FUNCTION(DoesModuleExist,(const XnDeviceHandle DeviceHandle, * @param DeviceHandle [in] The requested device handle. * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. -* @param phCallback [out] A handle for unregister. +* @param hCallback [out] A handle for unregister. */ -XN_DEVICE_INTERFACE_FUNCTION(RegisterToStreamsChange,(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)) +XN_DEVICE_INTERFACE_FUNCTION(RegisterToStreamsChange,(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback)) /** * Unregisters from the event of streams change (stream created / destroyed) @@ -169,9 +165,9 @@ XN_DEVICE_INTERFACE_FUNCTION(DestroyStreamData,(XnStreamData** ppStreamData)) * @param DeviceHandle [in] The requested device handle. * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. -* @param phCallback [out] A handle for unregister. +* @param hCallback [out] A handle for unregister. */ -XN_DEVICE_INTERFACE_FUNCTION(RegisterToNewStreamData,(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)) +XN_DEVICE_INTERFACE_FUNCTION(RegisterToNewStreamData,(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback)) /** * Unregisters from the event of new data from a stream. @@ -389,9 +385,9 @@ XN_DEVICE_INTERFACE_FUNCTION(GetAllProperties,(const XnDeviceHandle DeviceHandle * @param PropertyName [in] Name of the property to register to. * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. -* @param phCallback [out] A handle for unregister. +* @param hCallback [out] A handle for unregister. */ -XN_DEVICE_INTERFACE_FUNCTION(RegisterToPropertyChange,(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)) +XN_DEVICE_INTERFACE_FUNCTION(RegisterToPropertyChange,(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback)) /** * Unregisters an event handler from the Property Changed event. diff --git a/Include/XnDeviceProxy.h b/Include/XnDeviceProxy.h index 154216a..3472229 100644 --- a/Include/XnDeviceProxy.h +++ b/Include/XnDeviceProxy.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_PROXY_H__ #define __XN_DEVICE_PROXY_H__ diff --git a/Include/XnEE.h b/Include/XnEE.h index 7f4c5de..cab443d 100644 --- a/Include/XnEE.h +++ b/Include/XnEE.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_COMMON_H_ #define _XN_EE_COMMON_H_ diff --git a/Include/XnEE/XnEEAlgorithms.h b/Include/XnEE/XnEEAlgorithms.h index aabd916..5639049 100644 --- a/Include/XnEE/XnEEAlgorithms.h +++ b/Include/XnEE/XnEEAlgorithms.h @@ -1,31 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_ALGORITHMS_H_ #define _XN_EE_ALGORITHMS_H_ diff --git a/Include/XnEE/XnEECore.h b/Include/XnEE/XnEECore.h index ce72bba..bf5b17f 100644 --- a/Include/XnEE/XnEECore.h +++ b/Include/XnEE/XnEECore.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_CORE_H_ #define _XN_EE_CORE_H_ diff --git a/Include/XnEE/XnEEFramework.h b/Include/XnEE/XnEEFramework.h index 5749f25..c332baa 100644 --- a/Include/XnEE/XnEEFramework.h +++ b/Include/XnEE/XnEEFramework.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_FW_H_ #define _XN_EE_FW_H_ diff --git a/Include/XnEE/XnEEGeometry.h b/Include/XnEE/XnEEGeometry.h index 889fbb4..e55ba9e 100644 --- a/Include/XnEE/XnEEGeometry.h +++ b/Include/XnEE/XnEEGeometry.h @@ -1,31 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_GEOMETRY_H_ #define _XN_EE_GEOMETRY_H_ diff --git a/Include/XnEE/XnEEMath.h b/Include/XnEE/XnEEMath.h index 7fd0309..5950673 100644 --- a/Include/XnEE/XnEEMath.h +++ b/Include/XnEE/XnEEMath.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_MATH_H_ #define _XN_EE_MATH_H_ diff --git a/Include/XnEE/XnEEObjects.h b/Include/XnEE/XnEEObjects.h index c835425..a62ff63 100644 --- a/Include/XnEE/XnEEObjects.h +++ b/Include/XnEE/XnEEObjects.h @@ -1,31 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_EE_OBJECTS_H_ #define _XN_EE_OBJECTS_H_ diff --git a/Include/XnEE/XnV3DBox.h b/Include/XnEE/XnV3DBox.h index d873b38..3a97d43 100644 --- a/Include/XnEE/XnV3DBox.h +++ b/Include/XnEE/XnV3DBox.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_3DBOX_H_ #define _XNV_3DBOX_H_ diff --git a/Include/XnEE/XnV3DGeometry.h b/Include/XnEE/XnV3DGeometry.h index 8aa827e..cf95927 100644 --- a/Include/XnEE/XnV3DGeometry.h +++ b/Include/XnEE/XnV3DGeometry.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_3DGEOMETRY_H_ #define _XNV_3DGEOMETRY_H_ diff --git a/Include/XnEE/XnV3DVector.h b/Include/XnEE/XnV3DVector.h index 1930794..2a0d7e5 100644 --- a/Include/XnEE/XnV3DVector.h +++ b/Include/XnEE/XnV3DVector.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_3DVECTOR_H_ #define _XNV_3DVECTOR_H_ diff --git a/Include/XnEE/XnVAudioBuffer.h b/Include/XnEE/XnVAudioBuffer.h index 08b97d1..fdea982 100644 --- a/Include/XnEE/XnVAudioBuffer.h +++ b/Include/XnEE/XnVAudioBuffer.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_AUDIO_BUFFER_H_ #define _XNV_AUDIO_BUFFER_H_ diff --git a/Include/XnEE/XnVBodyPart.h b/Include/XnEE/XnVBodyPart.h index 586546c..63f6c10 100644 --- a/Include/XnEE/XnVBodyPart.h +++ b/Include/XnEE/XnVBodyPart.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_BODY_PART_H #define _XNV_BODY_PART_H diff --git a/Include/XnEE/XnVBoundingBox.h b/Include/XnEE/XnVBoundingBox.h index 23270af..c3a4028 100644 --- a/Include/XnEE/XnVBoundingBox.h +++ b/Include/XnEE/XnVBoundingBox.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_BOUNDING_BOX_H_ #define _XNV_BOUNDING_BOX_H_ diff --git a/Include/XnEE/XnVCenterOfMass.h b/Include/XnEE/XnVCenterOfMass.h index b4bd137..72e0251 100644 --- a/Include/XnEE/XnVCenterOfMass.h +++ b/Include/XnEE/XnVCenterOfMass.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_CENTER_OF_MASS_H_ #define _XNV_CENTER_OF_MASS_H_ diff --git a/Include/XnEE/XnVClosestPointFinder.h b/Include/XnEE/XnVClosestPointFinder.h index 1781b48..9eca0b1 100644 --- a/Include/XnEE/XnVClosestPointFinder.h +++ b/Include/XnEE/XnVClosestPointFinder.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_CLOSEST_POINT_FINDER_H_ #define _XNV_CLOSEST_POINT_FINDER_H_ diff --git a/Include/XnEE/XnVConnectedComponentDetector.h b/Include/XnEE/XnVConnectedComponentDetector.h index 4562a67..6543bf9 100644 --- a/Include/XnEE/XnVConnectedComponentDetector.h +++ b/Include/XnEE/XnVConnectedComponentDetector.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_CONNECTED_COMPONENT_DETECTOR_H_ #define _XNV_CONNECTED_COMPONENT_DETECTOR_H_ diff --git a/Include/XnEE/XnVContainer.h b/Include/XnEE/XnVContainer.h index 69ab678..98fcbe9 100644 --- a/Include/XnEE/XnVContainer.h +++ b/Include/XnEE/XnVContainer.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_CONTAINER_H_ #define _XNV_CONTAINER_H_ diff --git a/Include/XnEE/XnVDepthMap.h b/Include/XnEE/XnVDepthMap.h index 8be7f1c..54b2657 100644 --- a/Include/XnEE/XnVDepthMap.h +++ b/Include/XnEE/XnVDepthMap.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DEPTH_MAP_H_ #define _XNV_DEPTH_MAP_H_ diff --git a/Include/XnEE/XnVDepthMatrix.h b/Include/XnEE/XnVDepthMatrix.h index b74b75a..ec00a37 100644 --- a/Include/XnEE/XnVDepthMatrix.h +++ b/Include/XnEE/XnVDepthMatrix.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DEPTH_MATRIX_H_ #define _XNV_DEPTH_MATRIX_H_ diff --git a/Include/XnEE/XnVDepthRepresentation.h b/Include/XnEE/XnVDepthRepresentation.h index f404ec9..9f32b5a 100644 --- a/Include/XnEE/XnVDepthRepresentation.h +++ b/Include/XnEE/XnVDepthRepresentation.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DEPTH_REPRESENTATION_H_ #define _XNV_DEPTH_REPRESENTATION_H_ diff --git a/Include/XnEE/XnVDevice.h b/Include/XnEE/XnVDevice.h index fd8cf1d..236fe50 100644 --- a/Include/XnEE/XnVDevice.h +++ b/Include/XnEE/XnVDevice.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DEVICE_H_ #define _XNV_DEVICE_H_ @@ -300,9 +294,9 @@ class XN_EE_CORE_API XnVDevice : public XnVStreamContainer, private XnVStreamCol XnStatus FindStreamOfType(const XnChar* strType, XnVStream& stream); - XnStatus RegisterForPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle* phCallback); - XnStatus RegisterForNewDataFromStreamEvent(XnVNewDataFromStreamHandler* pHandler, XnCallbackHandle* phCallback); - XnStatus RegisterForStreamCollectionChangedEvent(XnVStreamCollectionChangedHandler* pHandler, XnCallbackHandle* phCallback); + XnStatus RegisterForPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle& hCallback); + XnStatus RegisterForNewDataFromStreamEvent(XnVNewDataFromStreamHandler* pHandler, XnCallbackHandle& hCallback); + XnStatus RegisterForStreamCollectionChangedEvent(XnVStreamCollectionChangedHandler* pHandler, XnCallbackHandle& hCallback); XnStatus UnregisterFromPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnCallbackHandle hCallback); XnStatus UnregisterFromNewDataFromStreamEvent(XnCallbackHandle hCallback); @@ -462,9 +456,9 @@ class XN_EE_CORE_API XnVDevice : public XnVStreamContainer, private XnVStreamCol static XnBool IsXnVDeviceStreamProp(const XnChar* strProperty); - static void XN_CALLBACK_TYPE OnStreamsChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie); + static void XN_CALLBACK_TYPE OnStreamsChangedCallback(const XnStreamCollectionChangedEventArgs& args, void* pCookie); static void XN_CALLBACK_TYPE OnPropertyChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); - static void XN_CALLBACK_TYPE OnNewStreamDataCallback(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, void* pCookie); + static void XN_CALLBACK_TYPE OnNewStreamDataCallback(const XnNewStreamDataEventArgs& args, void* pCookie); static XnStatus XN_CALLBACK_TYPE OnXnVDevicePropertyChanged(const XnProperty* pSender, void* pCookie); XnDeviceHandle m_DeviceHandle; @@ -692,7 +686,7 @@ class XN_EE_CORE_API XnVDevice : public XnVStreamContainer, private XnVStreamCol XN_3_6_API XnStatus InitS2DTables36() const; XN_3_6_API XnStatus GetProperty36(const XnChar* strModule, const XnChar* strProperty, XnDouble& fValue) const; static void XN_CALLBACK_TYPE OnS2DTableChanged36(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); - static void XN_CALLBACK_TYPE OnNewStreamDataCallback36(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, void* pCookie); + static void XN_CALLBACK_TYPE OnNewStreamDataCallback36(const XnNewStreamDataEventArgs& args, void* pCookie); }; #pragma warning (pop) diff --git a/Include/XnEE/XnVDeviceCallbackHandler.h b/Include/XnEE/XnVDeviceCallbackHandler.h index 459636e..b9eea92 100644 --- a/Include/XnEE/XnVDeviceCallbackHandler.h +++ b/Include/XnEE/XnVDeviceCallbackHandler.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DEVICE_CALLBACK_HANDLER_H_ #define _XNV_DEVICE_CALLBACK_HANDLER_H_ diff --git a/Include/XnEE/XnVDeviceRecorder.h b/Include/XnEE/XnVDeviceRecorder.h index 1d1e6d7..6e8618e 100644 --- a/Include/XnEE/XnVDeviceRecorder.h +++ b/Include/XnEE/XnVDeviceRecorder.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_V_DEVICE_RECORDER_H__ #define __XN_V_DEVICE_RECORDER_H__ diff --git a/Include/XnEE/XnVDownscale.h b/Include/XnEE/XnVDownscale.h index ac1f7ac..7042ec9 100644 --- a/Include/XnEE/XnVDownscale.h +++ b/Include/XnEE/XnVDownscale.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_DOWNSCALE_H_ #define _XNV_DOWNSCALE_H_ diff --git a/Include/XnEE/XnVEventHandlers.h b/Include/XnEE/XnVEventHandlers.h index 760ae34..cd80eb2 100644 --- a/Include/XnEE/XnVEventHandlers.h +++ b/Include/XnEE/XnVEventHandlers.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_V_EVENT_HANDLERS_H__ #define __XN_V_EVENT_HANDLERS_H__ diff --git a/Include/XnEE/XnVExtremes.h b/Include/XnEE/XnVExtremes.h index b0a476a..d62acfa 100644 --- a/Include/XnEE/XnVExtremes.h +++ b/Include/XnEE/XnVExtremes.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_EXTREMES_H_ #define _XNV_EXTREMES_H_ diff --git a/Include/XnEE/XnVGeneralStaticMap.h b/Include/XnEE/XnVGeneralStaticMap.h index e42490b..d9a3c75 100644 --- a/Include/XnEE/XnVGeneralStaticMap.h +++ b/Include/XnEE/XnVGeneralStaticMap.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_GENERAL_STATIC_MAP_H_ #define _XNV_GENERAL_STATIC_MAP_H_ diff --git a/Include/XnEE/XnVHand.h b/Include/XnEE/XnVHand.h index 0343149..eb86ec4 100644 --- a/Include/XnEE/XnVHand.h +++ b/Include/XnEE/XnVHand.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_HAND_H #define _XNV_HAND_H diff --git a/Include/XnEE/XnVHead.h b/Include/XnEE/XnVHead.h index 83ec8a1..8f7f617 100644 --- a/Include/XnEE/XnVHead.h +++ b/Include/XnEE/XnVHead.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_HEAD_H #define _XNV_HEAD_H diff --git a/Include/XnEE/XnVHumanStretch.h b/Include/XnEE/XnVHumanStretch.h index a743e9a..bec70ef 100644 --- a/Include/XnEE/XnVHumanStretch.h +++ b/Include/XnEE/XnVHumanStretch.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_HUMAN_STRETCH_H_ #define _XNV_HUMAN_STRETCH_H_ diff --git a/Include/XnEE/XnVImageMap.h b/Include/XnEE/XnVImageMap.h index b40905c..f0f78f2 100644 --- a/Include/XnEE/XnVImageMap.h +++ b/Include/XnEE/XnVImageMap.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_IMAGE_MAP_H_ #define _XNV_IMAGE_MAP_H_ diff --git a/Include/XnEE/XnVImageMatrix.h b/Include/XnEE/XnVImageMatrix.h index 51357f0..c14a4be 100644 --- a/Include/XnEE/XnVImageMatrix.h +++ b/Include/XnEE/XnVImageMatrix.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_IMAGE_MATRIX_H_ #define _XNV_IMAGE_MATRIX_H_ diff --git a/Include/XnEE/XnVInitStreamProperties.h b/Include/XnEE/XnVInitStreamProperties.h index 63e652d..d607b1e 100644 --- a/Include/XnEE/XnVInitStreamProperties.h +++ b/Include/XnEE/XnVInitStreamProperties.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_INIT_STREAM_PROPERTIES_H #define _XNV_INIT_STREAM_PROPERTIES_H diff --git a/Include/XnEE/XnVLabelMatrix.h b/Include/XnEE/XnVLabelMatrix.h index 28e5333..dc799d6 100644 --- a/Include/XnEE/XnVLabelMatrix.h +++ b/Include/XnEE/XnVLabelMatrix.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_LABEL_MATRIX_H_ #define _XNV_LABEL_MATRIX_H_ diff --git a/Include/XnEE/XnVLabelPruner.h b/Include/XnEE/XnVLabelPruner.h index 53d5217..62fa484 100644 --- a/Include/XnEE/XnVLabelPruner.h +++ b/Include/XnEE/XnVLabelPruner.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_LABEL_PRUNER_H_ #define _XNV_LABEL_PRUNER_H_ diff --git a/Include/XnEE/XnVLabeledObject.h b/Include/XnEE/XnVLabeledObject.h index 86dbdb9..f9debfe 100644 --- a/Include/XnEE/XnVLabeledObject.h +++ b/Include/XnEE/XnVLabeledObject.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_LABELED_OBJECT_H_ #define _XNV_LABELED_OBJECT_H_ diff --git a/Include/XnEE/XnVMathCommon.h b/Include/XnEE/XnVMathCommon.h index 12704b3..77cdac6 100644 --- a/Include/XnEE/XnVMathCommon.h +++ b/Include/XnEE/XnVMathCommon.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_MATH_COMMON_H_ #define _XNV_MATH_COMMON_H_ diff --git a/Include/XnEE/XnVMatrix.h b/Include/XnEE/XnVMatrix.h index 0041fd7..055774c 100644 --- a/Include/XnEE/XnVMatrix.h +++ b/Include/XnEE/XnVMatrix.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_MATRIX_H_ #define _XNV_MATRIX_H_ diff --git a/Include/XnEE/XnVMatrix3X3.h b/Include/XnEE/XnVMatrix3X3.h index 1f9db0f..260a4e6 100644 --- a/Include/XnEE/XnVMatrix3X3.h +++ b/Include/XnEE/XnVMatrix3X3.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_MATRIX3X3_H_ #define _XNV_MATRIX3X3_H_ diff --git a/Include/XnEE/XnVModule.h b/Include/XnEE/XnVModule.h index 354fe29..02472ff 100644 --- a/Include/XnEE/XnVModule.h +++ b/Include/XnEE/XnVModule.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_MODULE_H_ #define _XNV_MODULE_H_ @@ -103,7 +97,7 @@ class XN_EE_CORE_API XnVModule XnStatus SetProperty(const XnChar* strProperty, const XnChar* strValue); XnStatus SetProperty(const XnChar* strProperty, const XnGeneralBuffer& gbValue); - XnStatus RegisterForPropertyChangedEvent(const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle* phCallback); + XnStatus RegisterForPropertyChangedEvent(const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle& hCallback); XnStatus UnregisterFromPropertyChangedEvent(const XnChar* strProperty, XnCallbackHandle hCallback); XN_3_6_API XnStatus GetProperty(const XnChar* strProperty, XnUInt8& nValue) const; diff --git a/Include/XnEE/XnVObject.h b/Include/XnEE/XnVObject.h index f180034..518ac19 100644 --- a/Include/XnEE/XnVObject.h +++ b/Include/XnEE/XnVObject.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_OBJECT_H_ #define _XNV_OBJECT_H_ diff --git a/Include/XnEE/XnVPixelStreamData.h b/Include/XnEE/XnVPixelStreamData.h index dde3e67..91dbb29 100644 --- a/Include/XnEE/XnVPixelStreamData.h +++ b/Include/XnEE/XnVPixelStreamData.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_V_PIXEL_STREAM_DATA_H__ #define __XN_V_PIXEL_STREAM_DATA_H__ diff --git a/Include/XnEE/XnVPoint.h b/Include/XnEE/XnVPoint.h index 9e93bf3..a2d9e63 100644 --- a/Include/XnEE/XnVPoint.h +++ b/Include/XnEE/XnVPoint.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_POINT_H_ #define _XNV_POINT_H_ diff --git a/Include/XnEE/XnVPointContainer.h b/Include/XnEE/XnVPointContainer.h index 471ddb0..d6ceca3 100644 --- a/Include/XnEE/XnVPointContainer.h +++ b/Include/XnEE/XnVPointContainer.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_POINT_CONTAINER_H_ #define _XNV_POINT_CONTAINER_H_ diff --git a/Include/XnEE/XnVPropertySet.h b/Include/XnEE/XnVPropertySet.h index cc0fb43..a888e09 100644 --- a/Include/XnEE/XnVPropertySet.h +++ b/Include/XnEE/XnVPropertySet.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_V_PROPERTY_SET_H__ #define __XN_V_PROPERTY_SET_H__ diff --git a/Include/XnEE/XnVRealObject.h b/Include/XnEE/XnVRealObject.h index 14b87ab..3eea457 100644 --- a/Include/XnEE/XnVRealObject.h +++ b/Include/XnEE/XnVRealObject.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_REAL_OBJECT_H_ #define _XNV_REAL_OBJECT_H_ diff --git a/Include/XnEE/XnVRealWorldTranslator.h b/Include/XnEE/XnVRealWorldTranslator.h index be49cf2..0016197 100644 --- a/Include/XnEE/XnVRealWorldTranslator.h +++ b/Include/XnEE/XnVRealWorldTranslator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_REAL_WORLD_TRANSLATOR_H_ #define _XNV_REAL_WORLD_TRANSLATOR_H_ diff --git a/Include/XnEE/XnVSkeleton.h b/Include/XnEE/XnVSkeleton.h index 246a20f..3733ba9 100644 --- a/Include/XnEE/XnVSkeleton.h +++ b/Include/XnEE/XnVSkeleton.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef XNV_SKELETON_H #define XNV_SKELETON_H diff --git a/Include/XnEE/XnVSphere.h b/Include/XnEE/XnVSphere.h index d99083b..b1feb92 100644 --- a/Include/XnEE/XnVSphere.h +++ b/Include/XnEE/XnVSphere.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_SPHERE_H_ #define _XNV_SPHERE_H_ diff --git a/Include/XnEE/XnVStaticMap.h b/Include/XnEE/XnVStaticMap.h index aafede5..79fb09b 100644 --- a/Include/XnEE/XnVStaticMap.h +++ b/Include/XnEE/XnVStaticMap.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_STATIC_SHIFT_MAP_H_ #define _XNV_STATIC_SHIFT_MAP_H_ diff --git a/Include/XnEE/XnVStatus.h b/Include/XnEE/XnVStatus.h index af8a256..4e17583 100644 --- a/Include/XnEE/XnVStatus.h +++ b/Include/XnEE/XnVStatus.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_STATUS_H_ #define _XNV_STATUS_H_ diff --git a/Include/XnEE/XnVStream.h b/Include/XnEE/XnVStream.h index 1dff329..6f4c0d7 100644 --- a/Include/XnEE/XnVStream.h +++ b/Include/XnEE/XnVStream.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_STREAM_H #define _XNV_STREAM_H diff --git a/Include/XnEE/XnVStreamContainer.h b/Include/XnEE/XnVStreamContainer.h index 9f7d978..fc0ba86 100644 --- a/Include/XnEE/XnVStreamContainer.h +++ b/Include/XnEE/XnVStreamContainer.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_STREAM_CONTAINER_H_ #define _XNV_STREAM_CONTAINER_H_ @@ -66,8 +60,8 @@ class XN_EE_CORE_API XnVStreamContainer virtual XnStatus SetProperty(const XnChar* strModule, const XnChar* strProperty, const XnChar* csValue) = 0; virtual XnStatus SetProperty(const XnChar* strModule, const XnChar* strProperty, const XnGeneralBuffer& gbValue) = 0; - virtual XnStatus RegisterForPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle* phCallback) = 0; - virtual XnStatus RegisterForStreamCollectionChangedEvent(XnVStreamCollectionChangedHandler* pHandler, XnCallbackHandle* phCallback) = 0; + virtual XnStatus RegisterForPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnVModulePropertyChangedHandler* pHandler, XnCallbackHandle& hCallback) = 0; + virtual XnStatus RegisterForStreamCollectionChangedEvent(XnVStreamCollectionChangedHandler* pHandler, XnCallbackHandle& hCallback) = 0; virtual XnStatus UnregisterFromPropertyChangedEvent(const XnChar* strModule, const XnChar* strProperty, XnCallbackHandle hCallback) = 0; virtual XnStatus UnregisterFromStreamCollectionChangedEvent(XnCallbackHandle hCallback) = 0; diff --git a/Include/XnEE/XnVStreamData.h b/Include/XnEE/XnVStreamData.h index 19ad626..d09f176 100644 --- a/Include/XnEE/XnVStreamData.h +++ b/Include/XnEE/XnVStreamData.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_V_STREAM_OUTPUT_H__ #define __XN_V_STREAM_OUTPUT_H__ @@ -32,7 +27,7 @@ //--------------------------------------------------------------------------- #include "XnVEventHandlers.h" #include "XnVStream.h" -#include +#include //--------------------------------------------------------------------------- // Types @@ -87,7 +82,7 @@ class XN_EE_CORE_API XnVStreamData : private XnVModulePropertyChangedHandler XnCallbackHandle hCallback; } XnWatchedProperty; - XN_DECLARE_LIST_DECL(XN_EE_CORE_API, XnWatchedProperty, XnWatchedPropertiesList) + typedef XnListT XnWatchedPropertiesList; XnBool m_bIsLive; XnBool m_bWaitForDataUpdate; diff --git a/Include/XnEE/XnVTorso.h b/Include/XnEE/XnVTorso.h index 9f88cd4..25e71d7 100644 --- a/Include/XnEE/XnVTorso.h +++ b/Include/XnEE/XnVTorso.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef XNV_TORSO_H #define XNV_TORSO_H diff --git a/Include/XnEE/XnVUpscale.h b/Include/XnEE/XnVUpscale.h index 5e8bddf..72263ed 100644 --- a/Include/XnEE/XnVUpscale.h +++ b/Include/XnEE/XnVUpscale.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_UPSCALE_H_ #define _XNV_UPSCALE_H_ diff --git a/Include/XnEE/XnVUserExtractor.h b/Include/XnEE/XnVUserExtractor.h index 13ec360..dfbedb4 100644 --- a/Include/XnEE/XnVUserExtractor.h +++ b/Include/XnEE/XnVUserExtractor.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_USER_EXTRACTOR_H_ #define _XNV_USER_EXTRACTOR_H_ diff --git a/Include/XnEE/XnVVirtualObject.h b/Include/XnEE/XnVVirtualObject.h index a15bd05..1df3db1 100644 --- a/Include/XnEE/XnVVirtualObject.h +++ b/Include/XnEE/XnVVirtualObject.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XNV_VIRTUAL_OBJECT_H_ #define _XNV_VIRTUAL_OBJECT_H_ diff --git a/Include/XnFormatsStatus.h b/Include/XnFormatsStatus.h index 0b81f07..9ef8bdb 100644 --- a/Include/XnFormatsStatus.h +++ b/Include/XnFormatsStatus.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_FORMATS_STATUS_H_ #define _XN_FORMATS_STATUS_H_ @@ -64,6 +58,7 @@ XN_STATUS_MESSAGE(XN_STATUS_IO_INVALID_STREAM_DEPTH_BUFFER_SIZE, "Invalid Xiron XN_STATUS_MESSAGE(XN_STATUS_IO_INVALID_STREAM_IMAGE_BUFFER_SIZE, "Invalid Xiron I/O stream image buffer size!") XN_STATUS_MESSAGE(XN_STATUS_IO_INVALID_STREAM_MISC_BUFFER_SIZE, "Invalid Xiron I/O stream misc buffer size!") XN_STATUS_MESSAGE(XN_STATUS_IO_INVALID_STREAM_AUDIO_BUFFER_SIZE, "Invalid Xiron I/O stream audio buffer size!") +XN_STATUS_MESSAGE(XN_STATUS_INVALID_OUTPUT_FORMAT_FOR_RESOLUTION, "Pixel format is not supported for this resolution!") XN_PS_STATUS_MESSAGE_MAP_END(XN_ERROR_GROUP_FORMATS) #endif //_XN_FORMATS_STATUS_H_ diff --git a/Include/XnIOFileStream.h b/Include/XnIOFileStream.h index a448f65..68229f3 100644 --- a/Include/XnIOFileStream.h +++ b/Include/XnIOFileStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IO_FILE_STREAM_H__ #define __XN_IO_FILE_STREAM_H__ @@ -47,8 +42,8 @@ class XN_CORE_CPP_API XnIOFileStream : public XnIOStream virtual XnStatus Init(); virtual XnStatus Free(); - XnStatus Tell(XnUInt32* pnOffset); - XnStatus Seek(XnUInt32 nOffset); + XnStatus Tell(XnUInt64* pnOffset); + XnStatus Seek(XnUInt64 nOffset); private: const XnChar* m_pcsFileName; diff --git a/Include/XnIONetworkStream.h b/Include/XnIONetworkStream.h index 4ba5b6f..4170314 100644 --- a/Include/XnIONetworkStream.h +++ b/Include/XnIONetworkStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IO_NETWORK_STREAM_H__ #define __XN_IO_NETWORK_STREAM_H__ diff --git a/Include/XnIOParams.h b/Include/XnIOParams.h index bed373f..003fa73 100644 --- a/Include/XnIOParams.h +++ b/Include/XnIOParams.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_IO_PARAMS_H_ #define _XN_IO_PARAMS_H_ diff --git a/Include/XnIOStream.h b/Include/XnIOStream.h index 7d1f83c..8cf8a83 100644 --- a/Include/XnIOStream.h +++ b/Include/XnIOStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IO_STREAM_H__ #define __XN_IO_STREAM_H__ diff --git a/Include/XnPlatformBC.h b/Include/XnPlatformBC.h index ac47afb..425fa20 100644 --- a/Include/XnPlatformBC.h +++ b/Include/XnPlatformBC.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PS_PLATFORM_H__ #define __XN_PS_PLATFORM_H__ diff --git a/Include/XnPropertySet.h b/Include/XnPropertySet.h index 3e783cd..a0c9d8a 100644 --- a/Include/XnPropertySet.h +++ b/Include/XnPropertySet.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PROPERTY_SET_H__ #define __XN_PROPERTY_SET_H__ diff --git a/Include/XnPsVersion.h b/Include/XnPsVersion.h index f2c5461..ba3e2c8 100644 --- a/Include/XnPsVersion.h +++ b/Include/XnPsVersion.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_PS_VERSION_H_ #define _XN_PS_VERSION_H_ @@ -39,11 +33,11 @@ /** Xiron major version. */ #define XN_PS_MAJOR_VERSION 5 /** Xiron minor version. */ -#define XN_PS_MINOR_VERSION 0 +#define XN_PS_MINOR_VERSION 1 /** Xiron maintenance version. */ -#define XN_PS_MAINTENANCE_VERSION 0 +#define XN_PS_MAINTENANCE_VERSION 2 /** Xiron build version. */ -#define XN_PS_BUILD_VERSION 24 +#define XN_PS_BUILD_VERSION 1 /** Xiron version (in brief string format): "Major.Minor.Maintenance (Build)" */ #define XN_PS_BRIEF_VERSION_STRING \ diff --git a/Include/XnStream.h b/Include/XnStream.h index 5642246..3c1a195 100644 --- a/Include/XnStream.h +++ b/Include/XnStream.h @@ -1,27 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_STREAM_H_ #define _XN_STREAM_H_ diff --git a/Include/XnStreamData.h b/Include/XnStreamData.h index 89e6e66..dff99cc 100644 --- a/Include/XnStreamData.h +++ b/Include/XnStreamData.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_OUTPUT_H__ #define __XN_STREAM_OUTPUT_H__ diff --git a/Include/XnStreamDataSet.h b/Include/XnStreamDataSet.h index 4155ba7..18291ee 100644 --- a/Include/XnStreamDataSet.h +++ b/Include/XnStreamDataSet.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_OUTPUT_SET_H__ #define __XN_STREAM_OUTPUT_SET_H__ diff --git a/Include/XnStreamFormats.h b/Include/XnStreamFormats.h index 8308e91..db29fe9 100644 --- a/Include/XnStreamFormats.h +++ b/Include/XnStreamFormats.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_FORMATS_H__ #define __XN_STREAM_FORMATS_H__ diff --git a/Include/XnStreamParams.h b/Include/XnStreamParams.h index ac42799..218aafc 100644 --- a/Include/XnStreamParams.h +++ b/Include/XnStreamParams.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_STREAM_PARAMS_H_ #define _XN_STREAM_PARAMS_H_ @@ -123,6 +117,8 @@ #define XN_STREAM_PROPERTY_INPUT_FORMAT "InputFormat" /** XnDynamicSizeBuffer */ #define XN_STREAM_PROPERTY_LAST_RAW_FRAME "LastRawFrame" +/** XnGeneralBuffer array */ +#define XN_STREAM_PROPERTY_EXTERNAL_BUFFER_POOL "ExternalBufferPool" //--------------------------------------------------------------------------- // Pixel-Based Stream Properties (Depth, Image, IR) @@ -138,12 +134,19 @@ /** XnCropping */ #define XN_STREAM_PROPERTY_CROPPING "Cropping" +/** Boolean */ +#define XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED "WhiteBalancedEnabled" +/** Integer */ +#define XN_STREAM_PROPERTY_GAIN "Gain" +/** Integer */ +#define XN_STREAM_PROPERTY_SUPPORT_MODES_COUNT "SupportedModesCount" +/** General (XnCmosPreset array) */ +#define XN_STREAM_PROPERTY_SUPPORT_MODES "SupportedModes" + //--------------------------------------------------------------------------- // Depth Specific Properties //--------------------------------------------------------------------------- /** Integer */ -#define XN_STREAM_PROPERTY_GAIN "Gain" -/** Integer */ #define XN_STREAM_PROPERTY_HOLE_FILTER "HoleFilter" /** Integer */ #define XN_STREAM_PROPERTY_MIN_DEPTH "MinDepthValue" @@ -157,8 +160,6 @@ #define XN_STREAM_PROPERTY_REGISTRATION "Registration" /** XnProcessingType */ #define XN_STREAM_PROPERTY_REGISTRATION_TYPE "RegistrationType" -/** Boolean */ -#define XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED "WhiteBalancedEnabled" /** XnDepthAGCBin* */ #define XN_STREAM_PROPERTY_AGC_BIN "AGCBin" /** Integer */ @@ -183,8 +184,14 @@ #define XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE "ZPPS" /** Real */ #define XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE "LDDIS" +/** Real */ +#define XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE "DCRCDIS" /** Boolean */ #define XN_STREAM_PROPERTY_GMC_MODE "GmcMode" +/** Boolean */ +#define XN_STREAM_PROPERTY_CLOSE_RANGE "CloseRange" +/** XnUInt16* (general) */ +#define XN_STREAM_PROPERTY_SHIFTS_MAP "ShiftsMap" //--------------------------------------------------------------------------- // Shifts Properties (up to v3.6) @@ -231,6 +238,28 @@ #define XN_STREAM_PROPERTY_FLICKER "Flicker" /** Integer */ #define XN_STREAM_PROPERTY_QUALITY "Quality" +/** Float */ +#define XN_STREAM_PROPERTY_BRIGHTNESS XN_CAPABILITY_BRIGHTNESS +/** Float */ +#define XN_STREAM_PROPERTY_CONTRAST XN_CAPABILITY_CONTRAST +/** Float */ +#define XN_STREAM_PROPERTY_SATURATION XN_CAPABILITY_SATURATION +/** Float */ +#define XN_STREAM_PROPERTY_SHARPNESS XN_CAPABILITY_SHARPNESS +/** Float */ +#define XN_STREAM_PROPERTY_COLOR_TEMPERATURE XN_CAPABILITY_COLOR_TEMPERATURE +/** Float */ +#define XN_STREAM_PROPERTY_BACKLIGHT_COMPENSATION XN_CAPABILITY_BACKLIGHT_COMPENSATION +/** Float */ +#define XN_STREAM_PROPERTY_ZOOM XN_CAPABILITY_ZOOM +/** Integer (in microseconds) */ +#define XN_STREAM_PROPERTY_EXPOSURE XN_CAPABILITY_EXPOSURE +/** Float */ +#define XN_STREAM_PROPERTY_PAN XN_CAPABILITY_PAN +/** Float */ +#define XN_STREAM_PROPERTY_TILT XN_CAPABILITY_TILT +/** Boolean */ +#define XN_STREAM_PROPERTY_LOW_LIGHT_COMPENSATION XN_CAPABILITY_LOW_LIGHT_COMPENSATION //--------------------------------------------------------------------------- // Audio Specific Properties @@ -263,6 +292,8 @@ #define XN_MODULE_PROPERTY_SDK_VERSION "SDKVersion" /** String */ #define XN_MODULE_PROPERTY_DEVICE_NAME "DeviceName" +/** String */ +#define XN_MODULE_PROPERTY_USB_PATH "USBPath" /** Integer (XnSensorUsbInterface) */ #define XN_MODULE_PROPERTY_USB_INTERFACE "UsbInterface" /** Integer */ @@ -275,6 +306,8 @@ #define XN_MODULE_PROPERTY_READ_ENDPOINT_3 "ReadEndpoint3" /** Boolean */ #define XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP "ResetSensorOnStartup" +/** Boolean */ +#define XN_MODULE_PROPERTY_LEAN_INIT "LeanInit" /** String */ #define XN_MODULE_PROPERTY_ID "ID" /** String */ @@ -308,15 +341,34 @@ /** Boolean */ #define XN_MODULE_PROPERTY_HIGH_RES_TIMESTAMPS "HighResTimestamps" /** Boolean */ +#define XN_MODULE_PROPERTY_HOST_TIMESTAMPS "HostTimestamps" +/** Boolean */ #define XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN "CloseStreamsOnShutdown" /** Integer */ #define XN_MODULE_PROPERTY_SERVER_NO_CLIENTS_TIMEOUT "ServerNoClientsTimeout" /** Integer */ #define XN_MODULE_PROPERTY_SERVER_START_NEW_LOG_FILE "ServerStartNewLogFile" +/** String */ +#define XN_MODULE_PROPERTY_SERVER_LOG_FILE "ServerLogFile" /** Integer */ #define XN_MODULE_PROPERTY_ERROR_STATE "ErrorState" /** Boolean */ #define XN_MODULE_PROPERTY_ENABLE_MULTI_PROCESS "EnableMultiProcess" +/** Boolean */ +#define XN_MODULE_PROPERTY_ENABLE_MULTI_USERS "EnableMultiUsers" +/** String */ +#define XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME "PhysicalDeviceName" +/** String */ +#define XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA "VendorSpecificData" +/** String */ +#define XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING "SensorPlatformString" +/** Boolean */ +#define XN_MODULE_PROPERTY_AUDIO_SUPPORTED "AudioSupported" +/** Boolean */ +#define XN_MODULE_PROPERTY_IMAGE_SUPPORTED "ImageSupported" +#define XN_MODULE_PROPERTY_IMAGE_CONTROL "ImageControl" +#define XN_MODULE_PROPERTY_DEPTH_CONTROL "DepthControl" +#define XN_MODULE_PROPERTY_AHB "AHB" //--------------------------------------------------------------------------- @@ -338,6 +390,7 @@ #define XN_UXGA_X_RES 1600 #define XN_UXGA_Y_RES 1200 +#define XN_IO_MAX_I2C_BUFFER_SIZE 10 //--------------------------------------------------------------------------- // Enums - values of various properties @@ -349,8 +402,18 @@ typedef enum XnResolutions XN_RESOLUTION_VGA = 1, // 640x480 XN_RESOLUTION_SXGA = 2, // 1280x1024 XN_RESOLUTION_UXGA = 3, // 1600x1200 - - XN_RESOLUTION_COUNT, + XN_RESOLUTION_QQVGA = 4, // 160x120 + XN_RESOLUTION_QCIF = 5, // 176x144 + XN_RESOLUTION_240P = 6, // 432x240 + XN_RESOLUTION_CIF = 7, // 352x288 + XN_RESOLUTION_WVGA = 8, // 640x360 + XN_RESOLUTION_480P = 9, // 864x480 + XN_RESOLUTION_800_448 = 10, // 800x448 + XN_RESOLUTION_SVGA = 11, // 800x600 + XN_RESOLUTION_576P = 12, // 1024x576 + XN_RESOLUTION_DV = 13, // 960x720 + XN_RESOLUTION_720P = 14, // 1280x720 + XN_RESOLUTION_1280_960 = 15, // 1280x960 } XnResolutions; typedef enum @@ -365,6 +428,10 @@ typedef enum XN_SENSOR_FW_VER_5_1 = 7, XN_SENSOR_FW_VER_5_2 = 8, XN_SENSOR_FW_VER_5_3 = 9, + XN_SENSOR_FW_VER_5_4 = 10, + XN_SENSOR_FW_VER_5_5 = 11, + XN_SENSOR_FW_VER_5_6 = 12, + XN_SENSOR_FW_VER_5_7 = 13, } XnFWVer; typedef enum @@ -387,13 +454,16 @@ typedef enum { XN_SENSOR_HW_VER_FPDB_10 = 1, XN_SENSOR_HW_VER_CDB_10 = 2, XN_SENSOR_HW_VER_RD_3 = 3, - XN_SENSOR_HW_VER_RD_5 = 4 + XN_SENSOR_HW_VER_RD_5 = 4, + XN_SENSOR_HW_VER_RD1081 = 5, + XN_SENSOR_HW_VER_RD1082 = 6 } XnHWVer; typedef enum { XN_SENSOR_CHIP_VER_UNKNOWN = 0, XN_SENSOR_CHIP_VER_PS1000 = 1, - XN_SENSOR_CHIP_VER_PS1080 = 2 + XN_SENSOR_CHIP_VER_PS1080 = 2, + XN_SENSOR_CHIP_VER_PS1080A6 = 3 } XnChipVer; typedef enum @@ -413,6 +483,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, } XnIOImageFormats; typedef enum @@ -524,6 +595,44 @@ typedef struct XnDynamicSizeBuffer XnUInt32 nDataSize; } XnDynamicSizeBuffer; +typedef struct XnCmosPreset +{ + XnUInt16 nFormat; + XnUInt16 nResolution; + XnUInt16 nFPS; +} XnCmosPreset; + +typedef struct XnI2CWriteData +{ + XnUInt16 nBus; + XnUInt16 nSlaveAddress; + XnUInt16 cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + XnUInt16 nWriteSize; +} XnI2CWriteData; + +typedef struct XnI2CReadData +{ + XnUInt16 nBus; + XnUInt16 nSlaveAddress; + XnUInt16 cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + XnUInt16 cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + XnUInt16 nReadSize; + XnUInt16 nWriteSize; +} XnI2CReadData; + +typedef struct XnControlProcessingData +{ + XnUInt16 nRegister; + XnUInt16 nValue; +} XnControlProcessingData; + +typedef struct +{ + XnUInt32 nRegister; + XnUInt32 nValue; + XnUInt32 nMask; +} XnAHBData; + #pragma pack (pop) diff --git a/LGPL.txt b/LGPL.txt index b14ca0a..65c5ca8 100644 --- a/LGPL.txt +++ b/LGPL.txt @@ -1,165 +1,165 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/OpenNI/Data/SamplesConfig.xml b/OpenNI/Data/SamplesConfig.xml new file mode 100644 index 0000000..331a413 --- /dev/null +++ b/OpenNI/Data/SamplesConfig.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PSCommon/Platform/Win32/CreateRedist/CopyToRepository.py b/PSCommon/Platform/Win32/CreateRedist/CopyToRepository.py new file mode 100644 index 0000000..2c39d0d --- /dev/null +++ b/PSCommon/Platform/Win32/CreateRedist/CopyToRepository.py @@ -0,0 +1,78 @@ +import os +import sys +import re +import time +import traceback + +packageFullPath = "..\..\..\..\..\PrimeSenseVersions.nsh" + +def find_package_number(findStr, text): + for line in text: + temp = re.search(findStr, line) + if temp != None: + packageNumber = temp.group(1) + return packageNumber + +def copy_files_to_repository(SourcePath,RepositoryPath, BuildDate, PackageVersion, Bits, ProjectName, + Major_version, Minor_version, Maintenance_version, Build_version): + fullVersion = Major_version + "." + Minor_version + "." + Maintenance_version + "." + Build_version + destPath = os.path.join(RepositoryPath, BuildDate + "__" + PackageVersion, "Win" + Bits, + ProjectName + "-" + fullVersion) + os.system("rmdir /S /q " + destPath) + os.system("mkdir " + destPath) + os.system("xcopy /E /I " + SourcePath + " " + destPath) + +def copy_zip_to_repository(SourcePath,RepositoryPath, BuildDate, PackageVersion, Bits, ProjectName, + Major_version, Minor_version, Maintenance_version, Build_version): + fullVersion = Major_version + "." + Minor_version + "." + Maintenance_version + "." + Build_version + destPath = os.path.join(RepositoryPath, BuildDate + "__" + PackageVersion, "Win" + Bits, + ProjectName + "-" + fullVersion) + os.system("rmdir /S /q " + destPath) + os.system("mkdir " + destPath) + os.system("xcopy /I " + SourcePath + " " + destPath) + +def open_package_file(path): + files = open(path).readlines() + packageNumber = find_package_number("!define PACKAGE_VER\s+\"(\S+)\"", files) + return packageNumber + +if __name__ == "__main__": + try: + if len(sys.argv) != 10: + print (("Usage: copyToRepository.py " \ + + " ")) + sys.exit(1) + + finalPath = sys.argv[1] + repositoryPath = sys.argv[2] + buildDate = sys.argv[3] + bits = sys.argv[4] + projectName = sys.argv[5] + major_version = sys.argv[6] + minor_version = sys.argv[7] + maintenance_version = sys.argv[8] + build_version = sys.argv[9] + + packageNumber = '' + if not(os.path.exists(packageFullPath)): + # Redist of OpenNI openSource + packageFullPath = "..\..\..\..\..\..\PrimeSenseVersions.nsh" + packageNumber = open_package_file(packageFullPath) + if packageNumber == '': + sys.exit(1) + copy_zip_to_repository("..\..\..\..\*.zip",repositoryPath, buildDate, packageNumber, bits, + projectName, major_version, minor_version, maintenance_version, build_version) + else: + # Redist of OpenNI + packageNumber = open_package_file(packageFullPath) + if packageNumber == '': + sys.exit(1) + copy_files_to_repository(finalPath,repositoryPath, buildDate, packageNumber, bits, + projectName, major_version, minor_version, maintenance_version, build_version) + + sys.exit(0) + except SystemExit as e: + sys.exit(e) + except: + print ((traceback.print_exc())) + sys.exit(1) diff --git a/PSCommon/Platform/Win32/CreateRedist/__init__.py b/PSCommon/Platform/Win32/CreateRedist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/PSCommon/Platform/Win32/CreateRedist/redist_base.py b/PSCommon/Platform/Win32/CreateRedist/redist_base.py new file mode 100644 index 0000000..f83c32c --- /dev/null +++ b/PSCommon/Platform/Win32/CreateRedist/redist_base.py @@ -0,0 +1,905 @@ +#/**************************************************************************** +#* THIS file should be DUPLICATED IN BOTH * +#* Engine\Platform\Win32\CreateRedist * +#* AND OpenNI\Platform\Win32\CreateRedist * +#* * +#****************************************************************************/ + +#/**************************************************************************** +#* * +#* PrimeSense OpenNI & Sensor * +#* Copyright (C) 2010 PrimeSense Ltd. * +#* * +#* This file is part of PrimeSense Common. * +#* * +#* PrimeSense OpenNI & Sensor are free software: you can redistribute * +#* it and/or modify * +#* it under the terms of the GNU Lesser General Public License as published * +#* by the Free Software Foundation, either version 3 of the License, or * +#* (at your option) any later version. * +#* * +#* PrimeSense OpenNI & Sensor are distributed in the hope that they will * +#* be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Lesser General Public License for more details. * +#* * +#* You should have received a copy of the GNU Lesser General Public License * +#* along with PrimeSense OpenNI & Sensor. * +#* If not, see . * +#* * +#****************************************************************************/ + +#-------------Imports----------------------------------------------------------# +from xml.dom.minidom import parse, parseString +import win32con,pywintypes,win32api +from time import strftime +import logging +import glob +import os +import re +import sys +import subprocess +import shutil +import stat +import threading + +#-------------Functions--------------------------------------------------------# + +def is_64_bit_platform(): + result = False + import platform + (bits,linkage) = platform.architecture() + matchObject = re.search('64',bits) + result = matchObject is not None + return result + +def write_dependencides(sln_file, all_samples,sample): + sln_file.write("\tProjectSection(ProjectDependencies) = postProject\n") + for depend in sample.dependencies: + sln_file.write("\t\t" + all_samples[depend].project_guid + " = " + all_samples[depend].project_guid + "\n") + sln_file.write("\tEndProjectSection\n") + +def remove_readonly(path): + for root, dirs, files in os.walk(path): + for fname in files: + full_path = os.path.join(root, fname) + os.chmod(full_path ,stat.S_IWRITE) + +def regx_replace(findStr,repStr,filePath): + "replaces all findStr by repStr in file filePath using regualr expression" + findStrRegx = re.compile(findStr) + tempName=filePath+'~~~' + input = open(filePath) + output = open(tempName,'w') + for s in input: + output.write(findStrRegx.sub(repStr,s)) + output.close() + input.close() + os.remove(filePath) + os.rename(tempName,filePath) + +def get_reg_values(reg_key, value_list): + # open the reg key + try: + reg_key = win32api.RegOpenKeyEx(*reg_key) + except pywintypes.error as e: + raise Exception("Failed to open registry key!") + # Get the values + try: + values = [(win32api.RegQueryValueEx(reg_key, name), data_type) for name, data_type in value_list] + # values list of ((value, type), expected_type) + for (value, data_type), expected in values: + if data_type != expected: + raise Exception("Bad registry value type! Expected %d, got %d instead." % (expected, data_type)) + # values okay, leave only values + values = [value for ((value, data_type), expected) in values] + except pywintypes.error as e: + raise Exception("Failed to get registry value!") + finally: + try: + win32api.RegCloseKey(reg_key) + except pywintypes.error as e: + # We don't care if reg key close failed... + pass + return tuple(values) + +#-------------Classes----------------------------------------------------------# +class SampleData(object): + def __init__(self): + self.name = '' + self.project_dir = '' + self.source_dir = '' + self.project_guid = '' + self.project_file = '' + self.is_net = False + self.is_other = False + self.project_name = '' + self.redist_dir = '' + self.dependencies = [] + + def print_(): + print((self.name)) + + def __str__(self): + return self.name + + def __eval__(self): + return self.name + +class RedistBase(object): + def __init__(self): + self.SCRIPT_DIR = '' + self.VC_version = 0 + self.vc_build_bits = "" + self.output_dir = "" + self.final_dir = "" + self.config_xml_filename = "" + self.redist_name = "" + self.redist_internal_name = '' + self.product_name = '' + self.doxy_file_name = "" + self.write_2010_sample_dependency = False + self.all_samples = None + self.internal_conf_name = '' + self.TIMEOUT_UPGRADE_VS10_SEC = 180 + self.project_is_2010 = False + + def finish_script(self,exit_code): + os.chdir(self.SCRIPT_DIR) + #logging.shutdown() + exit(exit_code) + + def check_args(self,args): + """ + Parse cmdline args; along them are doxy,bitness,VC. + """ + if len(sys.argv) not in [4,5]: + print ("Args: []") + exit(1) + if sys.argv[1] == 'y' or sys.argv[1] == 'Yes': + self.Make_Doxy=1 + elif sys.argv[1] == 'n' or sys.argv[1] == 'No': + self.Make_Doxy=0 + else: + print("Args: ") + print("Doxygen param must be y or n!") + exit(1) + + if sys.argv[2] == '32': + self.vc_build_bits = "32" + elif sys.argv[2] == '64': + self.vc_build_bits = "64" + else: + print("Args: ") + print("BuildTarget param must be 32 or 64!") + exit(1) + + if sys.argv[3] == 'y' or sys.argv[3] == 'Yes': + self.vc_build_type = "/Rebuild" + elif sys.argv[3] == 'n' or sys.argv[3] == 'No': + self.vc_build_type = "/Build" + else: + print("Args: ") + print("FullRebuild param must be y or n!") + exit(1) + + if self.project_is_2010: + self.VC_version = 10 + if len(sys.argv) > 4: + if sys.argv[4] == '9': + print("Project does not support VS2008!") + exit(1) + else: + self.VC_version = 9 + if len(sys.argv) > 4: + if sys.argv[4] == '10': + self.VC_version = 10 + + def init_vs_vars(self): + """ + Checks for the availablity of Visual Studio to compile with. + Currently supports VS2008 (vc9) and VS2010(vc10). + If 64-bit platform, registry key under Software/Wow6432Node/... + """ + self.VS_NEED_UPGRADE = 0 + try: + if self.is_64_bit_platform: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0") + else: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\9.0") + MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] + self.VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] + except Exception as e: + self.VC_version = 10 + + if self.VC_version == 10: + if not self.project_is_2010: + self.VS_NEED_UPGRADE = 1 + + if self.is_64_bit_platform: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0") + else: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\10.0") + MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] + self.VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] + + def init_vars(self): + """ + Initializae misc variables. + Among them: is_64_bit_platform + """ + self.inst_proj_path = 'Platform\\Win32\\Install\\%s\\'%self.redist_internal_name + self.is_64_bit_platform = is_64_bit_platform() + self.DateTimeSTR = strftime("%Y-%m-%d %H:%M:%S") + DateSTR = strftime("%Y-%m-%d") + CONFIG_XML = parse(self.config_xml_filename) + self.WORK_DIR = str(CONFIG_XML.getElementsByTagName("WORK_DIR")[0].firstChild.data) + # Fix to allow reletive path + os.chdir(self.WORK_DIR) + self.WORK_DIR = os.getcwd() + "\\" + os.chdir(self.SCRIPT_DIR) + self.VER = str(CONFIG_XML.getElementsByTagName("VERSION_NUMBER")[0].firstChild.data) + PLATFORM = str(CONFIG_XML.getElementsByTagName("PLATFORM")[0].firstChild.data) + self.PROJECT_SLN = str(CONFIG_XML.getElementsByTagName("PROJECT_SLN")[0].firstChild.data) + self.SAMPLES_SLN = str(CONFIG_XML.getElementsByTagName("SAMPLES_SLN")[0].firstChild.data) + self.PROJECT_NAME = str(CONFIG_XML.getElementsByTagName("PROJECT")[0].firstChild.data) + self.BUILD_DIR = os.path.join(self.WORK_DIR, "Platform", "Win32", "Build") + + ver_regx = re.compile("SDK \d.*\s") + global samples_proj_list + global samples_guid_list + global samples_guid_list_net + samples_proj_list = [] + samples_guid_list = [] + samples_guid_list_net = [] + + if self.vc_build_bits=="32": + self.bin_dir = "Bin" + self.lib_dir = "Lib" + self.vc_build_platform = "Win32" + self.output_dir = "Output32" + self.final_dir = "Final32" + else: + self.bin_dir = "Bin64" + self.lib_dir = "Lib64" + self.vc_build_platform = "x64" + self.output_dir = "Output64" + self.final_dir = "Final64" + + def init_logger(self,name): + """ + Initilizes the logger. + """ + #-------------Log--------------------------------------------------------------# + out_path = os.path.join(self.SCRIPT_DIR,self.output_dir) + if not(os.path.exists(out_path)): + os.mkdir(out_path) + self.logger = logging.getLogger(name) + hdlr = logging.FileHandler(os.path.join(self.output_dir, '%s_redist_maker.log'%name)) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + hdlr.setFormatter(formatter) + self.logger.addHandler(hdlr) + self.logger.setLevel(logging.INFO) + + def print_message(self): + """ + TO DO: fix that function in Redist_OpenNi to resemble this (better) version. + """ + #------------Welcome Messege--------=------------------------------------------# + print("\n"); + print("*********************************") + print(("* PrimeSense " + self.redist_name + " Redist *")) + print(("* " + self.DateTimeSTR + " *")) + print("*********************************") + + def build_proj_solution(self): + #--------------Build Project---------------------------------------------------# + print(("* Building " + self.PROJECT_NAME + "...")) + path2output = os.path.join(self.SCRIPT_DIR,self.output_dir) + if not os.path.exists(path2output): + os.makedirs(path2output) + path2final = os.path.join(self.SCRIPT_DIR,self.final_dir) + if not os.path.exists(path2final): + os.makedirs(path2final) + + self.logger.info(("Building " + self.PROJECT_NAME + "...")) + # Set Intel Env + os.system("set INTEL_LICENSE_FILE=C:\\Program Files\\Common Files\\Intel\\Licenses") + # Build project solution + os.chdir(self.WORK_DIR + self.PROJECT_SLN.rpartition("\\")[0]) + print((os.getcwd())) + + out_file = os.path.join(self.SCRIPT_DIR, self.output_dir, "Build"+self.PROJECT_NAME+".txt") + upg_out_file = os.path.join(self.SCRIPT_DIR, self.output_dir, "Build"+self.PROJECT_NAME+"UPG"+".txt") + if self.VS_NEED_UPGRADE == 1: + os.system("attrib -r * /s") + devenv_upg_cmd_str = "\""+self.VS_INST_DIR + "devenv\" " + self.PROJECT_SLN.rpartition("\\")[2]+\ + " /upgrade > " + upg_out_file + print(('upgrading. out put in %s'%out_file)) + print(('command is %s'%devenv_upg_cmd_str)) + my_rc = os.system(devenv_upg_cmd_str) + print(('upgrading finished w result %d'%my_rc)) + #devenv_upg_cmd = Command(devenv_upg_cmd_str) + #devenv_upg_cmd.run(self.TIMEOUT_UPGRADE_VS10_SEC) + + devenv_cmd = '\"'+self.VS_INST_DIR + 'devenv\" ' + self.PROJECT_SLN.rpartition("\\")[2]+\ + " " + self.vc_build_type + " \"release|" + self.vc_build_platform + "\" /out " + \ + out_file + self.logger.debug('Calling vs : %s'%devenv_cmd) + rc = subprocess.call(devenv_cmd, close_fds=True) + self.logger.debug('Calling vs, RC: %d'%rc) + # Get the build output + lines = open(out_file).readlines() + build_result = lines[-2] + print(build_result) + self.logger.info(build_result) + # Check for failed build + failed_builds = 0 + fail_to_open = 0 + + temp = re.search("(\d*) failed",build_result) + if temp != None : + failed_builds = int(temp.group(1)) + + temp2 = re.search('cannot be opened',str(lines)) + if temp2 != None : + fail_to_open = 1 + + if failed_builds != 0 or fail_to_open !=0: + print("Building Failed!!") + self.logger.critical("Building Failed!") + self.finish_script(1) + + # return to work dir + os.chdir(self.WORK_DIR) + + def make_doxy(self): + """ + Make Doxy. + """ + if self.Make_Doxy==1: + print("* Creating Doxygen...") + self.logger.info("Creating Doxygen...") + os.chdir(os.path.join(self.WORK_DIR,"Source\\Doxygen")); + # Replacing version number in the doxygen setup file + res = os.system("attrib -r " + self.doxy_file_name) + print(('removing readonly attribute for Doxyfile: ' + str(res))) + regx_replace(self.redist_name + " \d*.\d*.\d*\s",self.PROJECT_NAME +" " + self.VER + " ",self.doxy_file_name) + if os.path.exists(self.WORK_DIR + "\\Source\\Doxygen\\html\\"): + os.system("rmdir /S /Q html") + # Running doxygen + os.system("mkdir html > null") + #os.system("copy PSSmallLogo.jpg html > null") // where is this file ? + doxy_out_file = os.path.join(self.SCRIPT_DIR,self.output_dir,self.PROJECT_NAME + "Doxy.txt") + doxygen_cmd = "doxygen.exe %s > " % (self.doxy_file_name) + doxy_out_file + os.system(doxygen_cmd) + self.copy_doxy_files() + os.chdir(self.WORK_DIR) + else: + print("Skipping Doxygen...") + + def create_redist_dir(self): + """ + Creates directory structure for Redist. + """ + #-------------Create Redist Dir------------------------------------------------# + print("* Creating Redist Dir...") + self.logger.info("Creating Redist Dir...") + os.chdir(os.path.join(self.WORK_DIR,"Platform","Win32")) + # Removing the old directory + os.system("rmdir /S /Q Redist") + # Creating new directory tree + os.system("mkdir Redist") + os.system("mkdir Redist\\" + self.bin_dir) + os.system("mkdir Redist\\" + self.lib_dir) + os.system("mkdir Redist\\Include") + os.system("mkdir Redist\\Documentation") + os.system("mkdir Redist\\Samples") + os.system("mkdir Redist\\Samples\\" + self.bin_dir) + os.system("mkdir Redist\\Samples\\" + self.bin_dir + "\\Debug") + os.system("mkdir Redist\\Samples\\" + self.bin_dir + "\\Release") + os.system("mkdir Redist\\Samples\\Build") + os.system("mkdir Redist\\Samples\\Res") + os.system("mkdir Redist\\Data") + os.chdir(self.WORK_DIR) + + def find_samples(self): + # returns a dictionary of all samples + all_samples = dict() + os.chdir(self.WORK_DIR) + samples_list = os.listdir(os.path.join(self.BUILD_DIR,"Samples")) + if '.svn' in samples_list: + samples_list.remove('.svn') + for sample in samples_list: + sample_data = SampleData() + sample_data.name = sample + sample_data.source_dir = os.path.join(self.WORK_DIR, "Samples", sample) + sample_data.project_dir = os.path.join(self.BUILD_DIR, "Samples", sample) + sample_data.is_other = False; + + vc_proj_name = sample_data.project_dir + "\\" + sample + ".vcproj" + cs_proj_name = sample_data.project_dir + "\\" + sample + ".csproj" + vcx_proj_name = sample_data.project_dir + "\\" + sample + ".vcxproj" + other_proj_name = os.path.join(sample_data.project_dir, "Build.bat") + + # check if this is a VC project + if os.path.exists(vc_proj_name): + sample_data.project_file = vc_proj_name + + # open it + prj = open(vc_proj_name, 'r') + lines = prj.readlines() + for line in lines: + # Search for name + if sample_data.project_name == "": + ProjNametmp = re.search(r"Name=\"(.*)\"",line) + if (ProjNametmp != None): + sample_data.project_name = ProjNametmp.group(1) + + # Search for GUID + if sample_data.project_guid == "": + ProjGUIDtmp = re.search(r"ProjectGUID=\"(.*)\"",line) + if (ProjGUIDtmp != None): + sample_data.project_guid = ProjGUIDtmp.group(1) + + prj.close() + + elif os.path.exists(vcx_proj_name): + # a VC project for VS 2010 + sample_data.project_file = vcx_proj_name + sample_data.project_name = sample + + # open it + prj = open(vcx_proj_name, 'r') + lines = prj.readlines() + for line in lines: + # Search for name + if sample_data.project_name == "": + ProjNametmp = re.search(r"Name=\"(.*)\"",line) + if (ProjNametmp != None): + sample_data.project_name = ProjNametmp.group(1) + + # Search for GUID + if sample_data.project_guid == "": + ProjGUIDtmp = re.search(r"(.*)", line) + if (ProjGUIDtmp != None): + sample_data.project_guid = ProjGUIDtmp.group(1) + + prj.close() + + elif os.path.exists(cs_proj_name): + # a .NET project + sample_data.project_file = cs_proj_name + sample_data.is_net = True + + # open it + prj = open(cs_proj_name, 'r') + lines = prj.readlines() + for line in lines: + # Search for name + if sample_data.project_name == "": + ProjNametmp = re.search(r"(.*)",line) + if (ProjNametmp != None): + sample_data.project_name = ProjNametmp.group(1) + + # Search for GUID + if sample_data.project_guid == "": + ProjGUIDtmp = re.search(r"(.*)",line) + if (ProjGUIDtmp != None): + sample_data.project_guid = ProjGUIDtmp.group(1) + + prj.close() + + elif os.path.exists(other_proj_name): + # some other type of project (java?) + sample_data.project_file = other_proj_name + sample_data.is_other = True + sample_data.project_name = sample + + else: + print(('Sample ' + sample + ' does not have a valid project file')) + self.finish_script(1) + + # check if it has a special configuration + redist_file_name = sample_data.source_dir + "\\.redist" + if os.path.exists(redist_file_name): + redist_file = open(redist_file_name, 'r') + + for line in redist_file.readlines(): + # seach for dependencies + match = re.search("^DEPENDS=(.*)$", line) + if match != None: + sample_data.dependencies.append(match.group(1)) + + redist_file.close() + + sample_data.redist_dir = "Redist\\Samples\\" + sample_data.name + all_samples[sample_data.name] = sample_data + + return all_samples + + def get_samples(self): + # returns a dictionary of all samples + if self.all_samples == None: + self.all_samples = self.find_samples() + + return self.all_samples + + def build_other_proj(self, build_dir): + # build other (not Visual Studio) project + ret = subprocess.call(os.path.join(build_dir, "Build.bat") + " " + self.vc_build_bits) + if ret != 0: + print(("Building project " + build_dir + " failed!")) + self.logger.critical("Building project " + build_dir + " failed!") + self.finish_script(1) + + def build_other_samples(self): + "Builds other samples (java?)" + all_samples = self.get_samples() + for sample in list(all_samples.values()): + if not sample.is_other: + continue + build_dir = os.path.join(self.BUILD_DIR, "Samples", sample.name) + self.build_other_proj(build_dir) + + def creating_samples(self): + """ + not exactly the same some further work needed. + """ + #-------Creating samples-------------------------------------------------------# + print("* Creating samples...") + self.logger.info("Creating samples...") + + all_samples = self.get_samples() + + os.chdir(os.path.join(self.WORK_DIR, "Platform", "Win32")) + + # open all solution files + if not self.project_is_2010: + OUTFILESLN2008 = open("Redist\\Samples\\Build\\All_2008.sln",'w') + OUTFILESLN2008.write("Microsoft Visual Studio Solution File, Format Version 10.00\n") + OUTFILESLN2008.write("# Visual Studio 2008\n") + + if not self.project_is_2010: + OUTFILESLN2010 = open("Redist\\Samples\\Build\\All_2010.sln",'w') + else: + OUTFILESLN2010 = open("Redist\\Samples\\Build\\All.sln",'w') + + OUTFILESLN2010.write("Microsoft Visual Studio Solution File, Format Version 11.00\n") + OUTFILESLN2010.write("# Visual Studio 2010\n") + + # copy java build script + try: + shutil.copy(os.path.join("Build", "BuildJava.py"), os.path.join("Redist", "Samples", "Build")) + except: + pass + + # add projects + for sample in list(all_samples.values()): + # make dir + os.system ("mkdir " + sample.redist_dir) + # copy source + os.system ("xcopy /S " + sample.source_dir + " " + sample.redist_dir) + + if sample.is_other: + shutil.copy(sample.project_file, sample.redist_dir) + else: + # copy the project file to 2008 and 2010: + prj_name_partitioned = os.path.splitext(sample.project_file); + prj2008_filename = sample.redist_dir + "\\" + sample.name + "_2008" + prj_name_partitioned[1] + + if self.project_is_2010: + prj2010_filename = sample.redist_dir + "\\" + sample.name + prj_name_partitioned[1] + else: + prj2010_filename = sample.redist_dir + "\\" + sample.name + "_2010" + prj_name_partitioned[1] + + if not self.project_is_2010: + shutil.copy(sample.project_file, prj2008_filename) + shutil.copy(sample.project_file, prj2010_filename) + + # create reletive path to samples + prj2008_path = "..\\" + prj2008_filename.partition("\\")[2].partition("\\")[2] + prj2010_path = "..\\" + prj2010_filename.partition("\\")[2].partition("\\")[2] + + # add project to solution + if not self.project_is_2010: + OUTFILESLN2008.write("Project(\"{19091980-2008-4CFA-1491-04CC20D8BCF9}\") = \""+\ + sample.project_name + "\", \"" + prj2008_path + "\", \"" + sample.project_guid + "\"\n") + OUTFILESLN2010.write("Project(\"{19091980-2008-4CFA-1491-04CC20D8BCF9}\") = \""+\ + sample.project_name + "\", \"" + prj2010_path + "\", \"" + sample.project_guid + "\"\n") + + # write down dependencies + if len(sample.dependencies) > 0: + if not self.project_is_2010: + OUTFILESLN2008.write("\tProjectSection(ProjectDependencies) = postProject\n") + for depend in sample.dependencies: + OUTFILESLN2008.write("\t\t" + all_samples[depend].project_guid + " = " + all_samples[depend].project_guid + "\n") + OUTFILESLN2008.write("\tEndProjectSection\n") + if self.write_2010_sample_dependency == True: + write_dependencides(OUTFILESLN2010,all_samples,sample) + + if not self.project_is_2010: + OUTFILESLN2008.write("EndProject\n") + OUTFILESLN2010.write("EndProject\n") + + # Close files + if not self.project_is_2010: + OUTFILESLN2008.write("Global\n") + OUTFILESLN2008.write(" GlobalSection(SolutionConfigurationPlatforms) = preSolution\n") + OUTFILESLN2008.write(" Debug|Win32 = Debug|Win32\n") + OUTFILESLN2008.write(" Debug|x64 = Debug|x64\n") + OUTFILESLN2008.write(" Release|Win32 = Release|Win32\n") + OUTFILESLN2008.write(" Release|x64 = Release|x64\n") + OUTFILESLN2008.write(" EndGlobalSection\n") + OUTFILESLN2008.write(" GlobalSection(ProjectConfigurationPlatforms) = postSolution\n") + OUTFILESLN2010.write("Global\n") + OUTFILESLN2010.write(" GlobalSection(SolutionConfigurationPlatforms) = preSolution\n") + OUTFILESLN2010.write(" Debug|Win32 = Debug|Win32\n") + OUTFILESLN2010.write(" Debug|x64 = Debug|x64\n") + OUTFILESLN2010.write(" Release|Win32 = Release|Win32\n") + OUTFILESLN2010.write(" Release|x64 = Release|x64\n") + OUTFILESLN2010.write(" EndGlobalSection\n") + OUTFILESLN2010.write(" GlobalSection(ProjectConfigurationPlatforms) = postSolution\n") + + for sample in list(all_samples.values()): + conf_32_name = "Win32" + if sample.is_net: + conf_32_name = "x86" + + if not self.project_is_2010: + OUTFILESLN2008.write(" " + sample.project_guid + ".Debug|Win32.ActiveCfg = Debug|" + conf_32_name + "\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Debug|Win32.Build.0 = Debug|" + conf_32_name + "\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Debug|x64.ActiveCfg = Debug|x64\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Debug|x64.Build.0 = Debug|x64\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Release|Win32.ActiveCfg = Release|" + conf_32_name + "\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Release|Win32.Build.0 = Release|" + conf_32_name + "\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Release|x64.ActiveCfg = Release|x64\n") + OUTFILESLN2008.write(" " + sample.project_guid + ".Release|x64.Build.0 = Release|x64\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Debug|Win32.ActiveCfg = Debug|" + conf_32_name + "\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Debug|Win32.Build.0 = Debug|" + conf_32_name + "\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Debug|x64.ActiveCfg = Debug|x64\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Debug|x64.Build.0 = Debug|x64\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Release|Win32.ActiveCfg = Release|" + conf_32_name + "\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Release|Win32.Build.0 = Release|" + conf_32_name + "\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Release|x64.ActiveCfg = Release|x64\n") + OUTFILESLN2010.write(" " + sample.project_guid + ".Release|x64.Build.0 = Release|x64\n") + + if not self.project_is_2010: + OUTFILESLN2008.write(" EndGlobalSection\n") + OUTFILESLN2008.write(" GlobalSection(SolutionProperties) = preSolution\n") + OUTFILESLN2008.write(" HideSolutionNode = FALSE\n") + OUTFILESLN2008.write(" EndGlobalSection\n") + OUTFILESLN2008.write("EndGlobal \n") + OUTFILESLN2010.write(" EndGlobalSection\n") + OUTFILESLN2010.write(" GlobalSection(SolutionProperties) = preSolution\n") + OUTFILESLN2010.write(" HideSolutionNode = FALSE\n") + OUTFILESLN2010.write(" EndGlobalSection\n") + OUTFILESLN2010.write("EndGlobal \n") + + if not self.project_is_2010: + OUTFILESLN2008.close() + OUTFILESLN2010.close() + + os.chdir(self.WORK_DIR) + + def remove_read_only_attributes(self): + #-----Remove Read Only Attrib--------------------------------------------------# + print("* Removing Read Only Attributes...") + full_path = os.path.join(self.WORK_DIR,"Platform", "Win32" , "Redist") + self.logger.info("Removing Read Only Attributes... (%s)" % (full_path)) + #os.system ("attrib -r -h -s /S Redist\\*.*") + remove_readonly(full_path) + + def make_installer(self,msi_dest_path): + """ + [dev_success,redist_success] + """ + wix_var_file = '%sVariables.wxi'%self.redist_internal_name.replace('_','') + + [dev_success,redist_success] = [False,False] + print("* Making Installer...") + self.logger.info("Making Installer...") + self.wix_inst_primitive_check() + os.chdir(os.path.join(self.WORK_DIR,self.inst_proj_path)) + # Replace version in the WIX + self.wix_dev_var_set() + self.check_upgrade_install_sln() + print("calling WIX") + conf_name = self.internal_conf_name + dev_success = self.build_installer(conf_name) + print(("moving %s Msi"%conf_name)) + src = ('.\\bin\Release\en-US\\%s.msi'%self.redist_internal_name) + dst = os.path.join( msi_dest_path ,self.final_dir,(self.product_name + '-Win' + self.vc_build_bits + "-" + self.VER + '-%s.msi'%conf_name)) + os.system(("move %s %s"%(src,dst))) + self.dev_to_redist_hack() + self.wix_redist_var_set() + print("calling WIX") + conf_name = 'Redist' + redist_success = self.build_installer(conf_name) + print(("moving %s Msi"%conf_name)) + os.system("move .\\bin\Release\en-US\\%s.msi %s"%(self.redist_internal_name,\ + os.path.join( msi_dest_path ,self.final_dir,self.product_name + '-Win' + self.vc_build_bits + "-" + self.VER + '-%s.msi'%conf_name))) + + os.chdir(self.WORK_DIR) + return [dev_success,redist_success] + + def build_installer(self,conf_name): + success = False + wix_log = 'Build%sWIX%s'%(self.redist_internal_name,conf_name) + wix_log.replace('_','') #because outside code expects EENI in the name instead of EE_NI + out_file = os.path.join('..\\..\\CreateRedist',self.output_dir,"%s.txt"%wix_log) + wix_rc = subprocess.call("\"" + self.VS_INST_DIR \ + + "devenv\" %s.wixproj /Build \"release|%s"%(self.redist_internal_name, 'x86' if self.vc_build_bits=='32' else 'x64') \ + + "\" /out " + out_file, close_fds=True) + failed_builds = self.check_vs_report_failed(out_file) + if failed_builds > 0 or wix_rc != 0: + self.logger.info('Fail to build installer for %s version'%conf_name) + else: + success = True + return success + + def wix_redist_var_set(self): + """preconsdition: CWD is where wix-variables-file is stored""" + temp = self.redist_internal_name.replace('_','') + os.system("attrib -r Includes\\%sVariables.wxi"%temp) + #print("setting WIX BuildPlatform") + #regx_replace("BuildPlatform=(.*)", "BuildPlatform=" + str(vc_build_bits) + "?>", "Includes\\OpenNIVariables.wxi") + print("setting WIX BinaryOnlyRedist=True") + regx_replace("BinaryOnlyRedist=(.*)", "BinaryOnlyRedist=True?>", "Includes\\%sVariables.wxi"%temp) + + def wix_dev_var_set(self): + """preconsdition: CWD is where wix-variables-file is stored""" + print("setting WIX BinaryOnlyRedist=False") + temp = self.redist_internal_name.replace('_','') + os.system("attrib -r Includes\\%sVariables.wxi"%temp) + regx_replace("BinaryOnlyRedist=(.*)", "BinaryOnlyRedist=False?>", "Includes\\%sVariables.wxi"%temp) + + def check_upgrade_install_sln(self): + """preconsdition: CWD is where wix-variables-file is stored""" + up_wix_file = os.path.join('..\\..\\CreateRedist',self.output_dir,"Upgrade%sWIX.txt"%(self.redist_internal_name)) + if self.VS_NEED_UPGRADE == 1: + subprocess.call("\"" + self.VS_INST_DIR + \ + "devenv\" %s.sln /upgrade /out "%(self.redist_internal_name) + up_wix_file, close_fds=True) + + def wix_inst_primitive_check(self): + wixPath = os.environ.get('WIX') + if wixPath == None: + print('*** no WIX env. var. defined ! use set WIX=C:\Program Files\Windows Installer XML v3.5\ or similar to set the path ***') + print('make installer is SERIOUSLY expected to fail') + self.logger.info('It seems that WIX is not installed and therefore teh installer cannot be built.') + else: + print(('WIX='+wixPath)) + + def dev_to_redist_hack(self): + pass + + def check_vs_report_failed(self,file): + lines = open(file).readlines() + build_result = lines[-2] + failed_builds = 0 + temp = re.search("(\d*) failed",build_result) + if temp != None : + failed_builds = int(temp.group(1)) + return failed_builds + + def fixing_files(self): + """ + fixing files + """ + #--------Fixing Files----------------------------------------------------------# + print("* Fixing Files...") + self.logger.info("Fixing Files...") + for dirpath, dirnames, filenames in os.walk(os.path.join(self.WORK_DIR, "Platform", "Win32", "Redist")): + self.fix_file('', dirpath, dirnames + filenames) + + def build_samples(self): + """ + Build Samples. + """ + #-------------Build Samples---------------------------------------------------# + print("* Building Samples in release configuration......") + self.logger.info("Building Samples in release configuration...") + # Build project solution + os.chdir(self.WORK_DIR + self.SAMPLES_SLN.rpartition("\\")[0]) + + output_file = os.path.join(self.SCRIPT_DIR ,self.output_dir ,self.PROJECT_NAME + "SmpRelease.txt") + + if self.VS_NEED_UPGRADE == 1: + os.system("\""+self.VS_INST_DIR + "devenv\" " +self.SAMPLES_SLN.rpartition("\\")[2]+\ + " /upgrade > " + output_file) + + subprocess.call("\""+self.VS_INST_DIR + "devenv\" " +self.SAMPLES_SLN.rpartition("\\")[2]+\ + " " + self.vc_build_type + " \"release|" + self.vc_build_platform + "\" /out " + output_file) + + # Get the build output + lines = open(output_file).readlines() + build_result = lines[-2] + print(build_result) + self.logger.info(build_result) + # Check for failed build + + failed_builds = 0 + temp = re.search("(\d*) failed",build_result) + + if temp != None : + failed_builds = int(temp.group(1)) + if failed_builds != 0: + print("Samples Building In Release Failed!!") + self.logger.critical("Samples Building Failed!") + self.finish_script(1) + + print("* Building Samples in debug configuration......") + self.logger.info("Building Samples in debug configuration...") + # Build project solution + os.chdir(self.WORK_DIR +self.SAMPLES_SLN.rpartition("\\")[0]) + + output_file = os.path.join(self.SCRIPT_DIR ,self.output_dir ,self.PROJECT_NAME + "SmpDebug.txt") + + if self.VS_NEED_UPGRADE == 1: + os.system("\""+self.VS_INST_DIR + "devenv\" " +self.SAMPLES_SLN.rpartition("\\")[2]+\ + " /upgrade > " + output_file) + + subprocess.call("\""+self.VS_INST_DIR + "devenv\" " +self.SAMPLES_SLN.rpartition("\\")[2]+\ + " " + self.vc_build_type + " \"debug|" + self.vc_build_platform + "\" /out " + output_file) + + # Get the build output + lines = open(output_file).readlines() + build_result = lines[-2] + print(build_result) + self.logger.info(build_result) + # Check for failed build + + failed_builds = 0 + tempReResult = re.search("(\d*) failed",build_result) + + if tempReResult != None : + failed_builds = int(tempReResult.group(1)) + if failed_builds != 0: + print("Samples Building In Debug Failed!!") + self.logger.critical("Samples Building Failed!") + self.finish_script(1) + + # Build other samples + all_samples = self.get_samples() + for sample in list(all_samples.values()): + if sample.is_other: + self.build_other_proj(os.path.join(self.WORK_DIR, "Platform", "Win32", "Redist", "Samples", sample.name)) + + # --------------------Delete stuff + os.chdir(self.WORK_DIR + "\\Platform\\Win32\\Redist\\Samples\\" + self.bin_dir +"\\Release\\") + os.system("del *.pdb") + os.chdir(self.WORK_DIR + "\\Platform\\Win32\\Redist\\Samples\\" + self.bin_dir +"\\Debug\\") + os.system("del *.pdb") + os.system("del *.ilk") + os.chdir(self.WORK_DIR + "\\Platform\\Win32\\Redist\\" + self.lib_dir + "\\") + os.system("del nim*.*") + + os.chdir(self.WORK_DIR) + + def clean_up(self): + temp_str = "Redist "+ self.redist_name +" Ended." + print(temp_str) + self.logger.info(temp_str) + #self.finish_script(0) +class Command(object): + def __init__(self, cmd): + self.cmd = cmd + self.process = None + + def run(self, timeout): + def target(): + print('Thread started') + self.process = subprocess.Popen(self.cmd, shell=True) + self.process.communicate() + print('Thread finished') + + thread = threading.Thread(target=target) + thread.start() + + thread.join(timeout) + if thread.is_alive(): + print('Terminating process') + self.process.terminate() + thread.join() + print((self.process.returncode)) diff --git a/PSCommon/Platform/Win32/CreateRedist/redist_base.pyc b/PSCommon/Platform/Win32/CreateRedist/redist_base.pyc new file mode 100644 index 0000000..c533fab Binary files /dev/null and b/PSCommon/Platform/Win32/CreateRedist/redist_base.pyc differ diff --git a/Platform/Android/jni/Android.mk b/Platform/Android/jni/Android.mk new file mode 100644 index 0000000..2414b04 --- /dev/null +++ b/Platform/Android/jni/Android.mk @@ -0,0 +1,6 @@ +# OpenNI Android makefile. +# + +include $(call all-subdir-makefiles) + +$(call import-module,OpenNI) diff --git a/Platform/Android/jni/Application.mk b/Platform/Android/jni/Application.mk new file mode 100644 index 0000000..6d2da24 --- /dev/null +++ b/Platform/Android/jni/Application.mk @@ -0,0 +1,28 @@ +APP_STL := gnustl_static + +# Android >= v2.3 +APP_PLATFORM := android-9 + +# Build ARMv7-A machine code. +APP_ABI := armeabi-v7a +APP_CFLAGS := -O3 -ftree-vectorize -ffast-math -funroll-loops + +APP_CFLAGS += -fPIC + +ifeq ($(APP_ABI),armeabi-v7a) + APP_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a9 -mfp=vfpv3-d16 -mfpu=vfp + +# optionally add NEON to compilation flags. +# to activate, run: "ndk-build USE_NEON=1" +ifdef USE_NEON +$(call __ndk_info,Building everything with NEON support!) + APP_CFLAGS += -mfpu=neon -DHAVE_NEON=1 -flax-vector-conversions +endif +endif + +APP_CPPFLAGS += -frtti + +#$(call __ndk_info,APP_CFLAGS=$(APP_CFLAGS)) +#$(call __ndk_info,APP_CPPFLAGS=$(APP_CPPFLAGS)) + +#-fsingle-precision-constant diff --git a/Platform/Android/jni/XnCore/Android.mk b/Platform/Android/jni/XnCore/Android.mk new file mode 100644 index 0000000..979c53b --- /dev/null +++ b/Platform/Android/jni/XnCore/Android.mk @@ -0,0 +1,35 @@ +# XnCore Android makefile. +# libXnCore.so +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# set path to source +MY_PREFIX := $(LOCAL_PATH)/../../../../Source/XnCore/ + +# list all source files +MY_SRC_FILES := \ + $(MY_PREFIX)*.cpp + +# expand the wildcards +MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) + +# make those paths relative to here +LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../Include/ \ + $(LOCAL_PATH)/../../../../Source/ \ + +LOCAL_CFLAGS:= -fvisibility=hidden -DXN_CORE_EXPORTS + +LOCAL_LDFLAGS += -Wl,--export-dynamic --dynamic-linker + +LOCAL_SHARED_LIBRARIES := OpenNI libusb + +LOCAL_PREBUILT_LIBS := libc + +LOCAL_MODULE := XnCore + +include $(BUILD_SHARED_LIBRARY) diff --git a/Platform/Android/jni/XnDDK/Android.mk b/Platform/Android/jni/XnDDK/Android.mk new file mode 100644 index 0000000..3c5d70b --- /dev/null +++ b/Platform/Android/jni/XnDDK/Android.mk @@ -0,0 +1,37 @@ +# XnDDK Android makefile. +# libXnDDK.so +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# set path to source +MY_PREFIX := $(LOCAL_PATH)/../../../../Source/XnDDK/ + +# list all source files +MY_SRC_FILES := \ + $(MY_PREFIX)*.cpp + +# expand the wildcards +MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) + +# make those paths relative to here +LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../Include/ \ + $(LOCAL_PATH)/../../../../Source/ \ + $(LOCAL_PATH)/../../../../Source/XnCommon \ + +LOCAL_CFLAGS := -fvisibility=hidden -DXN_DDK_EXPORTS + +LOCAL_LDFLAGS += -Wl,--export-dynamic --dynamic-linker + +LOCAL_SHARED_LIBRARIES := OpenNI libusb XnCore XnFormats + +LOCAL_PREBUILT_LIBS := libc + +LOCAL_MODULE := XnDDK + +include $(BUILD_SHARED_LIBRARY) + diff --git a/Platform/Android/jni/XnDeviceFile/Android.mk b/Platform/Android/jni/XnDeviceFile/Android.mk new file mode 100644 index 0000000..9fcabe5 --- /dev/null +++ b/Platform/Android/jni/XnDeviceFile/Android.mk @@ -0,0 +1,37 @@ +# XnDeviceFile Android makefile. +# libXnDeviceFile.so +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# set path to source +MY_PREFIX := $(LOCAL_PATH)/../../../../Source/XnDeviceFile/ + +# list all source files +MY_SRC_FILES := \ + $(MY_PREFIX)*.cpp + +# expand the wildcards +MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) + +# make those paths relative to here +LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../Include/ \ + $(LOCAL_PATH)/../../../../Source/ \ + $(LOCAL_PATH)/../../../../Source/XnCommon \ + +LOCAL_CFLAGS := -fvisibility=hidden -DXN_DEVICE_EXPORTS + +LOCAL_LDFLAGS += -Wl,--export-dynamic --dynamic-linker + +LOCAL_SHARED_LIBRARIES := OpenNI libusb XnCore XnFormats XnDDK + +LOCAL_PREBUILT_LIBS := libc + +LOCAL_MODULE := XnDeviceFile + +include $(BUILD_SHARED_LIBRARY) + diff --git a/Platform/Android/jni/XnDeviceSensorV2/Android.mk b/Platform/Android/jni/XnDeviceSensorV2/Android.mk new file mode 100644 index 0000000..8df6499 --- /dev/null +++ b/Platform/Android/jni/XnDeviceSensorV2/Android.mk @@ -0,0 +1,37 @@ +# XnDeviceSensorV2 Android makefile. +# libXnDeviceSensorV2.so +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# set path to source +MY_PREFIX := $(LOCAL_PATH)/../../../../Source/XnDeviceSensorV2/ + +# list all source files +MY_SRC_FILES := \ + $(MY_PREFIX)*.cpp + +# expand the wildcards +MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) + +# make those paths relative to here +LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../Include/ \ + $(LOCAL_PATH)/../../../../Source/ \ + $(LOCAL_PATH)/../../../../Source/XnCommon \ + +LOCAL_CFLAGS := -fvisibility=hidden -DXN_DEVICE_EXPORTS + +LOCAL_LDFLAGS += -Wl,--export-dynamic --dynamic-linker + +LOCAL_SHARED_LIBRARIES := OpenNI libusb XnCore XnFormats XnDDK + +LOCAL_PREBUILT_LIBS := libc + +LOCAL_MODULE := XnDeviceSensorV2 + +include $(BUILD_SHARED_LIBRARY) + diff --git a/Platform/Android/jni/XnFormats/Android.mk b/Platform/Android/jni/XnFormats/Android.mk new file mode 100644 index 0000000..de31310 --- /dev/null +++ b/Platform/Android/jni/XnFormats/Android.mk @@ -0,0 +1,39 @@ +# XnFormats Android makefile. +# libXnFormats.so +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# set path to source +MY_PREFIX := $(LOCAL_PATH)/../../../../Source/XnFormats/ + +# list all source files +MY_SRC_FILES := \ + $(MY_PREFIX)*.cpp \ + $(MY_PREFIX)../External/LibJPEG/*.c + +# expand the wildcards +MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) + +# make those paths relative to here +LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../Include/ \ + $(LOCAL_PATH)/../../../../Source/ \ + $(LOCAL_PATH)/../../../../Source/XnCommon \ + $(LOCAL_PATH)/../../../../Source/External/LibJPEG \ + +LOCAL_CFLAGS := -fvisibility=hidden -DXN_FORMATS_EXPORTS + +LOCAL_LDFLAGS += -Wl,--export-dynamic --dynamic-linker + +LOCAL_SHARED_LIBRARIES := OpenNI libusb XnCore + +LOCAL_PREBUILT_LIBS := libc + +LOCAL_MODULE := XnFormats + +include $(BUILD_SHARED_LIBRARY) + diff --git a/Platform/Linux-x86/CreateRedist/RedistMaker b/Platform/Linux-x86/CreateRedist/RedistMaker deleted file mode 100755 index c500be2..0000000 --- a/Platform/Linux-x86/CreateRedist/RedistMaker +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -e - -SCRIPT_DIR=`pwd` - -# Take version -MAJOR=`grep "#define XN_PS_MAJOR_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }'` -MINOR=`grep "#define XN_PS_MINOR_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }'` -MAINTENANCE=`grep "#define XN_PS_MAINTENANCE_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }'` -BUILD=`grep "#define XN_PS_BUILD_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }'` - -PS_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$BUILD" - -# clean -rm -rf Final -rm -rf ../Redist - -# Build Engine -make -C ../Build - -# create redist folder structure -mkdir -p ../Redist -mkdir -p ../Redist/Lib -mkdir -p ../Redist/Bin -mkdir -p ../Redist/Install -mkdir -p ../Redist/Config - -# copy files to redist -cp ../../../GPL.txt ../Redist -cp ../../../LGPL.txt ../Redist -cp ../Bin/Release/libXnDeviceSensorV2.so ../Redist/Lib -cp ../Bin/Release/libXnDeviceFile.so ../Redist/Lib -cp ../Bin/Release/libXnDDK.so ../Redist/Lib -cp ../Bin/Release/libXnFormats.so ../Redist/Lib -cp ../Bin/Release/libXnCore.so ../Redist/Lib -cp ../Bin/Release/XnSensorServer ../Redist/Bin -cp ../Install/* ../Redist/Install -cp ../../../Data/GlobalDefaults.ini ../Redist/Config -cp install.sh ../Redist - -# create tar -mkdir -p Final -cd ../Redist -tar -cjf $SCRIPT_DIR/Final/Engine.v$PS_VERSION.tar.bz2 * -cd - - - diff --git a/Platform/Linux-x86/CreateRedist/install.sh b/Platform/Linux-x86/CreateRedist/install.sh deleted file mode 100755 index 56a6ecd..0000000 --- a/Platform/Linux-x86/CreateRedist/install.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -e - -SCRIPT_DIR=`pwd`/`dirname $0` - -INSTALL_LIB=/usr/lib -INSTALL_BIN=/usr/bin -INSTALL_ETC=/usr/etc/primesense -INSTALL_RULES=/etc/udev/rules.d - -MODULES="libXnDeviceSensorV2.so libXnDeviceFile.so" -RULES_FILE="55-primesense-usb.rules" - -# read arguments -INSTALL="1" - -while (( "$#" )); do - case "$1" in - "-i") - INSTALL="1" - ;; - "-u") - INSTALL="0" - ;; - *) - echo "Usage: $0 [options]" - echo "Available options:" - printf "\t-i\tInstall (default)\n" - printf "\t-u\tUninstall\n" - exit 1 - ;; - esac - shift -done - -# create file list -LIB_FILES=`ls $SCRIPT_DIR/Lib/*` -BIN_FILES=`ls $SCRIPT_DIR/Bin/*` - -if [ "$INSTALL" == "1" ]; then - - # create config dir - printf "creating config dir $INSTALL_ETC..." - mkdir -p $INSTALL_ETC - printf "OK\n" - - # Copy shared libraries - printf "copying shared libraries..." - cp $LIB_FILES $INSTALL_LIB - printf "OK\n" - - # Copy executables - printf "copying executables..." - cp $BIN_FILES $INSTALL_BIN - printf "OK\n" - - # register modules - for module in $MODULES; do - printf "registering module '$module' with OpenNI..." - niReg -r $INSTALL_LIB/$module $INSTALL_ETC - printf "OK\n" - done - - # copy config file - printf "copying server config file..." - cp Config/GlobalDefaults.ini $INSTALL_ETC - printf "OK\n" - - # make server run as root - printf "setting uid of server..." - chown root $INSTALL_BIN/XnSensorServer - chmod +s $INSTALL_BIN/XnSensorServer - printf "OK\n" - - # create server log dir - printf "creating server logs dir..." - mkdir -p /var/log/primesense/XnSensorServer - # make this dir readable and writable by all (we allow anyone to delete logs) - chmod a+w /var/log/primesense/XnSensorServer - printf "OK\n" - - # install USB rules (so that PrimeSense sensors will be mounted with write permissions) - printf "installing usb rules..." - cp Install/$RULES_FILE $INSTALL_RULES - printf "OK\n" - -else #uninstall - - # unregister modules - for module in $MODULES; do - printf "unregistering module '$module' from OpenNI..." - if niReg -u $INSTALL_LIB/$module; then - printf "OK\n" - fi - done - - # delete shared libraries - printf "removing shared libraries..." - for filename in $LIB_FILES; do - rm -f $INSTALL_LIB/`basename $filename` - done - printf "OK\n" - - # delete executables - printf "removing executables..." - for filename in $BIN_FILES; do - rm -f $INSTALL_BIN/`basename $filename` - done - printf "OK\n" - - # delete config dir - printf "removing config dir..." - rm -rf $INSTALL_ETC - printf "OK\n" - - # remove USB rules - printf "removing usb rules..." - rm -f $INSTALL_RULES/$RULES_FILE - printf "OK\n" - -fi - -printf "\n*** DONE ***\n\n" diff --git a/Platform/Linux-x86/Install/55-primesense-usb.rules b/Platform/Linux-x86/Install/55-primesense-usb.rules deleted file mode 100644 index bd4799c..0000000 --- a/Platform/Linux-x86/Install/55-primesense-usb.rules +++ /dev/null @@ -1,7 +0,0 @@ -# make primesense device mount with writing permissions (default is read only for unknown devices) -SYSFS{idProduct}=="0200",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users" -SYSFS{idProduct}=="0300",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users" -SYSFS{idProduct}=="0400",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users" -SYSFS{idProduct}=="0500",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users" -SYSFS{idProduct}=="0600",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users" - diff --git a/Platform/Linux/Build/Common/CommonCSMakefile b/Platform/Linux/Build/Common/CommonCSMakefile new file mode 100644 index 0000000..136e69d --- /dev/null +++ b/Platform/Linux/Build/Common/CommonCSMakefile @@ -0,0 +1,58 @@ +############################################################################# +# Primesense template makefile. +# This file should not be made, but only included from other makefiles. +# By default, this makefile compiles in release. To compile a debug version: +# make CFG=Debug +# +# Project makefile should define the following BEFORE including this file: +# SRC_FILES - a list of all source files +# Output name under one of the following: +# NETLIB_NAME (.net module) or +# NETEXE_NAME (.net executable) +# BIN_DIR - Bin directory (output dir) +# INC_DIRS - a list of additional include directories +# USED_LIBS - a list of libraries to link with +# CSFLAGS - [Optional] additional flags for mono compiler +# NET_WIN_FORMS - [Optional] when 1, application uses WinForms +############################################################################# + +# take this file's dir +COMMON_CS_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST))) + +include $(COMMON_CS_MAKE_FILE_DIR)CommonDefs.mak + +# create -r option to mcs +USED_NETLIBS_OPTION = $(foreach lib,$(USED_LIBS),-r:$(lib).dll) + +ifeq "$(NET_WIN_FORMS)" "1" + USED_NETLIBS_OPTION += -r:System.Windows.Forms.dll -r:System.Drawing.dll +endif + +# add the output dir as a place to search for assemblies +USED_NETLIBS_OPTION += -lib:$(OUT_DIR) + +ifeq "$(CFG)" "Release" + CSFLAGS += -o+ +endif + +# some lib / exe specifics +ifneq "$(NETLIB_NAME)" "" + OUTPUT_NAME = $(NETLIB_NAME).dll + TARGET = library +endif +ifneq "$(NETEXE_NAME)" "" + OUTPUT_NAME = $(NETEXE_NAME).exe + TARGET = winexe +endif + +OUTPUT_COMMAND = gmcs -out:$(OUTPUT_FILE) -target:$(TARGET) $(CSFLAGS) $(USED_NETLIBS_OPTION) $(SRC_FILES) + +############################################################################# +# Targets +############################################################################# +include $(COMMON_CS_MAKE_FILE_DIR)CommonTargets.mak + +# Final output file +$(OUTPUT_FILE): + $(OUTPUT_COMMAND) + diff --git a/Platform/Linux/Build/Common/CommonCppMakefile b/Platform/Linux/Build/Common/CommonCppMakefile new file mode 100644 index 0000000..5a15c82 --- /dev/null +++ b/Platform/Linux/Build/Common/CommonCppMakefile @@ -0,0 +1,132 @@ +############################################################################# +# Primesense template makefile. +# This file should not be made, but only included from other makefiles. +# By default, this makefile compiles in release. To compile a debug version: +# make CFG=Debug +# +# Project makefile should define the following BEFORE including this file: +# SRC_FILES - a list of all source files +# Output name under one of the following: +# EXE_NAME (executable), +# LIB_NAME (dynamic library) or +# SLIB_NAME (static library) or +# BIN_DIR - Bin directory (output dir) +# INC_DIRS - a list of additional include directories +# LIB_DIRS - a list of additional library directories +# USED_LIBS - a list of libraries to link with +# DEFINES - [Optional] additional preprocessor defines +# CFLAGS - [Optional] additional flags for the compiler +# LDFLAGS - [Optional] additional flags for the linker +# SSE_GENERATION - [Optional] The SSE generation to use (default is 3) +# TARGET_SYS_ROOT - [Optional] The path to the root of the target +############################################################################# + +# take this file's dir +COMMON_CPP_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST))) + +include $(COMMON_CPP_MAKE_FILE_DIR)CommonDefs.mak + +# define a function to figure .o file for each source file (placed under intermediate directory) +SRC_TO_OBJ = $(addprefix ./$(INT_DIR)/,$(addsuffix .o,$(notdir $(basename $1)))) + +# create a list of all object files +OBJ_FILES = $(call SRC_TO_OBJ,$(SRC_FILES_LIST)) + +# define a function to translate any source file to its dependency file (note that the way we create +# dep files, as a side affect of compilation, always puts the files in the INT_DIR with suffix .d) +SRC_TO_DEP = $(addprefix ./$(INT_DIR)/,$(addsuffix .d,$(notdir $(basename $1)))) + +# create a list of all dependency files +DEP_FILES = $(call SRC_TO_DEP,$(SRC_FILES_LIST)) + +# older version of gcc doesn't support the '=' symbol in include dirs, so we replace it ourselves with sysroot +INC_DIRS_FROM_SYSROOT = $(patsubst =/%,$(TARGET_SYS_ROOT)/%,$(INC_DIRS)) + +# append the -I switch to each include directory +INC_DIRS_OPTION = $(foreach dir,$(INC_DIRS_FROM_SYSROOT),-I$(dir)) + +# append the -L switch to each library directory +LIB_DIRS_OPTION = $(foreach dir,$(LIB_DIRS),-L$(dir)) -L$(OUT_DIR) + +# append the -l switch to each library used +USED_LIBS_OPTION = $(foreach lib,$(USED_LIBS),-l$(lib)) + +# append the -D switch to each define +DEFINES_OPTION = $(foreach def,$(DEFINES),-D$(def)) + +# tell compiler to use the target system root +ifdef TARGET_SYS_ROOT + CFLAGS += --sysroot=$(TARGET_SYS_ROOT) + LDFLAGS += --sysroot=$(TARGET_SYS_ROOT) +endif + +# set Debug / Release flags +ifeq "$(CFG)" "Debug" + CFLAGS += -O0 -g +endif +ifeq "$(CFG)" "Release" + CFLAGS += -O2 -DNDEBUG +endif + +CFLAGS += $(INC_DIRS_OPTION) $(DEFINES_OPTION) +LDFLAGS += $(LIB_DIRS_OPTION) $(USED_LIBS_OPTION) + +# some lib / exe specifics +ifneq "$(LIB_NAME)" "" + OUTPUT_NAME = lib$(LIB_NAME).so + CFLAGS += -fPIC -fvisibility=hidden + ifneq ("$(OSTYPE)","Darwin") + LDFLAGS += -Wl,--no-undefined + OUTPUT_NAME = lib$(LIB_NAME).so + OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared + else + LDFLAGS += -undefined error + OUTPUT_NAME = lib$(LIB_NAME).dylib + OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -dynamiclib -headerpad_max_install_names + endif +endif +ifneq "$(EXE_NAME)" "" + OUTPUT_NAME = $(EXE_NAME) + OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) +endif +ifneq "$(SLIB_NAME)" "" + CFLAGS += -fPIC + OUTPUT_NAME = lib$(SLIB_NAME).a + OUTPUT_COMMAND = $(AR) -cq $(OUTPUT_FILE) $(OBJ_FILES) +endif + +define CREATE_SRC_TARGETS +# create a target for the object file (the CXX command creates both an .o file +# and a .d file) +ifneq ("$(OSTYPE)","Darwin") +$(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR) + $(CXX) -MD -MP -MT "$(call SRC_TO_DEP,$1) $$@" -c $(CFLAGS) -o $$@ $$< +else +$(call SRC_TO_OBJ,$1) : $1 | $(INT_DIR) + $(CXX) -c $(CFLAGS) -o $$@ $$< +endif +endef + +############################################################################# +# Targets +############################################################################# +.PHONY: clean-objs clean-defs + +include $(COMMON_CPP_MAKE_FILE_DIR)CommonTargets.mak + +# create targets for each source file +$(foreach src,$(SRC_FILES_LIST),$(eval $(call CREATE_SRC_TARGETS,$(src)))) + +# include all dependency files (we don't need them the first time, so we can use -include) +-include $(DEP_FILES) + +$(OUTPUT_FILE): $(OBJ_FILES) + $(OUTPUT_COMMAND) + +clean-objs: + rm -rf $(OBJ_FILES) + +clean-defs: + rm -rf $(DEP_FILES) + +clean: clean-objs clean-defs diff --git a/Platform/Linux/Build/Common/CommonDefs.mak b/Platform/Linux/Build/Common/CommonDefs.mak new file mode 100644 index 0000000..cb142f8 --- /dev/null +++ b/Platform/Linux/Build/Common/CommonDefs.mak @@ -0,0 +1,62 @@ +ifndef _COMMON_DEFS_MAKE_ +_COMMON_DEFS_MAKE_=1 + +# some defaults +ifndef CFG + CFG = Release +endif + +# find out the platform on which we're running +MACHINE = $(shell uname -m) +ifneq (,$(findstring x86_64,$(MACHINE))) + HOST_PLATFORM = x64 +else ifneq (,$(findstring x86,$(MACHINE))) + HOST_PLATFORM = x86 +else ifneq (,$(findstring i686,$(MACHINE))) + HOST_PLATFORM = x86 +else ifneq (,$(findstring i386,$(MACHINE))) + HOST_PLATFORM = x86 +else ifneq (,$(findstring arm,$(MACHINE))) + HOST_PLATFORM = Arm +else + DUMMY:=$(error Can't determine host platform) +endif + +# now check if this is a cross-compilation or not +ifeq "$(PLATFORM)" "" + PLATFORM = $(HOST_PLATFORM) +else + ifneq "$(PLATFORM)" "$(HOST_PLATFORM)" + # cross compiling. Take CXX and STAGING_DIR from environment + PLATFORM_UPPER = $(shell echo $(PLATFORM) | tr 'a-z' 'A-Z') + DUMMY:=$(eval CXX = $($(PLATFORM_UPPER)_CXX)) + DUMMY:=$(eval TARGET_SYS_ROOT = $($(PLATFORM_UPPER)_STAGING)) + + ifeq "$(and $(CXX), $(TARGET_SYS_ROOT))" "" + DUMMY:=$(error Cross-Compilation error. Can't find $(PLATFORM_UPPER)_CXX and $(PLATFORM_UPPER)_STAGING) + endif + endif +endif + +# expand file list +SRC_FILES_LIST = $(wildcard $(SRC_FILES)) + +# define the intermediate directory +INT_DIR = $(PLATFORM)-$(CFG) + +# define output directory +OUT_DIR = $(BIN_DIR)/$(PLATFORM)-$(CFG) + +# full path to output file +OUTPUT_FILE = $(OUT_DIR)/$(OUTPUT_NAME) + +# take this file's dir +COMMON_MAK_DIR = $(dir $(lastword $(MAKEFILE_LIST))) + +# get the OS type +OSTYPE := $(shell uname -s) + +# platform specific args +include $(COMMON_MAK_DIR)Platform.$(PLATFORM) + +endif # _COMMON_DEFS_MAKE_ \ No newline at end of file diff --git a/Platform/Linux/Build/Common/CommonJavaMakefile b/Platform/Linux/Build/Common/CommonJavaMakefile new file mode 100644 index 0000000..5faffab --- /dev/null +++ b/Platform/Linux/Build/Common/CommonJavaMakefile @@ -0,0 +1,79 @@ +############################################################################# +# Primesense template makefile. +# This file should not be made, but only included from other makefiles. +# By default, this makefile compiles in release. To compile a debug version: +# make CFG=Debug +# +# Project makefile should define the following BEFORE including this file: +# SRC_FILES - a list of all source files +# JAR_NAME - name of the package +# BIN_DIR - Bin directory (output dir) +# INC_DIRS - a list of additional include directories +# LIB_DIRS - a list of additional library directories +# USED_JARS - a list of libraries used +# MAIN_CLASS - [Optional] for executable jar +############################################################################# + +# take this file's dir +COMMON_CS_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST))) + +include $(COMMON_CS_MAKE_FILE_DIR)CommonDefs.mak + +nullstring := +space := $(nullstring) # end of the line + +USED_JARS_OPTION = +ifneq "$(USED_JARS)" "" + USED_JARS_PATH = $(foreach jar, $(USED_JARS), $(OUT_DIR)/$(jar).jar /usr/share/java/$(jar).jar) + USED_JARS_OPTION = -cp $(subst $(space),:,$(strip $(USED_JARS_PATH))) +endif + +OUTPUT_NAME = $(JAR_NAME).jar + +# create manifest file if needed +JAR_MANIFEST_CREATE_COMMAND := +MANIFEST_FILE := +JAR_OPTIONS = -cf + +ifneq (, $(if $(or $(MAIN_CLASS), $(USED_JARS)),1)) + JAR_OPTIONS = -cfm + MANIFEST_FILE = Manifest.txt + JAR_MANIFEST_CREATE_COMMAND = ( + ifneq (,$(MAIN_CLASS)) + JAR_MANIFEST_CREATE_COMMAND += echo "Main-Class: $(MAIN_CLASS)"; + endif + ifneq (,$(USED_JARS)) + JAR_MANIFEST_CREATE_COMMAND += echo "Class-Path: $(USED_JARS_PATH)"; + endif + JAR_MANIFEST_CREATE_COMMAND += ) > $(MANIFEST_FILE) +endif + +CREATE_SHORTCUT = +ifneq (, $(MAIN_CLASS)) + SHORTCUT = $(OUT_DIR)/$(JAR_NAME) + CREATE_SHORTCUT = echo java -jar $(OUTPUT_NAME) > $(SHORTCUT); chmod +x $(SHORTCUT) +endif + +############################################################################# +# Targets +############################################################################# +include $(COMMON_CS_MAKE_FILE_DIR)CommonTargets.mak + +.PHONY: clean-manifest clean-int + +# Final output file +$(OUTPUT_FILE): | $(INT_DIR) + javac $(USED_JARS_OPTION) -d $(INT_DIR) $(SRC_FILES) + $(JAR_MANIFEST_CREATE_COMMAND) + jar $(JAR_OPTIONS) $@ $(MANIFEST_FILE) -C $(INT_DIR) . + $(CREATE_SHORTCUT) + +clean-manifest: + rm -rf $(MANIFEST_FILE) + +clean-int: + rm -rf $(INT_DIR) + +clean: clean-manifest clean-int + + diff --git a/Platform/Linux/Build/Common/CommonTargets.mak b/Platform/Linux/Build/Common/CommonTargets.mak new file mode 100644 index 0000000..ca13126 --- /dev/null +++ b/Platform/Linux/Build/Common/CommonTargets.mak @@ -0,0 +1,23 @@ +############################################################################# +# Targets +############################################################################# +.PHONY: all clean clean-$(OUTPUT_FILE) + +# define the target 'all' (it is first, and so, default) +all: $(OUTPUT_FILE) + +# Intermediate directory +$(INT_DIR): + mkdir -p $(INT_DIR) + +# Output directory +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +# Final output file +$(OUTPUT_FILE): $(SRC_FILES_LIST) | $(OUT_DIR) + +clean-$(OUTPUT_FILE): + rm -rf $(OUTPUT_FILE) + +clean: clean-$(OUTPUT_FILE) \ No newline at end of file diff --git a/Platform/Linux/Build/Common/Platform.Arm b/Platform/Linux/Build/Common/Platform.Arm new file mode 100644 index 0000000..32cc34d --- /dev/null +++ b/Platform/Linux/Build/Common/Platform.Arm @@ -0,0 +1,12 @@ +ifeq "$(CFG)" "Release" + + # Hardware specifying flags + CFLAGS += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-mcpu=cortex-a8 + + # Optimization level, minus currently buggy optimizing methods (which break bit-exact) + CFLAGS += -O3 -fno-tree-pre -fno-strict-aliasing + + # More optimization flags + CFLAGS += -ftree-vectorize -ffast-math -funsafe-math-optimizations -fsingle-precision-constant + +endif diff --git a/Platform/Linux/Build/Common/Platform.x64 b/Platform/Linux/Build/Common/Platform.x64 new file mode 100644 index 0000000..fe69083 --- /dev/null +++ b/Platform/Linux/Build/Common/Platform.x64 @@ -0,0 +1,5 @@ +# take this file's dir +COMMON_MAK_DIR = $(dir $(lastword $(MAKEFILE_LIST))) + +# everything is the same as in x86 +include $(COMMON_MAK_DIR)Platform.x86 diff --git a/Platform/Linux/Build/Common/Platform.x86 b/Platform/Linux/Build/Common/Platform.x86 new file mode 100644 index 0000000..1891a27 --- /dev/null +++ b/Platform/Linux/Build/Common/Platform.x86 @@ -0,0 +1,25 @@ +# some defaults +export GLUT_SUPPORTED=1 + +ifndef SSE_GENERATION + SSE_GENERATION = 3 +endif + +ifeq ("$(OSTYPE)","Darwin") + # Making the binary a universal one (x86 + x64) + CFLAGS += -arch i386 -arch x86_64 + LDFLAGS += -arch i386 -arch x86_64 +endif + +ifeq ($(SSE_GENERATION), 2) + CFLAGS += -msse2 +else + ifeq ($(SSE_GENERATION), 3) + CFLAGS += -msse3 + ifeq ($(SSSE3_ENABLED), 1) + CFLAGS += -mssse3 + endif + else + DUMMY:=($error "Only SSE2 and SSE3 are supported") + endif +endif diff --git a/Platform/Linux-x86/Build/EngineLibMakefile b/Platform/Linux/Build/EngineLibMakefile similarity index 93% rename from Platform/Linux-x86/Build/EngineLibMakefile rename to Platform/Linux/Build/EngineLibMakefile index 885a58c..56b274f 100644 --- a/Platform/Linux-x86/Build/EngineLibMakefile +++ b/Platform/Linux/Build/EngineLibMakefile @@ -14,12 +14,12 @@ ############################################################################# INC_DIRS += \ - /usr/include/ni \ + =/usr/include/ni \ ../../../../Include \ ../../../../Source \ ../../../../Source/XnCommon BIN_DIR = ../../Bin -include /usr/include/ni/CommonMakefile +include ../Common/CommonCppMakefile diff --git a/Platform/Linux-x86/Build/Makefile b/Platform/Linux/Build/Makefile similarity index 94% rename from Platform/Linux-x86/Build/Makefile rename to Platform/Linux/Build/Makefile index d482819..01de736 100644 --- a/Platform/Linux-x86/Build/Makefile +++ b/Platform/Linux/Build/Makefile @@ -5,6 +5,8 @@ #* Copyright (C) 2010 PrimeSense Ltd. * #* * #******************************************************************************/ +include Common/CommonDefs.mak + # default config is Release ifndef CFG CFG = Release diff --git a/Platform/Linux-x86/Build/Utils/EngineUtilMakefile b/Platform/Linux/Build/Utils/EngineUtilMakefile similarity index 93% rename from Platform/Linux-x86/Build/Utils/EngineUtilMakefile rename to Platform/Linux/Build/Utils/EngineUtilMakefile index ab76199..9f57574 100644 --- a/Platform/Linux-x86/Build/Utils/EngineUtilMakefile +++ b/Platform/Linux/Build/Utils/EngineUtilMakefile @@ -14,11 +14,11 @@ ############################################################################# INC_DIRS += \ - /usr/include/ni \ + =/usr/include/ni \ ../../../../../Include \ ../../../../../Source \ ../../../../../Source/XnCommon BIN_DIR = ../../../Bin -include /usr/include/ni/CommonMakefile +include ../../Common/CommonCppMakefile diff --git a/Platform/Linux-x86/Build/Utils/XnSensorServer/Makefile b/Platform/Linux/Build/Utils/XnSensorServer/Makefile similarity index 61% rename from Platform/Linux-x86/Build/Utils/XnSensorServer/Makefile rename to Platform/Linux/Build/Utils/XnSensorServer/Makefile index 37ba75a..dae9d52 100644 --- a/Platform/Linux-x86/Build/Utils/XnSensorServer/Makefile +++ b/Platform/Linux/Build/Utils/XnSensorServer/Makefile @@ -1,7 +1,8 @@ SRC_FILES = ../../../../../Source/Utils/XnSensorServer/*.cpp EXE_NAME = XnSensorServer -USED_LIBS = OpenNI XnCore XnFormats XnDDK XnDeviceSensorV2 +#--avin mod-- +USED_LIBS = OpenNI XnCore XnFormats XnDDK XnDeviceSensorV2KM include ../EngineUtilMakefile diff --git a/Platform/Linux-x86/Build/XnCore/Makefile b/Platform/Linux/Build/XnCore/Makefile similarity index 100% rename from Platform/Linux-x86/Build/XnCore/Makefile rename to Platform/Linux/Build/XnCore/Makefile diff --git a/Platform/Linux-x86/Build/XnDDK/Makefile b/Platform/Linux/Build/XnDDK/Makefile similarity index 100% rename from Platform/Linux-x86/Build/XnDDK/Makefile rename to Platform/Linux/Build/XnDDK/Makefile diff --git a/Platform/Linux-x86/Build/XnDeviceFile/Makefile b/Platform/Linux/Build/XnDeviceFile/Makefile similarity index 100% rename from Platform/Linux-x86/Build/XnDeviceFile/Makefile rename to Platform/Linux/Build/XnDeviceFile/Makefile diff --git a/Platform/Linux-x86/Build/XnDeviceSensorV2/Makefile b/Platform/Linux/Build/XnDeviceSensorV2/Makefile similarity index 76% rename from Platform/Linux-x86/Build/XnDeviceSensorV2/Makefile rename to Platform/Linux/Build/XnDeviceSensorV2/Makefile index 20f0f56..bac2a3b 100644 --- a/Platform/Linux-x86/Build/XnDeviceSensorV2/Makefile +++ b/Platform/Linux/Build/XnDeviceSensorV2/Makefile @@ -1,7 +1,7 @@ SRC_FILES = \ ../../../../Source/XnDeviceSensorV2/*.cpp - -LIB_NAME = XnDeviceSensorV2 +#--avin mod-- +LIB_NAME = XnDeviceSensorV2KM USED_LIBS = XnCore XnFormats XnDDK OpenNI DEFINES = XN_DEVICE_EXPORTS diff --git a/Platform/Linux-x86/Build/XnFormats/Makefile b/Platform/Linux/Build/XnFormats/Makefile similarity index 89% rename from Platform/Linux-x86/Build/XnFormats/Makefile rename to Platform/Linux/Build/XnFormats/Makefile index 5f19943..4a04486 100644 --- a/Platform/Linux-x86/Build/XnFormats/Makefile +++ b/Platform/Linux/Build/XnFormats/Makefile @@ -3,7 +3,7 @@ SRC_FILES = \ ../../../../Source/External/LibJPEG/*.c LIB_NAME = XnFormats -LIB_USED = XnCore OpenNI +USED_LIBS = XnCore OpenNI DEFINES = XN_FORMATS_EXPORTS INC_DIRS = ../../../../Source/External/LibJPEG diff --git a/Platform/Linux/CreateRedist/RedistMaker b/Platform/Linux/CreateRedist/RedistMaker new file mode 100755 index 0000000..f812133 --- /dev/null +++ b/Platform/Linux/CreateRedist/RedistMaker @@ -0,0 +1,105 @@ +#!/bin/bash -e + +OS_TYPE=`uname -s` +MACHINE_TYPE=`uname -m` + +function calc_jobs_number() { + if [ $OS_TYPE == "Darwin" ] ; then + N_CORES=$(sysctl -n hw.physicalcpu) + else + N_CORES=$(grep "processor\W:" /proc/cpuinfo | wc -l) + fi + echo $((N_CORES*2)) +} + +if [ $# -gt 1 ] +then + echo "Usaga: $0 [PLATFORM]" + exit 1 +fi + +if [ $# -eq 1 ] +then + PLATFORM=$1 +else + case $MACHINE_TYPE in + x86 | i386 | i686) + PLATFORM="x86" ;; + x86_64) + PLATFORM="x64" ;; + arm*) + PLATFORM="Arm" ;; + *) + echo "Unknown machine type: $MACHINE_TYPE" + exit 1 + ;; + esac +fi + +export PLATFORM + +if [ "$OS_TYPE" == "Darwin" ]; then + TAR_TARGET="MacOSX" +else + TAR_TARGET="Linux-$PLATFORM" +fi + +SCRIPT_DIR=`pwd` + +# Take version +MAJOR=`grep "#define XN_PS_MAJOR_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }' | strings -n 1` +MINOR=`grep "#define XN_PS_MINOR_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }' | strings -n 1` +MAINTENANCE=`grep "#define XN_PS_MAINTENANCE_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }' | strings -n 1` +BUILD=`grep "#define XN_PS_BUILD_VERSION" ../../../Include/XnPsVersion.h | awk '{ print $3 }' | strings -n 1` + +PS_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$BUILD" + +echo "Creating redist for Sensor v$PS_VERSION" + +REDIST_NAME="Sensor-Bin-$TAR_TARGET-v$PS_VERSION" +REDIST_DIR="Redist/$REDIST_NAME" + +# clean +echo "Cleaning previous outputs..." +rm -rf Final +rm -rf ../$REDIST_DIR + +# Build Engine +echo "Building..." +make -C ../Build clean > /dev/null +make -j$(calc_jobs_number) -C ../Build + +# create redist folder structure +echo "Creating redist folder..." +mkdir -p ../$REDIST_DIR +mkdir -p ../$REDIST_DIR/Lib +mkdir -p ../$REDIST_DIR/Bin +mkdir -p ../$REDIST_DIR/Install +mkdir -p ../$REDIST_DIR/Config + +# copy files to redist +cp ../../../GPL.txt ../$REDIST_DIR +cp ../../../LGPL.txt ../$REDIST_DIR +#--avin mod-- +cp ../Bin/$PLATFORM-Release/libXnDeviceSensorV2KM.* ../$REDIST_DIR/Lib +cp ../Bin/$PLATFORM-Release/libXnDeviceFile.* ../$REDIST_DIR/Lib +cp ../Bin/$PLATFORM-Release/libXnDDK.* ../$REDIST_DIR/Lib +cp ../Bin/$PLATFORM-Release/libXnFormats.* ../$REDIST_DIR/Lib +cp ../Bin/$PLATFORM-Release/libXnCore.* ../$REDIST_DIR/Lib +cp ../Bin/$PLATFORM-Release/XnSensorServer ../$REDIST_DIR/Bin +cp ../Install/* ../$REDIST_DIR/Install +cp install.sh ../$REDIST_DIR + +#--avin mod-- +cp ../../../Data/GlobalDefaultsKinect.ini ../$REDIST_DIR/Config + +# create tar +echo "Creating tar..." +mkdir -p Final +cd ../Redist + +tar -cjf $SCRIPT_DIR/Final/$REDIST_NAME.tar.bz2 $REDIST_NAME + +cd $SCRIPT_DIR + +echo "Done!" diff --git a/Platform/Linux/CreateRedist/install.sh b/Platform/Linux/CreateRedist/install.sh new file mode 100755 index 0000000..af1db3f --- /dev/null +++ b/Platform/Linux/CreateRedist/install.sh @@ -0,0 +1,192 @@ +#!/bin/sh -e + +usage=" +Usage: $0 [OPTIONS] +Installs PrimeSense Sensor Driver to current machine. + +-i,--install + Installs PrimeSense Sensor Driver (default mode) +-u,--uninstall + Uninstalls PrimeSense Sensor Driver. +-c,--cross-compile-rootfs + Used for cross-compiling. Installs PrimeSense Sensor Driver to instead of '/'. +-h,--help + Shows this help screen. +" + +OS_NAME=`uname -s` + +#--avin mod-- +case $OS_NAME in +Darwin) + MODULES="libXnDeviceSensorV2KM.dylib libXnDeviceFile.dylib" + ;; +*) + MODULES="libXnDeviceSensorV2KM.so libXnDeviceFile.so" + ;; +esac + +RULES_FILE="55-primesense-usb.rules" +#--avin mod-- +MODPROBE_BLACKLIST="blacklist-gspca-kinect.conf" + +# create file list +SCRIPT_DIR=`pwd`/`dirname $0` + +LIB_FILES=`ls $SCRIPT_DIR/Lib/*` +BIN_FILES=`ls $SCRIPT_DIR/Bin/*` + +rootfs= + +# parse command line +while [ "$1" ]; do + case $1 in + -i|--install) + install=yes + ;; + -u|--uninstall) + uninstall=yes + ;; + -c|--cross-staging-dir) + shift + rootfs=$1 + ;; + -h|--help) + echo "$usage" + exit 0 + ;; + *) + echo "Unrecognized option $1" + exit 1 + esac + shift +done + +# default mode is install +if [ ! "$install" = yes ] && [ ! "$uninstall" = yes ]; then + install=yes +fi + +# validity check +if [ "$install" = yes ] && [ "$uninstall" = yes ]; then + echo "-i and -u flags cannot be used together!" + exit 1 +fi + +INSTALL_LIB=$rootfs/usr/lib +INSTALL_BIN=$rootfs/usr/bin +INSTALL_ETC=$rootfs/usr/etc/primesense +INSTALL_RULES=$rootfs/etc/udev/rules.d +SERVER_LOGS_DIR=$rootfs/var/log/primesense/XnSensorServer +#--avin mod-- +MODPROBE_CONF_DIR=$rootfs/etc/modprobe.d + +# make all calls into OpenNI run in this filesystem +export OPEN_NI_INSTALL_PATH=$rootfs +# make sure the staging dir OpenNI is the one being run +export LD_LIBRARY_PATH=$INSTALL_LIB + +if [ "$install" = yes ]; then + printf "Installing PrimeSense Sensor\n" + printf "****************************\n\n" + + # create config dir + printf "creating config dir $INSTALL_ETC..." + mkdir -p $INSTALL_ETC + printf "OK\n" + + # Copy shared libraries + printf "copying shared libraries..." + cp $LIB_FILES $INSTALL_LIB + printf "OK\n" + + # Copy executables + printf "copying executables..." + cp $BIN_FILES $INSTALL_BIN + printf "OK\n" + + # register modules + for module in $MODULES; do + printf "registering module '$module' with OpenNI..." + $INSTALL_BIN/niReg -r $INSTALL_LIB/$module $INSTALL_ETC + printf "OK\n" + done + + # copy config file + printf "copying server config file..." +#--avin mod-- + cp Config/GlobalDefaultsKinect.ini $INSTALL_ETC + printf "OK\n" + + # make server run as root + printf "setting uid of server..." + chown root $INSTALL_BIN/XnSensorServer + chmod +s $INSTALL_BIN/XnSensorServer + printf "OK\n" + + # create server log dir + printf "creating server logs dir..." + mkdir -p $SERVER_LOGS_DIR + # make this dir readable and writable by all (we allow anyone to delete logs) + chmod a+w $SERVER_LOGS_DIR + printf "OK\n" + + if [ "`uname -s`" != "Darwin" ]; then + # install USB rules (so that PrimeSense sensors will be mounted with write permissions) + printf "installing usb rules..." + cp Install/$RULES_FILE $INSTALL_RULES + printf "OK\n" + #--avin mod-- + printf "installing modprobe blacklist..." + cp Install/$MODPROBE_BLACKLIST $MODPROBE_CONF_DIR + printf "OK\n" + fi + + printf "\n*** DONE ***\n\n" + +elif [ "$uninstall" = yes ]; then + + printf "Uninstalling PrimeSense Sensor\n" + printf "******************************\n\n" + + # unregister modules + for module in $MODULES; do + printf "unregistering module '$module' from OpenNI..." + if $INSTALL_BIN/niReg -u $INSTALL_LIB/$module; then + printf "OK\n" + fi + done + + # delete shared libraries + printf "removing shared libraries..." + for filename in $LIB_FILES; do + rm -f $INSTALL_LIB/`basename $filename` + done + printf "OK\n" + + # delete executables + printf "removing executables..." + for filename in $BIN_FILES; do + rm -f $INSTALL_BIN/`basename $filename` + done + printf "OK\n" + + # delete config dir + printf "removing config dir..." + rm -rf $INSTALL_ETC + printf "OK\n" + + if [ "`uname -s`" != "Darwin" ]; then + # remove USB rules + printf "removing usb rules..." + rm -f $INSTALL_RULES/$RULES_FILE + printf "OK\n" + #--avin mod-- + printf "removing modprobe blacklist..." + rm -f $MODPROBE_CONF_DIR/$MODPROBE_BLACKLIST + printf "OK\n" + fi + + printf "\n*** DONE ***\n\n" + +fi diff --git a/Platform/Linux/Install/55-primesense-usb.rules b/Platform/Linux/Install/55-primesense-usb.rules new file mode 100644 index 0000000..1af2f51 --- /dev/null +++ b/Platform/Linux/Install/55-primesense-usb.rules @@ -0,0 +1,15 @@ +# PrimeSense 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}=="0400", 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" + +#--avin mod-- +# Kinect +SUBSYSTEM=="usb", ATTR{idProduct}=="02ae", ATTR{idVendor}=="045e", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="02ad", ATTR{idVendor}=="045e", MODE:="0666", OWNER:="root", GROUP:="audio" +SUBSYSTEM=="usb", ATTR{idProduct}=="02b0", ATTR{idVendor}=="045e", MODE:="0666", OWNER:="root", GROUP:="video" +SUBSYSTEM=="usb", ATTR{idProduct}=="02be", ATTR{idVendor}=="045e", MODE:="0666", OWNER:="root", GROUP:="audio" +SUBSYSTEM=="usb", ATTR{idProduct}=="02bf", ATTR{idVendor}=="045e", MODE:="0666", OWNER:="root", GROUP:="video" diff --git a/Platform/Linux/Install/blacklist-gspca-kinect.conf b/Platform/Linux/Install/blacklist-gspca-kinect.conf new file mode 100644 index 0000000..6b7c903 --- /dev/null +++ b/Platform/Linux/Install/blacklist-gspca-kinect.conf @@ -0,0 +1,2 @@ +blacklist gspca_kinect + diff --git a/Platform/Win32/Build/Res/Resource-DDK.h b/Platform/Win32/Build/Res/Resource-DDK.h index c1e2fbb..fb398c9 100644 --- a/Platform/Win32/Build/Res/Resource-DDK.h +++ b/Platform/Win32/Build/Res/Resource-DDK.h @@ -1,41 +1,37 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by DDK.rc -// -#define IDI_MAINICON 110 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 116 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1016 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by DDK.rc +// +#define IDI_MAINICON 110 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 116 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1016 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj b/Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj index f9285cd..621a18f 100644 --- a/Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj +++ b/Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj @@ -12,14 +12,17 @@ + @@ -49,6 +52,7 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" + DisableSpecificWarnings="4251;4275;1744" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platform/Win32/Build/XnCore/XnCore.vcproj b/Platform/Win32/Build/XnCore/XnCore.vcproj index e2acb03..78ac3a8 100644 --- a/Platform/Win32/Build/XnCore/XnCore.vcproj +++ b/Platform/Win32/Build/XnCore/XnCore.vcproj @@ -12,20 +12,23 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -209,7 +392,7 @@ Name="Core" > + + + + + + + @@ -47,8 +50,9 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4251;4275;1744" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -343,6 +521,14 @@ RelativePath="..\..\..\..\Source\XnDDK\XnDeviceStream.h" > + + + + @@ -402,6 +588,14 @@ GeneratePreprocessedFile="0" /> + + + + @@ -48,8 +51,9 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4251;4275;1744" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj b/Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj index aa1ebbd..cdca628 100644 --- a/Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj +++ b/Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj @@ -2,9 +2,9 @@ @@ -12,14 +12,17 @@ + @@ -50,8 +53,9 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4251;4275;1744" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -237,14 +424,6 @@ RelativePath="..\..\..\..\Source\XnDeviceSensorV2\XnSensor.h" > - - - - @@ -363,6 +542,14 @@ RelativePath="..\..\..\..\Source\XnDeviceSensorV2\XnPacked11DepthProcessor.h" > + + + + @@ -407,6 +594,14 @@ RelativePath="..\..\..\..\Source\XnDeviceSensorV2\XnJpegImageProcessor.h" > + + + + @@ -491,6 +686,14 @@ GeneratePreprocessedFile="0" /> + + + - - - - + + + - - + + - - - - - - - - - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + @@ -47,8 +50,9 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" + DisableSpecificWarnings="4251;4275;1744" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -229,26 +407,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Debug + x86 + 3.5 + {c48cadd9-ccff-4819-a860-840fc26e90ae} + 2.0 + EE_NI + Package + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + + + bin\$(Configuration)\ + obj\$(Configuration)\ + Debug;EE_NIFilesDir=..\..\..\..\Redist + -arch x86 + + + bin\$(Configuration)\ + obj\$(Configuration)\ + EE_NIFilesDir=..\..\..\..\Redist + -arch x86 + + + Debug;EE_NIFilesDir=..\..\..\..\..\Redist + bin\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + -arch x64 + + + EE_NIFilesDir=..\..\..\..\..\Redist + bin\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + -arch x64 + + + + + + + + + + + + + + + + + + + + + + + + + + $(WixExtDir)\WixUtilExtension.dll + WixUtilExtension + + + $(WixExtDir)\WixUIExtension.dll + WixUIExtension + + + $(WixExtDir)\WixNetFxExtension.dll + WixNetFxExtension + + + + + + "$(WIX)bin\heat.exe" dir "..\..\..\..\Redist" -cg EE_NIFiles -gg -scom -sreg -sfrag -srd -dr INSTALLLOCATION -var var.EE_NIFilesDir -out "$(ProjectDir)Fragments\FilesFragment.wxs" + "$(WIX)bin\setupbld.exe" -out EE_NI_setup.exe -msu "!(TargetPath)" -setup "$(ProjectDir)setup.exe" -title "EE_NI setup" + + \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/EE_NI/EE_NI.wxs b/Platform/Win32/CreateRedist/EE_NI/EE_NI.wxs new file mode 100644 index 0000000..f9460c2 --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/EE_NI.wxs @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT Installed + + + Not Installed + NOT Installed + NOT Installed + NOT Installed + NOT Installed + + + + REMOVE ~= "ALL" + REMOVE ~= "ALL" + + + + + + + + + + + + + + + + + diff --git a/Platform/Win32/CreateRedist/EE_NI/Fragments/BinariesFragment.wxs b/Platform/Win32/CreateRedist/EE_NI/Fragments/BinariesFragment.wxs new file mode 100644 index 0000000..248bbfb --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/Fragments/BinariesFragment.wxs @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi b/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi new file mode 100644 index 0000000..1b81c51 --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi.bak b/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi.bak new file mode 100644 index 0000000..3f0c9f2 --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi.bak @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platform/Win32/CreateRedist/EE_NI/Lang/en-us/Loc_en-us.wxl b/Platform/Win32/CreateRedist/EE_NI/Lang/en-us/Loc_en-us.wxl new file mode 100644 index 0000000..639ec5d --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/Lang/en-us/Loc_en-us.wxl @@ -0,0 +1,15 @@ + + + 1033 + + PrimeSense Sensor KinectMod + for Windows + for Windows 64-bit + Sensor + + PrimeSense + This application is is not supported on your current OS. Minimal OS supported is Windows XP SP2 + .NET Framework 2.0 is required. Please install the .NET Framework then run this installer again. + A newer version of !(loc.ProductName) is already installed. + Choose the folder in which to install !(loc.ProductName) + \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/EE_NI/Resources/Header.bmp b/Platform/Win32/CreateRedist/EE_NI/Resources/Header.bmp new file mode 100644 index 0000000..4caa2e7 Binary files /dev/null and b/Platform/Win32/CreateRedist/EE_NI/Resources/Header.bmp differ diff --git a/Platform/Win32/CreateRedist/EE_NI/Resources/mainicon.ico b/Platform/Win32/CreateRedist/EE_NI/Resources/mainicon.ico new file mode 100644 index 0000000..1e1d312 Binary files /dev/null and b/Platform/Win32/CreateRedist/EE_NI/Resources/mainicon.ico differ diff --git a/Platform/Win32/CreateRedist/EE_NI/UI/CustomeInstallUI.wxs b/Platform/Win32/CreateRedist/EE_NI/UI/CustomeInstallUI.wxs new file mode 100644 index 0000000..c3782a5 --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/UI/CustomeInstallUI.wxs @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + 1 + + 1 + + 1 + 1 + + 1 + + 1 + 1 + 1 + + + + + NOT Installed + + + + + \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/EE_NI/checkVersion.vbs b/Platform/Win32/CreateRedist/EE_NI/checkVersion.vbs new file mode 100644 index 0000000..9febe02 --- /dev/null +++ b/Platform/Win32/CreateRedist/EE_NI/checkVersion.vbs @@ -0,0 +1,24 @@ +Function CheckVersionNI() + set WSHShell = CreateObject("WScript.Shell") + arrMinVersion = Split("1.2.0.4", ".") + currOpenNiVer = Session.Property("OPENNIVERSION") + + if currOpenNiVer = "" Then + WSHShell.PopUp("Please install OpenNI version 1.2.0.4 or higher!") + CheckVersionNI = 3 + Exit Function + End If + arrCurrOpenNiVer = Split(currOpenNiVer, ".") + + For index = 0 to 4 + if CInt(arrMinVersion(index)) > CInt(arrCurrOpenNiVer(index)) Then + WSHShell.PopUp("Please install OpenNI version 1.2.0.4 and higher!") + CheckVersionNI = 3 + Exit Function + ElseIf CInt(arrMinVersion(index)) < CInt(arrCurrOpenNiVer(index)) Then + CheckVersionNI = 0 + Exit Function + End If + Next + CheckVerionNI = 0 +End Function \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/EE_NI/setup.exe b/Platform/Win32/CreateRedist/EE_NI/setup.exe new file mode 100644 index 0000000..a7b1b74 Binary files /dev/null and b/Platform/Win32/CreateRedist/EE_NI/setup.exe differ diff --git a/Platform/Win32/CreateRedist/Engine.nsi b/Platform/Win32/CreateRedist/Engine.nsi deleted file mode 100644 index 74af27b..0000000 --- a/Platform/Win32/CreateRedist/Engine.nsi +++ /dev/null @@ -1,194 +0,0 @@ -;/**************************************************************************** -;* * -;* PrimeSense Sensor 5.0 Alpha * -;* Copyright (C) 2010 PrimeSense Ltd. * -;* * -;* This file is part of PrimeSense Common. * -;* * -;* PrimeSense Sensor is free software: you can redistribute it and/or modify* -;* it under the terms of the GNU Lesser General Public License as published * -;* by the Free Software Foundation, either version 3 of the License, or * -;* (at your option) any later version. * -;* * -;* PrimeSense Sensor is distributed in the hope that it will be useful, * -;* but WITHOUT ANY WARRANTY; without even the implied warranty of * -;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -;* GNU Lesser General Public License for more details. * -;* * -;* You should have received a copy of the GNU Lesser General Public License * -;* along with PrimeSense Sensor. If not, see .* -;* * -;****************************************************************************/ -; - -; - - -;SetCompress off -SetCompress auto -SetCompressor ZLIB - -!include "MUI.nsh" -!include "x64.nsh" -!include "winmessages.nsh" -!include LogicLib.nsh -!include "FileFunc.nsh" -;*************** -;*** General *** -;*************** -!define EE_VER "5.0.0" -!define EE_NAME "PrimeSensor ${EE_VER} for Windows" -!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' -!define OPENNI_VER "1.0.0" -!define OPENNI_NAME "PrimeSense - OpenNI ${OPENNI_VER} for Windows" -Var OPEN_NI_INST - -Name "${EE_NAME}" -OutFile "Output\Sensor-Win32-${EE_VER}.exe" -InstallDir "$PROGRAMFILES\Prime Sense\Sensor" - -;******************************* -;*** face Configuration *** -;******************************* -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "Header.bmp" -!define MUI_ABORTWARNING - -;************* -;*** Pages *** -;************* -;!insertmacro MUI_PAGE_LICENSE "License.txt" --- Not needed for now -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - -;**************** -;*** Languages*** -;**************** -!insertmacro MUI_LANGUAGE "English" - -;*************** -;*** Install *** -;*************** - -; OpenNI Section -Section "OpenNI" - - ; Section is mandatory - SectionIn RO - - ClearErrors - ReadRegStr $0 HKLM "Software\OpenNI" "Version" - IfErrors NotInstalled - - - ; Check the version - ${If} $0 == ${OPENNI_VER} - ; That version is already installed - ${Else} - ; Is installed with diferent version, install to the same directory - ReadEnvStr $3 "OPEN_NI_INSTALL_PATH" - ExecWait "OpenNI-Win32-${OPENNI_VER}.exe /D=$3" - ${EndIf} - - - Goto Done - - AddSize 121902 - - - NotInstalled: - ExecWait "OpenNI-Win32-${OPENNI_VER}.exe" - - Done: - -SectionEnd - - - -; EE Section -Section "Sensor" Sensor - - CreateDirectory $INSTDIR - CreateDirectory "$INSTDIR\Bin" - CreateDirectory "$INSTDIR\Data" - - ; Copy all the files from the redist dir - File "/oname=$INSTDIR\GPL.txt" ..\redist\GPL.txt - File "/oname=$INSTDIR\LGPL.txt" ..\redist\LGPL.txt - File "/oname=$INSTDIR\Bin\XnCore.dll" ..\redist\Bin\XnCore.dll - File "/oname=$INSTDIR\Bin\XnFormats.dll" ..\redist\Bin\XnFormats.dll - File "/oname=$INSTDIR\Bin\XnDDK.dll" ..\redist\Bin\XnDDK.dll - File "/oname=$INSTDIR\Bin\XnDeviceSensorV2.dll" ..\redist\Bin\XnDeviceSensorV2.dll - File "/oname=$INSTDIR\Bin\XnDeviceFile.dll" ..\redist\Bin\XnDeviceFile.dll - File "/oname=$INSTDIR\Bin\XnSensorServer.exe" ..\redist\Bin\XnSensorServer.exe - File "/oname=$INSTDIR\Data\GlobalDefaults.ini" ..\redist\Data\GlobalDefaults.ini - - ; Register it in OpenNI - ReadRegStr $OPEN_NI_INST HKLM "Software\OpenNI" "InstallDir" - ; Also add OPEN_NI_INSTALL_PATH to current environment (current environment is not updated by writing to registry) - System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("OPEN_NI_INSTALL_PATH", "$OPEN_NI_INST").r2' - ExecWait '"$OPEN_NI_INST\Bin\niReg.exe" "$INSTDIR\Bin\XnDeviceFile.dll"' - IfErrors FailedToRegister - ExecWait '"$OPEN_NI_INST\Bin\niReg.exe" "$INSTDIR\Bin\XnDeviceSensorV2.dll" "$INSTDIR\Data"' - IfErrors FailedToRegister - - ; Create an uninstaller - WriteUninstaller "$INSTDIR\Uninstall EE ${EE_VER}.exe" - - ; Register the .xns file type - WriteRegStr HKCR ".xns" "" "PrimeSenseRecording" - WriteRegStr HKCR "PrimeSenseRecording" "" "PrimeSense Recording File" - WriteRegStr HKCR "PrimeSenseRecording\DefaultIcon" "" "$OPEN_NI_INST\Samples\Bin\Release\NiViewer.exe,0" - WriteRegStr HKCR "PrimeSenseRecording\shell\open\command" "" '"$OPEN_NI_INST\Samples\Bin\Release\NiViewer.exe" "%1"' - - ; Add the uninstall option into the control panel add/remove - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${EE_NAME}" "DisplayName"\ - "${EE_NAME} (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${EE_NAME}" "UninstallString" \ - "$INSTDIR\Uninstall EE ${EE_VER}.exe" - - WriteRegStr HKLM "Software\PrimeSense\EE" "Version" "${EE_VER}" - - ; Add Env Var - WriteRegExpandStr ${env_hklm} XN_EE_INSTALL_PATH $INSTDIR - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - Goto Done - - FailedToRegister: - MessageBox MB_OK|MB_ICONSTOP "Installation Failed! Could not register module with OpenNI!" - Abort "Installation Failed! Could not register module with OpenNI!" - - Done: - -SectionEnd - - -;***************** -;*** Uninstall *** -;***************** -Section "Uninstall" - ; Unreg from OpenNI - ReadEnvStr $0 "OPEN_NI_BIN" - ExecWait '"$0\niReg.exe" -u "$INSTDIR\Bin\XnDeviceFile.dll"' - ExecWait '"$0\niReg.exe" -u "$INSTDIR\Bin\XnDeviceSensorV2.dll"' - - ; Unregister the .xns file type - DeleteRegKey HKCR ".xns" - DeleteRegKey HKCR "PrimeSenseRecording" - - ; Delete the files - RMDir /r /REBOOTOK $INSTDIR - RMDir $INSTDIR - - ; Delete the uninstall option from the control panel add/remove - DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${EE_NAME}" - DeleteRegKey HKLM "Software\PrimeSense\EE" - - ; Remove the Env Var - DeleteRegValue ${env_hklm} XN_EE_INSTALL_PATH - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -SectionEnd \ No newline at end of file diff --git a/Platform/Win32/CreateRedist/Engine_Config.xml b/Platform/Win32/CreateRedist/Engine_Config.xml new file mode 100644 index 0000000..5291a51 --- /dev/null +++ b/Platform/Win32/CreateRedist/Engine_Config.xml @@ -0,0 +1,8 @@ + + EngineWin32 + WIN32 + 5.1.2 + ..\..\..\ + \Platform\Win32\Build\EngineWin32.sln + \Platform\Win32\Redist\Samples\Build\All_2008.sln + diff --git a/Platform/Win32/CreateRedist/Header.bmp b/Platform/Win32/CreateRedist/Header.bmp deleted file mode 100644 index 026675e..0000000 Binary files a/Platform/Win32/CreateRedist/Header.bmp and /dev/null differ diff --git a/Platform/Win32/CreateRedist/Redist.py b/Platform/Win32/CreateRedist/Redist.py index 5e6b889..38b5ea7 100644 --- a/Platform/Win32/CreateRedist/Redist.py +++ b/Platform/Win32/CreateRedist/Redist.py @@ -1,24 +1,24 @@ -#/**************************************************************************** -#* * -#* PrimeSense Sensor 5.0 Alpha * -#* Copyright (C) 2010 PrimeSense Ltd. * -#* * -#* This file is part of PrimeSense Common. * -#* * -#* PrimeSense Sensor is free software: you can redistribute it and/or modify* -#* it under the terms of the GNU Lesser General Public License as published * -#* by the Free Software Foundation, either version 3 of the License, or * -#* (at your option) any later version. * -#* * -#* PrimeSense Sensor is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Lesser General Public License for more details. * -#* * -#* You should have received a copy of the GNU Lesser General Public License * -#* along with PrimeSense Sensor. If not, see .* -#* * -#****************************************************************************/ +#/*************************************************************************** +#* * +#* PrimeSense Sensor 5.x Alpha * +#* Copyright (C) 2011 PrimeSense Ltd. * +#* * +#* This file is part of PrimeSense Sensor. * +#* * +#* PrimeSense Sensor is free software: you can redistribute it and/or modif* +#* it under the terms of the GNU Lesser General Public License as published* +#* by the Free Software Foundation, either version 3 of the License, or * +#* (at your option) any later version. * +#* * +#* PrimeSense Sensor is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Lesser General Public License for more details. * +#* * +#* You should have received a copy of the GNU Lesser General Public License* +#* along with PrimeSense Sensor. If not, see * +#* * +#***************************************************************************/ # # @@ -26,12 +26,74 @@ import sys import shutil import win32con, pywintypes, win32api +import re +import subprocess +from xml.dom.minidom import parse, parseString +import platform + +def is_64_bit_platform(): + result = False + import platform + (bits,linkage) = platform.architecture() + matchObject = re.search('64',bits) + result = matchObject is not None + return result + +is_64_bit_platform = is_64_bit_platform() + + + +#------------Check args---------------------------------------------# + +Make_Doxy=1 +vc_build_bits = "32" +vc_build_type = "/Rebuild" +VC_version = 9 + +if len(sys.argv) in [4,5]: + if sys.argv[1] == 'n': + Make_Doxy=0 + if sys.argv[2] == '64': + vc_build_bits = "64" + if sys.argv[3] == 'n': + vc_build_type = "/Build" + if len(sys.argv) > 4: + if sys.argv[4] == '10': + VC_version = 10 + +CONFIG_XML = parse("Engine_Config.xml") +SDK_VER = str(CONFIG_XML.getElementsByTagName("VERSION_NUMBER")[0].firstChild.data) + +output_dir__ = 'Output'+vc_build_bits +final_dir__ = 'Final'+vc_build_bits ROOT_DIR = os.path.abspath(os.path.dirname(sys.argv[0])) REDIST_DIR = os.path.join(ROOT_DIR, "..", "Redist") -OUTPUT_DIR = os.path.join(ROOT_DIR, "Output") +OUTPUT_DIR = os.path.join(ROOT_DIR, output_dir__) +path2final = os.path.join(ROOT_DIR,final_dir__) SCRIPT_DIR = os.getcwd() +print('work dir of redist.py:') +print(SCRIPT_DIR) + +def finish_script(exit_code): + os.chdir(SCRIPT_DIR) + #logging.shutdown() + exit(exit_code) + +def regx_replace(findStr,repStr,filePath): + "replaces all findStr by repStr in file filePath using regualr expression" + findStrRegx = re.compile(findStr) + tempName=filePath+'~~~' + input = open(filePath) + output = open(tempName,'w') + for s in input: + output.write(findStrRegx.sub(repStr,s)) + output.close() + input.close() + os.remove(filePath) + os.rename(tempName,filePath) + def get_reg_values(reg_key, value_list): # open the reg key try: @@ -57,6 +119,9 @@ def get_reg_values(reg_key, value_list): pass return tuple(values) + + + # remove output dir if os.path.exists(REDIST_DIR): os.system("rmdir /S /Q \"" + REDIST_DIR + "\"") @@ -64,27 +129,50 @@ def get_reg_values(reg_key, value_list): os.system("rmdir /S /Q \"" + OUTPUT_DIR + "\"") os.mkdir(REDIST_DIR) os.mkdir(OUTPUT_DIR) +if not os.path.exists(path2final): + os.makedirs(path2final) -# build -print("Building...") try: - MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\9.0") - MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] - VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] - VS_NEED_UPGRADE = 0 + VS_NEED_UPGRADE = 0 + if not is_64_bit_platform: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\9.0") + else: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0") + #MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0") + MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] + VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] except Exception as e: - MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\10.0") - MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] - VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] - VS_NEED_UPGRADE = 1 + VC_version = 10 + +if VC_version == 10: + VS_NEED_UPGRADE = 1 + if not is_64_bit_platform: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\10.0") + else: + MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0") + MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] + VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] + +# build +print("Building...") os.chdir(os.path.join(ROOT_DIR, "..", "Build")) +out_file = os.path.join('..\\CreateRedist',output_dir__,'build.log') if VS_NEED_UPGRADE == 1: - res = os.system("\"" + VS_INST_DIR + "devenv\" " + "Engine.sln" + " /upgrade > ..\\CreateRedist\\Output\\build.log") - if res != 0: - raise Exception("build failed!") -res = os.system("\"" + VS_INST_DIR + "devenv\" " + "Engine.sln" + " /build Release > ..\\CreateRedist\\Output\\build.log") + #os.system("attrib -r * /s") + res = os.system("\"" + VS_INST_DIR + "devenv\" " + "Engine.sln" + " /upgrade > " + out_file) + if res != 0: + raise Exception("build failed!") +build_cmd = "\"%s\" %s /Rebuild \"release|%s\" /out %s"%(os.path.join(VS_INST_DIR,'devenv'),'Engine.sln', + 'win32' if vc_build_bits == '32' else 'x64',out_file) +#build_cmd = "\"%s\" %s /Rebuild \"Release|x%s\""%(os.path.join(VS_INST_DIR,'devenv.exe'),'Engine.sln', +# '86' if vc_build_bits == '32' else '64') +print(('building .. %s'%build_cmd)) +#res = os.system("\"" + VS_INST_DIR + "devenv\" " + "Engine.sln" + " /build Release > ..\\CreateRedist\\Output\\build.log") +#res = os.system(build_cmd) +res = subprocess.call(build_cmd) +res = 0 if res != 0: raise Exception("build failed!") os.chdir(SCRIPT_DIR) @@ -92,8 +180,12 @@ def get_reg_values(reg_key, value_list): print("Copying into redist folder...") # create folder structure -os.mkdir(os.path.join(REDIST_DIR, "Bin")) +os.mkdir(os.path.join(REDIST_DIR, "Bin" if vc_build_bits == "32" else "Bin64")) os.mkdir(os.path.join(REDIST_DIR, "Data")) +#--avin mod +os.mkdir(os.path.join(REDIST_DIR, "Driver")) +os.mkdir(os.path.join(REDIST_DIR, "Driver", "amd64")) +os.mkdir(os.path.join(REDIST_DIR, "Driver", "x86")) # copy EPL shutil.copy(os.path.join(ROOT_DIR, "..", "..", "..", "GPL.txt"), REDIST_DIR) @@ -102,25 +194,86 @@ def get_reg_values(reg_key, value_list): shutil.copy(os.path.join(ROOT_DIR, "..", "..", "..", "LGPL.txt"), OUTPUT_DIR) # copy binaries -RELEASE_DIR = os.path.join(ROOT_DIR, "..", "Bin", "Release") +RELEASE_DIR = os.path.join(ROOT_DIR, "..", "Bin" if vc_build_bits == "32" else "Bin64", "Release") for file in os.listdir(RELEASE_DIR): if os.path.splitext(file)[1] in [".dll", ".exe"]: - shutil.copy(os.path.join(RELEASE_DIR, file), os.path.join(REDIST_DIR, "Bin")) + shutil.copy(os.path.join(RELEASE_DIR, file), os.path.join(REDIST_DIR, "Bin" if vc_build_bits == "32" else "Bin64")) # copy data DATA_DIR = os.path.join(ROOT_DIR, "..", "..", "..", "Data") for file in os.listdir(DATA_DIR): shutil.copy(os.path.join(DATA_DIR, file), os.path.join(REDIST_DIR, "Data")) + +#if vc_build_bits == '64': +# print 'Finishing without creating the installer' +# exit(0) + +#--avin mod +# copy driver +DRIVER_DIR = os.path.join(ROOT_DIR, "..", "Driver") +for file in os.listdir(DRIVER_DIR): + try: + shutil.copy(os.path.join(DRIVER_DIR, file), os.path.join(REDIST_DIR, "Driver")) + except IOError: + pass + +DRIVER_DIRX86 = os.path.join(ROOT_DIR, "..", "Driver", "x86") +for file in os.listdir(DRIVER_DIRX86): + shutil.copy(os.path.join(DRIVER_DIRX86, file), os.path.join(REDIST_DIR, "Driver", "x86")) + +DRIVER_DIRAMD64 = os.path.join(ROOT_DIR, "..", "Driver", "amd64") +for file in os.listdir(DRIVER_DIRAMD64): + shutil.copy(os.path.join(DRIVER_DIRAMD64, file), os.path.join(REDIST_DIR, "Driver", "amd64")) # create installer print("Creating installer...") -NSIS_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS") -NSIS_VALUES = [("InstallLocation", win32con.REG_EXPAND_SZ)] -NSIS_INST_DIR = get_reg_values(NSIS_KEY, NSIS_VALUES)[0] -# make installer -os.chdir(ROOT_DIR) -res = os.system("\"" + NSIS_INST_DIR + "\\makensis.exe\" " + "Engine.nsi" + " > ..\\CreateRedist\\Output\\nsis.log") +os.chdir(SCRIPT_DIR + "\\EE_NI") +#print "* move XnLeanDeviceSensorV2.dll" +#os.system("move /Y " + WORK_DIR + "\\Platform\\Win32\\Bin\\XnLeanDeviceSensorV2.dll \\Platform\\Win32\\Bin\\XnDeviceSensorV2.dll") + +print("* Set BinaryOnlyRedist=True") +os.system("attrib -r Includes\\EENIVariables.wxi") +regx_replace("BinaryOnlyRedist=(.*)", "BinaryOnlyRedist=True?>", "Includes\\EENIVariables.wxi") + +logFilename = "BuildEngine" + + + +print("* Build EE_NI.wixproj") + +wix_out_file = os.path.join(SCRIPT_DIR,output_dir__, logFilename + ".txt") +if VS_NEED_UPGRADE == 1: + res = subprocess.call("\""+VS_INST_DIR + "devenv\" EE_NI.sln /upgrade /out %s"%wix_out_file,close_fds=True) + if res != 0: + raise Exception("Failed upgrade installer!") + + +wix_build_cmd = '"%s" %s /Build "release|%s" /out %s'%(os.path.join(VS_INST_DIR,'devenv'), 'EE_NI.wixproj' ,'x86' if vc_build_bits == '32' else 'x64', + wix_out_file) +print(("wix_build_cmd=%s"%wix_build_cmd)) +res = subprocess.call(wix_build_cmd) +#res = subprocess.call("\""+VS_INST_DIR + "devenv\" EE_NI.wixproj /build \"release|x86"\ +# +"\" /out "+SCRIPT_DIR+"\\Output\\" + logFilename + ".txt",close_fds=True) if res != 0: raise Exception("Failed creating installer!") +currDir = os.getcwd() +print(currDir) +target_path = os.path.join(SCRIPT_DIR, final_dir__,"Sensor-Win-OpenSource" + str(vc_build_bits) + "-" + SDK_VER + ".msi") +moveCmd = "move bin\\Release\\en-US\\EE_NI.msi %s"%target_path +print((moveCmd + "...")) +os.system(moveCmd) +#print "* Move installers" +#os.system("move .\\Output\\*.msi " + SCRIPT_DIR + "\\Output") + +#NSIS_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS") +#NSIS_VALUES = [("InstallLocation", win32con.REG_EXPAND_SZ)] +#NSIS_INST_DIR = get_reg_values(NSIS_KEY, NSIS_VALUES)[0] +# make installer +#os.chdir(ROOT_DIR) +#res = os.system("\"" + NSIS_INST_DIR + "\\makensis.exe\" " + "Engine.nsi" + " > ..\\CreateRedist\\Output\\nsis.log") +#if res != 0: + #raise Exception("Failed creating installer!") + print("Done.") +finish_script(0) diff --git a/Platform/Win32/Driver/amd64/WdfCoInstaller01009.dll b/Platform/Win32/Driver/amd64/WdfCoInstaller01009.dll new file mode 100644 index 0000000..1731b96 Binary files /dev/null and b/Platform/Win32/Driver/amd64/WdfCoInstaller01009.dll differ diff --git a/Platform/Win32/Driver/amd64/psdrv3.sys b/Platform/Win32/Driver/amd64/psdrv3.sys new file mode 100644 index 0000000..d83c22b Binary files /dev/null and b/Platform/Win32/Driver/amd64/psdrv3.sys differ diff --git a/Platform/Win32/Driver/dpinst-amd64.exe b/Platform/Win32/Driver/dpinst-amd64.exe new file mode 100644 index 0000000..0096441 Binary files /dev/null and b/Platform/Win32/Driver/dpinst-amd64.exe differ diff --git a/Platform/Win32/Driver/dpinst-x86.exe b/Platform/Win32/Driver/dpinst-x86.exe new file mode 100644 index 0000000..410a135 Binary files /dev/null and b/Platform/Win32/Driver/dpinst-x86.exe differ diff --git a/Platform/Win32/Driver/dpinst.xml b/Platform/Win32/Driver/dpinst.xml new file mode 100644 index 0000000..cc0ff24 --- /dev/null +++ b/Platform/Win32/Driver/dpinst.xml @@ -0,0 +1,16 @@ + + + + + + PrimeSense Sensor Device Driver Installer + + Welcome to the PrimeSense Sensor Device Driver Installer! + This wizard will walk you through updating the drivers for your PrimeSense Sensor device. + + Installing the software for your PrimeSense Sensor device... + + Congratulations! You have finished installing your PrimeSense Sensor device drivers! + + psdrv3.ico + diff --git a/Platform/Win32/Driver/psdrv3.cat b/Platform/Win32/Driver/psdrv3.cat new file mode 100644 index 0000000..0dca907 Binary files /dev/null and b/Platform/Win32/Driver/psdrv3.cat differ diff --git a/Platform/Win32/Driver/psdrv3.ico b/Platform/Win32/Driver/psdrv3.ico new file mode 100644 index 0000000..1e1d312 Binary files /dev/null and b/Platform/Win32/Driver/psdrv3.ico differ diff --git a/Platform/Win32/Driver/psdrv3.inf b/Platform/Win32/Driver/psdrv3.inf new file mode 100644 index 0000000..84605b6 --- /dev/null +++ b/Platform/Win32/Driver/psdrv3.inf @@ -0,0 +1,191 @@ +;/**************************************************************************** +;* * +;* PrimeSense Sensor Device Driver v3.x INF * +;* * +;* Author: Ziv Hendel * +;* * +;* Copyright (C) 2006 PrimeSense Ltd. All Rights Reserved. * +;* * +;* This file has been provided pursuant to a License Agreement containing * +;* restrictions on its use. This data contains valuable trade secrets * +;* and proprietary information of PrimeSense Inc. and is protected by law. * +;* * +;****************************************************************************/ +; +; Modded by avin to support the Kinect. +; + +; ================= Version section =================== + +[Version] +Signature="$WINDOWS NT$" +Class=PrimeSense +ClassGuid={dce97d75-aef7-1980-1909-531357633222} +Provider=%PS% +DriverVer=05/22/2012,3.1.3.1 +CatalogFile=psdrv3.cat + +; ================= Class section ===================== + +[ClassInstall32] +Addreg=PrimeSenseClassReg + +[PrimeSenseClassReg] +HKR,,,0,%ClassName% +HKR,,Icon,,"-20" + +; ================= Device section ===================== + +[DestinationDirs] +DefaultDestDir = 12 ; Driver Dir + +[Manufacturer] +%MfgName%=PrimeSense,NTx86,NTamd64 + +[PrimeSense.NTx86] +%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200&MI_00 +%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200 +%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300&MI_00 +%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300 +%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400&MI_00 +%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400 +%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500&MI_00 +%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600&MI_00 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0601&MI_00 +%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280&MI_00 +%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280 +%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100&MI_00 +%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100 +%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200&MI_00 +%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200 +%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB&MI_00 +%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB +%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0&MI_00 +%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0 +%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD&MI_00 +%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD +%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE&MI_00 +%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE +%USB\VID_045E&PID_02BE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BE&MI_00 +%USB\VID_045E&PID_02BE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BE +%USB\VID_045E&PID_02BF.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BF&MI_00 +%USB\VID_045E&PID_02BF.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BF + +[PrimeSense.NTamd64] +%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200&MI_00 +%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200 +%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300&MI_00 +%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300 +%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400&MI_00 +%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400 +%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500&MI_00 +%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600&MI_00 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600 +%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0601&MI_00 +%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280&MI_00 +%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280 +%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100&MI_00 +%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100 +%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200&MI_00 +%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200 +%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB&MI_00 +%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB +%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0&MI_00 +%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0 +%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD&MI_00 +%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD +%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE&MI_00 +%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE +%USB\VID_045E&PID_02BE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BE&MI_00 +%USB\VID_045E&PID_02BE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BE +%USB\VID_045E&PID_02BF.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BF&MI_00 +%USB\VID_045E&PID_02BF.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02BF + +[psdrv3.Dev.NT] +CopyFiles=psdrv3.Files.Ext + +[psdrv3.Dev.NT.Services] +Addservice = psdrv3, 0x00000002, psdrv3.AddService + +[psdrv3.AddService] +DisplayName = %psdrv3.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\System32\Drivers\psdrv3.sys +AddReg = psdrv3.AddReg +LoadOrderGroup = Base + +[psdrv3.AddReg] +HKR,"Parameters","MaximumTransferSize",0x10001,65536 +HKR,"Parameters","DebugLevel",0x10001,2 +HKR,"Parameters","RemovableIcon",0x10001,0 + +[psdrv3.Files.Ext] +psdrv3.sys + +[SourceDisksNames.x86] +1=%Disk_Description%,,,\x86 + +[SourceDisksNames.amd64] +2=%Disk_Description%,,,\amd64 + +[SourceDisksFiles.x86] +psdrv3.sys = 1 + +[SourceDisksFiles.amd64] +psdrv3.sys = 2 + +; ================= WDF section ===================== + +[DestinationDirs] +CoInstaller_CopyFiles = 11 ; System Dir + +[psdrv3.Dev.NT.CoInstallers] +AddReg=CoInstaller_AddReg +CopyFiles=CoInstaller_CopyFiles + +[CoInstaller_CopyFiles] +WdfCoInstaller01009.dll + +[SourceDisksFiles.x86] +WdfCoInstaller01009.dll=1 + +[SourceDisksFiles.amd64] +WdfCoInstaller01009.dll=2 + +[CoInstaller_AddReg] +HKR,,CoInstallers32,0x00010000, "WdfCoInstaller01009.dll,WdfCoInstaller" + +[psdrv3.Dev.NT.Wdf] +KmdfService = psdrv3, psdrv3_wdfsect + +[psdrv3_wdfsect] +KmdfLibraryVersion = 1.9 + +; ================= Strings section ===================== + +[Strings] +PS = "PrimeSense" +MfgName = "PrimeSense Ltd." +Disk_Description= "PrimeSense Sensor Device Driver Installation Disk v3.x" +psdrv3.SvcDesc = "PrimeSense Sensor Device Driver Service v3.x" +ClassName = "PrimeSense" +USB\VID_1D27&PID_0200.DeviceDesc="PrimeSense Sensor Development Kit 2.x" +USB\VID_1D27&PID_0300.DeviceDesc="PrimeSense Sensor Development Kit 3.x" +USB\VID_1D27&PID_0400.DeviceDesc="PrimeSense Sensor Development Kit 4.x" +USB\VID_1D27&PID_0500.DeviceDesc="PrimeSense Sensor Development Kit 5.x" +USB\VID_1D27&PID_0600.DeviceDesc="PrimeSense PS1080" +USB\VID_1D27&PID_0601.DeviceDesc="PrimeSense PS1080" +USB\VID_1D27&PID_1280.DeviceDesc="PrimeSense RD 1.28" +USB\VID_1D27&PID_2100.DeviceDesc="PrimeSense Sensor Development Kit NG 2100" +USB\VID_1D27&PID_2200.DeviceDesc="PrimeSense Sensor Development Kit NG 2200" +USB\VID_1D27&PID_F9DB.DeviceDesc="PrimeSense Sensor Development Kit NG Debug" +USB\VID_045E&PID_02B0.DeviceDesc="Kinect Motor" +USB\VID_045E&PID_02AD.DeviceDesc="Kinect Audio" +USB\VID_045E&PID_02AE.DeviceDesc="Kinect Camera" +USB\VID_045E&PID_02BE.DeviceDesc="Kinect4Windows Audio" +USB\VID_045E&PID_02BF.DeviceDesc="Kinect4Windows Camera" \ No newline at end of file diff --git a/Platform/Win32/Driver/x86/WdfCoInstaller01009.dll b/Platform/Win32/Driver/x86/WdfCoInstaller01009.dll new file mode 100644 index 0000000..30e81af Binary files /dev/null and b/Platform/Win32/Driver/x86/WdfCoInstaller01009.dll differ diff --git a/Platform/Win32/Driver/x86/psdrv3.sys b/Platform/Win32/Driver/x86/psdrv3.sys new file mode 100644 index 0000000..6d00c6c Binary files /dev/null and b/Platform/Win32/Driver/x86/psdrv3.sys differ diff --git a/README b/README index 2cfd793..6a8f27a 100644 --- a/README +++ b/README @@ -1,6 +1,111 @@ -PrimeSensor Modules for OpenNI ------------------------------- -Website: www.primesense.com +PrimeSense Sensor Module for OpenNI (Version 5.1.2.1 - May 15th 2012) +--------------------------------------------------------------------- + +Kinect Mod: +----------- + +***** Important notice: ***** +You must use this kinect mod version with the unstable OpenNI release which is available at: +http://www.openni.org/Downloads/OpenNIModules.aspx + +Changes: +v0.93: + 1) Added preliminary support for the Kinect4Windows sensor. + +v0.92: + 1) Updated codebase to the latest OpenNI / Sensor version (1.5.4.0 / 5.1.2.1) + +v0.91: + 1) Removed an unnecessary USB set interface command that caused timeout problems on Linux & Mac. + +v0.9: + 1) Updated codebase to the latest OpenNI / Sensor version (1.5.2.7 / 5.1.0.25) + 2) Changed the Bayer-to-RGB function to use the ROS (www.ros.org) code as requested by many community members. + (Thanks to Suat Gedikli from Willow Garage for writing the code and to Raphael Dumusc for the OpenNI adaptation!) + +v0.8: + 1) Updated codebase to the latest OpenNI / Sensor version (1.4.0.2 / 5.0.5.1) + +v0.7: + 1) Updated codebase to the latest OpenNI / Sensor version (1.3.2.3 / 5.0.3.34) + 2) Added a 64-bit binary installer for Windows. + +v0.6: + 1) Updated codebase to the latest OpenNI / Sensor version (1.3.2.1 / 5.0.3.33) + +v0.5: + 1) Updated codebase to the latest OpenNI / Sensor version (1.1.0.39 / 5.0.1.32) + 2) Changed to install directory from Sensor to SensorKinect to co-exist with the original PrimeSense Sensor module. + +v0.4: + 1) Merged code with the new unstable sensor driver from PrimeSense that adds MacOSX and multiple sensor support. + 2) Added precompiled binaries for Linux & MacOSX. + +v0.3: + 1) Added support for high-res 1280x1024 IR and Image (at ~10 FPS) + Checkout the file OPENNI\Data\SamplesConfig.xml for usage example. + (Copy it to your OpenNI\Data dir and use NiViewer to test the different resolutions) + +v0.2: + 1) VS2010 redist will now be installed automatically. + 2) The driver will now also be installed automatically on both x86 and x64 machines. + 3) Turned off the IR projector anti-cover thingy. It is off on the Xbox360 so it must be safe and it was very annoying... + +v0.1: + 1) Added the kinect USB VID/PID to the PSDrv3 driver and to the code. + 2) Changed the packet sequence field from 16-bit to 8-bit (don't know why it's different...) + 3) Changed the image format from YUV to 8-bit uncompressed bayer in the GlobalDefaults.ini file. + 4) Fixed the software depth-to-RGB registration. (Thanks ROS.org for that!) + +Install notes: + 1) Install unstable OpenNI (http://www.openni.org/Downloads/OpenNIModules.aspx) + On Linux/Mac please do: ./sudo install.sh + 2) Install Sensor (this version...) + On Linux/Mac please do: ./sudo install.sh + 3) Install unstable NITE (http://www.openni.org/Downloads/OpenNIModules.aspx) + On Linux/Mac please do: ./sudo install.sh + 4) Test #1: Run the NiViewer sample to make sure depth & image streams are working. + 5) Test #2: Run the OpenNI/NiUserTracker sample play with the skeleton. + 6) Test #3: Try the NITE/Sample-PointViewer sample for the hand tracking demo. + + For Mac/Linux, you will need to install the latest LibUSB. + Linux: + 1) Run: sudo apt-get install libusb-1.0-0-dev + 2) Run: sudo apt-get install freeglut3-dev + MaxOSX: + 1) Install MacPorts for OSX 10.6 from: https://distfiles.macports.org/MacPorts/MacPorts-1.9.2-10.6-SnowLeopard.dmg + for OSX 10.7 from: https://distfiles.macports.org/MacPorts/MacPorts-2.0.4-10.7-Lion.dmg + 2) Run: sudo port install libtool + 3) Run: sudo port install libusb-devel +universal + Note: Do not forget the +universal, it's very important!! + If you're previously already installed libusb-devel then use "sudo port uninstall libusb-devel" and reinstall it again with the +universal flag. +TIPs: + 1) If the driver is installed correctly you should see "Kinect Camera" and "Kinect Motor" under the "PrimeSensor" category in the device manager. + If not, try to install the driver manually by running the dp-inst files from the Driver directory. + +Todo: + 1) Add motor & led control. + 2) Add windows 8 support - it's not working at the moment due to manually modified INF files. + 3) Fix kinect4windows on Linux/MacOSX - it's very unstable. + +The source code for this version is available at: +https://github.com/avin2/SensorKinect + +-------------------------- ORIGINAL README BELOW -------------------------- + +Website: http://www.primesense.com +Forum: http://groups.google.com/group/openni-dev +Wiki: http://wiki.openni.org + +Binaries are available at: +http://www.openni.org/Downloads/OpenNIModules.aspx +(The "OpenNI Compliant Hardware Binaries" section) + +Sources are available at: +https://github.com/PrimeSense/Sensor +or +https://github.com/PrimeSense/Sensor/tree/unstable +for the unstable branch Release Notes: -------------- @@ -9,55 +114,141 @@ Release Notes: (A good hint for this error is that you encounter an "illegal instructions" messages) * By default, the linux kernel mounts unknown USB devices with write permissions to root only, and read-only permissions to other users. When not running as root, this prevents communicating with the device. To fix this issue: - - Navigate to Platform/Linux-x86/Build + - Navigate to Platform/Linux/Build - run 'make install-usb-rules' - if the device was connected, unplug and reconnect it. This part is done automatically by the install script, but you will need to do it manually if you choose not to use the automated install. -* The device driver contains a thread for reading from the USB device. This thread should have high priority in order to function correctly. Each process using the device driver should have the CAP_SYS_NICE capability in order to raise thread priority. Failing to have that capability, will cause a failure in setting priority, consequently causing loss of data. +* Linux: The device driver contains a thread for reading from the USB device. This thread should have high priority in order to function correctly. Each process using the device driver should have the CAP_SYS_NICE capability in order to raise thread priority. Failing to have that capability, will cause a failure in setting priority, consequently causing loss of data. +* MacOSX: Only OSX 10.6 (Snow Leopard) and above with a 64-bit Intel based CPU is currently supported. + Client/Server is not supported yet so do not attempt to access the sensor with more then one application. + Build Notes: ------------ Windows: Requirements: - 1) Microsoft Visual Studio 2008/2010 - 2) Python 2.x/3.x (must be at least 2.6 and above) - 3) PyWin32 - 4) NSIS 2.46 - 5) NSIS-2.46-strlen_8192.zip patch (An important patch to fix problems with adding strings to the path. you can find it in the Platform\Win32\Build\Prerequisites\ directory) - 6) Doxygen & GraphViz (to create docs...) - 7) OpenNI 1.x - + 1) Microsoft Visual Studio 2010 + From: http://msdn.microsoft.com/en-us/vstudio/bb984878.aspx + 2) Python 2.6+/3.x + From: http://www.python.org/download/ + 3) PyWin32 + From: http://sourceforge.net/projects/pywin32/files/pywin32/ + Please make sure you download the version that matches your exact python version. + 4) WIX 3.5 + From: http://wix.codeplex.com/releases/view/60102 + 5) OpenNI 1.5.x.x + From: http://www.openni.org/Downloads/OpenNIModules.aspx + + Optional Requirements (To build the documentation): + 1) Doxygen + From: http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc + 2) GraphViz + From: http://www.graphviz.org/Download_windows.php + Building Sensor: - 1) Go into the directory: "Platform\Win32\CreateRedist". Run the script: "Redist.py". This will compile and prepare the redist exe files that includes everything. - 2) Install the exe you've just made which is located in Platform\Win32\CreateRedist\Output\Sensor-Win32-5.0.0.exe + 1) Go to the directory: "Platform\Win32\CreateRedist". + Run the script: "Redist.py". + This will compile and prepare the redist exe files that includes everything. + 2) Install the exe you've just made which is located in Platform\Win32\CreateRedist\FinalXX\Sensor-Win32-5.x.x.x.exe + (XX being the number of bits: 32 or 64) The installer will also automatically register all the modules into OpenNI via the NiReg utility. The visual studio solution is located in: Platform\Win32\Build\EngineWin32.sln. - Important: Please note that even though the directory is called Win32, you can also use it to compile it for 64-bit targets (AMD64/x64). - + Important: Please note that even though the directory is called Win32, you can also use it to compile it for 64-bit targets (AMD64/x64). + Linux: Requirements: 1) GCC 4.x - 2) Python 2.6/2.7/3.0/3.1 - 3) libusb 1.0.8 (libusb-1.0-0-dev) - 4) freeglut3 (freeglut3-dev) - 5) Doxygen & GraphViz (to create docs...) - 6) OpenNI 1.x - + From: http://gcc.gnu.org/releases.html + Or via apt: + sudo apt-get install g++ + 2) Python 2.6+/3.x + From: http://www.python.org/download/ + Or via apt: + sudo apt-get install python + 3) OpenNI 1.5.x.x + From: http://www.openni.org/Downloads/OpenNIModules.aspx + Building Sensor: - 1) Go into the directory: "Platform/Linux-x86/CreateRedist". Run the script: "RedistMaker". This will compile everything and create a redist package in the "Platform/Linux-x86/Redist" directory. - 2) Go into the directory: "Platform/Linux-x86/Redist". Run the script: "sudo ./install.sh" (needs to run as root) + 1) Go into the directory: "Platform/Linux/CreateRedist". + Run the script: "./RedistMaker". + This will compile everything and create a redist package in the "Platform/Linux/Redist" directory. + It will also create a distribution in the "Platform/Linux/CreateRedist/Final" directory. + 2) Go into the directory: "Platform/Linux/Redist". + Run the script: "sudo ./install.sh" (needs to run as root) + + The install script copies key files to the following location: + Libs into: /usr/lib + Bins into: /usr/bin + Config files into: /usr/etc/primesense + USB rules into: /etc/udev/rules.d + Logs will be created in: /var/log/primesense + + To build the package manually, you can run "make" in the "Platform\Linux\Build" directory. - The install script copies key files to the following location: - Libs into: /usr/lib - Bins into: /usr/bin - Config files: /usr/etc/primesense - USB rules: /etc/udev/rules.d - Logs will be created in: /var/log/primesense + Important: Please note that even though the directory is called Linux, you can also use it to compile it for 64-bit targets and pretty much any other linux based environment. + + Building Sensor using a cross-compiler: + 1) Make sure to define two environment variables: + - _CXX - the name of the cross g++ for platform + - _STAGING - a path to the staging dir (a directory which simulates the target root filesystem). + Note that should be upper cased. + For example, if wanting to compile for ARM from a x86 machine, ARM_CXX and ARM_STAGING should be defined. + 2) Go into the directory: "Platform/Linux/CreateRedist". + Run: "./RedistMaker " (for example: "./RedistMake Arm"). + This will compile everything and create a redist package in the "Platform/Linux/Redist" directory. + It will also create a distribution in the "Platform/Linux/CreateRedist/Final" directory. + 3) To install OpenNI files on the target file system: + Go into the directory: "Platform/Linux/Redist". + Run the script: "./install.sh -c $_STAGING" (for example: "./install.sh -c $ARM_STAGING"). + + The install script copies key files to the following location: + Libs into: STAGING/usr/lib + Bins into: STAGING/usr/bin + Config files into: STAGING/usr/etc/primesense + USB rules into: STAGING/etc/udev/rules.d + Logs will be created in: STAGING/var/log/primesense - To build the package manually, you can run make in the "Platform\Linux-x86\Build" directory. - (You can also find a SlickEdit project there...) + To build the package manually, you can run "make PLATFORM=" in the "Platform\Linux\Build" directory. + If you wish to build the Mono wrappers, also run "make PLATFORM= mono_wrapper" and "make PLATFORM= mono_samples". - Important: Please note that even though the directory is called Linux-x86, you can also use it to compile it for 64-bit targets and pretty much any other linux based environment. - \ No newline at end of file +MacOSX: + Requirements: + 1) For Mac OSX 10.7, Xcode 4.3.2 + From: http://developer.apple.com/devcenter/mac/index.action + http://adcdownload.apple.com/Developer_Tools/xcode_4.3.2/xcode_432_lion.dmg + + You will also need to download and install the "Commandline Tools for XCode - Late March 2012" package: + http://adcdownload.apple.com/Developer_Tools/command_line_tools_for_xcode_4.4__late_march_2012/cltools_lion_latemarch12.dmg + + Note: Since Xcode is now a normal application, it no longer automatically install itself. You have to copy&paste Xcode yourself into your Applications folder. + (or run the application "Install Xcode" from your Applications folder / LaunchPad). + It's also recommended to run the following command after you do the above: + sudo xcode-select -switch /Applications/Xcode.app/ + + For Mac OSX 10.6, Xcode 3.2.6: + From: http://developer.apple.com/devcenter/mac/index.action + http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg + + Please note that you need to register as a mac developer (It's free!). + + 2) OpenNI 1.5.x.x + From: http://www.openni.org/Downloads/OpenNIModules.aspx + + Building Sensor: + 1) Go into the directory: "Platform/Linux/CreateRedist". + Run the script: "./RedistMaker". + This will compile everything and create a redist package in the "Platform/Linux/Redist" directory. + It will also create a distribution in the "Platform/Linux/CreateRedist/Final" directory. + 2) Go into the directory: "Platform/Linux/Redist". + Run the script: "sudo ./install.sh" (needs to run as root) + + The install script copies key files to the following location: + Libs into: /usr/lib + Bins into: /usr/bin + Config files into: /usr/etc/primesense + USB rules into: /etc/udev/rules.d + Logs will be created in: /var/log/primesense + + To build the package manually, you can run "make" in the "Platform\Linux\Build" directory. diff --git a/Source/External/LibJPEG/jconfig.h b/Source/External/LibJPEG/jconfig.h index fbc67c3..56860d8 100644 --- a/Source/External/LibJPEG/jconfig.h +++ b/Source/External/LibJPEG/jconfig.h @@ -4,10 +4,9 @@ #elif SN_TARGET_PS3 #include "jconfig.ps3" #include -#elif (linux && i386) +#elif ((linux) || (__APPLE__)) #include "jconfig.lnx86" #include #else - #include "jconfig.lnx86" - #include + #error "LibJPEG: Unsupported Platform!" #endif diff --git a/Source/Utils/XnSensorServer/SensorServer.cpp b/Source/Utils/XnSensorServer/SensorServer.cpp index d81e64d..affc7a3 100644 --- a/Source/Utils/XnSensorServer/SensorServer.cpp +++ b/Source/Utils/XnSensorServer/SensorServer.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -62,13 +56,13 @@ int main(int argc, char* argv[]) nRetVal = XnSensorServerGetGlobalConfigFile(strConfigDir, strConfigFile, XN_FILE_MAX_PATH); XN_CHECK_RC(nRetVal, "Resolving global config file"); - nRetVal = XnFormatsInitFromINIFile(strConfigFile); - XN_CHECK_RC(nRetVal, "Initializing DDK"); - -#if (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM) +#if (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_MACOSX) xnLogSetOutputFolder("/var/log/primesense/XnSensorServer/"); #endif + nRetVal = XnFormatsInitFromINIFile(strConfigFile); + XN_CHECK_RC(nRetVal, "Initializing DDK"); + printf("Running...\n"); nRetVal = XnSensorServerRun(strConfigFile); XN_CHECK_RC(nRetVal, "starting sensor server"); diff --git a/Source/XnCore/XnBuffer.cpp b/Source/XnCore/XnBuffer.cpp index 5119aa3..57330ae 100644 --- a/Source/XnCore/XnBuffer.cpp +++ b/Source/XnCore/XnBuffer.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnCore/XnBuffer.h b/Source/XnCore/XnBuffer.h index 3b32ec7..a021109 100644 --- a/Source/XnCore/XnBuffer.h +++ b/Source/XnCore/XnBuffer.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_BUFFER_H__ #define __XN_BUFFER_H__ diff --git a/Source/XnCore/XnCore.cpp b/Source/XnCore/XnCore.cpp index 2462419..da5e49d 100644 --- a/Source/XnCore/XnCore.cpp +++ b/Source/XnCore/XnCore.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnCore/XnCoreGlobals.h b/Source/XnCore/XnCoreGlobals.h index d0a8198..df2de09 100644 --- a/Source/XnCore/XnCoreGlobals.h +++ b/Source/XnCore/XnCoreGlobals.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_COREGLOBALS_H_ #define _XN_COREGLOBALS_H_ diff --git a/Source/XnCore/XnCoreStatus.cpp b/Source/XnCore/XnCoreStatus.cpp index 40ea4e5..dcfcbd3 100644 --- a/Source/XnCore/XnCoreStatus.cpp +++ b/Source/XnCore/XnCoreStatus.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnCore/XnIOFileStream.cpp b/Source/XnCore/XnIOFileStream.cpp index 4c11580..f4272b2 100644 --- a/Source/XnCore/XnIOFileStream.cpp +++ b/Source/XnCore/XnIOFileStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -74,12 +68,12 @@ XnStatus XnIOFileStream::ReadData(XnUChar *pData, XnUInt32 nDataSize) return (XN_STATUS_OK); } -XnStatus XnIOFileStream::Tell(XnUInt32* pnOffset) +XnStatus XnIOFileStream::Tell(XnUInt64* pnOffset) { - return xnOSTellFile(m_hFile, pnOffset); + return xnOSTellFile64(m_hFile, pnOffset); } -XnStatus XnIOFileStream::Seek(XnUInt32 nOffset) +XnStatus XnIOFileStream::Seek(XnUInt64 nOffset) { - return xnOSSeekFile(m_hFile, XN_OS_SEEK_SET, nOffset); + return xnOSSeekFile64(m_hFile, XN_OS_SEEK_SET, nOffset); } diff --git a/Source/XnCore/XnIONetworkStream.cpp b/Source/XnCore/XnIONetworkStream.cpp index b154043..7db02b2 100644 --- a/Source/XnCore/XnIONetworkStream.cpp +++ b/Source/XnCore/XnIONetworkStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnCore/XnVersion.cpp b/Source/XnCore/XnVersion.cpp index 8df08aa..069b9db 100644 --- a/Source/XnCore/XnVersion.cpp +++ b/Source/XnCore/XnVersion.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/IXnDevice.h b/Source/XnDDK/IXnDevice.h index 5cc4308..8162dcf 100644 --- a/Source/XnDDK/IXnDevice.h +++ b/Source/XnDDK/IXnDevice.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __IXN_DEVICE_BASE_H__ #define __IXN_DEVICE_BASE_H__ @@ -116,9 +111,9 @@ class XN_DDK_CPP_API IXnDevice * * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. - * @param phCallback [out] A handle for unregister. + * @param hCallback [out] A handle for unregister. */ - virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0; + virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) = 0; /** * Unregisters from the event of streams change (stream created / destroyed) @@ -140,9 +135,9 @@ class XN_DDK_CPP_API IXnDevice * * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. - * @param phCallback [out] A handle for unregister. + * @param hCallback [out] A handle for unregister. */ - virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0; + virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) = 0; /** * Unregisters from the event of new data from a stream. @@ -336,9 +331,9 @@ class XN_DDK_CPP_API IXnDevice * @param PropertyName [in] Name of the property to register to. * @param Handler [in] A pointer to the function that will handle the event. * @param pCookie [in] User cookie that will be passed as an argument to the event handler. - * @param phCallback [out] A handle for unregister. + * @param hCallback [out] A handle for unregister. */ - virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0; + virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) = 0; /** * Unregisters an event handler from the Property Changed event. diff --git a/Source/XnDDK/XnActualGeneralProperty.cpp b/Source/XnDDK/XnActualGeneralProperty.cpp index cd9c398..ad853ec 100644 --- a/Source/XnDDK/XnActualGeneralProperty.cpp +++ b/Source/XnDDK/XnActualGeneralProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -65,12 +59,12 @@ void XnActualGeneralProperty::SetAsBufferOwner(XnBool bOwner) m_bOwner = bOwner; } -XnStatus XnActualGeneralProperty::SetCallback(XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XnActualGeneralProperty::SetCallback(XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* /*pCookie*/) { return pSender->UnsafeUpdateValue(gbValue); } -XnStatus XnActualGeneralProperty::GetCallback(const XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XnActualGeneralProperty::GetCallback(const XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* /*pCookie*/) { if (gbValue.nDataSize != pSender->GetValue().nDataSize) { diff --git a/Source/XnDDK/XnActualGeneralProperty.h b/Source/XnDDK/XnActualGeneralProperty.h index 1c9f5ab..9b5d105 100644 --- a/Source/XnDDK/XnActualGeneralProperty.h +++ b/Source/XnDDK/XnActualGeneralProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_GENERAL_PROPERTY_H__ #define __XN_ACTUAL_GENERAL_PROPERTY_H__ diff --git a/Source/XnDDK/XnActualIntProperty.cpp b/Source/XnDDK/XnActualIntProperty.cpp index d9b26c2..46579d2 100644 --- a/Source/XnDDK/XnActualIntProperty.cpp +++ b/Source/XnDDK/XnActualIntProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -41,12 +35,12 @@ XnActualIntProperty::XnActualIntProperty(const XnChar* strName, XnUInt64 nInitia UpdateGetCallback(GetCallback, this); } -XnStatus XN_CALLBACK_TYPE XnActualIntProperty::SetCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnActualIntProperty::SetCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* /*pCookie*/) { return pSender->UnsafeUpdateValue(nValue); } -XnStatus XN_CALLBACK_TYPE XnActualIntProperty::GetCallback(const XnActualIntProperty* pSender, XnUInt64* pnValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnActualIntProperty::GetCallback(const XnActualIntProperty* pSender, XnUInt64* pnValue, void* /*pCookie*/) { *pnValue = pSender->GetValue(); return XN_STATUS_OK; diff --git a/Source/XnDDK/XnActualIntProperty.h b/Source/XnDDK/XnActualIntProperty.h index dc90168..223d84e 100644 --- a/Source/XnDDK/XnActualIntProperty.h +++ b/Source/XnDDK/XnActualIntProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_INT_PROPERTY_H__ #define __XN_ACTUAL_INT_PROPERTY_H__ diff --git a/Source/XnDDK/XnActualPropertiesHash.cpp b/Source/XnDDK/XnActualPropertiesHash.cpp index fcd0b1c..281dea1 100644 --- a/Source/XnDDK/XnActualPropertiesHash.cpp +++ b/Source/XnDDK/XnActualPropertiesHash.cpp @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #include "XnActualPropertiesHash.h" #include "XnActualIntProperty.h" @@ -38,9 +34,9 @@ XnActualPropertiesHash::XnActualPropertiesHash(const XnChar* strName) XnActualPropertiesHash::~XnActualPropertiesHash() { // free all properties - for (Iterator it = begin(); it != end(); ++it) + for (Iterator it = Begin(); it != End(); ++it) { - XN_DELETE(it.Value()); + XN_DELETE(it->Value()); } } @@ -48,7 +44,7 @@ XnStatus XnActualPropertiesHash::Add(const XnChar* strName, XnUInt64 nValue) { XnStatus nRetVal = XN_STATUS_OK; - Iterator it = end(); + Iterator it = End(); if (XN_STATUS_OK == Find(strName, it)) { return XN_STATUS_DEVICE_PROPERTY_ALREADY_EXISTS; @@ -73,7 +69,7 @@ XnStatus XnActualPropertiesHash::Add(const XnChar* strName, XnDouble dValue) { XnStatus nRetVal = XN_STATUS_OK; - Iterator it = end(); + Iterator it = End(); if (XN_STATUS_OK == Find(strName, it)) { return XN_STATUS_DEVICE_PROPERTY_ALREADY_EXISTS; @@ -98,7 +94,7 @@ XnStatus XnActualPropertiesHash::Add(const XnChar* strName, const XnChar* strVal { XnStatus nRetVal = XN_STATUS_OK; - Iterator it = end(); + Iterator it = End(); if (XN_STATUS_OK == Find(strName, it)) { return XN_STATUS_DEVICE_PROPERTY_ALREADY_EXISTS; @@ -123,7 +119,7 @@ XnStatus XnActualPropertiesHash::Add(const XnChar* strName, const XnGeneralBuffe { XnStatus nRetVal = XN_STATUS_OK; - Iterator it = end(); + Iterator it = End(); if (XN_STATUS_OK == Find(strName, it)) { return XN_STATUS_DEVICE_PROPERTY_ALREADY_EXISTS; @@ -158,23 +154,18 @@ XnStatus XnActualPropertiesHash::Remove(const XnChar* strName) { XnStatus nRetVal = XN_STATUS_OK; - XnProperty* pProp = NULL; - nRetVal = m_Hash.Remove(strName, pProp); + ConstIterator it; + nRetVal = Find(strName, it); XN_IS_STATUS_OK(nRetVal); - if (pProp != NULL) - { - XN_DELETE(pProp); - } - - return (XN_STATUS_OK); + return Remove(it); } XnStatus XnActualPropertiesHash::Remove(ConstIterator where) { XnStatus nRetVal = XN_STATUS_OK; - XnProperty* pProp = where.Value(); + XnProperty* pProp = where->Value(); nRetVal = m_Hash.Remove(where); XN_IS_STATUS_OK(nRetVal); @@ -188,7 +179,7 @@ XnStatus XnActualPropertiesHash::Clear() { while (!IsEmpty()) { - Remove(begin()); + Remove(Begin()); } return XN_STATUS_OK; @@ -201,40 +192,40 @@ XnStatus XnActualPropertiesHash::CopyFrom(const XnActualPropertiesHash& other) Clear(); strncpy(m_strName, other.m_strName, XN_DEVICE_MAX_STRING_LENGTH); - for (ConstIterator it = other.begin(); it != other.end(); ++it) + for (ConstIterator it = other.Begin(); it != other.End(); ++it) { - switch (it.Value()->GetType()) + switch (it->Value()->GetType()) { case XN_PROPERTY_TYPE_INTEGER: { - XnActualIntProperty* pProp = (XnActualIntProperty*)it.Value(); + XnActualIntProperty* pProp = (XnActualIntProperty*)it->Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_REAL: { - XnActualRealProperty* pProp = (XnActualRealProperty*)it.Value(); + XnActualRealProperty* pProp = (XnActualRealProperty*)it->Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_STRING: { - XnActualStringProperty* pProp = (XnActualStringProperty*)it.Value(); + XnActualStringProperty* pProp = (XnActualStringProperty*)it->Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_GENERAL: { - XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)it.Value(); + XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)it->Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d\n", it.Value()->GetType()); + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d\n", it->Value()->GetType()); } } diff --git a/Source/XnDDK/XnActualPropertiesHash.h b/Source/XnDDK/XnActualPropertiesHash.h index 8d30852..1539228 100644 --- a/Source/XnDDK/XnActualPropertiesHash.h +++ b/Source/XnDDK/XnActualPropertiesHash.h @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_PROPERTIES_HASH_H__ #define __XN_ACTUAL_PROPERTIES_HASH_H__ @@ -59,10 +55,10 @@ class XN_DDK_CPP_API XnActualPropertiesHash inline XnStatus Find(const XnChar* strName, ConstIterator& iter) const { return m_Hash.Find(strName, iter); } inline XnStatus Get(const XnChar* strName, XnProperty*& pProp) const { return m_Hash.Get(strName, pProp); } - inline Iterator begin() { return m_Hash.begin(); } - inline ConstIterator begin() const { return m_Hash.begin(); } - inline Iterator end() { return m_Hash.end(); } - inline ConstIterator end() const { return m_Hash.end(); } + inline Iterator Begin() { return m_Hash.Begin(); } + inline ConstIterator Begin() const { return m_Hash.Begin(); } + inline Iterator End() { return m_Hash.End(); } + inline ConstIterator End() const { return m_Hash.End(); } XnStatus CopyFrom(const XnActualPropertiesHash& other); diff --git a/Source/XnDDK/XnActualPropertyFactory.cpp b/Source/XnDDK/XnActualPropertyFactory.cpp index 5b41f9f..1ffe1d2 100644 --- a/Source/XnDDK/XnActualPropertyFactory.cpp +++ b/Source/XnDDK/XnActualPropertyFactory.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -40,8 +34,7 @@ //--------------------------------------------------------------------------- XnStatus XnActualPropertyFactory::CreateProperty(XnPropertyType nType, const XnChar* strName, XnProperty** ppProperty, XnUInt32 nSize /* = 0 */) { - XnStatus nRetVal = XN_STATUS_OK; - + switch (nType) { case XN_PROPERTY_TYPE_INTEGER: @@ -67,8 +60,6 @@ XnStatus XnActualPropertyFactory::CreateProperty(XnPropertyType nType, const XnC XnStatus XnActualPropertyFactory::FreeProperty(XnProperty* pProperty) { - XnStatus nRetVal = XN_STATUS_OK; - if (pProperty->GetType() == XN_PROPERTY_TYPE_GENERAL) { XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProperty; diff --git a/Source/XnDDK/XnActualPropertyFactory.h b/Source/XnDDK/XnActualPropertyFactory.h index 3f38514..b788297 100644 --- a/Source/XnDDK/XnActualPropertyFactory.h +++ b/Source/XnDDK/XnActualPropertyFactory.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_PROPERTY_FACTORY_H__ #define __XN_ACTUAL_PROPERTY_FACTORY_H__ diff --git a/Source/XnDDK/XnActualRealProperty.cpp b/Source/XnDDK/XnActualRealProperty.cpp index 01417bc..bbff73a 100644 --- a/Source/XnDDK/XnActualRealProperty.cpp +++ b/Source/XnDDK/XnActualRealProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -41,12 +35,12 @@ XnActualRealProperty::XnActualRealProperty(const XnChar* strName, XnDouble dInit UpdateGetCallback(GetCallback, this); } -XnStatus XnActualRealProperty::SetCallback(XnActualRealProperty* pSender, XnDouble dValue, void* pCookie) +XnStatus XnActualRealProperty::SetCallback(XnActualRealProperty* pSender, XnDouble dValue, void* /*pCookie*/) { return pSender->UnsafeUpdateValue(dValue); } -XnStatus XN_CALLBACK_TYPE XnActualRealProperty::GetCallback(const XnActualRealProperty* pSender, XnDouble* pdValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnActualRealProperty::GetCallback(const XnActualRealProperty* pSender, XnDouble* pdValue, void* /*pCookie*/) { *pdValue = pSender->GetValue(); return XN_STATUS_OK; diff --git a/Source/XnDDK/XnActualRealProperty.h b/Source/XnDDK/XnActualRealProperty.h index a98a0ac..2232af6 100644 --- a/Source/XnDDK/XnActualRealProperty.h +++ b/Source/XnDDK/XnActualRealProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_REAL_PROPERTY_H__ #define __XN_ACTUAL_REAL_PROPERTY_H__ diff --git a/Source/XnDDK/XnActualStringProperty.cpp b/Source/XnDDK/XnActualStringProperty.cpp index 8610ba6..d0deab5 100644 --- a/Source/XnDDK/XnActualStringProperty.cpp +++ b/Source/XnDDK/XnActualStringProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -41,12 +35,12 @@ XnActualStringProperty::XnActualStringProperty(const XnChar* strName, const XnCh UpdateGetCallback(GetCallback, this); } -XnStatus XnActualStringProperty::SetCallback(XnActualStringProperty* pSender, const XnChar* strValue, void* pCookie) +XnStatus XnActualStringProperty::SetCallback(XnActualStringProperty* pSender, const XnChar* strValue, void* /*pCookie*/) { return pSender->UnsafeUpdateValue(strValue); } -XnStatus XnActualStringProperty::GetCallback(const XnActualStringProperty* pSender, XnChar* csValue, void* pCookie) +XnStatus XnActualStringProperty::GetCallback(const XnActualStringProperty* pSender, XnChar* csValue, void* /*pCookie*/) { strncpy(csValue, pSender->GetValue(), XN_DEVICE_MAX_STRING_LENGTH); return XN_STATUS_OK; diff --git a/Source/XnDDK/XnActualStringProperty.h b/Source/XnDDK/XnActualStringProperty.h index 2998ae0..26ce989 100644 --- a/Source/XnDDK/XnActualStringProperty.h +++ b/Source/XnDDK/XnActualStringProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_ACTUAL_STRING_PROPERTY_H__ #define __XN_ACTUAL_STRING_PROPERTY_H__ diff --git a/Source/XnDDK/XnAudioStream.cpp b/Source/XnDDK/XnAudioStream.cpp index 33028dc..6003857 100644 --- a/Source/XnDDK/XnAudioStream.cpp +++ b/Source/XnDDK/XnAudioStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -89,8 +83,6 @@ XnStatus XnAudioStream::SetNumberOfChannels(XnUInt32 nNumberOfChannels) XnStatus XnAudioStream::CalcRequiredSize(XnUInt32* pnRequiredSize) const { - XnStatus nRetVal = XN_STATUS_OK; - XnUInt32 nSampleSize = 2 * m_nMaxNumberOfChannels; // 16-bit per channel (2 bytes) XnUInt32 nSamples = (XnUInt32)(GetSampleRate() * XN_AUDIO_STREAM_BUFFER_SIZE_IN_SECONDS); @@ -99,13 +91,13 @@ XnStatus XnAudioStream::CalcRequiredSize(XnUInt32* pnRequiredSize) const return (XN_STATUS_OK); } -XnStatus XnAudioStream::SetSampleRateCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XnAudioStream::SetSampleRateCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnAudioStream* pStream = (XnAudioStream*)pCookie; return pStream->SetSampleRate((XnSampleRate)nValue); } -XnStatus XnAudioStream::SetNumberOfChannelsCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XnAudioStream::SetNumberOfChannelsCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnAudioStream* pStream = (XnAudioStream*)pCookie; return pStream->SetNumberOfChannels((XnUInt32)nValue); diff --git a/Source/XnDDK/XnAudioStream.h b/Source/XnDDK/XnAudioStream.h index a9bb13e..b597a67 100644 --- a/Source/XnDDK/XnAudioStream.h +++ b/Source/XnDDK/XnAudioStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_AUDIO_STREAM_H__ #define __XN_AUDIO_STREAM_H__ diff --git a/Source/XnDDK/XnBackwardsCompatibility36.cpp b/Source/XnDDK/XnBackwardsCompatibility36.cpp index b6fc095..fa3a69c 100644 --- a/Source/XnDDK/XnBackwardsCompatibility36.cpp +++ b/Source/XnDDK/XnBackwardsCompatibility36.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,8 +31,6 @@ //--------------------------------------------------------------------------- XnStatus XnBCDepthFormatToOutputFormat(XnStreamDepthFormat nDepthFormat, XnOutputFormats* pnOutputFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nDepthFormat) { case XN_DEPTH_FORMAT_RAW10: @@ -57,8 +49,6 @@ XnStatus XnBCDepthFormatToOutputFormat(XnStreamDepthFormat nDepthFormat, XnOutpu XnStatus XnBCOutputFormatToDepthFormat(XnOutputFormats nOutputFormat, XnStreamDepthFormat* pnDepthFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nOutputFormat) { case XN_OUTPUT_FORMAT_DEPTH_VALUES: @@ -76,8 +66,6 @@ XnStatus XnBCOutputFormatToDepthFormat(XnOutputFormats nOutputFormat, XnStreamDe XnStatus XnBCImageFormatToOutputFormat(XnStreamImageFormat nImageFormat, XnOutputFormats* pnOutputFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nImageFormat) { case XN_IMAGE_FORMAT_GRAYSCALE8: @@ -98,8 +86,6 @@ XnStatus XnBCImageFormatToOutputFormat(XnStreamImageFormat nImageFormat, XnOutpu XnStatus XnBCOutputFormatToImageFormat(XnOutputFormats nOutputFormat, XnStreamImageFormat* pnImageFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nOutputFormat) { case XN_OUTPUT_FORMAT_GRAYSCALE8: @@ -123,8 +109,6 @@ XnStatus XnBCOutputFormatToImageFormat(XnOutputFormats nOutputFormat, XnStreamIm XnStatus XnBCAudioFormatToOutputFormat(XnStreamAudioFormat nAudioFormat, XnOutputFormats* pnOutputFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nAudioFormat) { case XN_AUDIO_FORMAT_PCM: @@ -139,8 +123,6 @@ XnStatus XnBCAudioFormatToOutputFormat(XnStreamAudioFormat nAudioFormat, XnOutpu XnStatus XnBCOutputFormatToAudioFormat(XnOutputFormats nOutputFormat, XnStreamAudioFormat* pnAudioFormat) { - XnStatus nRetVal = XN_STATUS_OK; - switch (nOutputFormat) { case XN_OUTPUT_FORMAT_PCM: diff --git a/Source/XnDDK/XnBackwardsCompatibility36.h b/Source/XnDDK/XnBackwardsCompatibility36.h index e48f096..01ed564 100644 --- a/Source/XnDDK/XnBackwardsCompatibility36.h +++ b/Source/XnDDK/XnBackwardsCompatibility36.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_BACKWARDS_COMPATIBILITY36_H__ #define __XN_BACKWARDS_COMPATIBILITY36_H__ diff --git a/Source/XnDDK/XnBufferPool.cpp b/Source/XnDDK/XnBufferPool.cpp index 20bad25..c150d87 100644 --- a/Source/XnDDK/XnBufferPool.cpp +++ b/Source/XnDDK/XnBufferPool.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -34,11 +28,11 @@ // Code //--------------------------------------------------------------------------- -XnBufferPool::XnBufferPool(XnUInt32 nBufferCount) : - m_nBufferCount(nBufferCount), +XnBufferPool::XnBufferPool() : m_nBufferSize(0), + m_nNextBufferID(0), m_hLock(NULL), - m_dump(XN_DUMP_CLOSED) + m_dump(NULL) {} XnBufferPool::~XnBufferPool() @@ -50,12 +44,13 @@ XnStatus XnBufferPool::Init(XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; - xnDumpInit(&m_dump, "BufferPool", "", "bufferpool_%x.txt", this); + m_dump = xnDumpFileOpen("BufferPool", "bufferpool_%x.txt", this); nRetVal = xnOSCreateCriticalSection(&m_hLock); XN_IS_STATUS_OK(nRetVal); // allocate buffers + xnDumpFileWriteString(m_dump, "Initializing with size %u\n", nBufferSize); nRetVal = ChangeBufferSize(nBufferSize); XN_IS_STATUS_OK(nRetVal); @@ -75,19 +70,24 @@ XnStatus XnBufferPool::ChangeBufferSize(XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; - xnDumpWriteString(m_dump, "changing buffer size to %d\n", nBufferSize); + xnDumpFileWriteString(m_dump, "Changing buffer size to %d\n", nBufferSize); xnOSEnterCriticalSection(&m_hLock); m_nBufferSize = nBufferSize; - nRetVal = AllocateBuffers(); + // first free old ones + FreeAll(FALSE); + + nRetVal = AllocateBuffers(nBufferSize); if (nRetVal != XN_STATUS_OK) { xnOSLeaveCriticalSection(&m_hLock); return (nRetVal); } + xnDumpFileWriteString(m_dump, "Buffers were allocated\n"); + xnOSLeaveCriticalSection(&m_hLock); return (XN_STATUS_OK); @@ -95,11 +95,11 @@ XnStatus XnBufferPool::ChangeBufferSize(XnUInt32 nBufferSize) void XnBufferPool::FreeAll(XnBool bForceDestroyOfLockedBuffers) { - XnStatus nRetVal = XN_STATUS_OK; - // free existing buffers - XnBuffersList::Iterator it = m_AllBuffers.begin(); - while (it != m_AllBuffers.end()) + xnDumpFileWriteString(m_dump, "freeing existing buffers...\n"); + + XnBuffersList::Iterator it = m_AllBuffers.Begin(); + while (it != m_AllBuffers.End()) { XnBuffersList::Iterator currIt = it; @@ -112,17 +112,43 @@ void XnBufferPool::FreeAll(XnBool bForceDestroyOfLockedBuffers) // check if item is in free list (or we're forcing deletion) if (bForceDestroyOfLockedBuffers || pBuffer->m_nRefCount == 0) { - DestroyBuffer(pBuffer); + xnDumpFileWriteString(m_dump, "\tdestroying buffer %u\n", pBuffer->m_nID); + DestroyBuffer((void*)pBuffer->GetData()); + XN_DELETE(pBuffer); m_AllBuffers.Remove(currIt); } else { // we can't free it, cause it's still locked. instead, mark it for deletion + xnDumpFileWriteString(m_dump, "\tBuffer %u can't be destroyed right now (locked). Just mark it for destruction.\n", pBuffer->m_nID); pBuffer->m_bDestroy = TRUE; } } m_FreeBuffers.Clear(); + + xnDumpFileWriteString(m_dump, "Buffers were freed\n"); +} + +XnStatus XnBufferPool::AddNewBuffer(void* pBuffer, XnUInt32 nSize) +{ + XnBufferInPool* pBufferInPool; + XN_VALIDATE_NEW(pBufferInPool, XnBufferInPool); + + xnOSEnterCriticalSection(&m_hLock); + + pBufferInPool->m_nID = m_nNextBufferID++; + pBufferInPool->SetExternalBuffer((XnUChar*)pBuffer, nSize); + + xnDumpFileWriteString(Dump(), "\tAdd new buffer %u with size %u at 0x%p\n", pBufferInPool->m_nID, nSize, pBuffer); + + // add it to free list + m_AllBuffers.AddLast(pBufferInPool); + m_FreeBuffers.AddLast(pBufferInPool); + + xnOSLeaveCriticalSection(&m_hLock); + + return XN_STATUS_OK; } XnStatus XnBufferPool::GetBuffer(XnBuffer** ppBuffer) @@ -131,8 +157,8 @@ XnStatus XnBufferPool::GetBuffer(XnBuffer** ppBuffer) xnOSEnterCriticalSection(&m_hLock); - XnBuffersList::Iterator it = m_FreeBuffers.begin(); - if (it == m_FreeBuffers.end()) + XnBuffersList::Iterator it = m_FreeBuffers.Begin(); + if (it == m_FreeBuffers.End()) { xnOSLeaveCriticalSection(&m_hLock); return XN_STATUS_ALLOC_FAILED; @@ -149,7 +175,7 @@ XnStatus XnBufferPool::GetBuffer(XnBuffer** ppBuffer) } pBuffer->m_nRefCount = 1; - xnDumpWriteString(m_dump, "%u taken from pool\n", pBuffer->m_nID); + xnDumpFileWriteString(m_dump, "%u taken from pool\n", pBuffer->m_nID); xnOSLeaveCriticalSection(&m_hLock); @@ -162,6 +188,7 @@ void XnBufferPool::AddRef(XnBuffer* pBuffer) { if (pBuffer == NULL) { + XN_ASSERT(FALSE); return; } @@ -169,7 +196,7 @@ void XnBufferPool::AddRef(XnBuffer* pBuffer) XnBufferInPool* pBufferInPool = (XnBufferInPool*)pBuffer; ++pBufferInPool->m_nRefCount; - xnDumpWriteString(m_dump, "%u add ref (%d)\n", pBufferInPool->m_nID, pBufferInPool->m_nRefCount); + xnDumpFileWriteString(m_dump, "%u add ref (%d)\n", pBufferInPool->m_nID, pBufferInPool->m_nRefCount); xnOSLeaveCriticalSection(&m_hLock); } @@ -178,6 +205,7 @@ void XnBufferPool::DecRef(XnBuffer* pBuffer) { if (pBuffer == NULL) { + XN_ASSERT(FALSE); return; } @@ -185,7 +213,7 @@ void XnBufferPool::DecRef(XnBuffer* pBuffer) xnOSEnterCriticalSection(&m_hLock); - xnDumpWriteString(m_dump, "%u dec ref (%d)", pBufInPool->m_nID, pBufInPool->m_nRefCount-1); + xnDumpFileWriteString(m_dump, "%u dec ref (%d)", pBufInPool->m_nID, pBufInPool->m_nRefCount-1); if (--pBufInPool->m_nRefCount == 0) { @@ -193,22 +221,22 @@ void XnBufferPool::DecRef(XnBuffer* pBuffer) { // remove it from all buffers pool XnBuffersList::ConstIterator it = m_AllBuffers.Find(pBufInPool); - XN_ASSERT(it != m_AllBuffers.end()); + XN_ASSERT(it != m_AllBuffers.End()); m_AllBuffers.Remove(it); // and free it - DestroyBuffer(pBufInPool); - xnDumpWriteString(m_dump, "destroy!\n"); + DestroyBuffer((void*)pBufInPool->GetData()); + xnDumpFileWriteString(m_dump, "destroy!\n"); } else { // return it to free buffers list m_FreeBuffers.AddLast(pBufInPool); - xnDumpWriteString(m_dump, "return to pool!\n"); + xnDumpFileWriteString(m_dump, "return to pool!\n"); } } else { - xnDumpWriteString(m_dump, "\n"); + xnDumpFileWriteString(m_dump, "\n"); } xnOSLeaveCriticalSection(&m_hLock); diff --git a/Source/XnDDK/XnBufferPool.h b/Source/XnDDK/XnBufferPool.h index d6a3c1a..a591763 100644 --- a/Source/XnDDK/XnBufferPool.h +++ b/Source/XnDDK/XnBufferPool.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_BUFFER_POOL_H__ #define __XN_BUFFER_POOL_H__ @@ -32,7 +26,7 @@ // Includes //--------------------------------------------------------------------------- #include -#include +#include #include #include @@ -56,7 +50,7 @@ class XN_DDK_CPP_API XnBufferInPool : public XnBuffer class XN_DDK_CPP_API XnBufferPool { public: - XnBufferPool(XnUInt32 nBufferCount); + XnBufferPool(); virtual ~XnBufferPool(); XnStatus Init(XnUInt32 nBufferSize); @@ -67,29 +61,28 @@ class XN_DDK_CPP_API XnBufferPool XnStatus GetBuffer(XnBuffer** ppBuffer); void AddRef(XnBuffer* pBuffer); - void DecRef(XnBuffer* pBuffer); inline void Lock() { xnOSEnterCriticalSection(&m_hLock); } inline void Unlock() { xnOSLeaveCriticalSection(&m_hLock); } - inline XnDump& Dump() { return m_dump; } - protected: - XN_DECLARE_LIST(XnBufferInPool*, XnBuffersList); - + inline XnDumpFile* Dump() { return m_dump; } + XnStatus AddNewBuffer(void* pBuffer, XnUInt32 nSize); void FreeAll(XnBool bForceDestroyOfLockedBuffers); - virtual XnStatus AllocateBuffers() = 0; - virtual void DestroyBuffer(XnBufferInPool* pBuffer) = 0; + virtual XnStatus AllocateBuffers(XnUInt32 nSize) = 0; + virtual void DestroyBuffer(void* pBuffer) = 0; + +private: + typedef XnListT XnBuffersList; -protected: XnUInt32 m_nBufferSize; - XnUInt32 m_nBufferCount; + XnUInt32 m_nNextBufferID; XnBuffersList m_AllBuffers; XnBuffersList m_FreeBuffers; // a list of available buffers XN_CRITICAL_SECTION_HANDLE m_hLock; - XnDump m_dump; + XnDumpFile* m_dump; }; #endif // __XN_BUFFER_POOL_H__ \ No newline at end of file diff --git a/Source/XnDDK/XnCodecFactory.cpp b/Source/XnDDK/XnCodecFactory.cpp index d65d649..8b809c5 100644 --- a/Source/XnDDK/XnCodecFactory.cpp +++ b/Source/XnDDK/XnCodecFactory.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -40,7 +34,7 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnStatus XnCodecFactory::Create(XnCompressionFormats nFormat, XnDeviceModule* pStream, const XnChar* StreamName, XnCodec** ppCodec) +XnStatus XnCodecFactory::Create(XnCompressionFormats nFormat, XnDeviceModule* pStream, const XnChar* /*StreamName*/, XnCodec** ppCodec) { XnStatus nRetVal = XN_STATUS_OK; XnCodec* pCodec = NULL; diff --git a/Source/XnDDK/XnCodecFactory.h b/Source/XnDDK/XnCodecFactory.h index 65c460d..df24d57 100644 --- a/Source/XnDDK/XnCodecFactory.h +++ b/Source/XnDDK/XnCodecFactory.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_CODEC_FACTORY_H__ #define __XN_CODEC_FACTORY_H__ diff --git a/Source/XnDDK/XnDDK.cpp b/Source/XnDDK/XnDDK.cpp index 1c2c67a..b4b75b0 100644 --- a/Source/XnDDK/XnDDK.cpp +++ b/Source/XnDDK/XnDDK.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,6 +26,7 @@ #include #include #include "XnDeviceManager.h" +#include // The following line is needed to be once in *ALL* of the high level shared library modules. DO NOT REMOVE!!! XN_API_EXPORT_INIT() @@ -142,3 +137,136 @@ XN_DDK_API XnStatus XnDDKShutdown() return (XN_STATUS_OK); } +XnResolution OldResToOpenNIRes(XnResolutions res) +{ + switch (res) + { + case XN_RESOLUTION_CUSTOM: return XN_RES_CUSTOM; + case XN_RESOLUTION_QVGA: return XN_RES_QVGA; + case XN_RESOLUTION_VGA: return XN_RES_VGA; + case XN_RESOLUTION_SXGA: return XN_RES_SXGA; + case XN_RESOLUTION_UXGA: return XN_RES_UXGA; + case XN_RESOLUTION_QQVGA: return XN_RES_QQVGA; + case XN_RESOLUTION_QCIF: return XN_RES_QCIF; + case XN_RESOLUTION_240P: return XN_RES_240P; + case XN_RESOLUTION_CIF: return XN_RES_CIF; + case XN_RESOLUTION_WVGA: return XN_RES_WVGA; + case XN_RESOLUTION_480P: return XN_RES_480P; + case XN_RESOLUTION_800_448: return XN_RES_CUSTOM; + case XN_RESOLUTION_SVGA: return XN_RES_SVGA; + case XN_RESOLUTION_576P: return XN_RES_576P; + case XN_RESOLUTION_DV: return XN_RES_DV; + case XN_RESOLUTION_720P: return XN_RES_720P; + case XN_RESOLUTION_1280_960: return XN_RES_CUSTOM; + default: + XN_ASSERT(FALSE); + return XN_RES_CUSTOM; + } +} + +XnResolutions OpenNIResToOldRes(XnResolution res) +{ + switch (res) + { + case XN_RES_CUSTOM: return XN_RESOLUTION_CUSTOM; + case XN_RES_QQVGA: return XN_RESOLUTION_QQVGA; + case XN_RES_CGA: return XN_RESOLUTION_CUSTOM; + case XN_RES_QVGA: return XN_RESOLUTION_QVGA; + case XN_RES_VGA: return XN_RESOLUTION_VGA; + case XN_RES_SVGA: return XN_RESOLUTION_SVGA; + case XN_RES_XGA: return XN_RESOLUTION_CUSTOM; + case XN_RES_720P: return XN_RESOLUTION_720P; + case XN_RES_SXGA: return XN_RESOLUTION_SXGA; + case XN_RES_UXGA: return XN_RESOLUTION_UXGA; + case XN_RES_1080P: return XN_RESOLUTION_CUSTOM; + case XN_RES_QCIF: return XN_RESOLUTION_QCIF; + case XN_RES_240P: return XN_RESOLUTION_240P; + case XN_RES_CIF: return XN_RESOLUTION_CIF; + case XN_RES_WVGA: return XN_RESOLUTION_WVGA; + case XN_RES_480P: return XN_RESOLUTION_480P; + case XN_RES_576P: return XN_RESOLUTION_576P; + case XN_RES_DV: return XN_RESOLUTION_DV; + default: + XN_ASSERT(FALSE); + return XN_RESOLUTION_CUSTOM; + } +} + +XN_DDK_API XnResolutions XnDDKGetResolutionFromXY(XnUInt32 nXRes, XnUInt32 nYRes) +{ + // check if this is a known OpenNI resolution + XnResolution res = xnResolutionGetFromXYRes(nXRes, nYRes); + if (res == XN_RES_CUSTOM) + { + // check if this is one of our special resolutions + if (nXRes == 800 && nYRes == 448) + { + return XN_RESOLUTION_800_448; + } + else if (nXRes == 1280 && nYRes == 960) + { + return XN_RESOLUTION_1280_960; + } + } + + return OpenNIResToOldRes(res); +} + +XN_DDK_API XnBool XnDDKGetXYFromResolution(XnResolutions res, XnUInt32* pnXRes, XnUInt32* pnYRes) +{ + // check if this is a known OpenNI resolution + XnResolution openRes = OldResToOpenNIRes(res); + if (openRes == XN_RES_CUSTOM) + { + // check if this is one of our special resolutions + if (res == XN_RESOLUTION_800_448) + { + *pnXRes = 800; + *pnYRes = 448; + return TRUE; + } + else if (res == XN_RESOLUTION_1280_960) + { + *pnXRes = 1280; + *pnYRes = 960; + return TRUE; + } + else + { + return FALSE; + } + } + else + { + *pnXRes = xnResolutionGetXRes(openRes); + *pnYRes = xnResolutionGetYRes(openRes); + return TRUE; + } +} + +XN_DDK_API const XnChar* XnDDKGetResolutionName(XnResolutions res) +{ + // check if this is a known OpenNI resolution + XnResolution openRes = OldResToOpenNIRes(res); + + if (openRes == XN_RES_CUSTOM) + { + // check if this is one of our special resolutions + if (res == XN_RESOLUTION_800_448) + { + return "800x448"; + } + else if (res == XN_RESOLUTION_1280_960) + { + return "1280x960"; + } + else + { + return "Custom"; + } + } + else + { + return xnResolutionGetName(openRes); + } +} diff --git a/Source/XnDDK/XnDDKStatus.cpp b/Source/XnDDK/XnDDKStatus.cpp index 07858c0..0ce9f68 100644 --- a/Source/XnDDK/XnDDKStatus.cpp +++ b/Source/XnDDK/XnDDKStatus.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnDataPacker.cpp b/Source/XnDDK/XnDataPacker.cpp index 1230dfd..dee6ea6 100644 --- a/Source/XnDDK/XnDataPacker.cpp +++ b/Source/XnDDK/XnDataPacker.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -171,43 +165,43 @@ XnStatus XnDataPacker::WritePropertySetProperties(const XnPropertySet* pSet) { XnStatus nRetVal = XN_STATUS_OK; - for (XnPropertySetData::Iterator it = pSet->pData->begin(); it != pSet->pData->end(); ++it) + for (XnPropertySetData::Iterator it = pSet->pData->Begin(); it != pSet->pData->End(); ++it) { - XnActualPropertiesHash* pModule = it.Value(); - for (XnActualPropertiesHash::ConstIterator itProp = pModule->begin(); itProp != pModule->end(); ++itProp) + XnActualPropertiesHash* pModule = it->Value(); + for (XnActualPropertiesHash::ConstIterator itProp = pModule->Begin(); itProp != pModule->End(); ++itProp) { - switch (itProp.Value()->GetType()) + switch (itProp->Value()->GetType()) { case XN_PROPERTY_TYPE_INTEGER: { - XnActualIntProperty* pProp = (XnActualIntProperty*)itProp.Value(); + XnActualIntProperty* pProp = (XnActualIntProperty*)itProp->Value(); nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_REAL: { - XnActualRealProperty* pProp = (XnActualRealProperty*)itProp.Value(); + XnActualRealProperty* pProp = (XnActualRealProperty*)itProp->Value(); nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_STRING: { - XnActualStringProperty* pProp = (XnActualStringProperty*)itProp.Value(); + XnActualStringProperty* pProp = (XnActualStringProperty*)itProp->Value(); nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_GENERAL: { - XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)itProp.Value(); + XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)itProp->Value(); nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", itProp.Value()->GetType()); + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", itProp->Value()->GetType()); } } } @@ -225,9 +219,9 @@ XnStatus XnDataPacker::WritePropertySetImpl(const XnPropertySet* pPropertySet) StartWritingIntenalObject(XN_PACKED_PROPERTY_SET); // Write module names - for (XnPropertySetData::Iterator it = pPropertySet->pData->begin(); it != pPropertySet->pData->end(); ++it) + for (XnPropertySetData::Iterator it = pPropertySet->pData->Begin(); it != pPropertySet->pData->End(); ++it) { - nRetVal = WriteString(it.Key()); + nRetVal = WriteString(it->Key()); XN_IS_STATUS_OK(nRetVal); } @@ -894,7 +888,7 @@ XnStatus XnDataPacker::FixReadBCObjects() // It is old version. Fix it. // read all module names (+ modules end marker) - while (TRUE) + for (;;) { nRetVal = ReadNextObjectImpl(); XN_IS_STATUS_OK(nRetVal); @@ -909,7 +903,7 @@ XnStatus XnDataPacker::FixReadBCObjects() } // read properties (+ properties end marker) - while (TRUE) + for (;;) { nRetVal = ReadNextObjectImpl(); XN_IS_STATUS_OK(nRetVal); @@ -964,7 +958,7 @@ XnStatus XnDataPacker::FixReadBCObjects() // move back to start m_nInternalBufferReadIndex = nStartReadIndex; // update size accordingly - pHeader->nSize = m_InternalBuffer.GetUnsafeWritePointer() - (XnUChar*)pHeader - sizeof(XnPackedDataHeader); + pHeader->nSize = (XnUInt32)(m_InternalBuffer.GetUnsafeWritePointer() - (XnUChar*)pHeader - sizeof(XnPackedDataHeader)); // now place header back at root object m_pCurrentHeader = pHeader; @@ -1035,7 +1029,7 @@ XnStatus XnDataPacker::WriteStringToBuffer(const XnChar* csString) XnStatus nRetVal = XN_STATUS_OK; // get length (including null termination) - XnUInt32 nLength = strlen(csString) + 1; + XnUInt32 nLength = (XnUInt32)strlen(csString) + 1; if (nLength >= XN_DEVICE_MAX_STRING_LENGTH) return (XN_STATUS_INTERNAL_BUFFER_TOO_SMALL); @@ -1079,7 +1073,7 @@ void XnDataPacker::StartWritingIntenalObject(XnUInt32 nType) void XnDataPacker::EndWritingInternalObject() { - m_pCurrentHeader->nSize = m_InternalBuffer.GetUnsafeWritePointer() - (XnUChar*)m_pCurrentHeader - sizeof(XnPackedDataHeader); + m_pCurrentHeader->nSize = (XnUInt32)(m_InternalBuffer.GetUnsafeWritePointer() - (XnUChar*)m_pCurrentHeader - sizeof(XnPackedDataHeader)); } XnStatus XnDataPacker::FlushInternalBuffer() diff --git a/Source/XnDDK/XnDataPacker.h b/Source/XnDDK/XnDataPacker.h index 064c469..7abd1e4 100644 --- a/Source/XnDDK/XnDataPacker.h +++ b/Source/XnDDK/XnDataPacker.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DATA_PACKER_H__ #define __XN_DATA_PACKER_H__ @@ -40,6 +35,8 @@ //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +typedef XnUInt32 XnPackedDataType; + typedef enum { XN_PACKED_PROPERTY_SET = 1, @@ -52,7 +49,7 @@ typedef enum XN_PACKED_STREAM_DATA = 8, XN_PACKED_END = 9, XN_PACKED_CUSTOM_MESSAGE = 2000, -} XnPackedDataType; +} XnPredefinedPackedDataType; struct XnPackedDataHeader; // Forward declaration diff --git a/Source/XnDDK/XnDepthStream.cpp b/Source/XnDDK/XnDepthStream.cpp index 06c8fc6..3435816 100644 --- a/Source/XnDDK/XnDepthStream.cpp +++ b/Source/XnDDK/XnDepthStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -53,9 +47,9 @@ XnDepthStream::XnDepthStream(const XnChar* csName, XnBool bAllowCustomResolution m_ZeroPlaneDistance(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE), m_ZeroPlanePixelSize(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE), m_EmitterDCmosDistance(XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE), + m_GetDCmosRCmosDistance(XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE), m_NoDepthValue(XN_STREAM_PROPERTY_NO_SAMPLE), - m_ShadowValue(XN_STREAM_PROPERTY_SHADOW), - m_S2DHelper(this) + m_ShadowValue(XN_STREAM_PROPERTY_SHADOW) { m_MinDepth.UpdateSetCallback(SetMinDepthCallback, this); m_MaxDepth.UpdateSetCallback(SetMaxDepthCallback, this); @@ -72,9 +66,9 @@ XnStatus XnDepthStream::Init() // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_MinDepth, &m_MaxDepth, &m_ConstShift, &m_PixelSizeFactor, &m_MaxShift, &m_ParamCoefficient, &m_ShiftScale, &m_ZeroPlaneDistance, &m_ZeroPlanePixelSize, - &m_EmitterDCmosDistance, &m_NoDepthValue, &m_ShadowValue, &m_DeviceMaxDepth); + &m_EmitterDCmosDistance, &m_GetDCmosRCmosDistance, &m_NoDepthValue, &m_ShadowValue, &m_DeviceMaxDepth); - nRetVal = m_S2DHelper.Init(); + nRetVal = m_S2DHelper.Init(this); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -118,9 +112,7 @@ XnStatus XnDepthStream::SetMaxDepth(XnDepthPixel nMaxDepth) XnStatus XnDepthStream::ValidateDepthValue(XnDepthPixel nDepth) { - XnStatus nRetVal = XN_STATUS_OK; - - if (nDepth < 0 || nDepth > GetDeviceMaxDepth()) + if (nDepth > GetDeviceMaxDepth()) { return XN_STATUS_DEVICE_BAD_PARAM; } @@ -159,19 +151,19 @@ XnStatus XnDepthStream::OnOutputFormatChanged() return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnDepthStream::SetMinDepthCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDepthStream::SetMinDepthCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDepthStream* pStream = (XnDepthStream*)pCookie; return pStream->SetMinDepth((XnDepthPixel)nValue); } -XnStatus XN_CALLBACK_TYPE XnDepthStream::SetMaxDepthCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDepthStream::SetMaxDepthCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDepthStream* pStream = (XnDepthStream*)pCookie; return pStream->SetMaxDepth((XnDepthPixel)nValue); } -XnStatus XN_CALLBACK_TYPE XnDepthStream::OutputFormatValueChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDepthStream::OutputFormatValueChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnDepthStream* pStream = (XnDepthStream*)pCookie; return pStream->OnOutputFormatChanged(); diff --git a/Source/XnDDK/XnDepthStream.h b/Source/XnDDK/XnDepthStream.h index 75e7957..1bdc666 100644 --- a/Source/XnDDK/XnDepthStream.h +++ b/Source/XnDDK/XnDepthStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEPTH_STREAM_H__ #define __XN_DEPTH_STREAM_H__ @@ -64,6 +59,7 @@ class XN_DDK_CPP_API XnDepthStream : public XnPixelStream inline XnDepthPixel GetZeroPlaneDistance() const { return (XnDepthPixel)m_ZeroPlaneDistance.GetValue(); } inline XnDouble GetZeroPlanePixelSize() const { return m_ZeroPlanePixelSize.GetValue(); } inline XnDouble GetEmitterDCmosDistance() const { return m_EmitterDCmosDistance.GetValue(); } + inline XnDouble GetDCmosRCmosDistance() const { return m_GetDCmosRCmosDistance.GetValue(); } inline XnDepthPixel GetNoDepthValue() const { return (XnDepthPixel)m_NoDepthValue.GetValue(); } inline XnDepthPixel GetShadowValue() const { return (XnDepthPixel)m_ShadowValue.GetValue(); } @@ -85,6 +81,7 @@ class XN_DDK_CPP_API XnDepthStream : public XnPixelStream inline XnActualIntProperty& ZeroPlaneDistanceProperty() { return m_ZeroPlaneDistance; } inline XnActualRealProperty& ZeroPlanePixelSizeProperty() { return m_ZeroPlanePixelSize; } inline XnActualRealProperty& EmitterDCmosDistanceProperty() { return m_EmitterDCmosDistance; } + inline XnActualRealProperty& GetDCmosRCmosDistanceProperty() { return m_GetDCmosRCmosDistance; } inline XnActualIntProperty& NoDepthValueProperty() { return m_NoDepthValue; } inline XnActualIntProperty& ShadowValueProperty() { return m_ShadowValue; } @@ -122,6 +119,7 @@ class XN_DDK_CPP_API XnDepthStream : public XnPixelStream XnActualIntProperty m_ZeroPlaneDistance; XnActualRealProperty m_ZeroPlanePixelSize; XnActualRealProperty m_EmitterDCmosDistance; + XnActualRealProperty m_GetDCmosRCmosDistance; XnActualIntProperty m_NoDepthValue; XnActualIntProperty m_ShadowValue; diff --git a/Source/XnDDK/XnDeviceBase.cpp b/Source/XnDDK/XnDeviceBase.cpp index 959ed6f..6007ea3 100644 --- a/Source/XnDDK/XnDeviceBase.cpp +++ b/Source/XnDDK/XnDeviceBase.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -58,26 +52,6 @@ typedef struct XnWaitForStreamData XnDeviceStream* pStream; } XnWaitForStreamData; -typedef struct XnPropertyCallback -{ - XnPropertyCallback(XnDeviceHandle DeviceHandle, const XnChar* strModule, const XnChar* strProp, XnDeviceOnPropertyChangedEventHandler pHandler, void* pCookie) : - DeviceHandle(DeviceHandle), - pHandler(pHandler), - pCookie(pCookie) - { - strcpy(this->strModule, strModule); - strcpy(this->strProp, strProp); - } - - XnDeviceHandle DeviceHandle; - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - XnDeviceOnPropertyChangedEventHandler pHandler; - void* pCookie; - XnCallbackHandle hCallback; - -} XnPropertyCallback; - //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- @@ -96,7 +70,7 @@ XnDeviceBase::XnDeviceBase(const XnChar* csName, XnBool bStrictProperties) : m_nLastReadFrameID(0), m_nLastTimestamp(0), m_nLastFrameID(0), - m_StreamsDataDump(XN_DUMP_CLOSED) + m_StreamsDataDump(NULL) { // update set callbacks m_PrimaryStream.UpdateSetCallback(SetPrimaryStreamCallback, this); @@ -168,7 +142,7 @@ XnStatus XnDeviceBase::InitImpl(const XnDeviceConfig* pDeviceConfig) XN_IS_STATUS_OK(nRetVal); // init dump - xnDumpInit(&m_StreamsDataDump, XN_DUMP_STREAMS_DATA, "", "%s.csv", XN_DUMP_STREAMS_DATA); + m_StreamsDataDump = xnDumpFileOpen(XN_DUMP_STREAMS_DATA, "%s.csv", XN_DUMP_STREAMS_DATA); return (XN_STATUS_OK); } @@ -180,7 +154,7 @@ XnStatus XnDeviceBase::Destroy() // free all modules while (m_Modules.Size() != 0) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)m_Modules.begin().Value(); + XnDeviceModuleHolder* pModuleHolder = m_Modules.Begin()->Value(); if (IsStream(pModuleHolder->GetModule())) { XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; @@ -191,11 +165,11 @@ XnStatus XnDeviceBase::Destroy() else { // free memory of registered properties to this module - FreeModuleRegisteredProperties(m_Modules.begin().Key()); + FreeModuleRegisteredProperties(m_Modules.Begin()->Key()); pModuleHolder->GetModule()->Free(); DestroyModule(pModuleHolder); - m_Modules.Remove(m_Modules.begin()); + m_Modules.Remove(m_Modules.Begin()); } } @@ -207,14 +181,13 @@ XnStatus XnDeviceBase::Destroy() xnOSCloseEvent(&m_hNewDataEvent); // close dump - xnDumpClose(&m_StreamsDataDump); + xnDumpFileClose(m_StreamsDataDump); return XN_STATUS_OK; } XnStatus XnDeviceBase::CreateModule(const XnChar* strName, XnDeviceModuleHolder** ppModuleHolder) { - XnStatus nRetVal = XN_STATUS_OK; XnDeviceModule* pModule; XnDeviceModuleHolder* pHolder; @@ -293,9 +266,9 @@ XnStatus XnDeviceBase::SetMirror(XnBool bMirror) XnStatus nRetVal = XN_STATUS_OK; // change all streams - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { XnDeviceStream* pStream = (XnDeviceStream*)pModuleHolder->GetModule(); @@ -323,8 +296,6 @@ XnStatus XnDeviceBase::SetHighresTimestamps(XnBool bHighRes) XnStatus XnDeviceBase::GetSupportedStreams(const XnChar** aStreamNames, XnUInt32* pnStreamNamesCount) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_OUTPUT_PTR(pnStreamNamesCount); // NOTE: we allow aStreamName to be NULL @@ -340,9 +311,9 @@ XnStatus XnDeviceBase::GetSupportedStreams(const XnChar** aStreamNames, XnUInt32 // now copy values nStreamsCount = 0; - for (XnStringsHash::Iterator it = m_SupportedStreams.begin(); it != m_SupportedStreams.end(); ++it) + for (XnStringsSet::Iterator it = m_SupportedStreams.Begin(); it != m_SupportedStreams.End(); ++it) { - aStreamNames[nStreamsCount] = it.Key(); + aStreamNames[nStreamsCount] = it->Key(); nStreamsCount++; } @@ -401,9 +372,9 @@ XnStatus XnDeviceBase::OpenAllStreams() xnLogVerbose(XN_MASK_DDK, "Opening all streams..."); // go over modules list, and look for closed streams - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { XnDeviceStream* pStream = (XnDeviceStream*)pModuleHolder->GetModule(); @@ -427,10 +398,9 @@ XnStatus XnDeviceBase::CloseAllStreams() xnLogVerbose(XN_MASK_DDK, "Closing all streams..."); // go over modules list, and look for closed streams - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - const XnChar* Name = it.Key(); - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { XnDeviceStream* pStream = (XnDeviceStream*)pModuleHolder->GetModule(); @@ -449,14 +419,12 @@ XnStatus XnDeviceBase::CloseAllStreams() XnStatus XnDeviceBase::GetStreamNames(const XnChar** pstrNames, XnUInt32* pnNamesCount) { - XnStatus nRetVal = XN_STATUS_OK; - // first we need to count them XnUInt32 nCount = 0; - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { nCount++; @@ -471,12 +439,12 @@ XnStatus XnDeviceBase::GetStreamNames(const XnChar** pstrNames, XnUInt32* pnName // OK. we have enough space. Copy into it nCount = 0; - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { - pstrNames[nCount] = it.Key(); + pstrNames[nCount] = it->Key(); nCount++; } } @@ -509,11 +477,11 @@ XnStatus XnDeviceBase::DoesModuleExist(const XnChar* ModuleName, XnBool* pbDoesE return XN_STATUS_OK; } -XnStatus XnDeviceBase::RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XnStatus XnDeviceBase::RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_INPUT_PTR(Handler); - return m_OnStreamsChangeEvent.Register((StreamCollectionChangedEvent::HandlerPtr)Handler, pCookie, phCallback); + return m_OnStreamsChangeEvent.Register((StreamCollectionChangedEvent::HandlerPtr)Handler, pCookie, hCallback); } XnStatus XnDeviceBase::UnregisterFromStreamsChange(XnCallbackHandle hCallback) @@ -549,11 +517,11 @@ XnStatus XnDeviceBase::DestroyStreamData(XnStreamData** ppStreamData) return XnStreamDataDestroy(ppStreamData); } -XnStatus XnDeviceBase::RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XnStatus XnDeviceBase::RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_INPUT_PTR(Handler); - return m_OnNewStreamDataEvent.Register(Handler, pCookie, phCallback); + return m_OnNewStreamDataEvent.Register(Handler, pCookie, hCallback); } XnStatus XnDeviceBase::UnregisterFromNewStreamData(XnCallbackHandle hCallback) @@ -686,7 +654,7 @@ XnStatus XnDeviceBase::Read(XnStreamDataSet* pStreamOutputSet) XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - xnDumpWriteString(m_StreamsDataDump, "%llu,Read Called\n", nNow); + xnDumpFileWriteString(m_StreamsDataDump, "%llu,Read Called\n", nNow); // First thing to do is wait for primary stream to advance. We do this BEFORE checking streams // because device streams might change during this wait. @@ -694,7 +662,7 @@ XnStatus XnDeviceBase::Read(XnStreamDataSet* pStreamOutputSet) XN_IS_STATUS_OK(nRetVal); xnOSGetHighResTimeStamp(&nNow); - xnDumpWriteString(m_StreamsDataDump, "%llu,Read Condition Met\n", nNow); + xnDumpFileWriteString(m_StreamsDataDump, "%llu,Read Condition Met\n", nNow); // take the list of stream output objects XnStreamData* apStreamOutputs[XN_DEVICE_BASE_MAX_STREAMS_COUNT]; @@ -793,8 +761,6 @@ XnStatus XnDeviceBase::Write(XnStreamDataSet* pStreamDataSet) XnStatus XnDeviceBase::Tell(XnUInt64* pnTimestamp) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_OUTPUT_PTR(pnTimestamp); *pnTimestamp = m_nLastTimestamp; @@ -804,8 +770,6 @@ XnStatus XnDeviceBase::Tell(XnUInt64* pnTimestamp) XnStatus XnDeviceBase::TellFrame(XnUInt32* pnFrameID) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_OUTPUT_PTR(pnFrameID); *pnFrameID = m_nLastFrameID; @@ -970,9 +934,9 @@ XnStatus XnDeviceBase::CreateStreamsFromFile(const XnChar* csINIFilePath, const XnUInt32 nStreamIndex = 0; XnChar csKeyName[XN_INI_MAX_LEN]; - while (TRUE) + for (;;) { - sprintf(csKeyName, "Stream%d_Type", nStreamIndex); + sprintf(csKeyName, "Stream%u_Type", nStreamIndex); XnChar csStreamType[XN_INI_MAX_LEN]; XnChar csStreamName[XN_INI_MAX_LEN]; @@ -984,7 +948,7 @@ XnStatus XnDeviceBase::CreateStreamsFromFile(const XnChar* csINIFilePath, const } // check if the stream has a name - sprintf(csKeyName, "Stream%d_Name", nStreamIndex); + sprintf(csKeyName, "Stream%u_Name", nStreamIndex); nRetVal = xnOSReadStringFromINI(csINIFilePath, csSectionName, csKeyName, csStreamName, XN_INI_MAX_LEN); if (nRetVal != XN_STATUS_OK) { @@ -1043,14 +1007,14 @@ XnStatus XnDeviceBase::BatchConfig(const XnPropertySet* pChangeSet) nRetVal = StartTransaction(); XN_IS_STATUS_OK(nRetVal); - for (XnPropertySetData::ConstIterator itModule = pChangeSet->pData->begin(); itModule != pChangeSet->pData->end(); ++itModule) + for (XnPropertySetData::ConstIterator itModule = pChangeSet->pData->Begin(); itModule != pChangeSet->pData->End(); ++itModule) { // find this module XnDeviceModule* pModule = NULL; - nRetVal = FindModule(itModule.Key(), &pModule); + nRetVal = FindModule(itModule->Key(), &pModule); XN_CHECK_RC_ROLLBACK(nRetVal); - nRetVal = pModule->BatchConfig(*itModule.Value()); + nRetVal = pModule->BatchConfig(*itModule->Value()); XN_CHECK_RC_ROLLBACK(nRetVal); } @@ -1082,9 +1046,9 @@ XnStatus XnDeviceBase::GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams / else { // enumerate over modules - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (bNoStreams && IsStream(pModuleHolder->GetModule())) continue; @@ -1097,7 +1061,7 @@ XnStatus XnDeviceBase::GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams / return XN_STATUS_OK; } -XnStatus XnDeviceBase::RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XnStatus XnDeviceBase::RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XnStatus nRetVal = XN_STATUS_OK; @@ -1105,11 +1069,11 @@ XnStatus XnDeviceBase::RegisterToPropertyChange(const XnChar* Module, const XnCh nRetVal = FindModule(Module, &pModule); XN_IS_STATUS_OK(nRetVal); - XnPropertyCallback* pRealCookie; + XnPropertyCallback* pRealCookie = NULL; XN_VALIDATE_NEW(pRealCookie, XnPropertyCallback, GetDeviceHandle(), Module, PropertyName, Handler, pCookie); // register - nRetVal = pModule->RegisterForOnPropertyValueChanged(PropertyName, PropertyValueChangedCallback, pRealCookie, &pRealCookie->hCallback); + nRetVal = pModule->RegisterForOnPropertyValueChanged(PropertyName, PropertyValueChangedCallback, pRealCookie, pRealCookie->hCallback); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pRealCookie); @@ -1118,7 +1082,7 @@ XnStatus XnDeviceBase::RegisterToPropertyChange(const XnChar* Module, const XnCh m_PropertyCallbacks.AddLast(pRealCookie); - *phCallback = pRealCookie; + hCallback = pRealCookie; return (XN_STATUS_OK); } @@ -1141,9 +1105,8 @@ XnStatus XnDeviceBase::UnregisterFromPropertyChange(const XnChar* Module, const nRetVal = pModule->UnregisterFromOnPropertyValueChanged(PropertyName, pRealCookie->hCallback); XN_IS_STATUS_OK(nRetVal); - XnValue val = pRealCookie; - XnList::Iterator it = m_PropertyCallbacks.Find(val); - if (it != m_PropertyCallbacks.end()) + PropertiesCallbacks::Iterator it = m_PropertyCallbacks.Find(pRealCookie); + if (it != m_PropertyCallbacks.End()) { m_PropertyCallbacks.Remove(it); } @@ -1163,8 +1126,7 @@ XnStatus XnDeviceBase::AddModule(XnDeviceModuleHolder* pModuleHolder) XnDeviceModule* pModule = pModuleHolder->GetModule(); // make sure module doesn't exist yet - XnStringsHash::Iterator it = m_Modules.end(); - if (XN_STATUS_OK == m_Modules.Find(pModule->GetName(), it)) + if (m_Modules.Find(pModule->GetName()) != m_Modules.End()) { xnLogError(XN_MASK_DEVICE, "A module with the name %s already exists!", pModule->GetName()); return XN_STATUS_ERROR; @@ -1180,8 +1142,7 @@ XnStatus XnDeviceBase::AddModule(XnDeviceModuleHolder* pModuleHolder) XnStatus XnDeviceBase::RemoveModule(const XnChar* ModuleName) { // remove it - XnValue props; - XnStatus nRetVal = m_Modules.Remove(ModuleName, props); + XnStatus nRetVal = m_Modules.Remove(ModuleName); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; @@ -1202,15 +1163,15 @@ XnStatus XnDeviceBase::FindModule(const XnChar* ModuleName, XnDeviceModule** ppM XnStatus XnDeviceBase::FindModule(const XnChar* ModuleName, XnDeviceModuleHolder** ppModuleHolder) { - XnStringsHash::Iterator it = m_Modules.end(); - XnStatus nRetVal = m_Modules.Find(ModuleName, it); - if (nRetVal == XN_STATUS_NO_MATCH) + XnStatus nRetVal = XN_STATUS_OK; + ModuleHoldersHash::Iterator it = m_Modules.Find(ModuleName); + if (it == m_Modules.End()) { return (XN_STATUS_DEVICE_MODULE_NOT_FOUND); } XN_IS_STATUS_OK(nRetVal); - *ppModuleHolder = (XnDeviceModuleHolder*)it.Value(); + *ppModuleHolder = it->Value(); return XN_STATUS_OK; } @@ -1269,7 +1230,7 @@ XnStatus XnDeviceBase::FindStream(const XnChar* StreamName, XnDeviceModuleHolder XnStatus XnDeviceBase::AddSupportedStream(const XnChar* StreamType) { // make sure stream doesn't exist yet - XnStringsHash::Iterator it = m_SupportedStreams.end(); + XnStringsSet::Iterator it = m_SupportedStreams.End(); if (XN_STATUS_OK == m_SupportedStreams.Find(StreamType, it)) { xnLogError(XN_MASK_DEVICE, "A stream with the name %s already exists!", StreamType); @@ -1277,7 +1238,7 @@ XnStatus XnDeviceBase::AddSupportedStream(const XnChar* StreamType) } // add it to the list - XnStatus nRetVal = m_SupportedStreams.Set(StreamType, NULL); + XnStatus nRetVal = m_SupportedStreams.Set(StreamType); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; @@ -1301,16 +1262,16 @@ XnStatus XnDeviceBase::CreateStreams(const XnPropertySet* pSet) { XnStatus nRetVal = XN_STATUS_OK; - for (XnPropertySetData::ConstIterator it = pSet->pData->begin(); it != pSet->pData->end(); ++it) + for (XnPropertySetData::ConstIterator it = pSet->pData->Begin(); it != pSet->pData->End(); ++it) { // check if this module is a stream - XnActualPropertiesHash* pModule = it.Value(); + XnActualPropertiesHash* pModule = it->Value(); - XnActualPropertiesHash::ConstIterator itProp = pModule->end(); + XnActualPropertiesHash::ConstIterator itProp = pModule->End(); if (XN_STATUS_OK == pModule->Find(XN_STREAM_PROPERTY_TYPE, itProp)) { // create a copy of the properties - XnActualPropertiesHash streamProps(it.Key()); + XnActualPropertiesHash streamProps(it->Key()); nRetVal = streamProps.CopyFrom(*pModule); XN_IS_STATUS_OK(nRetVal); @@ -1319,8 +1280,8 @@ XnStatus XnDeviceBase::CreateStreams(const XnPropertySet* pSet) XN_IS_STATUS_OK(nRetVal); // and create the stream - XnActualStringProperty* pActualProp = (XnActualStringProperty*)itProp.Value(); - nRetVal = CreateStreamImpl(pActualProp->GetValue(), it.Key(), &streamProps); + XnActualStringProperty* pActualProp = (XnActualStringProperty*)itProp->Value(); + nRetVal = CreateStreamImpl(pActualProp->GetValue(), it->Key(), &streamProps); XN_IS_STATUS_OK(nRetVal); } } @@ -1330,20 +1291,18 @@ XnStatus XnDeviceBase::CreateStreams(const XnPropertySet* pSet) XnStatus XnDeviceBase::ValidateOnlyModule(const XnPropertySet* pSet, const XnChar* StreamName) { - XnStatus nRetVal = XN_STATUS_OK; - - XnPropertySetData::ConstIterator it = pSet->pData->begin(); - if (it == pSet->pData->end()) + XnPropertySetData::ConstIterator it = pSet->pData->Begin(); + if (it == pSet->pData->End()) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set did not contain any stream!"); } - if (strcmp(it.Key(), StreamName) != 0) + if (strcmp(it->Key(), StreamName) != 0) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set module name does not match stream name!"); } - if (++it != pSet->pData->end()) + if (++it != pSet->pData->End()) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set contains more than one module!"); } @@ -1367,7 +1326,7 @@ XnStatus XnDeviceBase::CreateStream(const XnChar* StreamType, const XnChar* Stre nRetVal = ValidateOnlyModule(pInitialValues, StreamName); XN_IS_STATUS_OK(nRetVal); - pInitialValuesHash = pInitialValues->pData->begin().Value(); + pInitialValuesHash = pInitialValues->pData->Begin()->Value(); } nRetVal = CreateStreamImpl(StreamType, StreamName, pInitialValuesHash); @@ -1430,7 +1389,7 @@ XnStatus XnDeviceBase::CreateStreamImpl(const XnChar* strType, const XnChar* str if (pInitialSet != NULL) { - XnActualPropertiesHash::ConstIterator it = pInitialSet->end(); + XnActualPropertiesHash::ConstIterator it = pInitialSet->End(); if (XN_STATUS_OK == pInitialSet->Find(XN_MODULE_PROPERTY_MIRROR, it)) { bSetMirror = FALSE; @@ -1468,8 +1427,6 @@ XnStatus XnDeviceBase::CreateStreamImpl(const XnChar* strType, const XnChar* str XnStatus XnDeviceBase::StreamAdded(XnDeviceStream* pStream) { - XnStatus nRetVal = XN_STATUS_OK; - // register to the NewData event if (m_ReadWriteMode.GetValue() == XN_DEVICE_MODE_READ) { @@ -1477,7 +1434,11 @@ XnStatus XnDeviceBase::StreamAdded(XnDeviceStream* pStream) } // raise the change event - m_OnStreamsChangeEvent.Raise(GetDeviceHandle(), pStream->GetName(), XN_DEVICE_STREAM_ADDED); + XnStreamCollectionChangedEventArgs eventArgs; + eventArgs.deviceHandle = GetDeviceHandle(); + eventArgs.strStreamName = pStream->GetName(); + eventArgs.eventType = XN_DEVICE_STREAM_ADDED; + m_OnStreamsChangeEvent.Raise(eventArgs); return (XN_STATUS_OK); } @@ -1485,13 +1446,13 @@ XnStatus XnDeviceBase::StreamAdded(XnDeviceStream* pStream) void XnDeviceBase::FreeModuleRegisteredProperties(const XnChar* strModule) { // free memory of registered properties to this stream - XnList::Iterator it = m_PropertyCallbacks.begin(); - while (it != m_PropertyCallbacks.end()) + PropertiesCallbacks::Iterator it = m_PropertyCallbacks.Begin(); + while (it != m_PropertyCallbacks.End()) { - XnList::Iterator cur = it; + PropertiesCallbacks::Iterator cur = it; it++; - XnPropertyCallback* pRealCallback = (XnPropertyCallback*)*cur; + XnPropertyCallback* pRealCallback = *cur; if (strcmp(pRealCallback->strModule, strModule) == 0) { m_PropertyCallbacks.Remove(cur); @@ -1526,7 +1487,12 @@ XnStatus XnDeviceBase::DestroyStream(const XnChar* StreamName) FreeModuleRegisteredProperties(StreamName); // raise event - m_OnStreamsChangeEvent.Raise(GetDeviceHandle(), strStreamName, XN_DEVICE_STREAM_DELETED); + // raise the change event + XnStreamCollectionChangedEventArgs eventArgs; + eventArgs.deviceHandle = GetDeviceHandle(); + eventArgs.strStreamName = strStreamName; + eventArgs.eventType = XN_DEVICE_STREAM_DELETED; + m_OnStreamsChangeEvent.Raise(eventArgs); xnLogVerbose(XN_MASK_DDK, "'%s' stream destroyed.", strStreamName); @@ -1537,9 +1503,9 @@ XnStatus XnDeviceBase::GetModulesList(XnDeviceModuleHolder** apModules, XnUInt32 { XnUInt32 nCount = 0; - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - apModules[nCount] = (XnDeviceModuleHolder*)it.Value(); + apModules[nCount] = it->Value(); nCount++; } @@ -1550,13 +1516,11 @@ XnStatus XnDeviceBase::GetModulesList(XnDeviceModuleHolder** apModules, XnUInt32 XnStatus XnDeviceBase::GetModulesList(XnDeviceModuleHolderList& list) { - XnStatus nRetVal = XN_STATUS_OK; - list.Clear(); - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - list.AddLast((XnDeviceModuleHolder*)it.Value()); + list.AddLast(it->Value()); } return (XN_STATUS_OK); @@ -1564,13 +1528,11 @@ XnStatus XnDeviceBase::GetModulesList(XnDeviceModuleHolderList& list) XnStatus XnDeviceBase::GetStreamsList(XnDeviceModuleHolderList& list) { - XnStatus nRetVal = XN_STATUS_OK; - list.Clear(); - for (XnStringsHash::Iterator it = m_Modules.begin(); it != m_Modules.end(); ++it) + for (ModuleHoldersHash::Iterator it = m_Modules.Begin(); it != m_Modules.End(); ++it) { - XnDeviceModuleHolder* pModuleHolder = (XnDeviceModuleHolder*)it.Value(); + XnDeviceModuleHolder* pModuleHolder = it->Value(); if (IsStream(pModuleHolder->GetModule())) { list.AddLast(pModuleHolder); @@ -1582,7 +1544,10 @@ XnStatus XnDeviceBase::GetStreamsList(XnDeviceModuleHolderList& list) XnStatus XnDeviceBase::RaiseNewStreamDataEvent(const XnChar* StreamName) { - m_OnNewStreamDataEvent.Raise(GetDeviceHandle(), StreamName); + XnNewStreamDataEventArgs eventArgs; + eventArgs.deviceHandle = GetDeviceHandle(); + eventArgs.strStreamName = StreamName; + m_OnNewStreamDataEvent.Raise(eventArgs); return XN_STATUS_OK; } @@ -1591,7 +1556,7 @@ void XnDeviceBase::OnNewStreamData(XnDeviceStream* pStream, XnUInt64 nTimestamp, { XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - xnDumpWriteString(m_StreamsDataDump, "%llu,%s,%llu,%u\n", nNow, pStream->GetName(), nTimestamp, nFrameID); + xnDumpFileWriteString(m_StreamsDataDump, "%llu,%s,%llu,%u\n", nNow, pStream->GetName(), nTimestamp, nFrameID); if (strcmp(m_PrimaryStream.GetValue(), XN_PRIMARY_STREAM_ANY) == 0 || strcmp(m_PrimaryStream.GetValue(), XN_PRIMARY_STREAM_NONE) == 0) @@ -1735,7 +1700,7 @@ XnStatus XnDeviceBase::WaitForPrimaryStream(XN_EVENT_HANDLE hNewDataEvent, XnStr return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnDeviceBase::PropertyValueChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceBase::PropertyValueChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnPropertyCallback* pUserCallback = (XnPropertyCallback*)pCookie; @@ -1745,21 +1710,29 @@ XnStatus XN_CALLBACK_TYPE XnDeviceBase::PropertyValueChangedCallback(const XnPro return XN_STATUS_OK; } -XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetPrimaryStreamCallback(XnActualStringProperty* pSender, const XnChar* strValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetPrimaryStreamCallback(XnActualStringProperty* /*pSender*/, const XnChar* strValue, void* pCookie) { XnDeviceBase* pThis = (XnDeviceBase*)pCookie; return pThis->SetPrimaryStream(strValue); } -XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetMirrorCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetMirrorCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceBase* pThis = (XnDeviceBase*)pCookie; return pThis->SetMirror((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetHighresTimestampsCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceBase::SetHighresTimestampsCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceBase* pThis = (XnDeviceBase*)pCookie; return pThis->SetHighresTimestamps((XnBool)nValue); } +XnDeviceBase::XnPropertyCallback::XnPropertyCallback(XnDeviceHandle DeviceHandle, const XnChar* strModule, const XnChar* strProp, XnDeviceOnPropertyChangedEventHandler pHandler, void* pCookie) : + DeviceHandle(DeviceHandle), + pHandler(pHandler), + pCookie(pCookie) +{ + strcpy(this->strModule, strModule); + strcpy(this->strProp, strProp); +} diff --git a/Source/XnDDK/XnDeviceBase.h b/Source/XnDDK/XnDeviceBase.h index 50e1ab4..8023bb9 100644 --- a/Source/XnDDK/XnDeviceBase.h +++ b/Source/XnDDK/XnDeviceBase.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_BASE_H__ #define __XN_DEVICE_BASE_H__ @@ -31,11 +26,11 @@ // Includes //--------------------------------------------------------------------------- #include -#include +#include #include #include #include "XnDeviceModuleHolder.h" -#include +#include #include #include #include @@ -101,11 +96,11 @@ class XN_DDK_CPP_API XnDeviceBase : public IXnDevice virtual XnStatus DoesModuleExist(const XnChar* ModuleName, XnBool* pbDoesExist); virtual XnStatus OpenAllStreams(); virtual XnStatus CloseAllStreams(); - virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback); + virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback); virtual XnStatus UnregisterFromStreamsChange(XnCallbackHandle hCallback); virtual XnStatus CreateStreamData(const XnChar* StreamName, XnStreamData** ppStreamData); static XnStatus DestroyStreamData(XnStreamData** ppStreamData); - virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback); + virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback); virtual XnStatus UnregisterFromNewStreamData(XnCallbackHandle hCallback); virtual XnStatus IsNewDataAvailable(const XnChar* StreamName, XnBool* pbNewDataAvailable, XnUInt64* pnTimestamp); virtual XnStatus ReadStream(XnStreamData* pStreamOutput); @@ -127,14 +122,14 @@ class XN_DDK_CPP_API XnDeviceBase : public IXnDevice virtual XnStatus LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName); virtual XnStatus BatchConfig(const XnPropertySet* pChangeSet); virtual XnStatus GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams = FALSE, const XnChar* strModule = NULL); - virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback); + virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback); virtual XnStatus UnregisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback); - XN_DECLARE_EVENT_3ARG(StreamCollectionChangedEvent, StreamCollectionChangedEventInterface, XnDeviceHandle, DeviceHandle, const XnChar*, StreamName, XnStreamsChangeEventType, EventType); - StreamCollectionChangedEventInterface& OnStreamCollectionChangedEvent() { return m_OnStreamsChangeEvent; } + typedef XnEventT StreamCollectionChangedEvent; + StreamCollectionChangedEvent::TInterface& OnStreamCollectionChangedEvent() { return m_OnStreamsChangeEvent; } - XN_DECLARE_EVENT_2ARG(NewStreamDataEvent, NewStreamDataEventInterface, XnDeviceHandle, DeviceHandle, const XnChar*, StreamName); - NewStreamDataEventInterface& OnNewStreamDataEvent() { return m_OnNewStreamDataEvent; } + typedef XnEventT NewStreamDataEvent; + NewStreamDataEvent::TInterface& OnNewStreamDataEvent() { return m_OnNewStreamDataEvent; } protected: virtual XnStatus InitImpl(const XnDeviceConfig* pDeviceConfig); @@ -298,16 +293,30 @@ class XN_DDK_CPP_API XnDeviceBase : public IXnDevice static XnStatus XN_CALLBACK_TYPE StreamNewDataCallback(XnDeviceStream* pStream, void* pCookie); - XnStringsHash m_Modules; - XnStringsHash m_SupportedStreams; + typedef XnStringsHashT ModuleHoldersHash; + ModuleHoldersHash m_Modules; + + XnStringsSet m_SupportedStreams; + + struct XnPropertyCallback + { + XnPropertyCallback(XnDeviceHandle DeviceHandle, const XnChar* strModule, const XnChar* strProp, XnDeviceOnPropertyChangedEventHandler pHandler, void* pCookie); - XnList m_PropertyCallbacks; + XnDeviceHandle DeviceHandle; + XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; + XnDeviceOnPropertyChangedEventHandler pHandler; + void* pCookie; + XnCallbackHandle hCallback; + }; + typedef XnListT PropertiesCallbacks; + PropertiesCallbacks m_PropertyCallbacks; StreamCollectionChangedEvent m_OnStreamsChangeEvent; NewStreamDataEvent m_OnNewStreamDataEvent; XnSDKVersion m_SDKVersion; - XnDump m_StreamsDataDump; + XnDumpFile* m_StreamsDataDump; }; #endif //__XN_DEVICE_BASE_H__ diff --git a/Source/XnDDK/XnDeviceBaseProxy.cpp b/Source/XnDDK/XnDeviceBaseProxy.cpp index 828efd5..b0aba03 100644 --- a/Source/XnDDK/XnDeviceBaseProxy.cpp +++ b/Source/XnDDK/XnDeviceBaseProxy.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnDeviceBaseProxy.h b/Source/XnDDK/XnDeviceBaseProxy.h index 6424fee..0136dda 100644 --- a/Source/XnDDK/XnDeviceBaseProxy.h +++ b/Source/XnDDK/XnDeviceBaseProxy.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_BASE_PROXY_H__ #define __XN_DEVICE_BASE_PROXY_H__ @@ -115,10 +110,10 @@ class XN_DDK_CPP_API XnDeviceBaseProxy : public IXnDevice return m_pActual->CloseAllStreams(); } - virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_ACTUAL_DEVICE; - return m_pActual->RegisterToStreamsChange(Handler, pCookie, phCallback); + return m_pActual->RegisterToStreamsChange(Handler, pCookie, hCallback); } virtual XnStatus UnregisterFromStreamsChange(XnCallbackHandle hCallback) @@ -133,10 +128,10 @@ class XN_DDK_CPP_API XnDeviceBaseProxy : public IXnDevice return m_pActual->CreateStreamData(StreamName, ppStreamData); } - virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_ACTUAL_DEVICE; - return m_pActual->RegisterToNewStreamData(Handler, pCookie, phCallback); + return m_pActual->RegisterToNewStreamData(Handler, pCookie, hCallback); } virtual XnStatus UnregisterFromNewStreamData(XnCallbackHandle hCallback) @@ -277,10 +272,10 @@ class XN_DDK_CPP_API XnDeviceBaseProxy : public IXnDevice return m_pActual->GetAllProperties(pSet, bNoStreams, strModule); } - virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_ACTUAL_DEVICE; - return m_pActual->RegisterToPropertyChange(Module, PropertyName, Handler, pCookie, phCallback); + return m_pActual->RegisterToPropertyChange(Module, PropertyName, Handler, pCookie, hCallback); } virtual XnStatus UnregisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback) diff --git a/Source/XnDDK/XnDeviceFunctionsTypedefs.h b/Source/XnDDK/XnDeviceFunctionsTypedefs.h index b864975..7edb94c 100644 --- a/Source/XnDDK/XnDeviceFunctionsTypedefs.h +++ b/Source/XnDDK/XnDeviceFunctionsTypedefs.h @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_FUNCTIONS_TYPEDEFS_H__ #define __XN_DEVICE_FUNCTIONS_TYPEDEFS_H__ diff --git a/Source/XnDDK/XnDeviceInterfaceAdapter.h b/Source/XnDDK/XnDeviceInterfaceAdapter.h index 2fae8f0..30bf25f 100644 --- a/Source/XnDDK/XnDeviceInterfaceAdapter.h +++ b/Source/XnDDK/XnDeviceInterfaceAdapter.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_INTERFACE_ADAPTER_H__ #define __XN_DEVICE_INTERFACE_ADAPTER_H__ @@ -98,9 +93,9 @@ class XnDeviceInterfaceAdapter : public IXnDevice return m_pFuncs->CloseAllStreams(m_Handle); } - virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { - return m_pFuncs->RegisterToStreamsChange(m_Handle, Handler, pCookie, phCallback); + return m_pFuncs->RegisterToStreamsChange(m_Handle, Handler, pCookie, hCallback); } virtual XnStatus UnregisterFromStreamsChange(XnCallbackHandle hCallback) @@ -113,9 +108,9 @@ class XnDeviceInterfaceAdapter : public IXnDevice return m_pFuncs->CreateStreamData(m_Handle, StreamName, ppStreamData); } - virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { - return m_pFuncs->RegisterToNewStreamData(m_Handle, Handler, pCookie, phCallback); + return m_pFuncs->RegisterToNewStreamData(m_Handle, Handler, pCookie, hCallback); } virtual XnStatus UnregisterFromNewStreamData(XnCallbackHandle hCallback) @@ -218,9 +213,9 @@ class XnDeviceInterfaceAdapter : public IXnDevice return m_pFuncs->GetAllProperties(m_Handle, pSet, bNoStreams, strModule); } - virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) + virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { - return m_pFuncs->RegisterToPropertyChange(m_Handle, Module, PropertyName, Handler, pCookie, phCallback); + return m_pFuncs->RegisterToPropertyChange(m_Handle, Module, PropertyName, Handler, pCookie, hCallback); } virtual XnStatus UnRegisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback) diff --git a/Source/XnDDK/XnDeviceInterfaceImpl.h b/Source/XnDDK/XnDeviceInterfaceImpl.h index b725f7d..7362ba6 100644 --- a/Source/XnDDK/XnDeviceInterfaceImpl.h +++ b/Source/XnDDK/XnDeviceInterfaceImpl.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ /** * This file is intended to allow any IXnDevice derivative to export its interface for * a "C" environment. @@ -59,7 +53,11 @@ XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(Create)(XnDeviceHandle* pDeviceHandl { IXnDevice* pDevice = XN_NEW(XN_DEVICE_BASE_DERIVATIVE); XnStatus nRetVal = pDevice->Init(pDeviceConfig); - XN_IS_STATUS_OK(nRetVal); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pDevice); + return (nRetVal); + } *pDeviceHandle = pDevice->GetDeviceHandle(); @@ -132,10 +130,10 @@ XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(DoesModuleExist)(const XnDeviceHandl return pDevice->DoesModuleExist(ModuleName, pbDoesExist); } -XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToStreamsChange)(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToStreamsChange)(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { IXnDevice* pDevice = IXnDevice::GetFromDeviceHandle(DeviceHandle); - return pDevice->RegisterToStreamsChange(Handler, pCookie, phCallback); + return pDevice->RegisterToStreamsChange(Handler, pCookie, hCallback); } XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(UnregisterFromStreamsChange)(const XnDeviceHandle DeviceHandle, XnCallbackHandle hCallback) @@ -155,10 +153,10 @@ XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(DestroyStreamData)(XnStreamData** pp return XN_DEVICE_BASE_DERIVATIVE::DestroyStreamData(ppStreamData); } -XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToNewStreamData)(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToNewStreamData)(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { IXnDevice* pDevice = IXnDevice::GetFromDeviceHandle(DeviceHandle); - return pDevice->RegisterToNewStreamData(Handler, pCookie, phCallback); + return pDevice->RegisterToNewStreamData(Handler, pCookie, hCallback); } XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(UnregisterFromNewStreamData)(const XnDeviceHandle DeviceHandle, XnCallbackHandle hCallback) @@ -299,10 +297,10 @@ XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(GetAllProperties)(const XnDeviceHand return pDevice->GetAllProperties(pPropertySet, bNoStreams, strModule); } -XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(RegisterToPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { IXnDevice* pDevice = IXnDevice::GetFromDeviceHandle(DeviceHandle); - return pDevice->RegisterToPropertyChange(Module, PropertyName, Handler, pCookie, phCallback); + return pDevice->RegisterToPropertyChange(Module, PropertyName, Handler, pCookie, hCallback); } XN_DEVICE_API XnStatus XN_DEVICE_PROTO_NAME(UnregisterFromPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback) diff --git a/Source/XnDDK/XnDeviceManager.cpp b/Source/XnDDK/XnDeviceManager.cpp index 188e77c..803c2c5 100644 --- a/Source/XnDDK/XnDeviceManager.cpp +++ b/Source/XnDDK/XnDeviceManager.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -237,8 +231,6 @@ XnStatus XnDeviceManagerShutdown() XnStatus XnDeviceManagerGetDeviceList(XnDeviceDefinition* aDeviceDefinitions, XnUInt32* pnCount) { - XnStatus nRetVal = XN_STATUS_OK; - // check if device manager is initialized if (g_pDeviceManager == NULL) { diff --git a/Source/XnDDK/XnDeviceManager.h b/Source/XnDDK/XnDeviceManager.h index 20be6dc..ea9afba 100644 --- a/Source/XnDDK/XnDeviceManager.h +++ b/Source/XnDDK/XnDeviceManager.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_MANAGER_H__ #define __XN_DEVICE_MANAGER_H__ diff --git a/Source/XnDDK/XnDeviceModule.cpp b/Source/XnDDK/XnDeviceModule.cpp index d577714..fd27013 100644 --- a/Source/XnDDK/XnDeviceModule.cpp +++ b/Source/XnDDK/XnDeviceModule.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -77,7 +71,7 @@ XnStatus XnDeviceModule::AddProperty(XnProperty* pProperty) XnStatus nRetVal = XN_STATUS_OK; // make sure another property with this name doesn't exist - XnPropertiesHash::Iterator it = m_Properties.end(); + XnPropertiesHash::Iterator it = m_Properties.End(); if (XN_STATUS_NO_MATCH != m_Properties.Find(pProperty->GetName(), it)) return XN_STATUS_DEVICE_PROPERTY_ALREADY_EXISTS; @@ -108,7 +102,7 @@ XnStatus XnDeviceModule::DoesPropertyExist(const XnChar* strName, XnBool* pbDoes *pbDoesExist = FALSE; - XnPropertiesHash::ConstIterator it = m_Properties.end(); + XnPropertiesHash::ConstIterator it = m_Properties.End(); nRetVal = m_Properties.Find(strName, it); if (nRetVal != XN_STATUS_NO_MATCH && nRetVal != XN_STATUS_OK) { @@ -334,7 +328,7 @@ XnStatus XnDeviceModule::UnsafeUpdateProperty(const XnChar* strName, const XnGen return (XN_STATUS_OK); } -XnStatus XnDeviceModule::RegisterForOnPropertyValueChanged(const XnChar* strName, XnProperty::OnValueChangedHandler pFunc, void* pCookie, XnCallbackHandle* pHandle) +XnStatus XnDeviceModule::RegisterForOnPropertyValueChanged(const XnChar* strName, XnProperty::OnValueChangedHandler pFunc, void* pCookie, XnCallbackHandle& hCallback) { XnStatus nRetVal = XN_STATUS_OK; @@ -342,7 +336,7 @@ XnStatus XnDeviceModule::RegisterForOnPropertyValueChanged(const XnChar* strName nRetVal = GetProperty(strName, &pProp); XN_IS_STATUS_OK(nRetVal); - nRetVal = pProp->OnChangeEvent().Register(pFunc, pCookie, pHandle); + nRetVal = pProp->OnChangeEvent().Register(pFunc, pCookie, hCallback); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -391,9 +385,9 @@ XnStatus XnDeviceModule::GetAllProperties(XnPropertySet* pSet) const XN_IS_STATUS_OK(nRetVal); // now add all properties - for (XnPropertiesHash::ConstIterator it = m_Properties.begin(); it != m_Properties.end(); ++it) + for (XnPropertiesHash::ConstIterator it = m_Properties.Begin(); it != m_Properties.End(); ++it) { - XnProperty* pProperty = it.Value(); + XnProperty* pProperty = it->Value(); if (pProperty->IsActual()) { @@ -416,9 +410,9 @@ XnStatus XnDeviceModule::LoadConfigFromFile(const XnChar* csINIFilePath, const X xnLogVerbose(XN_MASK_DDK, "Configuring module '%s' from section '%s' in file '%s'...", GetName(), strSectionName, csINIFilePath); - for (XnPropertiesHash::Iterator it = m_Properties.begin(); it != m_Properties.end(); ++it) + for (XnPropertiesHash::Iterator it = m_Properties.Begin(); it != m_Properties.End(); ++it) { - XnProperty* pProp = it.Value(); + XnProperty* pProp = it->Value(); // only read writable properties if (!pProp->IsReadOnly()) @@ -437,9 +431,9 @@ XnStatus XnDeviceModule::BatchConfig(const XnActualPropertiesHash& props) { XnStatus nRetVal = XN_STATUS_OK; - for (XnActualPropertiesHash::ConstIterator it = props.begin(); it != props.end(); ++it) + for (XnActualPropertiesHash::ConstIterator it = props.Begin(); it != props.End(); ++it) { - XnProperty* pRequestProp = it.Value(); + XnProperty* pRequestProp = it->Value(); switch (pRequestProp->GetType()) { case XN_PROPERTY_TYPE_INTEGER: @@ -482,9 +476,9 @@ XnStatus XnDeviceModule::UnsafeBatchConfig(const XnActualPropertiesHash& props) { XnStatus nRetVal = XN_STATUS_OK; - for (XnActualPropertiesHash::ConstIterator it = props.begin(); it != props.end(); ++it) + for (XnActualPropertiesHash::ConstIterator it = props.Begin(); it != props.End(); ++it) { - XnProperty* pRequestProp = it.Value(); + XnProperty* pRequestProp = it->Value(); switch (pRequestProp->GetType()) { case XN_PROPERTY_TYPE_INTEGER: @@ -547,7 +541,7 @@ XnStatus XnDeviceModule::SetLockState(XnBool bLocked) return (nRetVal); } -XnStatus XnDeviceModule::SetLockStateCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XnDeviceModule::SetLockStateCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceModule* pThis = (XnDeviceModule*)pCookie; return pThis->SetLockState(nValue != FALSE); diff --git a/Source/XnDDK/XnDeviceModule.h b/Source/XnDDK/XnDeviceModule.h index 45fbd92..edf7396 100644 --- a/Source/XnDDK/XnDeviceModule.h +++ b/Source/XnDDK/XnDeviceModule.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_MODULE_H__ #define __XN_DEVICE_MODULE_H__ @@ -31,7 +26,6 @@ // Includes //--------------------------------------------------------------------------- #include -#include #include #include #include @@ -81,7 +75,7 @@ class XN_DDK_CPP_API XnDeviceModule XnStatus GetAllProperties(XnPropertySet* pSet) const; - XnStatus RegisterForOnPropertyValueChanged(const XnChar* strName, XnProperty::OnValueChangedHandler pFunc, void* pCookie, XnCallbackHandle* pHandle); + XnStatus RegisterForOnPropertyValueChanged(const XnChar* strName, XnProperty::OnValueChangedHandler pFunc, void* pCookie, XnCallbackHandle& hCallback); XnStatus UnregisterFromOnPropertyValueChanged(const XnChar* strName, XnCallbackHandle hCallback); /** @@ -112,11 +106,11 @@ class XN_DDK_CPP_API XnDeviceModule }; #define XN_VALIDATE_ADD_PROPERTIES(pModule, ...) \ - do { \ + { \ XnProperty* _aProps[] = { __VA_ARGS__ }; \ XnStatus _nRetVal = (pModule)->AddProperties(_aProps, sizeof(_aProps)/sizeof(XnProperty*)); \ - XN_IS_STATUS_OK(_nRetVal); \ - } while (0) + XN_IS_STATUS_OK(_nRetVal); \ + } #endif //__XN_DEVICE_MODULE_H__ diff --git a/Source/XnDDK/XnDeviceModuleHolder.cpp b/Source/XnDDK/XnDeviceModuleHolder.cpp index 260fdc1..43c785d 100644 --- a/Source/XnDDK/XnDeviceModuleHolder.cpp +++ b/Source/XnDDK/XnDeviceModuleHolder.cpp @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #include "XnDeviceModuleHolder.h" #include "XnActualIntProperty.h" #include "XnActualRealProperty.h" @@ -70,8 +66,8 @@ XnStatus XnDeviceModuleHolder::Free() // them from Module). while (!m_Allocated.IsEmpty()) { - XnProperty* pProp = *(m_Allocated.begin()); - m_Allocated.Remove(m_Allocated.begin()); + XnProperty* pProp = *(m_Allocated.Begin()); + m_Allocated.Remove(m_Allocated.Begin()); XN_DELETE(pProp); } @@ -82,9 +78,9 @@ XnStatus XnDeviceModuleHolder::UnsafeSetProperties(const XnActualPropertiesHash& { XnStatus nRetVal = XN_STATUS_OK; - for (XnActualPropertiesHash::ConstIterator it = props.begin(); it != props.end(); ++it) + for (XnActualPropertiesHash::ConstIterator it = props.Begin(); it != props.End(); ++it) { - XnProperty* pRequestProp = it.Value(); + XnProperty* pRequestProp = it->Value(); XnProperty* pProp = NULL; // check if property already exist diff --git a/Source/XnDDK/XnDeviceModuleHolder.h b/Source/XnDDK/XnDeviceModuleHolder.h index 3e0447b..5ebfaf3 100644 --- a/Source/XnDDK/XnDeviceModuleHolder.h +++ b/Source/XnDDK/XnDeviceModuleHolder.h @@ -1,33 +1,30 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_MODULE_HOLDER_H__ #define __XN_DEVICE_MODULE_HOLDER_H__ #include "XnActualPropertiesHash.h" #include "XnDeviceModule.h" +#include class XN_DDK_CPP_API XnDeviceModuleHolder { @@ -58,7 +55,7 @@ class XN_DDK_CPP_API XnDeviceModuleHolder XnBool m_bAllowNewProps; }; -XN_DECLARE_LIST_DECL(XN_DDK_CPP_API, XnDeviceModuleHolder*, XnDeviceModuleHolderList) +typedef XnListT XnDeviceModuleHolderList; #endif //__XN_DEVICE_MODULE_HOLDER_H__ diff --git a/Source/XnDDK/XnDeviceProxy.cpp b/Source/XnDDK/XnDeviceProxy.cpp index 23ef5a9..4fda33f 100644 --- a/Source/XnDDK/XnDeviceProxy.cpp +++ b/Source/XnDDK/XnDeviceProxy.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,7 +26,7 @@ #include #include "XnDeviceManager.h" #include -#include +#include #include "XnDeviceInterfaceAdapter.h" #include @@ -52,19 +46,19 @@ typedef struct XnDeviceProxyDeviceHandle XnDeviceHandle ActualDevice; } XnDeviceProxyDeviceHandle; +typedef XnHashT XnStreamOutputHash; + //--------------------------------------------------------------------------- // Global Variables //--------------------------------------------------------------------------- /** Stores a hash of streamoutput objects to their creating device name. */ -XnHash g_StreamOutputHash; +XnStreamOutputHash g_StreamOutputHash; //--------------------------------------------------------------------------- // XnDeviceProxy functions //--------------------------------------------------------------------------- XN_DDK_API XnStatus XnDeviceProxyGetDeviceList(XnDeviceDefinition* aDeviceDefinitions, XnUInt32* pnCount) { - XnStatus nRetVal = XN_STATUS_OK; - // take definitions return XnDeviceManagerGetDeviceList(aDeviceDefinitions, pnCount); } @@ -241,7 +235,6 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(Enumerate)(XnConnectionString* aConnec XnUInt32 nDeviceCount = 0; XnConnectionString* pDeviceConnectionStrings = NULL; XnUInt32 nTotalCount = 0; - XnDeviceDescriptor* pDescriptor = NULL; XnChar csConnectionStringPrefix[XN_DEVICE_MAX_STRING_LENGTH]; XnUInt32 nBytesWritten = 0; @@ -288,7 +281,7 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(Create)(XnDeviceHandle* pDeviceHandle, // copy device name XnChar csDeviceName[XN_DEVICE_MAX_STRING_LENGTH]; - nRetVal = xnOSStrNCopy(csDeviceName, pDeviceConfig->cpConnectionString, pSeparator - pDeviceConfig->cpConnectionString, XN_DEVICE_MAX_STRING_LENGTH); + nRetVal = xnOSStrNCopy(csDeviceName, pDeviceConfig->cpConnectionString, (XnUInt32)(pSeparator - pDeviceConfig->cpConnectionString), XN_DEVICE_MAX_STRING_LENGTH); XN_IS_STATUS_OK(nRetVal); csDeviceName[pSeparator - pDeviceConfig->cpConnectionString] = '\0'; @@ -389,11 +382,11 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(DoesModuleExist)(const XnDeviceHandle return pHandle->pDesc->Interface.DoesModuleExist(pHandle->ActualDevice, ModuleName, pbDoesExist); } -XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToStreamsChange)(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToStreamsChange)(const XnDeviceHandle DeviceHandle, XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_INPUT_PTR(DeviceHandle); XnDeviceProxyDeviceHandle* pHandle = (XnDeviceProxyDeviceHandle*)DeviceHandle; - return pHandle->pDesc->Interface.RegisterToStreamsChange(pHandle->ActualDevice, Handler, pCookie, phCallback); + return pHandle->pDesc->Interface.RegisterToStreamsChange(pHandle->ActualDevice, Handler, pCookie, hCallback); } XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(UnregisterFromStreamsChange)(const XnDeviceHandle DeviceHandle, XnCallbackHandle hCallback) @@ -435,7 +428,7 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(DestroyStreamData)(XnStreamData** ppSt // find descriptor of the device that created this object XnDeviceDescriptor* pDesc = NULL; - nRetVal = g_StreamOutputHash.Get(*ppStreamData, (XnValue&)pDesc); + nRetVal = g_StreamOutputHash.Get(*ppStreamData, pDesc); XN_IS_STATUS_OK(nRetVal); // destroy the object @@ -443,16 +436,16 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(DestroyStreamData)(XnStreamData** ppSt XN_IS_STATUS_OK(nRetVal); // and remove it from map - g_StreamOutputHash.Remove(pObject, (XnValue&)pDesc); + g_StreamOutputHash.Remove(pObject); return (XN_STATUS_OK); } -XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToNewStreamData)(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToNewStreamData)(const XnDeviceHandle DeviceHandle, XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_INPUT_PTR(DeviceHandle); XnDeviceProxyDeviceHandle* pHandle = (XnDeviceProxyDeviceHandle*)DeviceHandle; - return pHandle->pDesc->Interface.RegisterToNewStreamData(pHandle->ActualDevice, Handler, pCookie, phCallback); + return pHandle->pDesc->Interface.RegisterToNewStreamData(pHandle->ActualDevice, Handler, pCookie, hCallback); } XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(UnregisterFromNewStreamData)(const XnDeviceHandle DeviceHandle, XnCallbackHandle hCallback) @@ -616,11 +609,11 @@ XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(GetAllProperties)(const XnDeviceHandle return pHandle->pDesc->Interface.GetAllProperties(pHandle->ActualDevice, pPropertySet, bNoStreams, strModule); } -XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) +XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(RegisterToPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle& hCallback) { XN_VALIDATE_INPUT_PTR(DeviceHandle); XnDeviceProxyDeviceHandle* pHandle = (XnDeviceProxyDeviceHandle*)DeviceHandle; - return pHandle->pDesc->Interface.RegisterToPropertyChange(pHandle->ActualDevice, Module, PropertyName, Handler, pCookie, phCallback); + return pHandle->pDesc->Interface.RegisterToPropertyChange(pHandle->ActualDevice, Module, PropertyName, Handler, pCookie, hCallback); } XN_DDK_API XnStatus XN_DEVICE_PROXY_PROTO(UnregisterFromPropertyChange)(const XnDeviceHandle DeviceHandle, const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback) diff --git a/Source/XnDDK/XnDeviceStream.cpp b/Source/XnDDK/XnDeviceStream.cpp index 4aab57a..5182f5e 100644 --- a/Source/XnDDK/XnDeviceStream.cpp +++ b/Source/XnDDK/XnDeviceStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -182,20 +176,10 @@ XnStatus XnDeviceStream::Read(XnStreamData* pStreamOutput) // and that we don't have new info m_bNewDataAvailable = FALSE; } - else - { - nRetVal = HandleNoNewData(pStreamOutput); - XN_IS_STATUS_OK(nRetVal); - } return (XN_STATUS_OK); } -XnStatus XnDeviceStream::HandleNoNewData(XnStreamData* pStreamOutput) -{ - return XN_STATUS_OK; -} - XnStatus XnDeviceStream::Write(XnStreamData* pStreamData) { XnStatus nRetVal = XN_STATUS_OK; @@ -220,7 +204,7 @@ XnStatus XnDeviceStream::RegisterRequiredSizeProperty(XnProperty* pProperty) XN_ASSERT(strcmp(pProperty->GetModule(), GetName()) == 0); XnCallbackHandle hCallbackDummy; - nRetVal = pProperty->OnChangeEvent().Register(UpdateRequiredSizeCallback, this, &hCallbackDummy); + nRetVal = pProperty->OnChangeEvent().Register(UpdateRequiredSizeCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); // recalculate it @@ -244,13 +228,13 @@ XnStatus XnDeviceStream::UpdateRequiredSize() return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnDeviceStream::UpdateRequiredSizeCallback(const XnProperty* pSenser, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceStream::UpdateRequiredSizeCallback(const XnProperty* /*pSenser*/, void* pCookie) { XnDeviceStream* pStream = (XnDeviceStream*)pCookie; return pStream->UpdateRequiredSize(); } -XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetIsOpenCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetIsOpenCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceStream* pStream = (XnDeviceStream*)pCookie; if (nValue == TRUE) @@ -263,13 +247,13 @@ XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetIsOpenCallback(XnActualIntProperty* } } -XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetOutputFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetOutputFormatCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceStream* pStream = (XnDeviceStream*)pCookie; return pStream->SetOutputFormat((XnOutputFormats)nValue); } -XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetIsMirrorCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnDeviceStream::SetIsMirrorCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnDeviceStream* pStream = (XnDeviceStream*)pCookie; return pStream->SetMirror((XnBool)nValue); diff --git a/Source/XnDDK/XnDeviceStream.h b/Source/XnDDK/XnDeviceStream.h index 6eefd38..098163f 100644 --- a/Source/XnDDK/XnDeviceStream.h +++ b/Source/XnDDK/XnDeviceStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_STREAM_H__ #define __XN_DEVICE_STREAM_H__ @@ -33,7 +28,6 @@ #include #include #include -#include #include //--------------------------------------------------------------------------- @@ -67,7 +61,7 @@ class XN_DDK_CPP_API XnDeviceStream : public XnDeviceModule void SetNewDataCallback(NewDataCallbackPtr pFunc, void* pCookie); /** Notifies new data is available in this stream. */ - void NewDataAvailable(XnUInt64 nTimestamp, XnUInt32 nFrameID); + virtual void NewDataAvailable(XnUInt64 nTimestamp, XnUInt32 nFrameID); void ResetLastTimestampAndFrameID(); @@ -101,6 +95,8 @@ class XN_DDK_CPP_API XnDeviceStream : public XnDeviceModule inline XN_CRITICAL_SECTION_HANDLE* GetLock() { return &m_hCriticalSection; } + inline void ResetNewDataAvailableFlag() { m_bNewDataAvailable = FALSE; } + protected: //--------------------------------------------------------------------------- // Virtual Functions @@ -114,8 +110,6 @@ class XN_DDK_CPP_API XnDeviceStream : public XnDeviceModule virtual XnStatus Mirror(XnStreamData* pStreamOutput) const = 0; /** Calculates the required size. */ virtual XnStatus CalcRequiredSize(XnUInt32* pnRequiredSize) const = 0; - /** Allows inheriting classes to do something when user called Read(), and there is no new data. */ - virtual XnStatus HandleNoNewData(XnStreamData* pStreamOutput); //--------------------------------------------------------------------------- // Utility Functions diff --git a/Source/XnDDK/XnExternalBufferPool.cpp b/Source/XnDDK/XnExternalBufferPool.cpp new file mode 100644 index 0000000..8f6d156 --- /dev/null +++ b/Source/XnDDK/XnExternalBufferPool.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnExternalBufferPool.h" + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnExternalBufferPool::XnExternalBufferPool() +{ +} + +XnExternalBufferPool::~XnExternalBufferPool() +{ + FreeAll(TRUE); +} + +XnStatus XnExternalBufferPool::SetBuffers(XnUInt32 nCount, const XnGeneralBuffer* aBuffers) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XN_VALIDATE_INPUT_PTR(aBuffers); + + // make sure we have at least 3 buffers (user, stable and working) + if (nCount < 3) + { + XN_LOG_WARNING_RETURN(XN_STATUS_BAD_PARAM, XN_MASK_DDK, "ExternalBufferPool: at least 3 buffers are required!"); + } + + m_buffers.Clear(); + + // add buffers to the list + for (XnUInt32 i = 0; i < nCount; ++i) + { + nRetVal = m_buffers.AddLast(aBuffers[i]); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnExternalBufferPool::AllocateBuffers(XnUInt32 nSize) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // make sure all buffers are in the correct size + for (XnUInt32 i = 0; i < m_buffers.GetSize(); ++i) + { + if (m_buffers[i].nDataSize < nSize) + { + return XN_STATUS_ALLOC_FAILED; + } + } + + // now "allocate" them + for (XnUInt32 i = 0; i < m_buffers.GetSize(); ++i) + { + nRetVal = AddNewBuffer(m_buffers[i].pData, m_buffers[i].nDataSize); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +void XnExternalBufferPool::DestroyBuffer(void* /*pBuffer*/) +{ +} diff --git a/Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.h b/Source/XnDDK/XnExternalBufferPool.h similarity index 53% rename from Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.h rename to Source/XnDDK/XnExternalBufferPool.h index 43b27ba..f44e0b2 100644 --- a/Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.h +++ b/Source/XnDDK/XnExternalBufferPool.h @@ -1,62 +1,52 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - -#ifndef __XN_SHARED_MEMORY_BUFFER_POOL_H__ -#define __XN_SHARED_MEMORY_BUFFER_POOL_H__ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef _XN_EXTERNAL_BUFFER_POOL_H_ +#define _XN_EXTERNAL_BUFFER_POOL_H_ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include +#include +#include //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- -class XnSharedMemoryBufferPool : public XnBufferPool +class XnExternalBufferPool : public XnBufferPool { public: - XnSharedMemoryBufferPool(XnUInt32 nBufferCount, const XnChar* strName, XnUInt32 nMaxBufferSize); - ~XnSharedMemoryBufferPool(); - - void Free(); + XnExternalBufferPool(); + ~XnExternalBufferPool(); - inline const XnChar* GetSharedMemoryName() const { return m_strName; } - - inline XnUInt32 GetBufferOffset(XnBuffer* pBuffer) const { return ((XnUChar*)pBuffer->GetData() - m_pSharedMemoryAddress); } + XnStatus SetBuffers(XnUInt32 nCount, const XnGeneralBuffer* aBuffers); protected: - virtual XnStatus AllocateBuffers(); - virtual void DestroyBuffer(XnBufferInPool* pBuffer); + virtual XnStatus AllocateBuffers(XnUInt32 nSize); + virtual void DestroyBuffer(void* pBuffer); private: - XnChar m_strName[XN_FILE_MAX_PATH]; - XnUInt32 m_nMaxBufferSize; - XN_SHARED_MEMORY_HANDLE m_hSharedMemory; - XnUChar* m_pSharedMemoryAddress; + XnArray m_buffers; }; -#endif // __XN_SHARED_MEMORY_BUFFER_POOL_H__ \ No newline at end of file + +#endif // _XN_EXTERNAL_BUFFER_POOL_H_ \ No newline at end of file diff --git a/Source/XnDDK/XnFrameBufferManager.cpp b/Source/XnDDK/XnFrameBufferManager.cpp index 816fca2..87edbe0 100644 --- a/Source/XnDDK/XnFrameBufferManager.cpp +++ b/Source/XnDDK/XnFrameBufferManager.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -57,9 +51,6 @@ XnStatus XnFrameBufferManager::Init(XnUInt32 nBufferSize) nRetVal = xnOSCreateCriticalSection(&m_hLock); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_pBufferPool->Init(nBufferSize); - XN_IS_STATUS_OK(nRetVal); - nRetVal = Reallocate(nBufferSize); XN_IS_STATUS_OK(nRetVal); @@ -92,11 +83,13 @@ XnStatus XnFrameBufferManager::Reallocate(XnUInt32 nBufferSize) if (m_pWorkingBuffer != NULL) { m_pBufferPool->DecRef(m_pWorkingBuffer); + m_pWorkingBuffer = NULL; } if (m_pStableBuffer != NULL) { m_pBufferPool->DecRef(m_pStableBuffer); + m_pStableBuffer = NULL; } // and take one @@ -150,6 +143,8 @@ void XnFrameBufferManager::MarkWriteBufferAsStable(XnUInt64 nTimestamp, XnUInt32 m_pStableBuffer = pPrevStable; m_pBufferPool->AddRef(m_pStableBuffer); m_pBufferPool->Unlock(); + + XN_ASSERT(FALSE); return; } @@ -160,7 +155,10 @@ void XnFrameBufferManager::MarkWriteBufferAsStable(XnUInt64 nTimestamp, XnUInt32 m_pWorkingBuffer->Reset(); // notify stream that new data is available - m_NewFrameEvent.Raise(this, m_nStableTimestamp); + NewFrameEventArgs args; + args.pTripleBuffer = this; + args.nTimestamp = m_nStableTimestamp; + m_NewFrameEvent.Raise(args); } void XnFrameBufferManager::ReadLastStableBuffer(XnBuffer** ppBuffer, XnUInt64* pnTimestamp, XnUInt32* pnFrameID) diff --git a/Source/XnDDK/XnFrameBufferManager.h b/Source/XnDDK/XnFrameBufferManager.h index fafa842..3496512 100644 --- a/Source/XnDDK/XnFrameBufferManager.h +++ b/Source/XnDDK/XnFrameBufferManager.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_MULTI_FRAME_BUFFER_H__ #define __XN_MULTI_FRAME_BUFFER_H__ @@ -32,7 +27,7 @@ //--------------------------------------------------------------------------- #include #include -#include +#include #include "XnBufferPool.h" //--------------------------------------------------------------------------- @@ -64,8 +59,14 @@ class XN_DDK_CPP_API XnFrameBufferManager inline XnUInt32 GetLastFrameID() const { return m_nStableFrameID; } - XN_DECLARE_EVENT_2ARG(NewFrameEvent, NewFrameEventInterface, XnFrameBufferManager*, pTripleBuffer, XnUInt64, nTimestamp); - NewFrameEventInterface& OnNewFrameEvent() { return m_NewFrameEvent; } + typedef struct NewFrameEventArgs + { + XnFrameBufferManager* pTripleBuffer; + XnUInt64 nTimestamp; + } NewFrameEventArgs; + + typedef XnEventT NewFrameEvent; + NewFrameEvent::TInterface& OnNewFrameEvent() { return m_NewFrameEvent; } private: XnBufferPool* m_pBufferPool; diff --git a/Source/XnDDK/XnFrameStream.cpp b/Source/XnDDK/XnFrameStream.cpp index 15370a4..61969aa 100644 --- a/Source/XnDDK/XnFrameStream.cpp +++ b/Source/XnDDK/XnFrameStream.cpp @@ -1,36 +1,31 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnFrameStream.h" #include "XnStreamDataInternal.h" #include "XnSimpleBufferPool.h" +#include "XnExternalBufferPool.h" //--------------------------------------------------------------------------- // Code @@ -40,6 +35,7 @@ XnFrameStream::XnFrameStream(const XnChar* csType, const XnChar* csName) : m_IsFrameStream(XN_STREAM_PROPERTY_IS_FRAME_BASED, TRUE), m_FPS(XN_STREAM_PROPERTY_FPS, 0), m_LastRawFrame(XN_STREAM_PROPERTY_LAST_RAW_FRAME), + m_externalBufferPool(XN_STREAM_PROPERTY_EXTERNAL_BUFFER_POOL), m_nLastReadFrame(0), m_bTripleBufferReallocated(FALSE), m_pBufferManager(NULL), @@ -48,18 +44,7 @@ XnFrameStream::XnFrameStream(const XnChar* csType, const XnChar* csName) : { m_FPS.UpdateSetCallback(SetFPSCallback, this); m_LastRawFrame.UpdateGetCallback(GetLastRawFrameCallback, this); -} - -XnStatus XnFrameStream::SetBufferPool(XnBufferPool* pBufferPool) -{ - // we only allow this if no buffer pool exists - if (m_pBufferPool != NULL) - { - return XN_STATUS_ERROR; - } - - m_pBufferPool = pBufferPool; - return (XN_STATUS_OK); + m_externalBufferPool.UpdateSetCallback(SetExternalBufferPoolCallback, this); } XnStatus XnFrameStream::Init() @@ -70,29 +55,47 @@ XnStatus XnFrameStream::Init() nRetVal = XnDeviceStream::Init(); XN_IS_STATUS_OK(nRetVal); - XN_VALIDATE_ADD_PROPERTIES(this, &m_IsFrameStream, &m_FPS, &m_LastRawFrame); + XN_VALIDATE_ADD_PROPERTIES(this, &m_IsFrameStream, &m_FPS, &m_LastRawFrame, &m_externalBufferPool ); XnCallbackHandle hDummy; // be notified when required size changes - nRetVal = RequiredSizeProperty().OnChangeEvent().Register(RequiredSizeChangedCallback, this, &hDummy); + nRetVal = RequiredSizeProperty().OnChangeEvent().Register(RequiredSizeChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); - if (m_pBufferPool == NULL) + return (XN_STATUS_OK); +} + +XnStatus XnFrameStream::GetTripleBuffer(XnFrameBufferManager** pBufferManager) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // lazy initialization (this allows us to set buffer pool after initialization of the stream + // and before data actually arrives (or stream data is allocated) + if (m_pBufferManager == NULL) { - XN_VALIDATE_NEW(m_pBufferPool, XnSimpleBufferPool, 3); - m_bPoolAllocated = TRUE; - } + if (m_pBufferPool == NULL) + { + XN_VALIDATE_NEW(m_pBufferPool, XnSimpleBufferPool, 3); + m_bPoolAllocated = TRUE; - // allocate buffer manager - XN_VALIDATE_NEW(m_pBufferManager, XnFrameBufferManager, m_pBufferPool); + nRetVal = m_pBufferPool->Init(GetRequiredDataSize()); + XN_IS_STATUS_OK(nRetVal); + } - nRetVal = m_pBufferManager->Init(GetRequiredDataSize()); - XN_IS_STATUS_OK(nRetVal); + // allocate buffer manager + XN_VALIDATE_NEW(m_pBufferManager, XnFrameBufferManager, m_pBufferPool); - // register for new data events - nRetVal = m_pBufferManager->OnNewFrameEvent().Register(OnTripleBufferNewData, this, &hDummy); - XN_IS_STATUS_OK(nRetVal); + nRetVal = m_pBufferManager->Init(GetRequiredDataSize()); + XN_IS_STATUS_OK(nRetVal); + + // register for new data events + XnCallbackHandle hDummy; + nRetVal = m_pBufferManager->OnNewFrameEvent().Register(OnTripleBufferNewData, this, hDummy); + XN_IS_STATUS_OK(nRetVal); + } + + *pBufferManager = m_pBufferManager; return (XN_STATUS_OK); } @@ -122,21 +125,34 @@ XnStatus XnFrameStream::CreateStreamData(XnStreamData** ppStreamData) XnStreamData* pStreamData; - // we create a StreamData object with no buffer allocated. The buffer will just be - // a pointer to the triple buffer - nRetVal = XnStreamDataCreateNoBuffer(&pStreamData, GetName()); - XN_IS_STATUS_OK(nRetVal); + // NOTE: in any case, we must make sure data is not null, because some old applications + // counts on it (they might read the data before the first frame). - // However, we don't want the user to get a null pointer, even if no new frame yet, - // so we'll initialize the data with one of the buffers - nRetVal = m_pBufferPool->GetBuffer(&pStreamData->pInternal->pLockedBuffer); - if (nRetVal != XN_STATUS_OK) + // check if the buffer pool has been set yet + if (m_pBufferPool == NULL) { - XnStreamDataDestroy(&pStreamData); - return (nRetVal); + // Create it with a buffer. This buffer will be later on freed when buffers from + // the buffer pool will be used. + nRetVal = XnStreamDataCreate(&pStreamData, GetName(), GetRequiredDataSize()); + XN_IS_STATUS_OK(nRetVal); + } + else + { + // we create a StreamData object with no buffer allocated. The buffer will just be + // a pointer from the buffer pool + nRetVal = XnStreamDataCreateNoBuffer(&pStreamData, GetName()); + XN_IS_STATUS_OK(nRetVal); + + // take a buffer from the pool + nRetVal = m_pBufferPool->GetBuffer(&pStreamData->pInternal->pLockedBuffer); + if (nRetVal != XN_STATUS_OK) + { + XnStreamDataDestroy(&pStreamData); + return (nRetVal); + } + + pStreamData->pData = (void*)pStreamData->pInternal->pLockedBuffer->GetData(); } - - pStreamData->pData = (void*)pStreamData->pInternal->pLockedBuffer->GetData(); *ppStreamData = pStreamData; @@ -157,6 +173,10 @@ XnStatus XnFrameStream::OnRequiredSizeChanging() { XnStatus nRetVal = XN_STATUS_OK; + // if the stream already notified it has new data, this must be undone, as we don't want + // the application getting frames of unexpected size + ResetNewDataAvailableFlag(); + nRetVal = ReallocTripleFrameBuffer(); XN_IS_STATUS_OK(nRetVal); @@ -167,10 +187,13 @@ XnStatus XnFrameStream::ReallocTripleFrameBuffer() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_pBufferManager->Reallocate(GetRequiredDataSize()); - XN_IS_STATUS_OK(nRetVal); + if (m_pBufferManager != NULL) + { + nRetVal = m_pBufferManager->Reallocate(GetRequiredDataSize()); + XN_IS_STATUS_OK(nRetVal); - m_bTripleBufferReallocated = TRUE; + m_bTripleBufferReallocated = TRUE; + } return (XN_STATUS_OK); } @@ -192,7 +215,17 @@ XnStatus XnFrameStream::ReadImpl(XnStreamData* pStreamOutput) XnStatus nRetVal = XN_STATUS_OK; // release previous buffer - m_pBufferPool->DecRef(pStreamOutput->pInternal->pLockedBuffer); + if (pStreamOutput->pInternal->pLockedBuffer != NULL) + { + m_pBufferPool->DecRef(pStreamOutput->pInternal->pLockedBuffer); + } + else if (pStreamOutput->pInternal->nAllocSize > 0) + { + // no need for this buffer, we're replacing it with a pointer to the + // buffer pool + nRetVal = XnStreamDataUpdateSize(pStreamOutput, 0); + XN_IS_STATUS_OK(nRetVal); + } m_pBufferManager->ReadLastStableBuffer( &pStreamOutput->pInternal->pLockedBuffer, @@ -209,19 +242,6 @@ XnStatus XnFrameStream::ReadImpl(XnStreamData* pStreamOutput) return XN_STATUS_OK; } -XnStatus XnFrameStream::HandleNoNewData(XnStreamData* pStreamOutput) -{ -/* // No new data, but if triple buffer was reallocated, we want the user buffer to be replaced - // (so that it has a buffer with a size that matches what he expects, even if no new data in it) - if (m_bTripleBufferReallocated && !pStreamOutput->pInternal->bAllocated) - { - XnFrameBuffer* pStableBuffer = m_pBufferManager->ReadLastStableBuffer(); - pStreamOutput->pData = (void*)pStableBuffer->DataBuf.GetData(); - } -*/ - return XN_STATUS_OK; -} - XnStatus XnFrameStream::GetLastRawFrame(XnDynamicSizeBuffer* pBuffer) { XnStatus nRetVal = XN_STATUS_OK; @@ -232,28 +252,66 @@ XnStatus XnFrameStream::GetLastRawFrame(XnDynamicSizeBuffer* pBuffer) return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnFrameStream::SetFPSCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie) +XnStatus XnFrameStream::SetExternalBufferPool(XnUInt32 nCount, XnGeneralBuffer* aBuffers) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_pBufferPool != NULL) + { + xnLogError(XN_MASK_DDK, "Cannot change buffer pool."); + return XN_STATUS_DEVICE_PROPERTY_READ_ONLY; + } + + XnExternalBufferPool* pExternalBufferPool; + XN_VALIDATE_NEW(pExternalBufferPool, XnExternalBufferPool); + + nRetVal = pExternalBufferPool->SetBuffers(nCount, aBuffers); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pExternalBufferPool); + return (nRetVal); + } + + nRetVal = pExternalBufferPool->Init(GetRequiredDataSize()); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pExternalBufferPool); + return (nRetVal); + } + + m_pBufferPool = pExternalBufferPool; + + return (XN_STATUS_OK); +} + +XnStatus XN_CALLBACK_TYPE XnFrameStream::SetFPSCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnFrameStream* pThis = (XnFrameStream*)pCookie; return pThis->SetFPS((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnFrameStream::RequiredSizeChangedCallback(const XnProperty* pSenser, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnFrameStream::RequiredSizeChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnFrameStream* pThis = (XnFrameStream*)pCookie; return pThis->OnRequiredSizeChanging(); } -void XN_CALLBACK_TYPE XnFrameStream::OnTripleBufferNewData(XnFrameBufferManager* pTripleBuffer, XnUInt64 nTimestamp, void* pCookie) +void XN_CALLBACK_TYPE XnFrameStream::OnTripleBufferNewData(const XnFrameBufferManager::NewFrameEventArgs& args, void* pCookie) { XnFrameStream* pThis = (XnFrameStream*)pCookie; - pThis->NewDataAvailable(nTimestamp, pThis->m_nLastReadFrame + 1); + pThis->NewDataAvailable(args.nTimestamp, pThis->m_nLastReadFrame + 1); } -XnStatus XN_CALLBACK_TYPE XnFrameStream::GetLastRawFrameCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnFrameStream::GetLastRawFrameCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnDynamicSizeBuffer); XnFrameStream* pThis = (XnFrameStream*)pCookie; XnDynamicSizeBuffer* pBuffer = (XnDynamicSizeBuffer*)gbValue.pData; return pThis->GetLastRawFrame(pBuffer); } + +XnStatus XN_CALLBACK_TYPE XnFrameStream::SetExternalBufferPoolCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XnFrameStream* pThis = (XnFrameStream*)pCookie; + return pThis->SetExternalBufferPool(gbValue.nDataSize / sizeof(XnGeneralBuffer), (XnGeneralBuffer*)gbValue.pData); +} \ No newline at end of file diff --git a/Source/XnDDK/XnFrameStream.h b/Source/XnDDK/XnFrameStream.h index 51be57d..bc88407 100644 --- a/Source/XnDDK/XnFrameStream.h +++ b/Source/XnDDK/XnFrameStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FRAME_STREAM_H__ #define __XN_FRAME_STREAM_H__ @@ -44,12 +39,11 @@ class XN_DDK_CPP_API XnFrameStream : public XnDeviceStream XnFrameStream(const XnChar* csType, const XnChar* csName); ~XnFrameStream() { Free(); } - XnStatus SetBufferPool(XnBufferPool* pBufferPool); - //--------------------------------------------------------------------------- // Getters //--------------------------------------------------------------------------- inline XnUInt32 GetFPS() const { return (XnUInt32)m_FPS.GetValue(); } + inline XnBufferPool* GetBufferPool() { return m_pBufferPool; } //--------------------------------------------------------------------------- // Overridden Methods @@ -59,17 +53,17 @@ class XN_DDK_CPP_API XnFrameStream : public XnDeviceStream XnStatus CreateStreamData(XnStreamData** ppStreamData); XnStatus Read(XnStreamData* pStreamOutput); - //--------------------------------------------------------------------------- - // Getters - //--------------------------------------------------------------------------- - inline XnFrameBufferManager* GetTripleBuffer() { return m_pBufferManager; } - protected: //--------------------------------------------------------------------------- // Properties Getters //--------------------------------------------------------------------------- inline XnActualIntProperty& FPSProperty() { return m_FPS; } + //--------------------------------------------------------------------------- + // Getters + //--------------------------------------------------------------------------- + XnStatus GetTripleBuffer(XnFrameBufferManager** pBufferManager); + //--------------------------------------------------------------------------- // Setters //--------------------------------------------------------------------------- @@ -78,23 +72,24 @@ class XN_DDK_CPP_API XnFrameStream : public XnDeviceStream //--------------------------------------------------------------------------- // Virtual Methods //--------------------------------------------------------------------------- - virtual XnStatus PostProcessFrame(XnStreamData* pFrameData) { return XN_STATUS_OK; } + virtual XnStatus PostProcessFrame(XnStreamData* /*pFrameData*/) { return XN_STATUS_OK; } virtual XnStatus ReallocTripleFrameBuffer(); //--------------------------------------------------------------------------- // Overridden Methods //--------------------------------------------------------------------------- XnStatus ReadImpl(XnStreamData* pStreamOutput); - XnStatus HandleNoNewData(XnStreamData* pStreamOutput); private: XnStatus OnRequiredSizeChanging(); XnStatus GetLastRawFrame(XnDynamicSizeBuffer* gbValue); + XnStatus SetExternalBufferPool(XnUInt32 nCount, XnGeneralBuffer* aBuffers); static XnStatus XN_CALLBACK_TYPE SetFPSCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE RequiredSizeChangedCallback(const XnProperty* pSenser, void* pCookie); - static void XN_CALLBACK_TYPE OnTripleBufferNewData(XnFrameBufferManager* pTripleBuffer, XnUInt64 nTimestamp, void* pCookie); + static void XN_CALLBACK_TYPE OnTripleBufferNewData(const XnFrameBufferManager::NewFrameEventArgs& args, void* pCookie); static XnStatus XN_CALLBACK_TYPE GetLastRawFrameCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetExternalBufferPoolCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); //--------------------------------------------------------------------------- // Members @@ -107,6 +102,7 @@ class XN_DDK_CPP_API XnFrameStream : public XnDeviceStream XnActualIntProperty m_IsFrameStream; XnActualIntProperty m_FPS; + XnGeneralProperty m_externalBufferPool; XnGeneralProperty m_LastRawFrame; XnBool m_bTripleBufferReallocated; }; diff --git a/Source/XnDDK/XnGeneralProperty.cpp b/Source/XnDDK/XnGeneralProperty.cpp index e1b58ab..20e2688 100644 --- a/Source/XnDDK/XnGeneralProperty.cpp +++ b/Source/XnDDK/XnGeneralProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -82,7 +76,7 @@ XnStatus XnGeneralProperty::ReadValueFromFile(const XnChar* csINIFile, const XnC return (XN_STATUS_OK); } -XnStatus XnGeneralProperty::AddToPropertySet(XnPropertySet* pSet) +XnStatus XnGeneralProperty::AddToPropertySet(XnPropertySet* /*pSet*/) { return (XN_STATUS_ERROR); } diff --git a/Source/XnDDK/XnGeneralProperty.h b/Source/XnDDK/XnGeneralProperty.h index 82ee343..6c2ba2d 100644 --- a/Source/XnDDK/XnGeneralProperty.h +++ b/Source/XnDDK/XnGeneralProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_GENERAL_PROPERTY_H__ #define __XN_GENERAL_PROPERTY_H__ diff --git a/Source/XnDDK/XnIRStream.cpp b/Source/XnDDK/XnIRStream.cpp index 9a69e06..009d1af 100644 --- a/Source/XnDDK/XnIRStream.cpp +++ b/Source/XnDDK/XnIRStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnIRStream.h b/Source/XnDDK/XnIRStream.h index 8c3acd4..2393540 100644 --- a/Source/XnDDK/XnIRStream.h +++ b/Source/XnDDK/XnIRStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IR_STREAM_H__ #define __XN_IR_STREAM_H__ diff --git a/Source/XnDDK/XnImageStream.cpp b/Source/XnDDK/XnImageStream.cpp index 558abcb..378a2a1 100644 --- a/Source/XnDDK/XnImageStream.cpp +++ b/Source/XnDDK/XnImageStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnImageStream.h b/Source/XnDDK/XnImageStream.h index a5313eb..c65fb8c 100644 --- a/Source/XnDDK/XnImageStream.h +++ b/Source/XnDDK/XnImageStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IMAGE_STREAM_H__ #define __XN_IMAGE_STREAM_H__ diff --git a/Source/XnDDK/XnIntProperty.cpp b/Source/XnDDK/XnIntProperty.cpp index b56ef65..d868b7d 100644 --- a/Source/XnDDK/XnIntProperty.cpp +++ b/Source/XnDDK/XnIntProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnIntProperty.h b/Source/XnDDK/XnIntProperty.h index 8e7f264..4592762 100644 --- a/Source/XnDDK/XnIntProperty.h +++ b/Source/XnDDK/XnIntProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_INT_PROPERTY_H__ #define __XN_INT_PROPERTY_H__ diff --git a/Source/XnDDK/XnIntPropertySynchronizer.cpp b/Source/XnDDK/XnIntPropertySynchronizer.cpp index 0cc726b..20fbe70 100644 --- a/Source/XnDDK/XnIntPropertySynchronizer.cpp +++ b/Source/XnDDK/XnIntPropertySynchronizer.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -55,7 +49,7 @@ XnIntPropertySynchronizer::XnIntPropertySynchronizer() XnIntPropertySynchronizer::~XnIntPropertySynchronizer() { - for (XnList::Iterator it = m_Cookies.begin(); it != m_Cookies.end(); ++it) + for (CookiesList::Iterator it = m_Cookies.Begin(); it != m_Cookies.End(); ++it) { XnIntSynchronizerCookie* pSynchData = (XnIntSynchronizerCookie*)*it; pSynchData->pSource->OnChangeEvent().Unregister(pSynchData->hCallback); @@ -110,11 +104,11 @@ XnStatus XnIntPropertySynchronizer::RegisterSynchronization(XnIntProperty* pSour return (nRetVal); } - nRetVal = pSource->OnChangeEvent().Register(IntPropertyValueChangedCallback, pCookie, &pCookie->hCallback); + nRetVal = pSource->OnChangeEvent().Register(IntPropertyValueChangedCallback, pCookie, pCookie->hCallback); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pCookie); - m_Cookies.Remove(m_Cookies.begin()); + m_Cookies.Remove(m_Cookies.Begin()); return (nRetVal); } diff --git a/Source/XnDDK/XnIntPropertySynchronizer.h b/Source/XnDDK/XnIntPropertySynchronizer.h index 0201c48..8ebfda5 100644 --- a/Source/XnDDK/XnIntPropertySynchronizer.h +++ b/Source/XnDDK/XnIntPropertySynchronizer.h @@ -1,36 +1,31 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_INT_PROPERTY_SYNCHRONIZER_H__ #define __XN_INT_PROPERTY_SYNCHRONIZER_H__ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- -#include +#include #include //--------------------------------------------------------------------------- @@ -38,6 +33,8 @@ //--------------------------------------------------------------------------- typedef XnStatus (XN_CALLBACK_TYPE* XnIntPropertyConvertCallback)(XnUInt64 nSourceValue, XnUInt64* pnDestValue); +class XnIntSynchronizerCookie; // forward declaration + class XN_DDK_CPP_API XnIntPropertySynchronizer { public: @@ -47,7 +44,8 @@ class XN_DDK_CPP_API XnIntPropertySynchronizer XnStatus RegisterSynchronization(XnIntProperty* pSource, XnIntProperty* pDestination, XnIntPropertyConvertCallback pConvertFunc = NULL); private: - XnList m_Cookies; + typedef XnListT CookiesList; + CookiesList m_Cookies; }; #endif //__XN_INT_PROPERTY_SYNCHRONIZER_H__ diff --git a/Source/XnDDK/XnPixelStream.cpp b/Source/XnDDK/XnPixelStream.cpp index db0f2cc..1ac5ff3 100644 --- a/Source/XnDDK/XnPixelStream.cpp +++ b/Source/XnDDK/XnPixelStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,6 +26,7 @@ #include #include #include +#include //--------------------------------------------------------------------------- // XnPixelStream @@ -44,9 +39,13 @@ XnPixelStream::XnPixelStream(const XnChar* csType, const XnChar* csName, XnBool m_YRes(XN_STREAM_PROPERTY_Y_RES, XN_VGA_Y_RES), m_BytesPerPixel(XN_STREAM_PROPERTY_BYTES_PER_PIXEL), m_Cropping(XN_STREAM_PROPERTY_CROPPING, &m_CroppingData, sizeof(XnCropping), ReadCroppingFromFileCallback), - m_bAllowCustomResolutions(bAllowCustomResolutions) + m_SupportedModesCount(XN_STREAM_PROPERTY_SUPPORT_MODES_COUNT, 0), + m_SupportedModes(XN_STREAM_PROPERTY_SUPPORT_MODES), + m_bAllowCustomResolutions(bAllowCustomResolutions), + m_supportedModesData(30) { xnOSMemSet(&m_CroppingData, 0, sizeof(XnCropping)); + m_SupportedModes.UpdateGetCallback(GetSupportedModesCallback, this); } XnStatus XnPixelStream::Init() @@ -64,7 +63,8 @@ XnStatus XnPixelStream::Init() m_Cropping.UpdateSetCallback(SetCroppingCallback, this); // add properties - XN_VALIDATE_ADD_PROPERTIES(this, &m_IsPixelStream, &m_Resolution, &m_XRes, &m_YRes, &m_BytesPerPixel, &m_Cropping); + XN_VALIDATE_ADD_PROPERTIES(this, &m_IsPixelStream, &m_Resolution, &m_XRes, &m_YRes, + &m_BytesPerPixel, &m_Cropping, &m_SupportedModesCount, &m_SupportedModes); // register required size properties nRetVal = RegisterRequiredSizeProperty(&m_XRes); @@ -78,21 +78,63 @@ XnStatus XnPixelStream::Init() // register for important properties XnCallbackHandle hDummyCallback; - nRetVal = m_Resolution.OnChangeEvent().Register(ResolutionValueChangedCallback, this, &hDummyCallback); + nRetVal = m_Resolution.OnChangeEvent().Register(ResolutionValueChangedCallback, this, hDummyCallback); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = OutputFormatProperty().OnChangeEvent().Register(OutputFormatValueChangedCallback, this, hDummyCallback); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_XRes.OnChangeEvent().Register(FixCroppingCallback, this, hDummyCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = OutputFormatProperty().OnChangeEvent().Register(OutputFormatValueChangedCallback, this, &hDummyCallback); + nRetVal = m_YRes.OnChangeEvent().Register(FixCroppingCallback, this, hDummyCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_XRes.OnChangeEvent().Register(FixCroppingCallback, this, &hDummyCallback); + return (XN_STATUS_OK); +} + +XnStatus XnPixelStream::AddSupportedModes(XnCmosPreset* aPresets, XnUInt32 nCount) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_supportedModesData.AddLast(aPresets, nCount); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_YRes.OnChangeEvent().Register(FixCroppingCallback, this, &hDummyCallback); + // update our general property + XnUInt32 nAllPresetsCount = m_supportedModesData.GetSize(); + + nRetVal = m_SupportedModesCount.UnsafeUpdateValue(nAllPresetsCount); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } +XnStatus XnPixelStream::ValidateSupportedMode(const XnCmosPreset& preset) +{ + for (XnUInt32 i = 0; i < m_supportedModesData.GetSize(); ++i) + { + if (preset.nFormat == m_supportedModesData[i].nFormat && + preset.nResolution == m_supportedModesData[i].nResolution && + preset.nFPS == m_supportedModesData[i].nFPS) + { + return (XN_STATUS_OK); + } + } + + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Mode is not supported (format: %d, resolution: %d, FPS: %d)!", preset.nFormat, preset.nResolution, preset.nFPS); +} + +XnStatus XnPixelStream::GetSupportedModes(XnCmosPreset* aPresets, XnUInt32& nCount) +{ + if (nCount < m_supportedModesData.GetSize()) + { + return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; + } + + xnOSMemCopy(aPresets, m_supportedModesData.GetData(), m_supportedModesData.GetSize() * sizeof(XnCmosPreset)); + return XN_STATUS_OK; +} + XnStatus XnPixelStream::SetResolution(XnResolutions nResolution) { XnStatus nRetVal = XN_STATUS_OK; @@ -107,39 +149,18 @@ XnStatus XnPixelStream::SetXRes(XnUInt32 nXRes) { XnStatus nRetVal = XN_STATUS_OK; - if (m_bAllowCustomResolutions) + XnResolutions res = XnDDKGetResolutionFromXY(nXRes, GetYRes()); + + // set resolution (this will also set X and Y resolution) + nRetVal = SetResolution(res); + XN_IS_STATUS_OK(nRetVal); + + if (res == XN_RESOLUTION_CUSTOM) { - // just update the value + // update X res ourselves nRetVal = m_XRes.UnsafeUpdateValue(nXRes); XN_IS_STATUS_OK(nRetVal); } - else - { - // instead of updating XRes, we'll update the resolution, and XRes will be updated - // via ValueChanged event - XnResolutions nRes; - - switch (nXRes) - { - case XN_QVGA_X_RES: - nRes = XN_RESOLUTION_QVGA; - break; - case XN_VGA_X_RES: - nRes = XN_RESOLUTION_VGA; - break; - case XN_SXGA_X_RES: - nRes = XN_RESOLUTION_SXGA; - break; - case XN_UXGA_X_RES: - nRes = XN_RESOLUTION_UXGA; - break; - default: - return (XN_STATUS_DEVICE_BAD_PARAM); - } - - nRetVal = SetResolution(nRes); - XN_IS_STATUS_OK(nRetVal); - } return (XN_STATUS_OK); } @@ -148,39 +169,18 @@ XnStatus XnPixelStream::SetYRes(XnUInt32 nYRes) { XnStatus nRetVal = XN_STATUS_OK; - if (m_bAllowCustomResolutions) + XnResolutions res = XnDDKGetResolutionFromXY(GetXRes(), nYRes); + + // set resolution (this will also set X and Y resolution) + nRetVal = SetResolution(res); + XN_IS_STATUS_OK(nRetVal); + + if (res == XN_RESOLUTION_CUSTOM) { - // just update the value + // update Y res ourselves nRetVal = m_YRes.UnsafeUpdateValue(nYRes); XN_IS_STATUS_OK(nRetVal); } - else - { - // instead of updating YRes, we'll update the resolution, and YRes will be updated - // via ValueChanged event - XnResolutions nRes; - - switch (nYRes) - { - case XN_QVGA_Y_RES: - nRes = XN_RESOLUTION_QVGA; - break; - case XN_VGA_Y_RES: - nRes = XN_RESOLUTION_VGA; - break; - case XN_SXGA_Y_RES: - nRes = XN_RESOLUTION_SXGA; - break; - case XN_UXGA_Y_RES: - nRes = XN_RESOLUTION_UXGA; - break; - default: - return (XN_STATUS_DEVICE_BAD_PARAM); - } - - nRetVal = SetResolution(nRes); - XN_IS_STATUS_OK(nRetVal); - } return (XN_STATUS_OK); } @@ -200,8 +200,6 @@ XnStatus XnPixelStream::SetCropping(const XnCropping* pCropping) XnStatus XnPixelStream::ValidateCropping(const XnCropping* pCropping) { - XnStatus nRetVal = XN_STATUS_OK; - if (pCropping->bEnabled) { if (pCropping->nXOffset > GetXRes() || @@ -225,30 +223,15 @@ XnStatus XnPixelStream::OnResolutionChanged() { XnStatus nRetVal = XN_STATUS_OK; - if (m_Resolution.GetValue() != XN_RESOLUTION_CUSTOM) + XnResolutions res = (XnResolutions)m_Resolution.GetValue(); + if (res != XN_RESOLUTION_CUSTOM) { // update XRes and YRes accordingly XnUInt32 nXRes; XnUInt32 nYRes; - - switch (m_Resolution.GetValue()) + if (!XnDDKGetXYFromResolution(res, &nXRes, &nYRes)) { - case XN_RESOLUTION_QVGA: - nXRes = XN_QVGA_X_RES; - nYRes = XN_QVGA_Y_RES; - break; - case XN_RESOLUTION_VGA: - nXRes = XN_VGA_X_RES; - nYRes = XN_VGA_Y_RES; - break; - case XN_RESOLUTION_UXGA: - nXRes = XN_UXGA_X_RES; - nYRes = XN_UXGA_Y_RES; - break; - case XN_RESOLUTION_SXGA: - nXRes = XN_SXGA_X_RES; - nYRes = XN_SXGA_Y_RES; - break; + XN_ASSERT(FALSE); } nRetVal = m_XRes.UnsafeUpdateValue(nXRes); @@ -358,8 +341,6 @@ XnStatus XnPixelStream::Mirror(XnStreamData* pStreamOutput) const XnStatus XnPixelStream::CropImpl(XnStreamData* pStreamOutput, const XnCropping* pCropping) { - XnStatus nRetVal = XN_STATUS_OK; - XnUChar* pPixelData = (XnUChar*)pStreamOutput->pData; XnUInt32 nCurDataSize = 0; @@ -378,43 +359,43 @@ XnStatus XnPixelStream::CropImpl(XnStreamData* pStreamOutput, const XnCropping* return XN_STATUS_OK; } -XnStatus XN_CALLBACK_TYPE XnPixelStream::ResolutionValueChangedCallback(const XnProperty* pSenser, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::ResolutionValueChangedCallback(const XnProperty* /*pSenser*/, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->OnResolutionChanged(); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::OutputFormatValueChangedCallback(const XnProperty* pSenser, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::OutputFormatValueChangedCallback(const XnProperty* /*pSenser*/, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->OnOutputFormatChanged(); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::FixCroppingCallback(const XnProperty* pSenser, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::FixCroppingCallback(const XnProperty* /*pSenser*/, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->FixCropping(); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::SetResolutionCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::SetResolutionCallback(XnActualIntProperty* /*pSenser*/, XnUInt64 nValue, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->SetResolution((XnResolutions)nValue); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::SetXResCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::SetXResCallback(XnActualIntProperty* /*pSenser*/, XnUInt64 nValue, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->SetXRes((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::SetYResCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::SetYResCallback(XnActualIntProperty* /*pSenser*/, XnUInt64 nValue, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; return pStream->SetYRes((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnPixelStream::SetCroppingCallback(XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnPixelStream::SetCroppingCallback(XnActualGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XnPixelStream* pStream = (XnPixelStream*)pCookie; if (gbValue.nDataSize != sizeof(XnCropping)) @@ -448,10 +429,10 @@ XnStatus XN_CALLBACK_TYPE XnPixelStream::ReadCroppingFromFileCallback(XnGeneralP XN_STATUS_OK == xnOSReadIntFromINI(csINIFile, csCroppingSection, "Enabled", &bEnabled)) { XnCropping Cropping; - Cropping.nXOffset = nOffsetX; - Cropping.nYOffset = nOffsetY; - Cropping.nXSize = nSizeX; - Cropping.nYSize = nSizeY; + Cropping.nXOffset = (XnUInt16)nOffsetX; + Cropping.nYOffset = (XnUInt16)nOffsetY; + Cropping.nXSize = (XnUInt16)nSizeX; + Cropping.nYSize = (XnUInt16)nSizeY; Cropping.bEnabled = bEnabled; // set value @@ -461,3 +442,35 @@ XnStatus XN_CALLBACK_TYPE XnPixelStream::ReadCroppingFromFileCallback(XnGeneralP return (XN_STATUS_OK); } + +XnStatus XN_CALLBACK_TYPE XnPixelStream::GetSupportedModesCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XnPixelStream* pThis = (XnPixelStream*)pCookie; + if ((gbValue.nDataSize % sizeof(XnCmosPreset)) != 0) + { + return XN_STATUS_INVALID_BUFFER_SIZE; + } + + XnUInt32 nCount = gbValue.nDataSize / sizeof(XnCmosPreset); + if (pThis->m_SupportedModesCount.GetValue() != nCount) + { + return XN_STATUS_INVALID_BUFFER_SIZE; + } + + return pThis->GetSupportedModes((XnCmosPreset*)gbValue.pData, nCount); +} + +//--------------------------------------------------------------------------- +// XnResolutionProperty +//--------------------------------------------------------------------------- +XnPixelStream::XnResolutionProperty::XnResolutionProperty(const XnChar* strName, XnUInt64 nInitialValue /* = 0 */, const XnChar* strModule /* = "" */) : + XnActualIntProperty(strName, nInitialValue, strModule) +{ +} + +XnBool XnPixelStream::XnResolutionProperty::ConvertValueToString(XnChar* csValue, const void* pValue) const +{ + XnUInt64 nValue = *(XnUInt64*)pValue; + strcpy(csValue, XnDDKGetResolutionName((XnResolutions)nValue)); + return TRUE; +} \ No newline at end of file diff --git a/Source/XnDDK/XnPixelStream.h b/Source/XnDDK/XnPixelStream.h index ff10b58..56ba822 100644 --- a/Source/XnDDK/XnPixelStream.h +++ b/Source/XnDDK/XnPixelStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PIXEL_STREAM_H__ #define __XN_PIXEL_STREAM_H__ @@ -32,6 +27,7 @@ //--------------------------------------------------------------------------- #include #include +#include //--------------------------------------------------------------------------- // Types @@ -57,8 +53,12 @@ class XN_DDK_CPP_API XnPixelStream : public XnFrameStream inline XnUInt32 GetYRes() const { return (XnUInt32)m_YRes.GetValue(); } inline XnUInt32 GetBytesPerPixel() const { return (XnUInt32)m_BytesPerPixel.GetValue(); } inline const XnCropping* GetCropping() const { return (XnCropping*)m_Cropping.GetValue().pData; } + inline const XnArray& GetSupportedModes() const { return m_supportedModesData; } protected: + XnStatus AddSupportedModes(XnCmosPreset* aPresets, XnUInt32 nCount); + XnStatus ValidateSupportedMode(const XnCmosPreset& preset); + //--------------------------------------------------------------------------- // Properties Getters //--------------------------------------------------------------------------- @@ -94,9 +94,17 @@ class XN_DDK_CPP_API XnPixelStream : public XnFrameStream XnStatus ValidateCropping(const XnCropping* pCropping); private: + class XN_DDK_CPP_API XnResolutionProperty : public XnActualIntProperty + { + public: + XnResolutionProperty(const XnChar* strName, XnUInt64 nInitialValue = 0, const XnChar* strModule = ""); + XnBool ConvertValueToString(XnChar* csValue, const void* pValue) const; + }; + XnStatus OnResolutionChanged(); XnStatus OnOutputFormatChanged(); XnStatus FixCropping(); + XnStatus GetSupportedModes(XnCmosPreset* aPresets, XnUInt32& nCount); static XnStatus XN_CALLBACK_TYPE SetResolutionCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetXResCallback(XnActualIntProperty* pSenser, XnUInt64 nValue, void* pCookie); @@ -106,12 +114,12 @@ class XN_DDK_CPP_API XnPixelStream : public XnFrameStream static XnStatus XN_CALLBACK_TYPE OutputFormatValueChangedCallback(const XnProperty* pSenser, void* pCookie); static XnStatus XN_CALLBACK_TYPE FixCroppingCallback(const XnProperty* pSenser, void* pCookie); static XnStatus XN_CALLBACK_TYPE ReadCroppingFromFileCallback(XnGeneralProperty* pSender, const XnChar* csINIFile, const XnChar* csSection); - + static XnStatus XN_CALLBACK_TYPE GetSupportedModesCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); //--------------------------------------------------------------------------- // Members //--------------------------------------------------------------------------- XnActualIntProperty m_IsPixelStream; - XnActualIntProperty m_Resolution; + XnResolutionProperty m_Resolution; XnActualIntProperty m_XRes; XnActualIntProperty m_YRes; XnActualIntProperty m_BytesPerPixel; @@ -119,6 +127,10 @@ class XN_DDK_CPP_API XnPixelStream : public XnFrameStream XnCropping m_CroppingData; + XnActualIntProperty m_SupportedModesCount; + XnGeneralProperty m_SupportedModes; + + XnArray m_supportedModesData; XnBool m_bAllowCustomResolutions; }; diff --git a/Source/XnDDK/XnProperty.cpp b/Source/XnDDK/XnProperty.cpp index f84f329..6e6579f 100644 --- a/Source/XnDDK/XnProperty.cpp +++ b/Source/XnDDK/XnProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -40,9 +34,12 @@ XnProperty::XnProperty(XnPropertyType Type, void* pValueHolder, const XnChar* strName, const XnChar* strModule) : m_Type(Type), m_pSetCallback(NULL), + m_pSetCallbackCookie(NULL), m_pGetCallback(NULL), + m_pGetCallbackCookie(NULL), m_pValueHolder(pValueHolder), - m_LogSeverity(XN_LOG_INFO) + m_LogSeverity(XN_LOG_INFO), + m_bAlwaysSet(FALSE) { UpdateName(strModule, strName); } @@ -67,8 +64,6 @@ XnStatus XnProperty::SetValue(const void* pValue) if (m_LogSeverity != -1) { XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; - XnBool bValueString = FALSE; - if (ConvertValueToString(strValue, pValue)) { xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "Setting %s.%s to %s...", GetModule(), GetName(), strValue); @@ -79,8 +74,6 @@ XnStatus XnProperty::SetValue(const void* pValue) } } - XnBool bShouldSet = TRUE; - if (!m_bAlwaysSet && IsActual() && IsEqual(m_pValueHolder, pValue)) { xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "%s.%s value did not change.", GetModule(), GetName()); @@ -172,7 +165,27 @@ void XnProperty::UpdateGetCallback(GetFuncPtr pFunc, void* pCookie) m_pGetCallbackCookie = pCookie; } -XnBool XnProperty::ConvertValueToString(XnChar* csValue, const void* pValue) const +XnBool XnProperty::ConvertValueToString(XnChar* /*csValue*/, const void* /*pValue*/) const { return FALSE; } + +XnStatus XnProperty::ChangeEvent::Raise(const XnProperty* pSender) +{ + XnStatus nRetVal = XN_STATUS_OK; + XnAutoCSLocker locker(m_hLock); + ApplyListChanges(); + + for (CallbackPtrList::ConstIterator it = m_callbacks.Begin(); it != m_callbacks.End(); ++it) + { + TCallback* pCallback = *it; + nRetVal = pCallback->pFunc(pSender, pCallback->pCookie); + if (nRetVal != XN_STATUS_OK) + { + break; + } + } + + ApplyListChanges(); + return (nRetVal); +} diff --git a/Source/XnDDK/XnProperty.h b/Source/XnDDK/XnProperty.h index adf7f66..c6a3d28 100644 --- a/Source/XnDDK/XnProperty.h +++ b/Source/XnDDK/XnProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PROPERTY_H__ #define __XN_PROPERTY_H__ @@ -31,10 +26,10 @@ // Includes //--------------------------------------------------------------------------- #include -#include -#include +#include +#include #include -#include +#include //--------------------------------------------------------------------------- // Types @@ -47,6 +42,9 @@ class XN_DDK_CPP_API XnProperty { public: + typedef XnStatus (XN_CALLBACK_TYPE* OnValueChangedHandler)(const XnProperty* pSender, void* pCookie); + typedef XnEventInterfaceT ChangeEventInterface; + /** * Creates a new property. * @@ -64,8 +62,6 @@ class XN_DDK_CPP_API XnProperty inline XnBool IsReadOnly() const { return (m_pGetCallback == NULL); } inline XnPropertyType GetType() const { return m_Type; } - XN_DECLARE_EVENT_1ARG_RETVAL(ChangeEvent, ChangeEventInterface, const XnProperty*, pSender); - inline ChangeEventInterface& OnChangeEvent() { return m_OnChangeEvent; } /** Updates property name. */ @@ -74,8 +70,6 @@ class XN_DDK_CPP_API XnProperty /** Updates the value of the property according to an INI file. */ virtual XnStatus ReadValueFromFile(const XnChar* csINIFile, const XnChar* csSection) = 0; - typedef XnStatus (XN_CALLBACK_TYPE* OnValueChangedHandler)(const XnProperty* pSender, void* pCookie); - /** Adds this property to the property set. */ virtual XnStatus AddToPropertySet(XnPropertySet* pSet) = 0; @@ -114,6 +108,12 @@ class XN_DDK_CPP_API XnProperty inline void* Value() const { return m_pValueHolder; } private: + class ChangeEvent : public XnEventInterfaceT + { + public: + XnStatus Raise(const XnProperty* pSender); + }; + XnChar m_strModule[XN_DEVICE_MAX_STRING_LENGTH]; // module name XnChar m_strName[XN_DEVICE_MAX_STRING_LENGTH]; // property name XnPropertyType m_Type; // property type @@ -135,9 +135,9 @@ class XN_DDK_CPP_API XnProperty }; /** A property list */ -XN_DECLARE_LIST_DECL(XN_DDK_CPP_API, XnProperty*, XnPropertiesList) +typedef XnListT XnPropertiesList; /** A hash table, mapping property name to the property */ -XN_DECLARE_STRINGS_HASH_DECL(XN_DDK_CPP_API, XnProperty*, XnPropertiesHash) +typedef XnStringsHashT XnPropertiesHash; #endif //__XN_PROPERTY_H__ diff --git a/Source/XnDDK/XnPropertySet.cpp b/Source/XnDDK/XnPropertySet.cpp index 8301d7d..1f906a5 100644 --- a/Source/XnDDK/XnPropertySet.cpp +++ b/Source/XnDDK/XnPropertySet.cpp @@ -1,36 +1,28 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnPropertySetInternal.h" -#include -#include #include "XnActualIntProperty.h" #include "XnActualRealProperty.h" #include "XnActualStringProperty.h" @@ -61,8 +53,6 @@ struct XnPropertySetEnumerator XN_DDK_API XnStatus XnPropertySetCreate(XnPropertySet** ppSet) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_OUTPUT_PTR(ppSet); XnPropertySet* pSet; @@ -76,14 +66,12 @@ XN_DDK_API XnStatus XnPropertySetCreate(XnPropertySet** ppSet) } *ppSet = pSet; - + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetDestroy(XnPropertySet** ppSet) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(ppSet); XN_VALIDATE_INPUT_PTR(*ppSet); @@ -98,19 +86,19 @@ XN_DDK_API XnStatus XnPropertySetDestroy(XnPropertySet** ppSet) xnOSFree(pSet); *ppSet = NULL; - + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetClear(XnPropertySet* pSet) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSet); while (!pSet->pData->IsEmpty()) { - nRetVal = XnPropertySetRemoveModule(pSet, pSet->pData->begin().Key()); + nRetVal = XnPropertySetRemoveModule(pSet, pSet->pData->Begin()->Key()); XN_IS_STATUS_OK(nRetVal); } @@ -120,7 +108,7 @@ XN_DDK_API XnStatus XnPropertySetClear(XnPropertySet* pSet) XN_DDK_API XnStatus XnPropertySetAddModule(XnPropertySet* pSet, const XnChar* strModuleName) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_INPUT_PTR(strModuleName); @@ -166,13 +154,13 @@ XN_DDK_API XnStatus XnPropertySetRemoveModule(XnPropertySet* pSet, const XnChar* XN_DDK_API XnStatus XnPropertySetAddIntProperty(XnPropertySet* pSet, const XnChar* strModuleName, const XnChar* strProperty, XnUInt64 nValue) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_INPUT_PTR(strModuleName); XN_VALIDATE_INPUT_PTR(strProperty); // get module - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); @@ -192,7 +180,7 @@ XN_DDK_API XnStatus XnPropertySetAddRealProperty(XnPropertySet* pSet, const XnCh XN_VALIDATE_INPUT_PTR(strProperty); // get module - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); @@ -213,7 +201,7 @@ XN_DDK_API XnStatus XnPropertySetAddStringProperty(XnPropertySet* pSet, const Xn XN_VALIDATE_INPUT_PTR(strValue); // get module - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); @@ -234,7 +222,7 @@ XN_DDK_API XnStatus XnPropertySetAddGeneralProperty(XnPropertySet* pSet, const X XN_VALIDATE_INPUT_PTR(pgbValue); // get module - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); @@ -248,18 +236,17 @@ XN_DDK_API XnStatus XnPropertySetAddGeneralProperty(XnPropertySet* pSet, const X XN_DDK_API XnStatus XnPropertySetRemoveProperty(XnPropertySet* pSet, const XnChar* strModuleName, const XnChar* strProperty) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_INPUT_PTR(strModuleName); XN_VALIDATE_INPUT_PTR(strProperty); // get module - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); // remove the property - XnProperty* pProp; nRetVal = pModule->Remove(strProperty); XN_IS_STATUS_OK(nRetVal); @@ -268,16 +255,14 @@ XN_DDK_API XnStatus XnPropertySetRemoveProperty(XnPropertySet* pSet, const XnCha XN_DDK_API XnStatus XnPropertySetGetModuleEnumerator(const XnPropertySet* pSet, XnPropertySetModuleEnumerator** ppEnumerator) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_OUTPUT_PTR(ppEnumerator); XnPropertySetModuleEnumerator* pEnumer; - XN_VALIDATE_ALLOC(pEnumer, XnPropertySetModuleEnumerator); + XN_VALIDATE_NEW(pEnumer, XnPropertySetModuleEnumerator); pEnumer->bFirst = TRUE; - pEnumer->it = pSet->pData->end(); + pEnumer->it = pSet->pData->End(); pEnumer->pModules = pSet->pData; *ppEnumerator = pEnumer; @@ -287,12 +272,10 @@ XN_DDK_API XnStatus XnPropertySetGetModuleEnumerator(const XnPropertySet* pSet, XN_DDK_API XnStatus XnPropertySetModuleEnumeratorFree(XnPropertySetModuleEnumerator** ppEnumer) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(ppEnumer); XN_VALIDATE_INPUT_PTR(*ppEnumer); - - xnOSFree(*ppEnumer); + + XN_DELETE(*ppEnumer); *ppEnumer = NULL; return (XN_STATUS_OK); @@ -300,17 +283,15 @@ XN_DDK_API XnStatus XnPropertySetModuleEnumeratorFree(XnPropertySetModuleEnumera XN_DDK_API XnStatus XnPropertySetModuleEnumeratorMoveNext(XnPropertySetModuleEnumerator* pEnumerator, XnBool* pbEnd) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pbEnd); if (pEnumerator->bFirst) { - pEnumerator->it = pEnumerator->pModules->begin(); + pEnumerator->it = pEnumerator->pModules->Begin(); pEnumerator->bFirst = FALSE; } - else if (pEnumerator->it == pEnumerator->pModules->end()) + else if (pEnumerator->it == pEnumerator->pModules->End()) { return XN_STATUS_ILLEGAL_POSITION; } @@ -319,24 +300,22 @@ XN_DDK_API XnStatus XnPropertySetModuleEnumeratorMoveNext(XnPropertySetModuleEnu pEnumerator->it++; } - *pbEnd = (pEnumerator->it == pEnumerator->pModules->end()); - + *pbEnd = (pEnumerator->it == pEnumerator->pModules->End()); + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetModuleEnumeratorGetCurrent(const XnPropertySetModuleEnumerator* pEnumer, const XnChar** pstrModuleName) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumer); XN_VALIDATE_OUTPUT_PTR(pstrModuleName); - - if (pEnumer->it == pEnumer->pModules->end()) + + if (pEnumer->it == pEnumer->pModules->End()) { return XN_STATUS_ILLEGAL_POSITION; } - *pstrModuleName = pEnumer->it.Key(); + *pstrModuleName = pEnumer->it->Key(); return (XN_STATUS_OK); } @@ -344,22 +323,22 @@ XN_DDK_API XnStatus XnPropertySetModuleEnumeratorGetCurrent(const XnPropertySetM XN_DDK_API XnStatus XnPropertySetGetEnumerator(const XnPropertySet* pSet, XnPropertySetEnumerator** ppEnumerator, const XnChar* strModule /* = NULL */) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_OUTPUT_PTR(ppEnumerator); if (strModule != NULL) { // make sure module exists - XnPropertySetData::ConstIterator it = pSet->pData->end(); + XnPropertySetData::ConstIterator it = pSet->pData->End(); nRetVal = pSet->pData->Find(strModule, it); XN_IS_STATUS_OK(nRetVal); } XnPropertySetEnumerator* pEnumer; - XN_VALIDATE_ALLOC(pEnumer, XnPropertySetEnumerator); + XN_VALIDATE_NEW(pEnumer, XnPropertySetEnumerator) - pEnumer->bFirst = TRUE; + pEnumer->bFirst = TRUE; pEnumer->pModules = pSet->pData; if (strModule != NULL) { @@ -369,7 +348,7 @@ XN_DDK_API XnStatus XnPropertySetGetEnumerator(const XnPropertySet* pSet, XnProp { pEnumer->strModule[0] = '\0'; } - + *ppEnumerator = pEnumer; return (XN_STATUS_OK); @@ -385,20 +364,20 @@ XN_DDK_API XnStatus XnPropertySetFindProperty(const XnPropertySet* pSet, const X XN_VALIDATE_OUTPUT_PTR(ppEnumerator); // find module - XnPropertySetData::Iterator itModule = pSet->pData->end(); + XnPropertySetData::Iterator itModule = pSet->pData->End(); nRetVal = pSet->pData->Find(strModule, itModule); XN_IS_STATUS_OK(nRetVal); - XnActualPropertiesHash* pModule = itModule.Value(); + XnActualPropertiesHash* pModule = itModule->Value(); // find property - XnActualPropertiesHash::Iterator itProp = pModule->end(); + XnActualPropertiesHash::Iterator itProp = pModule->End(); nRetVal = pModule->Find(strProp, itProp); XN_IS_STATUS_OK(nRetVal); // create enumerator XnPropertySetEnumerator* pEnumer; - XN_VALIDATE_ALLOC(pEnumer, XnPropertySetEnumerator); + XN_VALIDATE_NEW(pEnumer, XnPropertySetEnumerator); pEnumer->itModule = itModule; pEnumer->itProp = itProp; @@ -413,21 +392,19 @@ XN_DDK_API XnStatus XnPropertySetFindProperty(const XnPropertySet* pSet, const X XN_DDK_API XnStatus XnPropertySetEnumeratorFree(XnPropertySetEnumerator** ppEnumerator) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(ppEnumerator); XN_VALIDATE_INPUT_PTR(*ppEnumerator); - xnOSFree(*ppEnumerator); + XN_DELETE(*ppEnumerator); *ppEnumerator = NULL; - + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetEnumeratorMoveNext(XnPropertySetEnumerator* pEnumerator, XnBool* pbEnd) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pbEnd); @@ -443,23 +420,23 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorMoveNext(XnPropertySetEnumerator* pEn nRetVal = pEnumerator->pModules->Find(pEnumerator->strModule, pEnumerator->itModule); if (nRetVal == XN_STATUS_NO_MATCH) { - pEnumerator->itModule = pEnumerator->pModules->end(); + pEnumerator->itModule = pEnumerator->pModules->End(); } XN_IS_STATUS_OK(nRetVal); - pEnumerator->itProp = pEnumerator->itModule.Value()->begin(); + pEnumerator->itProp = pEnumerator->itModule->Value()->Begin(); } - else if (pEnumerator->itProp == pEnumerator->itModule.Value()->end()) + else if (pEnumerator->itProp == pEnumerator->itModule->Value()->End()) { return XN_STATUS_ILLEGAL_POSITION; } else { // advance prop iterator - pEnumerator->itProp++; + ++pEnumerator->itProp; } - *pbEnd = (pEnumerator->itProp == pEnumerator->itModule.Value()->end()); + *pbEnd = (pEnumerator->itProp == pEnumerator->itModule->Value()->End()); } else // all modules { @@ -468,16 +445,16 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorMoveNext(XnPropertySetEnumerator* pEn pEnumerator->bFirst = FALSE; // search for the first modules that has properties - pEnumerator->itModule = pEnumerator->pModules->begin(); - while (pEnumerator->itModule != pEnumerator->pModules->end() && pEnumerator->itModule.Value()->IsEmpty()) + pEnumerator->itModule = pEnumerator->pModules->Begin(); + while (pEnumerator->itModule != pEnumerator->pModules->End() && pEnumerator->itModule->Value()->IsEmpty()) { pEnumerator->itModule++; } // if we found one, take it's first property - if (pEnumerator->itModule != pEnumerator->pModules->end()) + if (pEnumerator->itModule != pEnumerator->pModules->End()) { - pEnumerator->itProp = pEnumerator->itModule.Value()->begin(); + pEnumerator->itProp = pEnumerator->itModule->Value()->Begin(); *pbEnd = FALSE; } else @@ -485,29 +462,29 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorMoveNext(XnPropertySetEnumerator* pEn *pbEnd = TRUE; } } - else if (pEnumerator->itModule == pEnumerator->pModules->end()) + else if (pEnumerator->itModule == pEnumerator->pModules->End()) { return XN_STATUS_ILLEGAL_POSITION; } else { // move to next one - pEnumerator->itProp++; + ++pEnumerator->itProp; // check if we reached end of module - if (pEnumerator->itProp == pEnumerator->itModule.Value()->end()) + if (pEnumerator->itProp == pEnumerator->itModule->Value()->End()) { // move to next module with properties do { pEnumerator->itModule++; } - while (pEnumerator->itModule != pEnumerator->pModules->end() && pEnumerator->itModule.Value()->IsEmpty()); + while (pEnumerator->itModule != pEnumerator->pModules->End() && pEnumerator->itModule->Value()->IsEmpty()); // if we found one, take it's first property - if (pEnumerator->itModule != pEnumerator->pModules->end()) + if (pEnumerator->itModule != pEnumerator->pModules->End()) { - pEnumerator->itProp = pEnumerator->itModule.Value()->begin(); + pEnumerator->itProp = pEnumerator->itModule->Value()->Begin(); *pbEnd = FALSE; } else @@ -527,29 +504,25 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorMoveNext(XnPropertySetEnumerator* pEn XN_DDK_API XnStatus XnPropertySetEnumeratorGetCurrentPropertyInfo(const XnPropertySetEnumerator* pEnumerator, XnPropertyType* pnType, const XnChar** pstrModule, const XnChar** pstrProp) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pnType); XN_VALIDATE_OUTPUT_PTR(pstrModule); XN_VALIDATE_OUTPUT_PTR(pstrProp); - - XnProperty* pProp = pEnumerator->itProp.Value(); + + XnProperty* pProp = pEnumerator->itProp->Value(); *pnType = pProp->GetType(); *pstrModule = pProp->GetModule(); *pstrProp = pProp->GetName(); - + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetEnumeratorGetIntValue(const XnPropertySetEnumerator* pEnumerator, XnUInt64* pnValue) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pnValue); - XnProperty* pPropBase = pEnumerator->itProp.Value(); + XnProperty* pPropBase = pEnumerator->itProp->Value(); if (pPropBase->GetType() != XN_PROPERTY_TYPE_INTEGER) { return XN_STATUS_DEVICE_PROPERTY_BAD_TYPE; @@ -563,12 +536,10 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorGetIntValue(const XnPropertySetEnumer XN_DDK_API XnStatus XnPropertySetEnumeratorGetRealValue(const XnPropertySetEnumerator* pEnumerator, XnDouble* pdValue) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pdValue); - XnProperty* pPropBase = pEnumerator->itProp.Value(); + XnProperty* pPropBase = pEnumerator->itProp->Value(); if (pPropBase->GetType() != XN_PROPERTY_TYPE_REAL) { return XN_STATUS_DEVICE_PROPERTY_BAD_TYPE; @@ -582,12 +553,10 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorGetRealValue(const XnPropertySetEnume XN_DDK_API XnStatus XnPropertySetEnumeratorGetStringValue(const XnPropertySetEnumerator* pEnumerator, const XnChar** pstrValue) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pstrValue); - XnProperty* pPropBase = pEnumerator->itProp.Value(); + XnProperty* pPropBase = pEnumerator->itProp->Value(); if (pPropBase->GetType() != XN_PROPERTY_TYPE_STRING) { return XN_STATUS_DEVICE_PROPERTY_BAD_TYPE; @@ -601,12 +570,10 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorGetStringValue(const XnPropertySetEnu XN_DDK_API XnStatus XnPropertySetEnumeratorGetGeneralValue(const XnPropertySetEnumerator* pEnumerator, XnGeneralBuffer* pgbValue) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pEnumerator); XN_VALIDATE_OUTPUT_PTR(pgbValue); - XnProperty* pPropBase = pEnumerator->itProp.Value(); + XnProperty* pPropBase = pEnumerator->itProp->Value(); if (pPropBase->GetType() != XN_PROPERTY_TYPE_GENERAL) { return XN_STATUS_DEVICE_PROPERTY_BAD_TYPE; @@ -621,46 +588,54 @@ XN_DDK_API XnStatus XnPropertySetEnumeratorGetGeneralValue(const XnPropertySetEn XN_DDK_API XnStatus XnPropertySetDataAttachModule(XnPropertySetData* pSetData, const XnChar* strModuleName, XnActualPropertiesHash* pModule) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSetData); XN_VALIDATE_INPUT_PTR(strModuleName); XN_VALIDATE_INPUT_PTR(pModule); nRetVal = pSetData->Set(strModuleName, pModule); XN_IS_STATUS_OK(nRetVal); - + return (XN_STATUS_OK); } XN_DDK_API XnStatus XnPropertySetDataDetachModule(XnPropertySetData* pSetData, const XnChar* strModuleName, XnActualPropertiesHash** ppModule) { XnStatus nRetVal = XN_STATUS_OK; - + XN_VALIDATE_INPUT_PTR(pSetData); XN_VALIDATE_INPUT_PTR(strModuleName); XN_VALIDATE_OUTPUT_PTR(ppModule); - + // remove it - nRetVal = pSetData->Remove(strModuleName, *ppModule); + XnPropertySetDataInternal::Iterator it = pSetData->Find(strModuleName); + if (it == pSetData->End()) + { + return XN_STATUS_NO_MATCH; + } + + *ppModule = it->Value(); + + nRetVal = pSetData->Remove(strModuleName); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } -XN_DDK_API XnStatus XnPropertySetCloneModule(XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName) +XN_DDK_API XnStatus XnPropertySetCloneModule(const XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName) { XnStatus nRetVal = XN_STATUS_OK; - - XnActualPropertiesHash* pModuleProps; + + XnActualPropertiesHash* pModuleProps = NULL; nRetVal = pSource->pData->Get(strModule, pModuleProps); XN_IS_STATUS_OK(nRetVal); nRetVal = XnPropertySetAddModule(pDest, strNewName); XN_IS_STATUS_OK(nRetVal); - for (XnActualPropertiesHash::ConstIterator it = pModuleProps->begin(); it != pModuleProps->end(); ++it) + for (XnActualPropertiesHash::ConstIterator it = pModuleProps->Begin(); it != pModuleProps->End(); ++it) { - XnProperty* pProp = it.Value(); + XnProperty* pProp = it->Value(); switch (pProp->GetType()) { case XN_PROPERTY_TYPE_INTEGER: @@ -695,6 +670,6 @@ XN_DDK_API XnStatus XnPropertySetCloneModule(XnPropertySet* pSource, XnPropertyS XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", pProp->GetType()); } } - + return (XN_STATUS_OK); } diff --git a/Source/XnDDK/XnPropertySetInternal.h b/Source/XnDDK/XnPropertySetInternal.h index 2f3b287..4e080e7 100644 --- a/Source/XnDDK/XnPropertySetInternal.h +++ b/Source/XnDDK/XnPropertySetInternal.h @@ -1,35 +1,31 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PROPERTY_SET_INTERNAL_H__ #define __XN_PROPERTY_SET_INTERNAL_H__ #include #include "XnActualPropertiesHash.h" -XN_DECLARE_STRINGS_HASH_DECL(XN_DDK_CPP_API, XnActualPropertiesHash*, XnPropertySetDataInternal) +typedef XnStringsHashT XnPropertySetDataInternal; class XnPropertySetData; @@ -58,6 +54,6 @@ class XnPropertySetData : public XnPropertySetDataInternal XN_DDK_API XnStatus XnPropertySetDataAttachModule(XnPropertySetData* pSetData, const XnChar* strModuleName, XnActualPropertiesHash* pModule); XN_DDK_API XnStatus XnPropertySetDataDetachModule(XnPropertySetData* pSetData, const XnChar* strModuleName, XnActualPropertiesHash** ppModule); -XN_DDK_API XnStatus XnPropertySetCloneModule(XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName); +XN_DDK_API XnStatus XnPropertySetCloneModule(const XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName); #endif //__XN_PROPERTY_SET_INTERNAL_H__ diff --git a/Source/XnDDK/XnRealProperty.cpp b/Source/XnDDK/XnRealProperty.cpp index 5980939..060b5d0 100644 --- a/Source/XnDDK/XnRealProperty.cpp +++ b/Source/XnDDK/XnRealProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnRealProperty.h b/Source/XnDDK/XnRealProperty.h index 2af3c24..13e553b 100644 --- a/Source/XnDDK/XnRealProperty.h +++ b/Source/XnDDK/XnRealProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_REAL_PROPERTY_H__ #define __XN_REAL_PROPERTY_H__ diff --git a/Source/XnDDK/XnShiftToDepth.cpp b/Source/XnDDK/XnShiftToDepth.cpp index 47a0394..bb87d49 100644 --- a/Source/XnDDK/XnShiftToDepth.cpp +++ b/Source/XnDDK/XnShiftToDepth.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -88,7 +82,7 @@ XN_DDK_API XnStatus XnShiftToDepthUpdate(XnShiftToDepthTables* pShiftToDepth, co for (nIndex = 1; nIndex < pConfig->nDeviceMaxShiftValue; nIndex++) { - nShiftValue = nIndex; + nShiftValue = (XnInt16)nIndex; dFixedRefX = (XnDouble)(nShiftValue - nConstShift) / (XnDouble)pConfig->nParamCoeff; dFixedRefX -= 0.375; @@ -103,7 +97,7 @@ XN_DDK_API XnStatus XnShiftToDepthUpdate(XnShiftToDepthTables* pShiftToDepth, co for (XnUInt16 i = nLastDepth; i < dDepth; i++) pDepthToShiftTable[i] = nLastIndex; - nLastIndex = nIndex; + nLastIndex = (XnUInt16)nIndex; nLastDepth = (XnUInt16)dDepth; } } diff --git a/Source/XnDDK/XnShiftToDepth.h b/Source/XnDDK/XnShiftToDepth.h index cdfca90..d6dd97e 100644 --- a/Source/XnDDK/XnShiftToDepth.h +++ b/Source/XnDDK/XnShiftToDepth.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_SHIFT_TO_DEPTH_H_ #define _XN_SHIFT_TO_DEPTH_H_ diff --git a/Source/XnDDK/XnShiftToDepthStreamHelper.cpp b/Source/XnDDK/XnShiftToDepthStreamHelper.cpp index 27c6e2b..e318e36 100644 --- a/Source/XnDDK/XnShiftToDepthStreamHelper.cpp +++ b/Source/XnDDK/XnShiftToDepthStreamHelper.cpp @@ -1,34 +1,30 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #include "XnShiftToDepthStreamHelper.h" -XnShiftToDepthStreamHelper::XnShiftToDepthStreamHelper(XnDeviceModule* pModule) : +XnShiftToDepthStreamHelper::XnShiftToDepthStreamHelper() : m_ShiftToDepthTable(XN_STREAM_PROPERTY_S2D_TABLE, NULL, 0, NULL), m_DepthToShiftTable(XN_STREAM_PROPERTY_D2S_TABLE, NULL, 0, NULL), - m_pModule(pModule), + m_pModule(NULL), m_bPropertiesAdded(FALSE) { m_ShiftToDepthTable.UpdateGetCallback(GetShiftToDepthTableCallback, this); @@ -41,9 +37,12 @@ XnShiftToDepthStreamHelper::~XnShiftToDepthStreamHelper() XnShiftToDepthStreamHelper::Free(); } -XnStatus XnShiftToDepthStreamHelper::Init() +XnStatus XnShiftToDepthStreamHelper::Init(XnDeviceModule* pModule) { XnStatus nRetVal = XN_STATUS_OK; + + XN_VALIDATE_INPUT_PTR(pModule); + m_pModule = pModule; // old depth streams did not have S2D tables as actual properties. Add these properties XnBool bDoesExist = FALSE; @@ -96,13 +95,15 @@ XnStatus XnShiftToDepthStreamHelper::InitShiftToDepth() XnUInt32 nPropCount = sizeof(propNames) / sizeof(const XnChar*); + XnCallbackHandle hDummy; + XnProperty* pProperty = NULL; for (XnUInt32 i = 0; i < nPropCount; ++i) { nRetVal = m_pModule->GetProperty(propNames[i], &pProperty); XN_IS_STATUS_OK(nRetVal); - nRetVal = pProperty->OnChangeEvent().Register(ShiftToDepthPropertyValueChangedCallback, this); + nRetVal = pProperty->OnChangeEvent().Register(ShiftToDepthPropertyValueChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); } @@ -110,13 +111,13 @@ XnStatus XnShiftToDepthStreamHelper::InitShiftToDepth() nRetVal = m_pModule->GetProperty(XN_STREAM_PROPERTY_MAX_SHIFT, &pProperty); XN_IS_STATUS_OK(nRetVal); - nRetVal = pProperty->OnChangeEvent().Register(DeviceS2DTablesSizeChangedCallback, this); + nRetVal = pProperty->OnChangeEvent().Register(DeviceS2DTablesSizeChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = m_pModule->GetProperty(XN_STREAM_PROPERTY_DEVICE_MAX_DEPTH, &pProperty); XN_IS_STATUS_OK(nRetVal); - nRetVal = pProperty->OnChangeEvent().Register(DeviceS2DTablesSizeChangedCallback, this); + nRetVal = pProperty->OnChangeEvent().Register(DeviceS2DTablesSizeChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); // now init the tables @@ -273,25 +274,25 @@ XnStatus XnShiftToDepthStreamHelper::GetDepthToShiftTableImpl(const XnGeneralBuf return XN_STATUS_OK; } -XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::GetShiftToDepthTableCallback(const XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::GetShiftToDepthTableCallback(const XnActualGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XnShiftToDepthStreamHelper* pStream = (XnShiftToDepthStreamHelper*)pCookie; return pStream->GetShiftToDepthTableImpl(gbValue); } -XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::GetDepthToShiftTableCallback(const XnActualGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::GetDepthToShiftTableCallback(const XnActualGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XnShiftToDepthStreamHelper* pStream = (XnShiftToDepthStreamHelper*)pCookie; return pStream->GetDepthToShiftTableImpl(gbValue); } -XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::ShiftToDepthPropertyValueChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::ShiftToDepthPropertyValueChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnShiftToDepthStreamHelper* pStream = (XnShiftToDepthStreamHelper*)pCookie; return pStream->OnShiftToDepthPropertyValueChanged(); } -XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::DeviceS2DTablesSizeChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnShiftToDepthStreamHelper::DeviceS2DTablesSizeChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnShiftToDepthStreamHelper* pStream = (XnShiftToDepthStreamHelper*)pCookie; return pStream->OnDeviceS2DTablesSizeChanged(); diff --git a/Source/XnDDK/XnShiftToDepthStreamHelper.h b/Source/XnDDK/XnShiftToDepthStreamHelper.h index a409d75..ba68ef4 100644 --- a/Source/XnDDK/XnShiftToDepthStreamHelper.h +++ b/Source/XnDDK/XnShiftToDepthStreamHelper.h @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SHIFT_TO_DEPTH_STREAM_HELPER_H__ #define __XN_SHIFT_TO_DEPTH_STREAM_HELPER_H__ @@ -32,10 +28,10 @@ class XN_DDK_CPP_API XnShiftToDepthStreamHelper { public: - XnShiftToDepthStreamHelper(XnDeviceModule* pModule); + XnShiftToDepthStreamHelper(); virtual ~XnShiftToDepthStreamHelper(); - XnStatus Init(); + XnStatus Init(XnDeviceModule* pModule); XnStatus Free(); inline XnDepthPixel* GetShiftToDepthTable() const { return m_ShiftToDepthTables.pShiftToDepthTable; } diff --git a/Source/XnDDK/XnSimpleBufferPool.cpp b/Source/XnDDK/XnSimpleBufferPool.cpp index ea0e99f..6968619 100644 --- a/Source/XnDDK/XnSimpleBufferPool.cpp +++ b/Source/XnDDK/XnSimpleBufferPool.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -33,7 +27,8 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnSimpleBufferPool::XnSimpleBufferPool(XnUInt32 nBufferCount) : XnBufferPool(nBufferCount) +XnSimpleBufferPool::XnSimpleBufferPool(XnUInt32 nBufferCount) : + m_nBufferCount(nBufferCount) {} XnSimpleBufferPool::~XnSimpleBufferPool() @@ -41,33 +36,24 @@ XnSimpleBufferPool::~XnSimpleBufferPool() FreeAll(TRUE); } -XnStatus XnSimpleBufferPool::AllocateBuffers() +XnStatus XnSimpleBufferPool::AllocateBuffers(XnUInt32 nSize) { XnStatus nRetVal = XN_STATUS_OK; - // first free old ones - FreeAll(FALSE); - // now allocate new for (XnUInt32 i = 0; i < m_nBufferCount; ++i) { - XnBufferInPool* pBufferInPool; - XN_VALIDATE_NEW(pBufferInPool, XnBufferInPool); - nRetVal = pBufferInPool->Allocate(m_nBufferSize); + void* pBuffer; + XN_VALIDATE_ALIGNED_CALLOC(pBuffer, XnUChar, nSize, XN_DEFAULT_MEM_ALIGN); + nRetVal = AddNewBuffer(pBuffer, nSize); XN_IS_STATUS_OK(nRetVal); - pBufferInPool->m_nID = i; - - // add it to all list - m_AllBuffers.AddLast(pBufferInPool); - // and to free list - m_FreeBuffers.AddLast(pBufferInPool); } return (XN_STATUS_OK); } -void XnSimpleBufferPool::DestroyBuffer(XnBufferInPool* pBuffer) +void XnSimpleBufferPool::DestroyBuffer(void* pBuffer) { - XN_DELETE(pBuffer); + xnOSFreeAligned(pBuffer); } diff --git a/Source/XnDDK/XnSimpleBufferPool.h b/Source/XnDDK/XnSimpleBufferPool.h index 55ceb1f..5232c37 100644 --- a/Source/XnDDK/XnSimpleBufferPool.h +++ b/Source/XnDDK/XnSimpleBufferPool.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SIMPLE_BUFFER_POOL_H__ #define __XN_SIMPLE_BUFFER_POOL_H__ @@ -32,7 +26,6 @@ // Includes //--------------------------------------------------------------------------- #include "XnBufferPool.h" -#include //--------------------------------------------------------------------------- // Types @@ -44,8 +37,11 @@ class XnSimpleBufferPool : public XnBufferPool ~XnSimpleBufferPool(); protected: - virtual XnStatus AllocateBuffers(); - virtual void DestroyBuffer(XnBufferInPool* pBuffer); + virtual XnStatus AllocateBuffers(XnUInt32 nSize); + virtual void DestroyBuffer(void* pBuffer); + +private: + XnUInt32 m_nBufferCount; }; #endif // __XN_SIMPLE_BUFFER_POOL_H__ \ No newline at end of file diff --git a/Source/XnDDK/XnStreamData.cpp b/Source/XnDDK/XnStreamData.cpp index 0b6e425..ceb6d41 100644 --- a/Source/XnDDK/XnStreamData.cpp +++ b/Source/XnDDK/XnStreamData.cpp @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -36,8 +31,6 @@ //--------------------------------------------------------------------------- XN_DDK_API XnStatus XnStreamDataCreateNoBuffer(XnStreamData** ppStreamOutput, const XnChar* StreamName) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_OUTPUT_PTR(ppStreamOutput); // allocate struct @@ -87,28 +80,33 @@ XN_DDK_API XnStatus XnStreamDataCreate(XnStreamData** ppStreamOutput, const XnCh XN_DDK_API XnStatus XnStreamDataUpdateSize(XnStreamData* pStreamOutput, XnUInt32 nAllocSize) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(pStreamOutput); // allocate new memory - void* pNew = xnOSMallocAligned(nAllocSize, XN_DEFAULT_MEM_ALIGN); - if (pNew == NULL) - return (XN_STATUS_ALLOC_FAILED); + void* pNew = NULL; + + if (nAllocSize > 0) + { + pNew = xnOSMallocAligned(nAllocSize, XN_DEFAULT_MEM_ALIGN); + if (pNew == NULL) + return (XN_STATUS_ALLOC_FAILED); - // zero it - xnOSMemSet(pNew, 0, nAllocSize); + // zero it + xnOSMemSet(pNew, 0, nAllocSize); + } // free the buffer if it is allocated - XN_ALIGNED_FREE_AND_NULL(pStreamOutput->pData); + if (pStreamOutput->pData != NULL) + { + XN_ALIGNED_FREE_AND_NULL(pStreamOutput->pData); + } // and now set new buffer pStreamOutput->pData = pNew; // and size pStreamOutput->pInternal->nAllocSize = nAllocSize; - - pStreamOutput->pInternal->bAllocated = TRUE; + pStreamOutput->pInternal->bAllocated = (nAllocSize > 0); return XN_STATUS_OK; } diff --git a/Source/XnDDK/XnStreamDataInternal.h b/Source/XnDDK/XnStreamDataInternal.h index 510e756..f31cb65 100644 --- a/Source/XnDDK/XnStreamDataInternal.h +++ b/Source/XnDDK/XnStreamDataInternal.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_DATA_INTERNAL_H__ #define __XN_STREAM_DATA_INTERNAL_H__ diff --git a/Source/XnDDK/XnStreamDataSet.cpp b/Source/XnDDK/XnStreamDataSet.cpp index 9e21ba1..13ce053 100644 --- a/Source/XnDDK/XnStreamDataSet.cpp +++ b/Source/XnDDK/XnStreamDataSet.cpp @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -61,9 +56,9 @@ XN_DDK_API XnStatus XnStreamDataSetDestroy(XnStreamDataSet** ppStreamOutputSet) XnStreamDataSet* pSet = (*ppStreamOutputSet); if (pSet != NULL) { - for (XnStreamDataHash::Iterator it = pSet->pHash->begin(); it != pSet->pHash->end(); ++it) + for (XnStreamDataHash::Iterator it = pSet->pHash->Begin(); it != pSet->pHash->End(); ++it) { - XnStreamData* pStreamData = it.Value(); + XnStreamData* pStreamData = it->Value(); XnStreamDataDestroy(&pStreamData); } @@ -83,7 +78,7 @@ XN_DDK_API XnStatus XnStreamDataSetAdd(XnStreamDataSet* pStreamOutputSet, XnStre XN_VALIDATE_INPUT_PTR(pStreamOutput); // make sure another object of this stream is not already in set - XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->end(); + XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->End(); if (XN_STATUS_NO_MATCH != pStreamOutputSet->pHash->Find(pStreamOutput->StreamName, it)) return XN_STATUS_STREAM_OUTPUT_SET_ALREADY_IN_SET; @@ -95,9 +90,9 @@ XN_DDK_API XnStatus XnStreamDataSetRemove(XnStreamDataSet* pStreamOutputSet, XnS XN_VALIDATE_INPUT_PTR(pStreamOutputSet); XN_VALIDATE_INPUT_PTR(pStreamOutput); - for (XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->begin(); it != pStreamOutputSet->pHash->end(); ++it) + for (XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->Begin(); it != pStreamOutputSet->pHash->End(); ++it) { - if (pStreamOutput == it.Value()) + if (pStreamOutput == it->Value()) { pStreamOutputSet->pHash->Remove(it); break; @@ -150,9 +145,9 @@ XN_DDK_API XnStatus XnStreamDataSetCopyToArray(const XnStreamDataSet* pStreamOut // now copy XnUInt32 nIndex = 0; - for (XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->begin(); it != pStreamOutputSet->pHash->end(); ++it) + for (XnStreamDataHash::Iterator it = pStreamOutputSet->pHash->Begin(); it != pStreamOutputSet->pHash->End(); ++it) { - apStreamOutputs[nIndex] = it.Value(); + apStreamOutputs[nIndex] = it->Value(); nIndex++; } diff --git a/Source/XnDDK/XnStreamDataSetInternal.h b/Source/XnDDK/XnStreamDataSetInternal.h index 331dd1c..60a8025 100644 --- a/Source/XnDDK/XnStreamDataSetInternal.h +++ b/Source/XnDDK/XnStreamDataSetInternal.h @@ -1,38 +1,34 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_DATA_SET_INTERNAL_H__ #define __XN_STREAM_DATA_SET_INTERNAL_H__ #include "XnStreamDataSet.h" -#include +#include //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- -XN_DECLARE_STRINGS_HASH(XnStreamData*, XnStreamDataHash) +typedef XnStringsHashT XnStreamDataHash; struct XnStreamDataSet { diff --git a/Source/XnDDK/XnStreamDevice.cpp b/Source/XnDDK/XnStreamDevice.cpp index c7d527e..2193ee0 100644 --- a/Source/XnDDK/XnStreamDevice.cpp +++ b/Source/XnDDK/XnStreamDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -67,12 +61,12 @@ void XnStreamDevice::DestroyImpl(XnBool bHasVTable) } } -XnStatus XnStreamDevice::Seek(XnUInt64 nTimestamp) +XnStatus XnStreamDevice::Seek(XnUInt64 /*nTimestamp*/) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } -XnStatus XnStreamDevice::SeekFrame(XnUInt32 nFrameID) +XnStatus XnStreamDevice::SeekFrame(XnUInt32 /*nFrameID*/) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } diff --git a/Source/XnDDK/XnStreamDevice.h b/Source/XnDDK/XnStreamDevice.h index a82ba21..2dbb9a7 100644 --- a/Source/XnDDK/XnStreamDevice.h +++ b/Source/XnDDK/XnStreamDevice.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_DEVICE_H__ #define __XN_STREAM_DEVICE_H__ @@ -62,6 +57,8 @@ class XN_DDK_CPP_API XnStreamDevice : public XnDeviceBase virtual void DestroyIOStreamImpl(XnIOStream* pStream) = 0; private: + XN_DISABLE_COPY_AND_ASSIGN(XnStreamDevice); + XnIOStream* m_pIOStream; XnDataPacker* m_pDataPacker; XnUInt32 m_nInternalBufferSize; diff --git a/Source/XnDDK/XnStreamDeviceStreamHolder.cpp b/Source/XnDDK/XnStreamDeviceStreamHolder.cpp index febe781..4cdd76d 100644 --- a/Source/XnDDK/XnStreamDeviceStreamHolder.cpp +++ b/Source/XnDDK/XnStreamDeviceStreamHolder.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -62,7 +56,8 @@ XnStatus XnStreamDeviceStreamHolder::Init(const XnActualPropertiesHash* pProps) nRetVal = m_CodecProperties.Set(&m_Compression, &m_Compression); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_Compression.OnChangeEvent().Register(CodecPropertyChangedCallback, this, NULL); + XnCallbackHandle hDummy; + nRetVal = m_Compression.OnChangeEvent().Register(CodecPropertyChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = ChooseCodec(); @@ -197,24 +192,33 @@ XnStatus XnStreamDeviceStreamHolder::ChooseCodec() } // register to new props - for (XnPropertiesList::Iterator it = CodecProps.begin(); it != CodecProps.end(); ++it) + for (XnPropertiesList::Iterator it = CodecProps.Begin(); it != CodecProps.End(); ++it) { XnProperty* pProp = *it; - XnPropertiesHash::Iterator hashIt = m_CodecProperties.end(); + XnPropertiesHash::Iterator hashIt = m_CodecProperties.End(); nRetVal = m_CodecProperties.Find(pProp, hashIt); if (nRetVal == XN_STATUS_NO_MATCH) { XnCallbackHandle hCallbackDummy; - nRetVal = pProp->OnChangeEvent().Register(CodecPropertyChangedCallback, this, &hCallbackDummy); - XN_IS_STATUS_OK(nRetVal); + nRetVal = pProp->OnChangeEvent().Register(CodecPropertyChangedCallback, this, hCallbackDummy); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pCodec); + return (nRetVal); + } nRetVal = m_CodecProperties.Set(pProp, NULL); - XN_IS_STATUS_OK(nRetVal); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pCodec); + return (nRetVal); + } } - else + else if (nRetVal != XN_STATUS_OK) { - XN_IS_STATUS_OK(nRetVal); + XN_DELETE(pCodec); + return (nRetVal); } } @@ -225,7 +229,7 @@ XnStatus XnStreamDeviceStreamHolder::ChooseCodec() return (XN_STATUS_OK); } -XnStatus XnStreamDeviceStreamHolder::CodecPropertyChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XnStreamDeviceStreamHolder::CodecPropertyChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnStreamDeviceStreamHolder* pThis = (XnStreamDeviceStreamHolder*)pCookie; return pThis->ChooseCodec(); diff --git a/Source/XnDDK/XnStreamDeviceStreamHolder.h b/Source/XnDDK/XnStreamDeviceStreamHolder.h index a01ed06..2e8bd4f 100644 --- a/Source/XnDDK/XnStreamDeviceStreamHolder.h +++ b/Source/XnDDK/XnStreamDeviceStreamHolder.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_DEVICE_STREAM_HOLDER_H__ #define __XN_STREAM_DEVICE_STREAM_HOLDER_H__ @@ -32,7 +27,7 @@ //--------------------------------------------------------------------------- #include "XnDeviceModuleHolder.h" #include "XnDeviceStream.h" -#include +#include #include //--------------------------------------------------------------------------- @@ -63,7 +58,7 @@ class XN_DDK_CPP_API XnStreamDeviceStreamHolder : public XnDeviceModuleHolder XnActualIntProperty m_Compression; XnCodec* m_pCodec; - XN_DECLARE_DEFAULT_HASH(XnProperty*, XnValue, XnPropertiesHash) + typedef XnHashT XnPropertiesHash; XnPropertiesHash m_CodecProperties; }; diff --git a/Source/XnDDK/XnStreamReaderDevice.cpp b/Source/XnDDK/XnStreamReaderDevice.cpp index d0f6dc0..12ab221 100644 --- a/Source/XnDDK/XnStreamReaderDevice.cpp +++ b/Source/XnDDK/XnStreamReaderDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -125,31 +119,31 @@ XnStatus XnStreamReaderDevice::SetInitialState(const XnDeviceConfig* pDeviceConf // now create the rest of the modules and streams (DEVICE was already created) XnPropertySetData* pPropSetData = pSet->pData; - for (XnPropertySetData::ConstIterator it = pPropSetData->begin(); it != pPropSetData->end(); ++it) + for (XnPropertySetData::ConstIterator it = pPropSetData->Begin(); it != pPropSetData->End(); ++it) { // ignore module DEVICE - if (strcmp(XN_MODULE_NAME_DEVICE, it.Key()) == 0) + if (strcmp(XN_MODULE_NAME_DEVICE, it->Key()) == 0) { continue; } // check if this is a stream - XnActualPropertiesHash::ConstIterator itProp = it.Value()->end(); - if (XN_STATUS_OK == it.Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) + XnActualPropertiesHash::ConstIterator itProp = it->Value()->End(); + if (XN_STATUS_OK == it->Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) { - XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp.Value(); - nRetVal = HandleNewStream(pTypeProp->GetValue(), it.Key(), it.Value()); + XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp->Value(); + nRetVal = HandleNewStream(pTypeProp->GetValue(), it->Key(), it->Value()); XN_IS_STATUS_OK(nRetVal); } else { // this is module. create it XnDeviceModuleHolder* pHolder = NULL; - nRetVal = CreateModule(it.Key(), &pHolder); + nRetVal = CreateModule(it->Key(), &pHolder); XN_IS_STATUS_OK(nRetVal); // set its props - nRetVal = pHolder->Init(it.Value()); + nRetVal = pHolder->Init(it->Value()); if (nRetVal != XN_STATUS_OK) { DestroyModule(pHolder); @@ -171,8 +165,6 @@ XnStatus XnStreamReaderDevice::SetInitialState(const XnDeviceConfig* pDeviceConf XnStatus XnStreamReaderDevice::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { - XnStatus nRetVal = XN_STATUS_OK; - XnStreamReaderStream* pStream; XN_VALIDATE_NEW(pStream, XnStreamReaderStream, StreamType, StreamName); @@ -282,7 +274,7 @@ XnStatus XnStreamReaderDevice::ReadNewStream() if (nRetVal == XN_STATUS_OK) { // create it - nRetVal = HandleNewStream(strType, strName, pPropertySet->pData->begin().Value()); + nRetVal = HandleNewStream(strType, strName, pPropertySet->pData->Begin()->Value()); } XnPropertySetDestroy(&pPropertySet); @@ -485,7 +477,7 @@ XnStatus XnStreamReaderDevice::ReadStreamData() return (XN_STATUS_OK); } -XnStatus XnStreamReaderDevice::HandleStreamData(XnStreamData* pDataProps, XnCompressionFormats nCompression, XnUInt32 nCompressedSize) +XnStatus XnStreamReaderDevice::HandleStreamData(XnStreamData* pDataProps, XnCompressionFormats /*nCompression*/, XnUInt32 /*nCompressedSize*/) { XnStatus nRetVal = XN_STATUS_OK; @@ -505,7 +497,7 @@ XnStatus XnStreamReaderDevice::HandleStreamData(XnStreamData* pDataProps, XnComp nRetVal = GetDataPacker()->ReadStreamData(pStreamData, pStreamHolder->GetCodec()); XN_IS_STATUS_OK(nRetVal); - pStream->NewDataAvailable(); + pStream->NewDataAvailable(pStreamData->nTimestamp, pStreamData->nFrameID); return (XN_STATUS_OK); } diff --git a/Source/XnDDK/XnStreamReaderDevice.h b/Source/XnDDK/XnStreamReaderDevice.h index 6f91d17..ad46004 100644 --- a/Source/XnDDK/XnStreamReaderDevice.h +++ b/Source/XnDDK/XnStreamReaderDevice.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_READER_DEVICE_H__ #define __XN_STREAM_READER_DEVICE_H__ diff --git a/Source/XnDDK/XnStreamReaderStream.cpp b/Source/XnDDK/XnStreamReaderStream.cpp index 0b5f10d..f29f6d1 100644 --- a/Source/XnDDK/XnStreamReaderStream.cpp +++ b/Source/XnDDK/XnStreamReaderStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -53,7 +47,8 @@ XnStatus XnStreamReaderStream::Init() XN_IS_STATUS_OK(nRetVal); // register for size change (so we can realloc stream data) - nRetVal = RequiredSizeProperty().OnChangeEvent().Register(RequiredSizeChangedCallback, this); + XnCallbackHandle hCallback; + nRetVal = RequiredSizeProperty().OnChangeEvent().Register(RequiredSizeChangedCallback, this, hCallback); XN_IS_STATUS_OK(nRetVal); // and create stream data @@ -76,8 +71,6 @@ XnStatus XnStreamReaderStream::Free() XnStatus XnStreamReaderStream::ReadImpl(XnStreamData* pStreamData) { - XnStatus nRetVal = XN_STATUS_OK; - pStreamData->nFrameID = m_pLastData->nFrameID; pStreamData->nTimestamp = m_pLastData->nTimestamp; @@ -103,8 +96,9 @@ XnStatus XnStreamReaderStream::CalcRequiredSize(XnUInt32* pnRequiredSize) const return XN_STATUS_OK; } -void XnStreamReaderStream::NewDataAvailable() +void XnStreamReaderStream::NewDataAvailable(XnUInt64 nTimestamp, XnUInt32 /*nFrameID*/) { + m_pLastData->nTimestamp = nTimestamp; m_pLastData->nFrameID = ++m_nLastFrameIDFromStream; XnDeviceStream::NewDataAvailable(m_pLastData->nTimestamp, m_pLastData->nFrameID); } @@ -135,7 +129,7 @@ XnStatus XnStreamReaderStream::OnRequiredSizeChanged() return (XN_STATUS_OK); } -XnStatus XnStreamReaderStream::RequiredSizeChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XnStreamReaderStream::RequiredSizeChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnStreamReaderStream* pThis = (XnStreamReaderStream*)pCookie; return pThis->OnRequiredSizeChanged(); diff --git a/Source/XnDDK/XnStreamReaderStream.h b/Source/XnDDK/XnStreamReaderStream.h index 3f21763..1792bad 100644 --- a/Source/XnDDK/XnStreamReaderStream.h +++ b/Source/XnDDK/XnStreamReaderStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_READER_STREAM_H__ #define __XN_STREAM_READER_STREAM_H__ @@ -45,14 +40,14 @@ class XN_DDK_CPP_API XnStreamReaderStream : public XnDeviceStream XnStatus Free(); inline XnStreamData* GetStreamData() { return m_pLastData; } - void NewDataAvailable(); + virtual void NewDataAvailable(XnUInt64 nTimestamp, XnUInt32 nFrameID); void ReMarkDataAsNew(); void Reset(); protected: - XnStatus WriteImpl(XnStreamData* pStreamData) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } + XnStatus WriteImpl(XnStreamData* /*pStreamData*/) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } XnStatus ReadImpl(XnStreamData* pStreamOutput); - XnStatus Mirror(XnStreamData* pStreamData) const { return XN_STATUS_OK; } + XnStatus Mirror(XnStreamData* /*pStreamData*/) const { return XN_STATUS_OK; } XnStatus CalcRequiredSize(XnUInt32* pnRequiredSize) const; diff --git a/Source/XnDDK/XnStreamReaderStreamHolder.cpp b/Source/XnDDK/XnStreamReaderStreamHolder.cpp index 63b948f..0f55cfa 100644 --- a/Source/XnDDK/XnStreamReaderStreamHolder.cpp +++ b/Source/XnDDK/XnStreamReaderStreamHolder.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -52,8 +46,8 @@ XnStatus XnStreamReaderStreamHolder::Init(const XnActualPropertiesHash* pProps) if (strcmp(GetStream()->GetType(), XN_STREAM_TYPE_DEPTH) == 0) { - XN_VALIDATE_NEW(m_pS2DHelper, XnShiftToDepthStreamHelper, GetStream()); - nRetVal = m_pS2DHelper->Init(); + XN_VALIDATE_NEW(m_pS2DHelper, XnShiftToDepthStreamHelper); + nRetVal = m_pS2DHelper->Init(GetStream()); XN_IS_STATUS_OK(nRetVal); } @@ -62,8 +56,6 @@ XnStatus XnStreamReaderStreamHolder::Init(const XnActualPropertiesHash* pProps) XnStatus XnStreamReaderStreamHolder::Free() { - XnStatus nRetVal = XN_STATUS_OK; - if (m_pS2DHelper != NULL) { m_pS2DHelper->Free(); diff --git a/Source/XnDDK/XnStreamReaderStreamHolder.h b/Source/XnDDK/XnStreamReaderStreamHolder.h index e48a049..af37c39 100644 --- a/Source/XnDDK/XnStreamReaderStreamHolder.h +++ b/Source/XnDDK/XnStreamReaderStreamHolder.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_READER_STREAM_HOLDER_H__ #define __XN_STREAM_READER_STREAM_HOLDER_H__ diff --git a/Source/XnDDK/XnStreamWriterDevice.cpp b/Source/XnDDK/XnStreamWriterDevice.cpp index 6bfa1c8..afe431e 100644 --- a/Source/XnDDK/XnStreamWriterDevice.cpp +++ b/Source/XnDDK/XnStreamWriterDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -310,8 +304,6 @@ XnStatus XnStreamWriterDevice::SetProperty(const XnChar* ModuleName, const XnCha XnStatus XnStreamWriterDevice::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { - XnStatus nRetVal = XN_STATUS_OK; - XnStreamWriterStream* pStream; XN_VALIDATE_NEW(pStream, XnStreamWriterStream, StreamType, StreamName, GetDataPacker()); diff --git a/Source/XnDDK/XnStreamWriterDevice.h b/Source/XnDDK/XnStreamWriterDevice.h index 2bd6f17..6b71fdd 100644 --- a/Source/XnDDK/XnStreamWriterDevice.h +++ b/Source/XnDDK/XnStreamWriterDevice.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_WRITER_DEVICE_H__ #define __XN_STREAM_WRITER_DEVICE_H__ diff --git a/Source/XnDDK/XnStreamWriterStream.cpp b/Source/XnDDK/XnStreamWriterStream.cpp index 2490775..ad75908 100644 --- a/Source/XnDDK/XnStreamWriterStream.cpp +++ b/Source/XnDDK/XnStreamWriterStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnStreamWriterStream.h b/Source/XnDDK/XnStreamWriterStream.h index 4c0c5fd..894c24f 100644 --- a/Source/XnDDK/XnStreamWriterStream.h +++ b/Source/XnDDK/XnStreamWriterStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_WRITER_STREAM_H__ #define __XN_STREAM_WRITER_STREAM_H__ @@ -47,8 +42,8 @@ class XN_DDK_CPP_API XnStreamWriterStream : public XnDeviceStream protected: XnStatus WriteImpl(XnStreamData* pStreamData); - XnStatus ReadImpl(XnStreamData* pStreamOutput) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } - XnStatus Mirror(XnStreamData* pStreamData) const { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } + XnStatus ReadImpl(XnStreamData* /*pStreamOutput*/) { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } + XnStatus Mirror(XnStreamData* /*pStreamData*/) const { return XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED; } XnStatus CalcRequiredSize(XnUInt32* pnRequiredSize) const; diff --git a/Source/XnDDK/XnStreamingStream.cpp b/Source/XnDDK/XnStreamingStream.cpp index e7d8fd2..55a3c8a 100644 --- a/Source/XnDDK/XnStreamingStream.cpp +++ b/Source/XnDDK/XnStreamingStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -66,7 +60,7 @@ XnStatus XnStreamingStream::SetReadChunkSize(XnUInt32 nChunkSize) return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnStreamingStream::SetReadChunkSizeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnStreamingStream::SetReadChunkSizeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnStreamingStream* pStream = (XnStreamingStream*)pCookie; return pStream->SetReadChunkSize((XnUInt32)nValue); diff --git a/Source/XnDDK/XnStreamingStream.h b/Source/XnDDK/XnStreamingStream.h index fc5c7ab..49c34d8 100644 --- a/Source/XnDDK/XnStreamingStream.h +++ b/Source/XnDDK/XnStreamingStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAMING_STREAM_H__ #define __XN_STREAMING_STREAM_H__ diff --git a/Source/XnDDK/XnStringProperty.cpp b/Source/XnDDK/XnStringProperty.cpp index da2722d..c4d13b5 100644 --- a/Source/XnDDK/XnStringProperty.cpp +++ b/Source/XnDDK/XnStringProperty.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDDK/XnStringProperty.h b/Source/XnDDK/XnStringProperty.h index 49a58ff..bd5f103 100644 --- a/Source/XnDDK/XnStringProperty.h +++ b/Source/XnDDK/XnStringProperty.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STRING_PROPERTY_H__ #define __XN_STRING_PROPERTY_H__ diff --git a/Source/XnDeviceFile/XnDeviceFile.cpp b/Source/XnDeviceFile/XnDeviceFile.cpp index 344d3be..72d3942 100644 --- a/Source/XnDeviceFile/XnDeviceFile.cpp +++ b/Source/XnDeviceFile/XnDeviceFile.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -51,7 +45,7 @@ XnStatus XnDeviceFile::GetDefinition(XnDeviceDefinition* pDeviceDefinition) return (XN_STATUS_OK); } -XnStatus XnDeviceFile::Enumerate(XnConnectionString* aConnectionStrings, XnUInt32* pnCount) +XnStatus XnDeviceFile::Enumerate(XnConnectionString* /*aConnectionStrings*/, XnUInt32* pnCount) { XN_VALIDATE_INPUT_PTR(pnCount); diff --git a/Source/XnDeviceFile/XnDeviceFile.h b/Source/XnDeviceFile/XnDeviceFile.h index a29e6bc..b3e2338 100644 --- a/Source/XnDeviceFile/XnDeviceFile.h +++ b/Source/XnDeviceFile/XnDeviceFile.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICEFILE_H_ #define _XN_DEVICEFILE_H_ diff --git a/Source/XnDeviceFile/XnDeviceFileReader.cpp b/Source/XnDeviceFile/XnDeviceFileReader.cpp index b45e10b..f399100 100644 --- a/Source/XnDeviceFile/XnDeviceFileReader.cpp +++ b/Source/XnDeviceFile/XnDeviceFileReader.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -39,12 +33,12 @@ //--------------------------------------------------------------------------- typedef struct XnLastStreamData { - XnUInt32 nPosition; + XnUInt64 nPosition; XnUInt32 nFrameID; XnUInt64 nTimestamp; } XnLastStreamData; -XN_DECLARE_STRINGS_HASH(XnLastStreamData, XnLastStreamDataHash); +typedef XnStringsHashT XnLastStreamDataHash; //--------------------------------------------------------------------------- // Code @@ -53,15 +47,15 @@ XnDeviceFileReader::XnDeviceFileReader() : XnStreamReaderDevice(XN_DEVICE_NAME, XN_DEVICE_FILE_MAX_INTERNAL_BUFFER), m_FrameDelay(XN_MODULE_PROPERTY_FRAME_DELAY, FALSE), m_pBCData(NULL), - m_nFileVersion(-1), + m_nFileVersion(0), m_nReferenceTime(0), m_nReferenceTimestamp(0), m_bFileHasData(FALSE), m_bStreamsCollectionChanged(FALSE), - m_pThis(this), - m_InstancePointer(XN_FILE_PROPERTY_INSTANCE_POINTER, &m_pThis, sizeof(m_pThis), NULL) + m_InstancePointer(XN_FILE_PROPERTY_INSTANCE_POINTER) { m_FrameDelay.UpdateSetCallbackToDefault(); + m_InstancePointer.UpdateGetCallback(GetInstanceCallback, this); } XnDeviceFileReader::~XnDeviceFileReader() @@ -77,7 +71,8 @@ XnStatus XnDeviceFileReader::InitImpl(const XnDeviceConfig* pDeviceConfig) XN_IS_STATUS_OK(nRetVal); // register to events - nRetVal = OnStreamCollectionChangedEvent().Register(StreamCollectionChangedCallback, this); + XnCallbackHandle hDummy = NULL; + nRetVal = OnStreamCollectionChangedEvent().Register(StreamCollectionChangedCallback, this, hDummy); XN_IS_STATUS_OK(nRetVal); // TODO: remove this @@ -188,7 +183,7 @@ XnStatus XnDeviceFileReader::ReadInitialState(XnPropertySet *pSet) // now continue reading until we get to first data XnPackedDataType nType; XnBool bStateEnd = FALSE; - XnUInt32 nPositionBefore; + XnUInt64 nPositionBefore; while (!bStateEnd) { @@ -224,11 +219,11 @@ XnStatus XnDeviceFileReader::ReadInitialState(XnPropertySet *pSet) nRetVal = GetDataPacker()->ReadProperty(strModule, strProp, &nValue); XN_IS_STATUS_OK(nRetVal); - XnActualPropertiesHash* pModule; + XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModule, pModule); XN_IS_STATUS_OK(nRetVal); - XnProperty* pProp; + XnProperty* pProp = NULL; nRetVal = pModule->Get(strProp, pProp); XN_IS_STATUS_OK(nRetVal); @@ -319,14 +314,14 @@ XnStatus XnDeviceFileReader::HandleStreamRemoved(const XnChar* strName) // check for specific case: all streams are removed and then end-of-file is reached. // in this case, we don't really want to destroy streams, just wrap around. - XnStringsHash StreamsToRemove; - nRetVal = StreamsToRemove.Set(strName, NULL); + XnStringsSet StreamsToRemove; + nRetVal = StreamsToRemove.Set(strName); XN_IS_STATUS_OK(nRetVal); XnPackedDataType nType = XN_PACKED_STREAM_REMOVED; - XnUInt32 nPositionBefore; + XnUInt64 nPositionBefore; - while (TRUE) + for (;;) { nRetVal = GetIOStream()->Tell(&nPositionBefore); XN_IS_STATUS_OK(nRetVal); @@ -340,7 +335,7 @@ XnStatus XnDeviceFileReader::HandleStreamRemoved(const XnChar* strName) nRetVal = GetDataPacker()->ReadStreamRemoved(strTempName); XN_IS_STATUS_OK(nRetVal); - nRetVal = StreamsToRemove.Set(strTempName, NULL); + nRetVal = StreamsToRemove.Set(strTempName); XN_IS_STATUS_OK(nRetVal); } else @@ -352,9 +347,9 @@ XnStatus XnDeviceFileReader::HandleStreamRemoved(const XnChar* strName) if (nType != XN_PACKED_END) { // Not the case we were looking for. Remove those streams. - for (XnStringsHash::Iterator it = StreamsToRemove.begin(); it != StreamsToRemove.end(); ++it) + for (XnStringsSet::Iterator it = StreamsToRemove.Begin(); it != StreamsToRemove.End(); ++it) { - nRetVal = XnStreamReaderDevice::HandleStreamRemoved(it.Key()); + nRetVal = XnStreamReaderDevice::HandleStreamRemoved(it->Key()); XN_IS_STATUS_OK(nRetVal); } } @@ -392,11 +387,11 @@ XnStatus XnDeviceFileReader::HandleStreamData(XnStreamData* pDataProps, XnCompre { XnStatus nRetVal = XN_STATUS_OK; - XnUInt32 nPosition; + XnUInt64 nPosition; nRetVal = GetIOStream()->Tell(&nPosition); XN_IS_STATUS_OK(nRetVal); - XnUIntHash::Iterator it = m_PositionsToIgnore.end(); + XnUIntHash::Iterator it = m_PositionsToIgnore.End(); if (XN_STATUS_OK == m_PositionsToIgnore.Find(nPosition, it)) { // ignore this one. Just update the frame ID @@ -405,7 +400,7 @@ XnStatus XnDeviceFileReader::HandleStreamData(XnStreamData* pDataProps, XnCompre XN_IS_STATUS_OK(nRetVal); XnStreamReaderStream* pStream = (XnStreamReaderStream*)pHolder->GetStream(); - pStream->NewDataAvailable(); + pStream->NewDataAvailable(pDataProps->nTimestamp, pDataProps->nFrameID); // and remove it from list nRetVal = m_PositionsToIgnore.Remove(it); @@ -439,7 +434,7 @@ XnStatus XnDeviceFileReader::Rewind() nRetVal = GetStreamsList(streams); XN_IS_STATUS_OK(nRetVal); - for (XnDeviceModuleHolderList::Iterator it = streams.begin(); it != streams.end(); ++it) + for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it) { XnDeviceModuleHolder* pHolder = *it; @@ -465,10 +460,10 @@ XnStatus XnDeviceFileReader::Rewind() } // now set state. - for (XnPropertySetData::Iterator it = state.pData->begin(); it != state.pData->end(); ++it) + for (XnPropertySetData::Iterator it = state.pData->Begin(); it != state.pData->End(); ++it) { - const XnChar* strName = it.Key(); - XnActualPropertiesHash* pHash = it.Value(); + const XnChar* strName = it->Key(); + XnActualPropertiesHash* pHash = it->Value(); // fix it first if (strcmp(strName, XN_MODULE_NAME_DEVICE) == 0) @@ -556,7 +551,7 @@ void XnDeviceFileReader::FrameDelay(XnUInt64 nTimestamp) } } -XnStatus XnDeviceFileReader::WaitForPrimaryStream(XN_EVENT_HANDLE hNewDataEvent, XnStreamDataSet* pSet) +XnStatus XnDeviceFileReader::WaitForPrimaryStream(XN_EVENT_HANDLE /*hNewDataEvent*/, XnStreamDataSet* pSet) { XnStatus nRetVal = XN_STATUS_OK; @@ -573,7 +568,7 @@ XnStatus XnDeviceFileReader::WaitForPrimaryStream(XN_EVENT_HANDLE hNewDataEvent, return (XN_STATUS_OK); } -XnStatus XnDeviceFileReader::WaitForStream(XN_EVENT_HANDLE hNewDataEvent, XnDeviceStream* pStream) +XnStatus XnDeviceFileReader::WaitForStream(XN_EVENT_HANDLE /*hNewDataEvent*/, XnDeviceStream* pStream) { XnStatus nRetVal = XN_STATUS_OK; @@ -637,7 +632,7 @@ XnStatus XnDeviceFileReader::SeekTo(XnUInt64 nMinTimestamp, XnUInt32 nMinFrameID XnBool bFoundNewData = FALSE; // Keep current position. - XnUInt32 nStartingPosition; + XnUInt64 nStartingPosition; nRetVal = GetIOStream()->Tell(&nStartingPosition); XN_IS_STATUS_OK(nRetVal); @@ -651,19 +646,19 @@ XnStatus XnDeviceFileReader::SeekTo(XnUInt64 nMinTimestamp, XnUInt32 nMinFrameID } // start seeking forward until point is reached. - XnUInt32 nFoundPosition; + XnUInt64 nFoundPosition; XnLastStreamDataHash StreamsHash; - while (TRUE) + for (;;) { - XnUInt32 nPositionBefore; + XnUInt64 nPositionBefore; nRetVal = GetIOStream()->Tell(&nPositionBefore); XN_IS_STATUS_OK(nRetVal); nRetVal = GetDataPacker()->ReadNextObject(&nType); XN_IS_STATUS_OK(nRetVal); - XnUInt32 nPositionAfter; + XnUInt64 nPositionAfter; nRetVal = GetIOStream()->Tell(&nPositionAfter); XN_IS_STATUS_OK(nRetVal); @@ -727,7 +722,7 @@ XnStatus XnDeviceFileReader::SeekTo(XnUInt64 nMinTimestamp, XnUInt32 nMinFrameID if (bFoundNewData) { // read everything up to position - XnUInt32 nPositionAfter = nStartingPosition; + XnUInt64 nPositionAfter = nStartingPosition; while (nPositionAfter < nFoundPosition) { @@ -745,7 +740,7 @@ XnStatus XnDeviceFileReader::SeekTo(XnUInt64 nMinTimestamp, XnUInt32 nMinFrameID nRetVal = GetStreamsList(streams); XN_IS_STATUS_OK(nRetVal); - for (XnDeviceModuleHolderList::Iterator it = streams.begin(); it != streams.end(); ++it) + for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it) { XnStreamReaderStream* pStream = (XnStreamReaderStream*)(*it)->GetModule(); pStream->ReMarkDataAsNew(); @@ -792,16 +787,16 @@ XnStatus XnDeviceFileReader::SeekFrame(XnUInt32 nFrameID) return (XN_STATUS_OK); } -XnStatus XnDeviceFileReader::OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType) +XnStatus XnDeviceFileReader::OnStreamCollectionChanged(const XnChar* /*StreamName*/, XnStreamsChangeEventType /*EventType*/) { m_bStreamsCollectionChanged = TRUE; return XN_STATUS_OK; } -void XnDeviceFileReader::StreamCollectionChangedCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie) +void XnDeviceFileReader::StreamCollectionChangedCallback(const XnStreamCollectionChangedEventArgs& args, void* pCookie) { XnDeviceFileReader* pThis = (XnDeviceFileReader*)pCookie; - pThis->OnStreamCollectionChanged(StreamName, EventType); + pThis->OnStreamCollectionChanged(args.strStreamName, args.eventType); } XnStatus XnDeviceFileReader::ReadNextData() @@ -809,3 +804,15 @@ XnStatus XnDeviceFileReader::ReadNextData() XnBool bDummy; return ReadTillNextData(&bDummy); } + +XnStatus XN_CALLBACK_TYPE XnDeviceFileReader::GetInstanceCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + if (gbValue.nDataSize != sizeof(void*)) + { + return XN_STATUS_DEVICE_PROPERTY_SIZE_DONT_MATCH; + } + + *(void**)gbValue.pData = pCookie; + return XN_STATUS_OK; +} + diff --git a/Source/XnDeviceFile/XnDeviceFileReader.h b/Source/XnDeviceFile/XnDeviceFileReader.h index 8080202..82dbd2c 100644 --- a/Source/XnDeviceFile/XnDeviceFileReader.h +++ b/Source/XnDeviceFile/XnDeviceFileReader.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_FILE_READER_H__ #define __XN_DEVICE_FILE_READER_H__ @@ -33,7 +28,7 @@ #include "XnDeviceFile.h" #include #include -#include +#include #define XN_FILE_PROPERTY_INSTANCE_POINTER "InstancePointer" @@ -41,7 +36,7 @@ // Types //--------------------------------------------------------------------------- struct XnFileBCData; -XN_DECLARE_DEFAULT_HASH(XnUInt32, XnValue, XnUIntHash); +typedef XnHashT XnUIntHash; class XnDeviceFileReader : public XnStreamReaderDevice { @@ -82,7 +77,8 @@ class XnDeviceFileReader : public XnStreamReaderDevice XnStatus OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType); - static void XN_CALLBACK_TYPE StreamCollectionChangedCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie); + static void XN_CALLBACK_TYPE StreamCollectionChangedCallback(const XnStreamCollectionChangedEventArgs& args, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetInstanceCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); // Some BC functions XnStatus BCSeek(XnUInt64 nTimestamp); @@ -103,8 +99,7 @@ class XnDeviceFileReader : public XnStreamReaderDevice XnFileBCData* m_pBCData; XnUIntHash m_PositionsToIgnore; - XnDeviceFileReader* m_pThis; - XnActualGeneralProperty m_InstancePointer; + XnGeneralProperty m_InstancePointer; }; #endif //__XN_DEVICE_FILE_READER_H__ diff --git a/Source/XnDeviceFile/XnDeviceFileReaderBC.cpp b/Source/XnDeviceFile/XnDeviceFileReaderBC.cpp index 59609a1..2837d22 100644 --- a/Source/XnDeviceFile/XnDeviceFileReaderBC.cpp +++ b/Source/XnDeviceFile/XnDeviceFileReaderBC.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -272,6 +266,9 @@ XnStatus BCSetDepthProperties(XnPropertySet* pSet, XnStreamPropertiesV3* pStream nRetVal = XnPropertySetAddStringProperty(pSet, XN_STREAM_NAME_DEPTH, XN_STREAM_PROPERTY_TYPE, XN_STREAM_TYPE_DEPTH); XN_IS_STATUS_OK(nRetVal); + nRetVal = XnPropertySetAddIntProperty(pSet, XN_STREAM_NAME_DEPTH, XN_STREAM_PROPERTY_STATE, pStreamProperties->DepthFormat != XN_DEPTH_FORMAT_DISABLED); + XN_IS_STATUS_OK(nRetVal); + XnCropping cropping = {0}; XnGeneralBuffer gbCropping = XN_PACK_GENERAL_BUFFER(cropping); nRetVal = XnPropertySetAddGeneralProperty(pSet, XN_STREAM_NAME_DEPTH, XN_STREAM_PROPERTY_CROPPING, &gbCropping); @@ -391,6 +388,9 @@ XnStatus BCSetImageProperties(XnPropertySet* pSet, XnStreamPropertiesV3* pStream nRetVal = XnPropertySetAddStringProperty(pSet, XN_STREAM_NAME_IMAGE, XN_STREAM_PROPERTY_TYPE, XN_STREAM_TYPE_IMAGE); XN_IS_STATUS_OK(nRetVal); + nRetVal = XnPropertySetAddIntProperty(pSet, XN_STREAM_NAME_IMAGE, XN_STREAM_PROPERTY_STATE, pStreamProperties->ImageFormat != XN_IMAGE_FORMAT_DISABLED); + XN_IS_STATUS_OK(nRetVal); + XnCropping cropping = {0}; XnGeneralBuffer gbCropping = XN_PACK_GENERAL_BUFFER(cropping); nRetVal = XnPropertySetAddGeneralProperty(pSet, XN_STREAM_NAME_IMAGE, XN_STREAM_PROPERTY_CROPPING, &gbCropping); @@ -459,6 +459,9 @@ XnStatus BCSetAudioProperties(XnPropertySet* pSet, XnStreamPropertiesV3* pStream nRetVal = XnPropertySetAddStringProperty(pSet, XN_STREAM_NAME_AUDIO, XN_STREAM_PROPERTY_TYPE, XN_STREAM_TYPE_AUDIO); XN_IS_STATUS_OK(nRetVal); + nRetVal = XnPropertySetAddIntProperty(pSet, XN_STREAM_NAME_AUDIO, XN_STREAM_PROPERTY_STATE, pStreamProperties->AudioFormat != XN_AUDIO_FORMAT_DISABLED); + XN_IS_STATUS_OK(nRetVal); + nRetVal = XnPropertySetAddIntProperty(pSet, XN_STREAM_NAME_AUDIO, XN_STREAM_PROPERTY_NUMBER_OF_FRAMES, (XnUInt64)pStreamProperties->nNumOfFrames); XN_IS_STATUS_OK(nRetVal); @@ -541,8 +544,6 @@ XnStatus ConvertStreamPropertiesToPropertySet(XnStreamPropertiesV3* pStreamPrope XnStatus XnDeviceFileReader::BCCalculatePackedBufferSize() { - XnStatus nRetVal = XN_STATUS_OK; - XnStreamPropertiesV3* pStreamProperties = &m_pBCData->StreamProperties; XnPackedStreamProperties* pPackedStreamProperties = &m_pBCData->PackedStreamProperties; @@ -666,8 +667,6 @@ XnStatus XnDeviceFileReader::BCCalculatePackedBufferSize() nBufferSize += sizeof(XnPackedStreamFrameHeaderV3); return nBufferSize; - - return (XN_STATUS_OK); } XnStatus XnDeviceFileReader::BCReadInitialState(XnPropertySet* pSet) @@ -818,7 +817,7 @@ XnStatus XnDeviceFileAdjustFileFrameHeaderV3(const XnDeviceFileFrameHeaderV3* pF return XnIOAdjustStreamFramePropertiesV3(&pFileFrameHeaderV3->FrameProperties, &pFileFrameHeader->FrameProperties); } -XnStatus XnDeviceFileReader::BCSeek(XnUInt64 nTimestamp) +XnStatus XnDeviceFileReader::BCSeek(XnUInt64 /*nTimestamp*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } @@ -925,7 +924,7 @@ XnStatus XnDeviceFileReader::BCSeekFrame(XnUInt32 nFrameID) } // Skip the frame data - XnUInt32 nPosition; + XnUInt64 nPosition; nRetVal = GetIOStream()->Tell(&nPosition); XN_IS_STATUS_OK(nRetVal); @@ -933,10 +932,10 @@ XnStatus XnDeviceFileReader::BCSeekFrame(XnUInt32 nFrameID) XN_IS_STATUS_OK(nRetVal); // increment streams frame ID - for (XnDeviceModuleHolderList::Iterator it = streams.begin(); it != streams.end(); ++it) + for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it) { XnStreamReaderStream* pStream = (XnStreamReaderStream*)(*it)->GetModule(); - pStream->NewDataAvailable(); + pStream->NewDataAvailable(0, 0); } // Make sure frame ids are sequential @@ -962,10 +961,6 @@ XnStatus XnDeviceFileReader::BCReadFrame(XnBool* pbWrapOccured) // Local function variables XnStatus nRetVal = XN_STATUS_OK; XnDeviceFileFrameHeaderV3 FileFrameHeader; - XnUInt64 nCurrTime = 0; - XnUInt64 nDiffTime = 0; - XnUInt64 nFramesDiffTime = 0; - XnUInt32 nSleepTime = 0; *pbWrapOccured = FALSE; @@ -1087,7 +1082,7 @@ XnStatus XnDeviceFileReader::BCReadFrame(XnBool* pbWrapOccured) pPackedBuffer += PackedStreamHeader.nCompDepthBufferSize; - pStream->NewDataAvailable(); + pStream->NewDataAvailable(pStreamData->nTimestamp, pStreamData->nFrameID); } // Image @@ -1110,7 +1105,7 @@ XnStatus XnDeviceFileReader::BCReadFrame(XnBool* pbWrapOccured) pPackedBuffer += PackedStreamHeader.nCompImageBufferSize; - pStream->NewDataAvailable(); + pStream->NewDataAvailable(pStreamData->nTimestamp, pStreamData->nFrameID); } // we do not support MISC @@ -1136,7 +1131,7 @@ XnStatus XnDeviceFileReader::BCReadFrame(XnBool* pbWrapOccured) pPackedBuffer += PackedStreamHeader.nCompAudioBufferSize; - pStream->NewDataAvailable(); + pStream->NewDataAvailable(pStreamData->nTimestamp, pStreamData->nFrameID); } // Increase the file frame position diff --git a/Source/XnDeviceFile/XnDeviceFileReaderBC.h b/Source/XnDeviceFile/XnDeviceFileReaderBC.h index 6cb0ed1..1e7aefe 100644 --- a/Source/XnDeviceFile/XnDeviceFileReaderBC.h +++ b/Source/XnDeviceFile/XnDeviceFileReaderBC.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICE_FILE_READER_BC_H_ #define _XN_DEVICE_FILE_READER_BC_H_ diff --git a/Source/XnDeviceFile/XnDeviceFileWriter.cpp b/Source/XnDeviceFile/XnDeviceFileWriter.cpp index d1ae22a..76e2a85 100644 --- a/Source/XnDeviceFile/XnDeviceFileWriter.cpp +++ b/Source/XnDeviceFile/XnDeviceFileWriter.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -88,7 +82,7 @@ XnStatus XnDeviceFileWriter::DestroyStream(const XnChar* StreamName) nRetVal = FindStream(StreamName, &pStream); XN_IS_STATUS_OK(nRetVal); - XnUInt32 nCurPos; + XnUInt64 nCurPos; nRetVal = GetIOStream()->Tell(&nCurPos); XN_IS_STATUS_OK(nRetVal); @@ -201,8 +195,6 @@ XnStatus XnDeviceFileWriter::StartTimer() XnStatus XnDeviceFileWriter::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { - XnStatus nRetVal = XN_STATUS_OK; - XnFileWriterStream* pStream; XN_VALIDATE_NEW(pStream, XnFileWriterStream, StreamType, StreamName, GetDataPacker()); @@ -231,7 +223,7 @@ XnStatus XnDeviceFileWriter::CreateIOStreamImpl(const XnChar* strConnectionStrin XN_VALIDATE_NEW_AND_INIT(pStream, XnIOFileStream, strConnectionString, XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE); // write down the magic - nRetVal = pStream->WriteData((const XnUChar*)XN_DEVICE_FILE_MAGIC_V4, strlen(XN_DEVICE_FILE_MAGIC_V4)); + nRetVal = pStream->WriteData((const XnUChar*)XN_DEVICE_FILE_MAGIC_V4, (XnUInt32)strlen(XN_DEVICE_FILE_MAGIC_V4)); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pStream); diff --git a/Source/XnDeviceFile/XnDeviceFileWriter.h b/Source/XnDeviceFile/XnDeviceFileWriter.h index ff8acda..3ba79dc 100644 --- a/Source/XnDeviceFile/XnDeviceFileWriter.h +++ b/Source/XnDeviceFile/XnDeviceFileWriter.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICE_FILE_WRITER_H_ #define _XN_DEVICE_FILE_WRITER_H_ diff --git a/Source/XnDeviceFile/XnExportedFileDevice.cpp b/Source/XnDeviceFile/XnExportedFileDevice.cpp index b03d4f5..47123e1 100644 --- a/Source/XnDeviceFile/XnExportedFileDevice.cpp +++ b/Source/XnDeviceFile/XnExportedFileDevice.cpp @@ -1,39 +1,33 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnExportedFileDevice.h" -#include +#include #include "XnDeviceFileReader.h" #include "XnFileDevice.h" #include -#include +#include //--------------------------------------------------------------------------- // XnExportedFileDevice class @@ -43,10 +37,10 @@ void XnExportedFileDevice::FillCommonDescriptionFields(XnProductionNodeDescripti strcpy(pDescription->strName, XN_DEVICE_NAME); strcpy(pDescription->strVendor, XN_VENDOR_PRIMESENSE); - pDescription->Version.nMajor = XN_MAJOR_VERSION; - pDescription->Version.nMinor = XN_MINOR_VERSION; - pDescription->Version.nMaintenance = XN_MAINTENANCE_VERSION; - pDescription->Version.nBuild = XN_BUILD_VERSION; + pDescription->Version.nMajor = XN_PS_MAJOR_VERSION; + pDescription->Version.nMinor = XN_PS_MINOR_VERSION; + pDescription->Version.nMaintenance = XN_PS_MAINTENANCE_VERSION; + pDescription->Version.nBuild = XN_PS_BUILD_VERSION; } void XnExportedFileDevice::GetDescription(XnProductionNodeDescription* pDescription) @@ -55,7 +49,7 @@ void XnExportedFileDevice::GetDescription(XnProductionNodeDescription* pDescript pDescription->Type = XN_NODE_TYPE_PLAYER; } -XnStatus XnExportedFileDevice::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors) +XnStatus XnExportedFileDevice::EnumerateProductionTrees(xn::Context& /*context*/, xn::NodeInfoList& TreesList, xn::EnumerationErrors* /*pErrors*/) { XnStatus nRetVal = XN_STATUS_OK; @@ -67,7 +61,7 @@ XnStatus XnExportedFileDevice::EnumerateProductionTrees(xn::Context& context, xn return (XN_STATUS_OK); } -XnStatus XnExportedFileDevice::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* strCreationInfo, xn::NodeInfoList* pNeededTrees, const XnChar* strConfigurationDir, xn::ModuleProductionNode** ppInstance) +XnStatus XnExportedFileDevice::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* /*strCreationInfo*/, xn::NodeInfoList* /*pNeededTrees*/, const XnChar* /*strConfigurationDir*/, xn::ModuleProductionNode** ppInstance) { XnStatus nRetVal = XN_STATUS_OK; @@ -80,6 +74,7 @@ XnStatus XnExportedFileDevice::Create(xn::Context& context, const XnChar* strIns nRetVal = pDevice->Init(); if (nRetVal != XN_STATUS_OK) { + XN_DELETE(pDevice); return (nRetVal); } diff --git a/Source/XnDeviceFile/XnExportedFileDevice.h b/Source/XnDeviceFile/XnExportedFileDevice.h index 23d116d..aac3963 100644 --- a/Source/XnDeviceFile/XnExportedFileDevice.h +++ b/Source/XnDeviceFile/XnExportedFileDevice.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_EXPORTED_SENSOR_DEVICE_H__ #define __XN_EXPORTED_SENSOR_DEVICE_H__ diff --git a/Source/XnDeviceFile/XnFileDevice.cpp b/Source/XnDeviceFile/XnFileDevice.cpp index 6f9e15a..262548a 100644 --- a/Source/XnDeviceFile/XnFileDevice.cpp +++ b/Source/XnDeviceFile/XnFileDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -51,7 +45,7 @@ typedef struct XnLastStreamData XnUInt64 nTimestamp; } XnLastStreamData; -XN_DECLARE_STRINGS_HASH(XnLastStreamData, XnLastStreamDataHash); +typedef XnStringsHashT XnLastStreamDataHash; //--------------------------------------------------------------------------- // XnFileDevice class @@ -69,7 +63,9 @@ XnFileDevice::XnFileDevice(xn::Context& context, const XnChar* strInstanceName) m_nCurrTimestamp(0), m_pBCData(NULL), m_bRepeat(TRUE), - m_bEOF(FALSE) + m_bEOF(FALSE), + m_strName(strInstanceName), + m_hSelf(NULL) { xnOSMemSet(&m_ShiftToDepth, 0, sizeof(m_ShiftToDepth)); } @@ -91,10 +87,16 @@ XnStatus XnFileDevice::Init() void XnFileDevice::Free() { - for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.begin(); it != m_nodeInfoMap.end(); ++it) + for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.Begin(); it != m_nodeInfoMap.End(); ++it) { - XnNodeInfo& nodeInfo = it.Value(); + XnNodeInfo& nodeInfo = it->Value(); XN_DELETE(nodeInfo.pXnCodec); + if (nodeInfo.codec.IsValid()) + { + xnRemoveNeededNode(GetSelfNodeHandle(), nodeInfo.codec); + nodeInfo.codec.Release(); + } + } m_nodeInfoMap.Clear(); @@ -199,7 +201,7 @@ XnStatus XnFileDevice::SetInitialState(XnPropertySet* pSet) pDeviceModule->Remove(XN_MODULE_PROPERTY_PRIMARY_STREAM); // check for timestamps resolution - XnActualIntProperty* pIntProp; + XnActualIntProperty* pIntProp = NULL; if (XN_STATUS_OK == pDeviceModule->Get(XN_MODULE_PROPERTY_HIGH_RES_TIMESTAMPS, (XnProperty*&)pIntProp)) { m_bHighresTimestamps = (pIntProp->GetValue() == TRUE); @@ -210,20 +212,20 @@ XnStatus XnFileDevice::SetInitialState(XnPropertySet* pSet) // now create the rest of the modules and streams (DEVICE was already created) XnPropertySetData* pPropSetData = pSet->pData; - for (XnPropertySetData::ConstIterator it = pPropSetData->begin(); it != pPropSetData->end(); ++it) + for (XnPropertySetData::ConstIterator it = pPropSetData->Begin(); it != pPropSetData->End(); ++it) { // ignore module DEVICE - if (strcmp(XN_MODULE_NAME_DEVICE, it.Key()) == 0) + if (strcmp(XN_MODULE_NAME_DEVICE, it->Key()) == 0) { continue; } // check if this is a stream - XnActualPropertiesHash::ConstIterator itProp = it.Value()->end(); - if (XN_STATUS_OK == it.Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) + XnActualPropertiesHash::ConstIterator itProp = it->Value()->End(); + if (XN_STATUS_OK == it->Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) { - XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp.Value(); - nRetVal = HandleNewStream(pTypeProp->GetValue(), it.Key(), it.Value()); + XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp->Value(); + nRetVal = HandleNewStream(pTypeProp->GetValue(), it->Key(), it->Value()); XN_IS_STATUS_OK(nRetVal); } } // modules loop @@ -241,6 +243,7 @@ XnStatus XnFileDevice::SetInputStream(void *pStreamCookie, XnPlayerInputStreamIn if (nRetVal != XN_STATUS_OK) { XN_DELETE(m_pInputStream); + m_pInputStream = NULL; return (nRetVal); } @@ -331,7 +334,7 @@ XnStatus XnFileDevice::SeekTo(XnUInt64 nMinTimestamp, const XnChar* strNodeName, XnPackedDataType nType = (XnPackedDataType)-1; XnLastStreamDataHash StreamsHash; - while (TRUE) + for (;;) { XnUInt32 nPositionBefore; nRetVal = m_pInputStream->Tell(&nPositionBefore); @@ -357,7 +360,7 @@ XnStatus XnFileDevice::SeekTo(XnUInt64 nMinTimestamp, const XnChar* strNodeName, XnLastStreamData data; if (XN_STATUS_OK != StreamsHash.Get(props.StreamName, data)) { - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; nRetVal = m_nodeInfoMap.Get(props.StreamName, pNodeInfo); XN_IS_STATUS_OK(nRetVal); @@ -427,7 +430,7 @@ XnStatus XnFileDevice::SeekTo(XnUInt64 nMinTimestamp, const XnChar* strNodeName, nRetVal = GetStreamsList(streams); XN_IS_STATUS_OK(nRetVal); - for (XnDeviceModuleHolderList::Iterator it = streams.begin(); it != streams.end(); ++it) + for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it) { XnStreamReaderStream* pStream = (XnStreamReaderStream*)(*it)->GetModule(); pStream->ReMarkDataAsNew(); @@ -439,8 +442,6 @@ XnStatus XnFileDevice::SeekTo(XnUInt64 nMinTimestamp, const XnChar* strNodeName, XnStatus XnFileDevice::SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin) { - XnStatus nRetVal = XN_STATUS_OK; - XnUInt64 nTimestamp = 0; if (origin == XN_PLAYER_SEEK_CUR) { @@ -472,7 +473,7 @@ XnStatus XnFileDevice::SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffs { XnStatus nRetVal = XN_STATUS_OK; - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; nRetVal = m_nodeInfoMap.Get(strNodeName, pNodeInfo); XN_IS_STATUS_OK(nRetVal); @@ -511,8 +512,6 @@ XnStatus XnFileDevice::SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffs XnStatus XnFileDevice::TellTimestamp(XnUInt64& nTimestamp) { - XnStatus nRetVal = XN_STATUS_OK; - nTimestamp = m_nCurrTimestamp; return (XN_STATUS_OK); @@ -522,7 +521,7 @@ XnStatus XnFileDevice::TellFrame(const XnChar* strNodeName, XnUInt32 &nFrameOffs { XnStatus nRetVal = XN_STATUS_OK; - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; nRetVal = m_nodeInfoMap.Get(strNodeName, pNodeInfo); XN_IS_STATUS_OK(nRetVal); @@ -553,7 +552,7 @@ XnBool XnFileDevice::IsEOF() XnStatus XnFileDevice::RegisterToEndOfFileReached(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) { - return m_eofEvent.Register(handler, pCookie, &hCallback); + return m_eofEvent.Register(handler, pCookie, hCallback); } void XnFileDevice::UnregisterFromEndOfFileReached(XnCallbackHandle hCallback) @@ -635,7 +634,7 @@ XnStatus XnFileDevice::ReadNewStream() if (nRetVal == XN_STATUS_OK) { // create it - nRetVal = HandleNewStream(strType, strName, pPropertySet->pData->begin().Value()); + nRetVal = HandleNewStream(strType, strName, pPropertySet->pData->Begin()->Value()); } XnPropertySetDestroy(&pPropertySet); @@ -673,7 +672,7 @@ XnStatus XnFileDevice::HandleNewStream(const XnChar *strType, const XnChar *strN XnStatus nRetVal = XN_STATUS_OK; // check if we need to ignore that (stream was not removed upon Rewind). - XnNodeInfoMap::Iterator it = m_ignoreNewNodes.end(); + XnNodeInfoMap::Iterator it = m_ignoreNewNodes.End(); if (m_ignoreNewNodes.Find(strName, it) == XN_STATUS_OK) { // ignore @@ -687,7 +686,7 @@ XnStatus XnFileDevice::HandleNewStream(const XnChar *strType, const XnChar *strN } // find compression type - XnActualIntProperty* pComp; + XnActualIntProperty* pComp = NULL; nRetVal = pInitialValues->Get(XN_STREAM_PROPERTY_COMPRESSION, (XnProperty*&)pComp); XN_IS_STATUS_OK(nRetVal); @@ -710,9 +709,9 @@ XnStatus XnFileDevice::HandleNewStream(const XnChar *strType, const XnChar *strN XN_IS_STATUS_OK(nRetVal); // now write state - for (XnActualPropertiesHash::ConstIterator it = pInitialValues->begin(); it != pInitialValues->end(); ++it) + for (XnActualPropertiesHash::ConstIterator it = pInitialValues->Begin(); it != pInitialValues->End(); ++it) { - XnProperty* pProp = it.Value(); + XnProperty* pProp = it->Value(); switch (pProp->GetType()) { @@ -804,7 +803,11 @@ XnStatus XnFileDevice::CreateCodec(xn::ProductionNode& node) { // release old codec XN_DELETE(pNodeInfo->pXnCodec); - pNodeInfo->codec.Unref(); + if (pNodeInfo->codec.IsValid()) + { + xnRemoveNeededNode(GetSelfNodeHandle(), pNodeInfo->codec); + pNodeInfo->codec.Release(); + } // special case: IR recorded with JPEG. This mode is no longer allowed by OpenNI (JPEG // can now only be used for image). We'll have to handle it ourselves. @@ -824,6 +827,11 @@ XnStatus XnFileDevice::CreateCodec(xn::ProductionNode& node) nRetVal = m_context.CreateCodec(codecID, node, pNodeInfo->codec); XN_IS_STATUS_OK(nRetVal); + // we need to make the codec a needed node, so that if xnForceShutdown() is called, we will be + // destroyed *before* it does (as we hold a reference to it). + nRetVal = xnAddNeededNode(GetSelfNodeHandle(), pNodeInfo->codec); + XN_IS_STATUS_OK(nRetVal); + XN_VALIDATE_NEW(pNodeInfo->pXnCodec, XnNiCodec, pNodeInfo->codec); } } @@ -873,14 +881,14 @@ XnStatus XnFileDevice::HandleStreamRemoved(const XnChar* strName) // check for specific case: all streams are removed and then end-of-file is reached. // in this case, we don't really want to destroy streams, just wrap around. - XnStringsHash StreamsToRemove; - nRetVal = StreamsToRemove.Set(strName, NULL); + XnStringsSet StreamsToRemove; + nRetVal = StreamsToRemove.Set(strName); XN_IS_STATUS_OK(nRetVal); XnPackedDataType nType = XN_PACKED_STREAM_REMOVED; XnUInt32 nPositionBefore; - while (TRUE) + for (;;) { nRetVal = m_pInputStream->Tell(&nPositionBefore); XN_IS_STATUS_OK(nRetVal); @@ -894,7 +902,7 @@ XnStatus XnFileDevice::HandleStreamRemoved(const XnChar* strName) nRetVal = m_pDataPacker->ReadStreamRemoved(strTempName); XN_IS_STATUS_OK(nRetVal); - nRetVal = StreamsToRemove.Set(strTempName, NULL); + nRetVal = StreamsToRemove.Set(strTempName); XN_IS_STATUS_OK(nRetVal); } else @@ -906,16 +914,16 @@ XnStatus XnFileDevice::HandleStreamRemoved(const XnChar* strName) if (nType != XN_PACKED_END) { // Not the case we were looking for. Remove those streams. - for (XnStringsHash::Iterator it = StreamsToRemove.begin(); it != StreamsToRemove.end(); ++it) + for (XnStringsSet::Iterator it = StreamsToRemove.Begin(); it != StreamsToRemove.End(); ++it) { - nRetVal = m_pNotifications->OnNodeRemoved(m_pNotificationsCookie, it.Key()); + nRetVal = m_pNotifications->OnNodeRemoved(m_pNotificationsCookie, it->Key()); XN_IS_STATUS_OK(nRetVal); - XnNodeInfo* pNodeInfo; - m_nodeInfoMap.Get(it.Key(), pNodeInfo); + XnNodeInfo* pNodeInfo = NULL; + m_nodeInfoMap.Get(it->Key(), pNodeInfo); XN_DELETE(pNodeInfo->pXnCodec); - m_nodeInfoMap.Remove(it.Key()); - m_ignoreNewNodes.Remove(it.Key()); + m_nodeInfoMap.Remove(it->Key()); + m_ignoreNewNodes.Remove(it->Key()); } m_bNodeCollectionChanged = TRUE; @@ -980,15 +988,15 @@ XnStatus XnFileDevice::HandleIntProperty(const XnChar *strModule, const XnChar * if (strcmp(strName, XN_STREAM_PROPERTY_X_RES) == 0) { - mode.nXRes = nValue; + mode.nXRes = (XnUInt32)nValue; } else if (strcmp(strName, XN_STREAM_PROPERTY_Y_RES) == 0) { - mode.nYRes = nValue; + mode.nYRes = (XnUInt32)nValue; } else if (strcmp(strName, XN_STREAM_PROPERTY_FPS) == 0) { - mode.nFPS = nValue; + mode.nFPS = (XnUInt32)nValue; } // change supported modes to this one @@ -1047,11 +1055,11 @@ XnStatus XnFileDevice::HandleIntProperty(const XnChar *strModule, const XnChar * if (strcmp(strName, XN_STREAM_PROPERTY_SAMPLE_RATE) == 0) { - mode.nSampleRate = nValue; + mode.nSampleRate = (XnUInt32)nValue; } else if (strcmp(strName, XN_STREAM_PROPERTY_NUMBER_OF_CHANNELS) == 0) { - mode.nChannels = nValue; + mode.nChannels = (XnUInt8)nValue; } // change supported modes to this one @@ -1107,7 +1115,7 @@ XnStatus XnFileDevice::HandleIntProperty(const XnChar *strModule, const XnChar * { // only after node is ready xn::DepthGenerator depth(node); - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; if (m_nodeInfoMap.Get(strModule, pNodeInfo) == XN_STATUS_OK && m_context.GetProductionNodeByName(strModule, depth) == XN_STATUS_OK) { @@ -1161,7 +1169,7 @@ XnStatus XnFileDevice::HandleRealProperty(const XnChar *strModule, const XnChar nRetVal = m_pNotifications->OnNodeRealPropChanged(m_pNotificationsCookie, strModule, strName, dValue); XN_IS_STATUS_OK(nRetVal); - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; if (strcmp(strName, XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE) == 0 || strcmp(strName, XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE) == 0) @@ -1284,10 +1292,10 @@ void TransformRGB24ToGrayscale16(XnUInt8* pBuffer, XnUInt32* pnBufferSize) pOutput++; } - *pnBufferSize = (XnUInt8*)pOutput - pBuffer; + *pnBufferSize = (XnUInt32)((XnUInt8*)pOutput - pBuffer); } -XnStatus XnFileDevice::HandleStreamData(XnStreamData* pDataProps, XnCompressionFormats nCompression, XnUInt32 nCompressedSize) +XnStatus XnFileDevice::HandleStreamData(XnStreamData* pDataProps, XnCompressionFormats /*nCompression*/, XnUInt32 /*nCompressedSize*/) { XnStatus nRetVal = XN_STATUS_OK; @@ -1295,11 +1303,11 @@ XnStatus XnFileDevice::HandleStreamData(XnStreamData* pDataProps, XnCompressionF nRetVal = m_pInputStream->Tell(&nPosition); XN_IS_STATUS_OK(nRetVal); - XnUIntHash::Iterator it = m_PositionsToIgnore.end(); + XnUIntHash::Iterator it = m_PositionsToIgnore.End(); if (XN_STATUS_OK == m_PositionsToIgnore.Find(nPosition, it)) { // ignore this one. Just update the frame ID - XnNodeInfo* pNodeInfo; + XnNodeInfo* pNodeInfo = NULL; nRetVal = m_nodeInfoMap.Get(pDataProps->StreamName, pNodeInfo); XN_IS_STATUS_OK(nRetVal); @@ -1441,9 +1449,9 @@ XnStatus XnFileDevice::Rewind() XN_IS_STATUS_OK(nRetVal); // first handle current streams. remove or reset them - for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.begin(); it != m_nodeInfoMap.end(); ++it) + for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.Begin(); it != m_nodeInfoMap.End(); ++it) { - const XnChar* strName = it.Key(); + const XnChar* strName = it->Key(); if (m_bNodeCollectionChanged) { @@ -1454,9 +1462,9 @@ XnStatus XnFileDevice::Rewind() else { // just reset frame ID - it.Value().nCurrFrameID = 0; + it->Value().nCurrFrameID = 0; // and mark not to recreate it - nRetVal = m_ignoreNewNodes.Set(strName, it.Value()); + nRetVal = m_ignoreNewNodes.Set(strName, it->Value()); XN_IS_STATUS_OK(nRetVal); } } @@ -1490,40 +1498,40 @@ XnStatus XnFileDevice::UpdateS2DTables(const xn::DepthGenerator& depth) nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nZeroPlaneDistance = nTemp; + config.nZeroPlaneDistance = (XnDepthPixel)nTemp; nRetVal = depth.GetRealProperty(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, dTemp); XN_IS_STATUS_OK(nRetVal); - config.fZeroPlanePixelSize = dTemp; + config.fZeroPlanePixelSize = (XnFloat)dTemp; nRetVal = depth.GetRealProperty(XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE, dTemp); XN_IS_STATUS_OK(nRetVal); - config.fEmitterDCmosDistance = dTemp; + config.fEmitterDCmosDistance = (XnFloat)dTemp; nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_MAX_SHIFT, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nDeviceMaxShiftValue = nTemp; + config.nDeviceMaxShiftValue = (XnUInt32)nTemp; config.nDeviceMaxDepthValue = depth.GetDeviceMaxDepth(); nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_CONST_SHIFT, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nConstShift = nTemp; + config.nConstShift = (XnUInt32)nTemp; nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nPixelSizeFactor = nTemp; + config.nPixelSizeFactor = (XnUInt32)nTemp; nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_PARAM_COEFF, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nParamCoeff = nTemp; + config.nParamCoeff = (XnUInt32)nTemp; nRetVal = depth.GetIntProperty(XN_STREAM_PROPERTY_SHIFT_SCALE, nTemp); XN_IS_STATUS_OK(nRetVal); - config.nShiftScale = nTemp; + config.nShiftScale = (XnUInt32)nTemp; config.nDepthMinCutOff = 0; - config.nDepthMaxCutOff = config.nDeviceMaxDepthValue; + config.nDepthMaxCutOff = (XnDepthPixel)config.nDeviceMaxDepthValue; if (!m_ShiftToDepth.bIsInitialized) { @@ -1572,3 +1580,18 @@ XnStatus XnFileDevice::UpdateRWData(const xn::DepthGenerator& depth) return (XN_STATUS_OK); } + +XnNodeHandle XnFileDevice::GetSelfNodeHandle() +{ + if (m_hSelf == NULL) + { + xn::Player player; + XnStatus nRetVal = m_context.GetProductionNodeByName(m_strName, player); + XN_ASSERT(nRetVal == XN_STATUS_OK); + + // keep only the handle (we don't want to keep a reference to ourself. This will prevent destruction) + m_hSelf = player; + } + + return m_hSelf; +} \ No newline at end of file diff --git a/Source/XnDeviceFile/XnFileDevice.h b/Source/XnDeviceFile/XnFileDevice.h index c32a213..73dfbd6 100644 --- a/Source/XnDeviceFile/XnFileDevice.h +++ b/Source/XnDeviceFile/XnFileDevice.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_DEVICE_H__ #define __XN_SENSOR_DEVICE_H__ @@ -34,13 +28,14 @@ #include #include #include -#include +#include #include #include #include "XnDeviceFileReaderBC.h" #include "XnNiInputStream.h" #include "XnDeviceFile.h" #include +#include //--------------------------------------------------------------------------- // Types @@ -53,7 +48,7 @@ class XnFileDevice : virtual public xn::ModulePlayer XnStatus Init(); - virtual XnBool IsCapabilitySupported(const XnChar* strCapabilityName) { return FALSE; } + virtual XnBool IsCapabilitySupported(const XnChar* /*strCapabilityName*/) { return FALSE; } virtual const XnChar* GetSupportedFormat() { return "XNS"; } virtual XnStatus SetInputStream(void *pStreamCookie, XnPlayerInputStreamInterface *pStream); @@ -100,6 +95,7 @@ class XnFileDevice : virtual public xn::ModulePlayer XnStatus UpdateRWData(const xn::DepthGenerator& depth); XnStatus CreateCodec(xn::ProductionNode& node); XnStatus CheckIRCompatibility(xn::ProductionNode& node); + XnNodeHandle GetSelfNodeHandle(); // Some BC functions XnStatus BCSeek(XnUInt64 nTimestamp); @@ -126,7 +122,7 @@ class XnFileDevice : virtual public xn::ModulePlayer XnBool bIRisRGB; } XnNodeInfo; - XN_DECLARE_STRINGS_HASH(XnNodeInfo, XnNodeInfoMap); + typedef XnStringsHashT XnNodeInfoMap; XnNodeInfoMap m_nodeInfoMap; XnNodeInfoMap m_ignoreNewNodes; @@ -140,16 +136,17 @@ class XnFileDevice : virtual public xn::ModulePlayer XnUInt64 m_nCurrTimestamp; - XN_DECLARE_DEFAULT_HASH(XnUInt32, XnValue, XnUIntHash); + typedef XnHashT XnUIntHash; XnUIntHash m_PositionsToIgnore; // used for seeking - XN_DECLARE_EVENT_0ARG(XnEOFEvent, IXnEOFEvent); - XnEOFEvent m_eofEvent; + XnEventNoArgs m_eofEvent; XnBool m_bEOF; XnShiftToDepthTables m_ShiftToDepth; XnFileBCData* m_pBCData; + const XnChar* m_strName; + XnNodeHandle m_hSelf; }; #endif // __XN_SENSOR_DEVICE_H__ \ No newline at end of file diff --git a/Source/XnDeviceFile/XnFileDeviceBC.cpp b/Source/XnDeviceFile/XnFileDeviceBC.cpp index 2795a63..d3fab15 100644 --- a/Source/XnDeviceFile/XnFileDeviceBC.cpp +++ b/Source/XnDeviceFile/XnFileDeviceBC.cpp @@ -1,28 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #include "XnFileDevice.h" #include "XnDeviceFileReaderBC.h" #include @@ -61,8 +57,6 @@ XnStatus XnFileDevice::BCInit() XnStatus XnFileDevice::BCCalculatePackedBufferSize() { - XnStatus nRetVal = XN_STATUS_OK; - XnStreamPropertiesV3* pStreamProperties = &m_pBCData->StreamProperties; XnPackedStreamProperties* pPackedStreamProperties = &m_pBCData->PackedStreamProperties; @@ -186,8 +180,6 @@ XnStatus XnFileDevice::BCCalculatePackedBufferSize() nBufferSize += sizeof(XnPackedStreamFrameHeaderV3); return nBufferSize; - - return (XN_STATUS_OK); } XnStatus XnFileDevice::BCReadInitialState(XnPropertySet* pSet) @@ -199,6 +191,7 @@ XnStatus XnFileDevice::BCReadInitialState(XnPropertySet* pSet) m_pBCData->nFramePos = 1; + xnOSFreeAligned(m_pBCData->pPackedStreamBuffer); m_pBCData->pPackedStreamBuffer = NULL; m_pBCData->nPackedStreamBufferSize = 0; @@ -308,7 +301,7 @@ XnStatus XnFileDevice::BCReadInitialState(XnPropertySet* pSet) XnUInt32 nBufferSize = BCCalculatePackedBufferSize(); if (nBufferSize != m_pBCData->nPackedStreamBufferSize) { - xnOSFree(m_pBCData->pPackedStreamBuffer); + xnOSFreeAligned(m_pBCData->pPackedStreamBuffer); XN_VALIDATE_ALIGNED_CALLOC(m_pBCData->pPackedStreamBuffer, XnUChar, nBufferSize, XN_DEFAULT_MEM_ALIGN); m_pBCData->nPackedStreamBufferSize = nBufferSize; } @@ -320,7 +313,7 @@ XnStatus XnFileDevice::BCReadInitialState(XnPropertySet* pSet) return (XN_STATUS_OK); } -XnStatus XnFileDevice::BCSeek(XnUInt64 nTimestamp) +XnStatus XnFileDevice::BCSeek(XnUInt64 /*nTimestamp*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } @@ -368,12 +361,6 @@ XnStatus XnFileDevice::BCSeekFrame(XnUInt32 nFrameID) nRetVal = m_pInputStream->Seek(nOffset); XN_IS_STATUS_OK(nRetVal); - // If the wanted position was the first frame, we're already there - if (m_pBCData->nFramePos == 1) - { - return (XN_STATUS_OK); - } - // Keep reading frames until we reach the wanted frame XnUInt32 nCurrFilePos = 1; while (nCurrFilePos < m_pBCData->nFramePos) @@ -430,9 +417,9 @@ XnStatus XnFileDevice::BCSeekFrame(XnUInt32 nFrameID) XN_IS_STATUS_OK(nRetVal); // increment streams frame ID - for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.begin(); it != m_nodeInfoMap.end(); ++it) + for (XnNodeInfoMap::Iterator it = m_nodeInfoMap.Begin(); it != m_nodeInfoMap.End(); ++it) { - it.Value().nCurrFrameID++; + it->Value().nCurrFrameID++; } // Make sure frame ids are sequential @@ -458,10 +445,6 @@ XnStatus XnFileDevice::BCReadFrame(XnBool* pbWrapOccured) // Local function variables XnStatus nRetVal = XN_STATUS_OK; XnDeviceFileFrameHeaderV3 FileFrameHeader; - XnUInt64 nCurrTime = 0; - XnUInt64 nDiffTime = 0; - XnUInt64 nFramesDiffTime = 0; - XnUInt32 nSleepTime = 0; *pbWrapOccured = FALSE; diff --git a/Source/XnDeviceFile/XnFileOpenNiteImpl.cpp b/Source/XnDeviceFile/XnFileOpenNiteImpl.cpp index a8d1ec6..ff0476f 100644 --- a/Source/XnDeviceFile/XnFileOpenNiteImpl.cpp +++ b/Source/XnDeviceFile/XnFileOpenNiteImpl.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceFile/XnFileWriterStream.cpp b/Source/XnDeviceFile/XnFileWriterStream.cpp index b0686a4..e96c11d 100644 --- a/Source/XnDeviceFile/XnFileWriterStream.cpp +++ b/Source/XnDeviceFile/XnFileWriterStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceFile/XnFileWriterStream.h b/Source/XnDeviceFile/XnFileWriterStream.h index e03a9d3..40ef2e2 100644 --- a/Source/XnDeviceFile/XnFileWriterStream.h +++ b/Source/XnDeviceFile/XnFileWriterStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FILE_STREAM_WRITER_H__ #define __XN_FILE_STREAM_WRITER_H__ @@ -45,7 +40,7 @@ class XnFileWriterStream : public XnStreamWriterStream inline XnUInt64 GetNumberOfFrames() const { return m_NumberOfFrames.GetValue(); } - XnUInt32 m_nNumFramesPos; + XnUInt64 m_nNumFramesPos; protected: XnStatus WriteImpl(XnStreamData* pStreamData); diff --git a/Source/XnDeviceFile/XnNiInputStream.h b/Source/XnDeviceFile/XnNiInputStream.h index 7ac77dc..4da35c7 100644 --- a/Source/XnDeviceFile/XnNiInputStream.h +++ b/Source/XnDeviceFile/XnNiInputStream.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_XN_INPUT_STREAM_H__ #define __XN_XN_INPUT_STREAM_H__ @@ -56,7 +50,7 @@ class XnInputStream : public XnIOStream m_pStreamInterface->Close(m_pCookie); return (XN_STATUS_OK); } - XnStatus WriteData(const XnUChar* pData, XnUInt32 nDataSize) + XnStatus WriteData(const XnUChar* /*pData*/, XnUInt32 /*nDataSize*/) { return XN_STATUS_NOT_IMPLEMENTED; } diff --git a/Source/XnDeviceSensorV2/Bayer.cpp b/Source/XnDeviceSensorV2/Bayer.cpp index 7c00cbe..b961ed6 100644 --- a/Source/XnDeviceSensorV2/Bayer.cpp +++ b/Source/XnDeviceSensorV2/Bayer.cpp @@ -1,129 +1,1229 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +/**************************************************************************** + * Edited 12.04.2011 by Raphael Dumusc * + * Incorporated ROS code for improved Bayer Pattern to RGB conversion. * + ***************************************************************************/ + /* + The ROS bayer pattern to RGB conversion + Modified to be used in Avin's mod of the Primesense driver. + Original code available here: + http://www.ros.org/doc/api/openni_camera/html/openni__image__bayer__grbg_8cpp_source.html +*/ +/* + * Software License Agreement (BSD License) + * + * Copyright (c) 2011 2011 Willow Garage, Inc. + * Suat Gedikli + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ - - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- #include "Bayer.h" -#include +#include +#include -//--------------------------------------------------------------------------- -// Global Variables -//--------------------------------------------------------------------------- -XnUInt8 Gamma[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}; +#define AVG(a,b) (((int)(a) + (int)(b)) >> 1) +#define AVG3(a,b,c) (((int)(a) + (int)(b) + (int)(c)) / 3) +#define AVG4(a,b,c,d) (((int)(a) + (int)(b) + (int)(c) + (int)(d)) >> 2) +#define WAVG4(a,b,c,d,x,y) ( ( ((int)(a) + (int)(b)) * (int)(x) + ((int)(c) + (int)(d)) * (int)(y) ) / ( 2 * ((int)(x) + (int(y))) ) ) +using namespace std; -//--------------------------------------------------------------------------- -// Code -//--------------------------------------------------------------------------- -void BayerUpdateGamma(float fGammaCorr) +typedef enum { - for(XnUInt32 iG = 0; iG < 256;++iG) - Gamma[iG] = XnUInt32(255*pow(XnDouble(iG)/255.0,(XnDouble)fGammaCorr) + 0.5); -} + Bilinear = 0, + EdgeAware, + EdgeAwareWeighted +} DebayeringMethod; -static inline void WriteRGB(XnUInt8 *pBuffer, XnUInt8 nRed, XnUInt8 nGreen, XnUInt8 nBlue) +void BayerUpdateGamma(float fGammaCorr) { - pBuffer[BAYER_RED] = Gamma[nRed]; - pBuffer[BAYER_GREEN] = Gamma[nGreen]; - pBuffer[BAYER_BLUE] = Gamma[nBlue]; } -void Bayer2RGB888(const XnUInt8* pBayerImage, XnUInt8* pRGBImage, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nDownSampleStep, XnUInt32 nBadPixels) +void fillRGB(unsigned width, unsigned height, const XnUInt8* bayer_pixel, unsigned char* rgb_buffer, DebayeringMethod debayering_method, XnUInt32 nDownSampleStep) { - XnUInt8 nRed; - XnUInt8 nGreen; - XnUInt8 nBlue; - const XnUInt8* pBayer; - XnUInt8* pRGB; - - //if (nBadPixels > 1) - //{ - //nBadPixels = 1; - //} - - XnInt32 BAYER_LINE_LENGTH = nXRes; - XnInt32 BAYER_LINE_LENGTH2 = BAYER_LINE_LENGTH*2; - XnInt32 BAYER_RGB_LINE_LENGTH = nXRes*BAYER_BPP; - XnInt32 BAYER_RGB_LINE_LENGTH2 = BAYER_RGB_LINE_LENGTH*2; - - const XnUInt8* pCurrBayer; - XnUInt8* pCurrRGB; - XnUInt32 nColCount; - XnUInt32 nTotalColsCount = (nXRes-2) / 2; - XnUInt32 nTotalRowsCount = (nYRes-4) / 2; - - pBayer = pBayerImage + BAYER_LINE_LENGTH - nBadPixels; - pRGB = pRGBImage + BAYER_RGB_LINE_LENGTH; - - do { - pCurrBayer = pBayer+ 1; - pCurrRGB = pRGB + BAYER_BPP; - - nColCount = nTotalColsCount; - - do { + + unsigned rgb_line_step = width * 3; + + // padding skip for destination image + unsigned rgb_line_skip = rgb_line_step - width * 3; + + if (nDownSampleStep == 1) + { + //register const XnUInt8 *bayer_pixel = image_md_->Data (); + register unsigned yIdx, xIdx; + + int bayer_line_step = width; + int bayer_line_step2 = width << 1; + + if (debayering_method == Bilinear) + { + // first two pixel values for first two lines + // Bayer 0 1 2 + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the first two lines + + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = bayer_pixel[bayer_line_step + 1]; + + // Bayer -1 0 1 2 + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + + // main processing + + for (yIdx = 2; yIdx < height - 2; yIdx += 2) + { + // first two pixel values + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // continue with rest of the line + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixels of the line + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + } + + //last two lines + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step B g b + //rgb_pixel[rgb_line_step ] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step b G b + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the last two lines + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // -1 g b g + // 0 r G r + // line_step g b g + rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 + // -1 g b g + // 0 r g R + // line_step g b g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]); + //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] ); + + // BGBG line + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g B g + //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] ); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g b G + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + } + else if (debayering_method == EdgeAware) + { + int dh, dv; + + // first two pixel values for first two lines + // Bayer 0 1 2 + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the first two lines + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = bayer_pixel[bayer_line_step + 1]; + + // Bayer -1 0 1 2 + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + // main processing + for (yIdx = 2; yIdx < height - 2; yIdx += 2) + { + // first two pixel values + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // continue with rest of the line + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + + dh = abs (bayer_pixel[0] - bayer_pixel[2]); + dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]); + + if (dh > dv) + rgb_buffer[4] = AVG (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1]); + else if (dv > dh) + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[2]); + else + rgb_buffer[4] = AVG4 (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1], bayer_pixel[0], bayer_pixel[2]); + + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]); + dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]); + + if (dv > dh) + rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + else if (dh > dv) + rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step2]); + else + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixels of the line + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + } + + //last two lines + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step B g b + //rgb_pixel[rgb_line_step ] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step b G b + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the last two lines + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // -1 g b g + // 0 r G r + // line_step g b g + rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 + // -1 g b g + // 0 r g R + // line_step g b g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]); + //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] ); + + // BGBG line + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g B g + //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] ); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g b G + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + } + else if (debayering_method == EdgeAwareWeighted) + { + int dh, dv; + + // first two pixel values for first two lines + // Bayer 0 1 2 + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the first two lines + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = bayer_pixel[bayer_line_step + 1]; + + // Bayer -1 0 1 2 + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 2 + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] ); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + // main processing + for (yIdx = 2; yIdx < height - 2; yIdx += 2) + { + // first two pixel values + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + // line_step2 g r g + + rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + // line_step2 g r g + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // 0 g r g + // line_step B g b + // line_step2 g r g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // pixel (1, 1) 0 1 2 + // 0 g r g + // line_step b G b + // line_step2 g r g + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // continue with rest of the line + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + // line_step2 r g r g + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + // line_step2 r g r g + + dh = abs (bayer_pixel[0] - bayer_pixel[2]); + dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]); + + if (dv == 0 && dh == 0) + rgb_buffer[4] = AVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2]); + else + rgb_buffer[4] = WAVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2], dh, dv); + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + // line_step2 r g r g + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]); + dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]); + + if (dv == 0 && dh == 0) + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + else + rgb_buffer[rgb_line_step + 1] = WAVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1], dh, dv); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + // line_step2 r g r g + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixels of the line + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // 0 r G r + // line_step g b g + // line_step2 r g r + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // 0 r g R + // line_step g b g + // line_step2 r g r + rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[5] = bayer_pixel[line_step]; + + // BGBG line + // Bayer -1 0 1 + // 0 r g r + // line_step g B g + // line_step2 r g r + rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]); + rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step]; + + // Bayer -1 0 1 + // 0 r g r + // line_step g b G + // line_step2 r g r + rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + + bayer_pixel += bayer_line_step + 2; + rgb_buffer += rgb_line_step + 6 + rgb_line_skip; + } + + //last two lines + // Bayer 0 1 2 + // -1 b g b + // 0 G r g + // line_step b g b + + rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel + rgb_buffer[1] = bayer_pixel[0]; // green pixel + rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue; + + // Bayer 0 1 2 + // -1 b g b + // 0 g R g + // line_step b g b + //rgb_pixel[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]); + + // BGBG line + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step B g b + //rgb_pixel[rgb_line_step ] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer 0 1 2 + // -1 b g b + // 0 g r g + // line_step b G b + //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] ); + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + + rgb_buffer += 6; + bayer_pixel += 2; + // rest of the last two lines + for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2) + { + // GRGR line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r G r g + // line_step g b g b + rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g R g + // line_step g b g b + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]); + rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]); + + // BGBG line + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g B g b + rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + + // Bayer -1 0 1 2 + // -1 g b g b + // 0 r g r g + // line_step g b G b + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]); + } + + // last two pixel values for first two lines + // GRGR line + // Bayer -1 0 1 + // -1 g b g + // 0 r G r + // line_step g b g + rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]); + rgb_buffer[1] = bayer_pixel[0]; + rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); + + // Bayer -1 0 1 + // -1 g b g + // 0 r g R + // line_step g b g + rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1]; + rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]); + //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] ); + + // BGBG line + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g B g + //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] ); + rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]); + rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step]; + + // Bayer -1 0 1 + // -1 g b g + // 0 r g r + // line_step g b G + //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1]; + rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1]; + //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step]; + } + //else + // THROW_OPENNI_EXCEPTION ("Unknwon debayering method: %d", (int)debayering_method); + } + //Warning: Downsampling mod is untested + else if (nDownSampleStep > 1) + { + // get each or each 2nd pixel group to find rgb values! + register unsigned bayerXStep = nDownSampleStep; + register unsigned bayerYSkip = (nDownSampleStep - 1) * width; + + // Downsampling and debayering at once + register const XnUInt8* bayer_buffer = bayer_pixel; + + for (register unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, rgb_buffer += rgb_line_skip) // skip a line + { + for (register unsigned xIdx = 0; xIdx < width; ++xIdx, rgb_buffer += 3, bayer_buffer += bayerXStep) + { + rgb_buffer[ 2 ] = bayer_buffer[ width ]; + rgb_buffer[ 1 ] = AVG (bayer_buffer[0], bayer_buffer[ width + 1]); + rgb_buffer[ 0 ] = bayer_buffer[ 1 ]; + } + } + } +} - nRed = ((XnUInt32)pCurrBayer[-BAYER_LINE_LENGTH]+pCurrBayer[BAYER_LINE_LENGTH]) / 2; - nBlue = ((XnUInt32)pCurrBayer[-1]+pCurrBayer[1]) / 2; - WriteRGB(pCurrRGB+0, nRed, pCurrBayer[0], nBlue); - nRed = ((XnUInt32)pCurrBayer[-BAYER_LINE_LENGTH+2]+pCurrBayer[BAYER_LINE_LENGTH+2]) / 2; - nGreen = ((XnUInt32)pCurrBayer[0]+pCurrBayer[2]) / 2; - WriteRGB(pCurrRGB+BAYER_BPP, nRed, nGreen, pCurrBayer[1]); - nGreen = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH-1]+pCurrBayer[BAYER_LINE_LENGTH+1]) / 2; - nBlue = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH2-1]+pCurrBayer[BAYER_LINE_LENGTH2+1]) / 2; - WriteRGB(pCurrRGB+BAYER_RGB_LINE_LENGTH, pCurrBayer[BAYER_LINE_LENGTH], nGreen, nBlue); +void Bayer2RGB888(const XnUInt8* pBayerImage, XnUInt8* pRGBImage, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nDownSampleStep, XnUInt32 nBadPixels) +{ + fillRGB(nXRes, nYRes, pBayerImage, pRGBImage, DebayeringMethod(1), nDownSampleStep); // DebayeringMethod(0) == bilinear, (1) == edge aware, (2) == edge aware weighted +} - nRed = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH]+pCurrBayer[BAYER_LINE_LENGTH+2]) / 2; - nBlue = ((XnUInt32)pCurrBayer[1]+pCurrBayer[BAYER_LINE_LENGTH2+1]) / 2; - WriteRGB(pCurrRGB+BAYER_RGB_LINE_LENGTH+BAYER_BPP, nRed, pCurrBayer[BAYER_LINE_LENGTH+1], nBlue); - pCurrBayer += 2; - pCurrRGB += 2*BAYER_BPP; - } while (--nColCount); - pBayer += BAYER_LINE_LENGTH2; - pRGB += BAYER_RGB_LINE_LENGTH2; - } while (--nTotalRowsCount); -} diff --git a/Source/XnDeviceSensorV2/Bayer.h b/Source/XnDeviceSensorV2/Bayer.h index 15c3925..7b866ad 100644 --- a/Source/XnDeviceSensorV2/Bayer.h +++ b/Source/XnDeviceSensorV2/Bayer.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_BAYER_H_ #define _XN_BAYER_H_ diff --git a/Source/XnDeviceSensorV2/IXnSensorStream.h b/Source/XnDeviceSensorV2/IXnSensorStream.h index c4fde67..7aeebec 100644 --- a/Source/XnDeviceSensorV2/IXnSensorStream.h +++ b/Source/XnDeviceSensorV2/IXnSensorStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __I_XN_SENSOR_STREAM_H__ #define __I_XN_SENSOR_STREAM_H__ @@ -32,7 +27,6 @@ //--------------------------------------------------------------------------- #include #include -#include "XnSharedMemoryBufferPool.h" //--------------------------------------------------------------------------- // Forward Declarations @@ -53,7 +47,6 @@ class IXnSensorStream virtual XnStatus CloseStreamImpl() = 0; virtual XnStatus CreateDataProcessor(XnDataProcessor** ppProcessor) = 0; virtual XnStatus MapPropertiesToFirmware() = 0; - virtual XnSharedMemoryBufferPool* GetSharedMemoryBuffer() = 0; }; #endif //__I_XN_SENSOR_STREAM_H__ diff --git a/Source/XnDeviceSensorV2/Registration.cpp b/Source/XnDeviceSensorV2/Registration.cpp index 290d65c..f5ce7e9 100644 --- a/Source/XnDeviceSensorV2/Registration.cpp +++ b/Source/XnDeviceSensorV2/Registration.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -61,8 +55,8 @@ inline XnDouble XnXRegistrationFunction1000(XnRegistrationInformation1000& regIn regInfo1000.FuncX.dD, regInfo1000.FuncX.dE, regInfo1000.FuncX.dF, - nX - nXRes/2, - nY - nYRes/2); + (XnUInt16)(nX - nXRes/2), + (XnUInt16)(nY - nYRes/2)); } inline XnDouble XnYRegistrationFunction1000(XnRegistrationInformation1000& regInfo1000, XnUInt16 nX, XnUInt16 nY, XnUInt32 nXRes, XnUInt32 nYRes) @@ -74,8 +68,8 @@ inline XnDouble XnYRegistrationFunction1000(XnRegistrationInformation1000& regIn regInfo1000.FuncY.dD, regInfo1000.FuncY.dE, regInfo1000.FuncY.dF, - nX - nXRes/2, - nY - nYRes/2); + (XnUInt16)(nX - nXRes/2), + (XnUInt16)(nY - nYRes/2)); } XnStatus XnRegistration::BuildRegTable1000() @@ -84,7 +78,7 @@ XnStatus XnRegistration::BuildRegTable1000() // take needed parameters to perform registration XnRegistrationInformation1000 regInfo1000; - nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, ®Info1000, sizeof(regInfo1000), m_pDepthStream->GetResolution(), m_pDepthStream->GetFPS()); + nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, ®Info1000, sizeof(regInfo1000), m_pDepthStream->GetResolution(), (XnUInt16)m_pDepthStream->GetFPS()); XN_IS_STATUS_OK(nRetVal); XnUInt16* pRegTable = m_pRegistrationTable; @@ -93,8 +87,8 @@ XnStatus XnRegistration::BuildRegTable1000() XnDouble dNewX = 0, dNewY = 0; - XnUInt64 nDepthXRes = m_pDepthStream->GetXRes(); - XnUInt64 nDepthYRes = m_pDepthStream->GetYRes(); + XnUInt32 nDepthXRes = m_pDepthStream->GetXRes(); + XnUInt32 nDepthYRes = m_pDepthStream->GetYRes(); const XnUInt16 nIllegalValue = XnUInt16(nDepthXRes*4); @@ -228,19 +222,16 @@ void CreateDXDYTables (XnDouble* RegXTable, XnDouble* RegYTable, #define RGB_REG_X_RES 640 #define RGB_REG_Y_RES 512 -#define XN_DEPTH_XRES 640 -#define XN_DEPTH_YRES 480 #define XN_CMOS_VGAOUTPUT_XRES 1280 #define XN_SENSOR_WIN_OFFET_X 1 #define XN_SENSOR_WIN_OFFET_Y 1 #define RGB_REG_X_VAL_SCALE 16 #define S2D_PEL_CONST 10 -#define XN_SENSOR_DEPTH_RGB_CMOS_DISTANCE 2.4 #define S2D_CONST_OFFSET 0.375 -void BuildDepthToShiftTable(XnUInt16* pDepth2Shift, XnSensorDepthStream* m_pStream) +void XnRegistration::BuildDepthToShiftTable(XnUInt16* pDepth2Shift, XnSensorDepthStream* m_pStream) { - XnUInt32 nXScale = XN_CMOS_VGAOUTPUT_XRES / XN_DEPTH_XRES; + XnUInt32 nXScale = XN_CMOS_VGAOUTPUT_XRES / m_pDepthStream->GetXRes(); XnInt16* pRGBRegDepthToShiftTable = (XnInt16*)pDepth2Shift; XnUInt32 nIndex = 0; XnDouble dDepth = 0; @@ -253,10 +244,13 @@ void BuildDepthToShiftTable(XnUInt16* pDepth2Shift, XnSensorDepthStream* m_pStre XnUInt64 nPlaneDsr; XnDouble dPlaneDsr; m_pStream->GetProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, &nPlaneDsr); - dPlaneDsr = nPlaneDsr; + dPlaneDsr = (XnDouble)nPlaneDsr; + + XnDouble dDCRCDist; + m_pStream->GetProperty(XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, &dDCRCDist); XnDouble dPelSize = 1.0 / (dPlanePixelSize * nXScale * S2D_PEL_CONST); - XnDouble dPelDCC = XN_SENSOR_DEPTH_RGB_CMOS_DISTANCE * dPelSize * S2D_PEL_CONST; + XnDouble dPelDCC = dDCRCDist * dPelSize * S2D_PEL_CONST; XnDouble dPelDSR = dPlaneDsr * dPelSize * S2D_PEL_CONST; memset(pRGBRegDepthToShiftTable, XN_DEVICE_SENSOR_NO_DEPTH_VALUE, nMaxDepth * sizeof(XnInt16)); @@ -264,7 +258,7 @@ void BuildDepthToShiftTable(XnUInt16* pDepth2Shift, XnSensorDepthStream* m_pStre for (nIndex = 0; nIndex < nMaxDepth; nIndex++) { dDepth = nIndex * dPelSize; - pRGBRegDepthToShiftTable[nIndex] = ((dPelDCC * (dDepth - dPelDSR) / dDepth) + (S2D_CONST_OFFSET)) * RGB_REG_X_VAL_SCALE; + pRGBRegDepthToShiftTable[nIndex] = (XnInt16)(((dPelDCC * (dDepth - dPelDSR) / dDepth) + (S2D_CONST_OFFSET)) * RGB_REG_X_VAL_SCALE); } } @@ -274,11 +268,7 @@ XnStatus XnRegistration::BuildRegTable1080() // take needed parameters to perform registration XnRegistrationInformation1080 RegData; - nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &RegData, sizeof(RegData), m_pDepthStream->GetResolution(), m_pDepthStream->GetFPS()); - XN_IS_STATUS_OK(nRetVal); - - xnOSMemSet(&m_padInfo, 0, sizeof(m_padInfo)); - nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_padInfo, sizeof(m_padInfo), m_pDepthStream->GetResolution(), m_pDepthStream->GetFPS()); + nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &RegData, sizeof(RegData), m_pDepthStream->GetResolution(), (XnUInt16)m_pDepthStream->GetFPS()); XN_IS_STATUS_OK(nRetVal); XN_VALIDATE_ALIGNED_CALLOC(m_pDepthToShiftTable, XnUInt16, m_pDepthStream->GetXRes()*m_pDepthStream->GetYRes(), XN_DEFAULT_MEM_ALIGN); @@ -289,10 +279,8 @@ XnStatus XnRegistration::BuildRegTable1080() XnDouble* RegXTable = XN_NEW_ARR(XnDouble, RGB_REG_X_RES*RGB_REG_Y_RES); XnDouble* RegYTable = XN_NEW_ARR(XnDouble, RGB_REG_X_RES*RGB_REG_Y_RES); - XnInt16* pRGBRegDepthToShiftTable = (XnInt16*)m_pDepthToShiftTable; - XnUInt16 nDepthXRes = XN_DEPTH_XRES; - XnUInt16 nDepthYRes = XN_DEPTH_YRES; - XnUInt32 nXScale = XN_CMOS_VGAOUTPUT_XRES / XN_DEPTH_XRES; + XnUInt16 nDepthXRes = m_pDepthStream->GetXRes(); + XnUInt16 nDepthYRes = m_pDepthStream->GetYRes(); XnDouble* pRegXTable = (XnDouble*)RegXTable; XnDouble* pRegYTable = (XnDouble*)RegYTable; XnInt16* pRegTable = (XnInt16*)m_pRegistrationTable; @@ -347,14 +335,14 @@ XnStatus XnRegistration::BuildRegTable1080() nNewX = ((nDepthXRes*4) * RGB_REG_X_VAL_SCALE); // set illegal value on purpose } - if (nNewY > nDepthYRes) + if (nNewY > nDepthYRes-2) { + nNewX = ((nDepthXRes*4) * RGB_REG_X_VAL_SCALE); // set illegal value on purpose nNewY = nDepthYRes; - goto FinishLoop; } - *pRegTable = nNewX; - *(pRegTable+1) = nNewY; + *pRegTable = (XnInt16)nNewX; + *(pRegTable+1) = (XnInt16)nNewY; pRegXTable++; pRegYTable++; @@ -362,17 +350,11 @@ XnStatus XnRegistration::BuildRegTable1080() } } -FinishLoop: - XN_DELETE_ARR(RegXTable); - XN_DELETE_ARR(RegYTable); - return (XN_STATUS_OK); } XnStatus XnRegistration::BuildRegTable() { - XnStatus nRetVal = XN_STATUS_OK; - m_b1000 = (m_pDevicePrivateData->ChipInfo.nChipVer == XN_SENSOR_CHIP_VER_PS1000); if (m_b1000) { @@ -382,8 +364,6 @@ XnStatus XnRegistration::BuildRegTable() { return BuildRegTable1080(); } - - return (XN_STATUS_OK); } XnStatus XnRegistration::Init(XnDevicePrivateData* pDevicePrivateData, XnSensorDepthStream* pDepthStream, XnUInt16* pDepthToShiftTable) @@ -509,21 +489,16 @@ void XnRegistration::Apply1080(XnDepthPixel* pInput, XnDepthPixel* pOutput) XnUInt32 nNewX = 0; XnUInt32 nNewY = 0; XnUInt32 nArrPos = 0; - XnUInt32 nDepthXRes = XN_DEPTH_XRES; - XnUInt32 nDepthYRes = XN_DEPTH_YRES; + XnUInt32 nDepthXRes = m_pDepthStream->GetXRes(); + XnUInt32 nDepthYRes = m_pDepthStream->GetYRes(); memset(pOutput, XN_DEVICE_SENSOR_NO_DEPTH_VALUE, nDepthXRes*nDepthYRes*sizeof(XnDepthPixel)); - // entire map should be shifted by X lines - XnUInt32 nConstOffset = nDepthYRes*m_padInfo.nStartLines; - - XnDepthPixel* pInputEnd = pInput + nDepthYRes*nDepthXRes; - XnBool bMirror = m_pDepthStream->IsMirrored(); for (XnUInt32 y = 0; y < nDepthYRes; ++y) { - pRegTable = (XnInt16*)&m_pRegistrationTable[ bMirror ? (y+1) * nDepthXRes * 2 - 2 : y * nDepthXRes * 2 ]; + pRegTable = (XnInt16*)&m_pRegistrationTable[ bMirror ? (y+1) * nDepthXRes * 2 : y * nDepthXRes * 2 ]; for (XnUInt32 x = 0; x < nDepthXRes; ++x) { nValue = *pInput; @@ -535,19 +510,27 @@ void XnRegistration::Apply1080(XnDepthPixel* pInput, XnDepthPixel* pOutput) if (nNewX < nDepthXRes) { - nArrPos = bMirror ? (nNewY+1)*nDepthXRes - nNewX - 2 : (nNewY*nDepthXRes) + nNewX; - nArrPos -= nConstOffset; + nArrPos = bMirror ? (nNewY+1)*nDepthXRes - nNewX : (nNewY*nDepthXRes) + nNewX; nOutValue = pOutput[nArrPos]; if ((nOutValue == XN_DEVICE_SENSOR_NO_DEPTH_VALUE) || (nOutValue > nValue)) { - if (nArrPos > nDepthXRes+1) + if ( nNewX > 0 && nNewY > 0 ) { + pOutput[nArrPos-nDepthXRes] = nValue; pOutput[nArrPos-nDepthXRes-1] = nValue; + pOutput[nArrPos-1] = nValue; + } + else if( nNewY > 0 ) + { pOutput[nArrPos-nDepthXRes] = nValue; } - pOutput[nArrPos-1] = nValue; + else if( nNewX > 0 ) + { + pOutput[nArrPos-1] = nValue; + } + pOutput[nArrPos] = nValue; } } diff --git a/Source/XnDeviceSensorV2/Registration.h b/Source/XnDeviceSensorV2/Registration.h index 8ed1a3e..a3ab18f 100644 --- a/Source/XnDeviceSensorV2/Registration.h +++ b/Source/XnDeviceSensorV2/Registration.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_REGISTRATION_H_ #define _XN_REGISTRATION_H_ @@ -51,6 +45,7 @@ class XnRegistration inline XnBool IsInitialized() { return m_bInitialized; } private: + void BuildDepthToShiftTable(XnUInt16* pDepth2Shift, XnSensorDepthStream* m_pStream); XnStatus BuildRegTable(); XnStatus BuildRegTable1000(); XnStatus BuildRegTable1080(); @@ -64,7 +59,6 @@ class XnRegistration XnUInt16* m_pDepthToShiftTable; XnBool m_bD2SAlloc; XnUInt16* m_pRegistrationTable; - XnRegistrationPaddingInformation m_padInfo; XnDepthPixel* m_pTempBuffer; XnDouble m_dShiftFactor; XnBool m_b1000; diff --git a/Source/XnDeviceSensorV2/Uncomp.cpp b/Source/XnDeviceSensorV2/Uncomp.cpp index 9b6edc4..bdcc2c0 100644 --- a/Source/XnDeviceSensorV2/Uncomp.cpp +++ b/Source/XnDeviceSensorV2/Uncomp.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -92,7 +86,7 @@ XnStatus XnStreamUncompressYUVImagePS(const XnUInt8* pInput, const XnUInt32 nInp { // take high_element only // diffs are between -6 and 6 (0x0 to 0xc) - nLastFullValue[nChannel] += (cInput >> 4) - 6; + nLastFullValue[nChannel] += XnInt8((cInput >> 4) - 6); } else if (cInput < 0xe0) // 0xd is dummy { @@ -108,7 +102,7 @@ XnStatus XnStreamUncompressYUVImagePS(const XnUInt8* pInput, const XnUInt32 nInp break; nTempValue += (*pInput >> 4); - nLastFullValue[nChannel] = nTempValue; + nLastFullValue[nChannel] = (XnUInt8)nTempValue; } } else @@ -121,7 +115,7 @@ XnStatus XnStreamUncompressYUVImagePS(const XnUInt8* pInput, const XnUInt32 nInp if (cInput < 0xd) // 0x0 to 0xc are diffs { // diffs are between -6 and 6 (0x0 to 0xc) - nLastFullValue[nChannel] += cInput - 6; + nLastFullValue[nChannel] += (XnInt8)(cInput - 6); } else if (cInput < 0xe) // 0xd is dummy { @@ -173,13 +167,13 @@ XnStatus XnStreamUncompressYUVImagePS(const XnUInt8* pInput, const XnUInt32 nInp if (bLastPart == TRUE) { - *pnOutputSize = (pOutput - pOrigOutput) * sizeof(XnUInt8); - *pnActualRead += (pInput - pInputOrig) * sizeof(XnUInt8); + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput) * sizeof(XnUInt8); + *pnActualRead += (XnUInt32)(pInput - pInputOrig) * sizeof(XnUInt8); } else if ((pOutputLastPossibleStop != pOrigOutput) && (pInputLastPossibleStop != pInputOrig)) { - *pnOutputSize = (pOutputLastPossibleStop - pOrigOutput) * sizeof(XnUInt8); - *pnActualRead += (pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); + *pnOutputSize = (XnUInt32)(pOutputLastPossibleStop - pOrigOutput) * sizeof(XnUInt8); + *pnActualRead += (XnUInt32)(pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); } // All is good... @@ -229,7 +223,7 @@ XnStatus XnStreamUncompressImageNew(const XnUInt8* pInput, const XnUInt32 nInput { // take high_element only // diffs are between -6 and 6 (0x0 to 0xc) - nLastFullValue[nChannel] += (cInput >> 4) - 6; + nLastFullValue[nChannel] += (XnInt8)((cInput >> 4) - 6); } else if (cInput < 0xe0) // 0xd is dummy { @@ -245,7 +239,7 @@ XnStatus XnStreamUncompressImageNew(const XnUInt8* pInput, const XnUInt32 nInput break; nTempValue += (*pInput >> 4); - nLastFullValue[nChannel] = nTempValue; + nLastFullValue[nChannel] = (XnUInt8)nTempValue; } } else @@ -258,7 +252,7 @@ XnStatus XnStreamUncompressImageNew(const XnUInt8* pInput, const XnUInt32 nInput if (cInput < 0xd) // 0x0 to 0xc are diffs { // diffs are between -6 and 6 (0x0 to 0xc) - nLastFullValue[nChannel] += cInput - 6; + nLastFullValue[nChannel] += (XnInt8)(cInput - 6); } else if (cInput < 0xe) // 0xd is dummy { @@ -306,13 +300,13 @@ XnStatus XnStreamUncompressImageNew(const XnUInt8* pInput, const XnUInt32 nInput if (bLastPart == TRUE) { - *pnOutputSize = (pOutput - pOrigOutput) * sizeof(XnUInt8); - *pnActualRead += (pInput - pInputOrig) * sizeof(XnUInt8); + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput) * sizeof(XnUInt8); + *pnActualRead += (XnUInt32)(pInput - pInputOrig) * sizeof(XnUInt8); } else if ((pOutputLastPossibleStop != pOrigOutput) && (pInputLastPossibleStop != pInputOrig)) { - *pnOutputSize = (pOutputLastPossibleStop - pOrigOutput) * sizeof(XnUInt8); - *pnActualRead += (pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); + *pnOutputSize = (XnUInt32)(pOutputLastPossibleStop - pOrigOutput) * sizeof(XnUInt8); + *pnActualRead += (XnUInt32)(pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); } // All is good... diff --git a/Source/XnDeviceSensorV2/Uncomp.h b/Source/XnDeviceSensorV2/Uncomp.h index a34af76..3712f38 100644 --- a/Source/XnDeviceSensorV2/Uncomp.h +++ b/Source/XnDeviceSensorV2/Uncomp.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_UNCOMP_H_ #define _XN_UNCOMP_H_ diff --git a/Source/XnDeviceSensorV2/XnAudioProcessor.cpp b/Source/XnDeviceSensorV2/XnAudioProcessor.cpp index f768383..90a1018 100644 --- a/Source/XnDeviceSensorV2/XnAudioProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnAudioProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -34,18 +28,19 @@ // Code //--------------------------------------------------------------------------- -XnAudioProcessor::XnAudioProcessor(XnSensorAudioStream* pStream, XnSensorStreamHelper* pHelper, XnUInt32 nInputPacketSize) : +XnAudioProcessor::XnAudioProcessor(XnSensorAudioStream* pStream, XnSensorStreamHelper* pHelper, XnDeviceAudioBuffer* pBuffer, XnUInt32 nInputPacketSize) : XnWholePacketProcessor(pHelper->GetPrivateData(), pStream->GetType(), nInputPacketSize), m_pStream(pStream), m_pHelper(pHelper), - m_AudioInDump(XN_DUMP_CLOSED) + m_pBuffer(pBuffer), + m_AudioInDump(NULL) { - xnDumpInit(&m_AudioInDump, XN_DUMP_AUDIO_IN, NULL, "AudioIn.pcm"); + m_AudioInDump = xnDumpFileOpen(XN_DUMP_AUDIO_IN, "AudioIn.pcm"); } XnAudioProcessor::~XnAudioProcessor() { - xnDumpClose(&m_AudioInDump); + xnDumpFileClose(m_AudioInDump); GetStream()->NumberOfChannelsProperty().OnChangeEvent().Unregister(m_hNumChannelsCallback); } @@ -56,7 +51,7 @@ XnStatus XnAudioProcessor::Init() nRetVal = XnWholePacketProcessor::Init(); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->NumberOfChannelsProperty().OnChangeEvent().Register(DeleteChannelChangedCallback, this, &m_hNumChannelsCallback); + nRetVal = GetStream()->NumberOfChannelsProperty().OnChangeEvent().Register(DeleteChannelChangedCallback, this, m_hNumChannelsCallback); XN_IS_STATUS_OK(nRetVal); CalcDeleteChannel(); @@ -66,12 +61,10 @@ XnStatus XnAudioProcessor::Init() void XnAudioProcessor::ProcessWholePacket(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData) { - XnInt32 nAvailableBytes = 0; - - xnOSEnterCriticalSection(&m_pDevicePrivateData->hAudioBufferCriticalSection); + xnOSEnterCriticalSection(&m_pBuffer->hLock); // take write packet - XnUChar* pWritePacket = m_pDevicePrivateData->pAudioBuffer + (m_pDevicePrivateData->nAudioWriteIndex * m_pDevicePrivateData->nAudioPacketSize); + XnUChar* pWritePacket = m_pBuffer->pAudioBuffer + (m_pBuffer->nAudioWriteIndex * m_pBuffer->nAudioPacketSize); if (m_bDeleteChannel) { @@ -95,35 +88,42 @@ void XnAudioProcessor::ProcessWholePacket(const XnSensorProtocolResponseHeader* } // mark timestamp - m_pDevicePrivateData->pAudioPacketsTimestamps[m_pDevicePrivateData->nAudioWriteIndex] = GetTimeStamp(pHeader->nTimeStamp); + if (ShouldUseHostTimestamps()) + { + m_pBuffer->pAudioPacketsTimestamps[m_pBuffer->nAudioWriteIndex] = GetHostTimestamp(); + } + else + { + m_pBuffer->pAudioPacketsTimestamps[m_pBuffer->nAudioWriteIndex] = CreateTimestampFromDevice(pHeader->nTimeStamp); + } if (m_nLastPacketID % 10 == 0) { XnUInt64 nSysTime; xnOSGetTimeStamp(&nSysTime); - xnDumpWriteString(m_pDevicePrivateData->BandwidthDump, "%llu,%s,%d,%d\n", + xnDumpFileWriteString(m_pDevicePrivateData->BandwidthDump, "%llu,%s,%d,%d\n", nSysTime, "Audio", -1, m_nBytesReceived); m_nBytesReceived = 0; } // move write index forward - m_pDevicePrivateData->nAudioWriteIndex = (m_pDevicePrivateData->nAudioWriteIndex + 1) % m_pDevicePrivateData->nAudioBufferNumOfPackets; + m_pBuffer->nAudioWriteIndex = (m_pBuffer->nAudioWriteIndex + 1) % m_pBuffer->nAudioBufferNumOfPackets; // if write index got to read index (end of buffer), move read index forward (and loose a packet) - if (m_pDevicePrivateData->nAudioWriteIndex == m_pDevicePrivateData->nAudioReadIndex) + if (m_pBuffer->nAudioWriteIndex == m_pBuffer->nAudioReadIndex) { - m_pDevicePrivateData->nAudioReadIndex = (m_pDevicePrivateData->nAudioReadIndex + 1) % m_pDevicePrivateData->nAudioBufferNumOfPackets; + m_pBuffer->nAudioReadIndex = (m_pBuffer->nAudioReadIndex + 1) % m_pBuffer->nAudioBufferNumOfPackets; } - xnOSLeaveCriticalSection(&m_pDevicePrivateData->hAudioBufferCriticalSection); + xnOSLeaveCriticalSection(&m_pBuffer->hLock); - xnDumpWriteBuffer(m_AudioInDump, pData, pHeader->nBufSize); + xnDumpFileWriteBuffer(m_AudioInDump, pData, pHeader->nBufSize); - if (m_pDevicePrivateData->pAudioCallback != NULL) + if (m_pBuffer->pAudioCallback != NULL) { - m_pDevicePrivateData->pAudioCallback(m_pDevicePrivateData->pAudioCallbackCookie); + m_pBuffer->pAudioCallback(m_pBuffer->pAudioCallbackCookie); } } @@ -132,7 +132,7 @@ void XnAudioProcessor::CalcDeleteChannel() m_bDeleteChannel = (m_pHelper->GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2 && GetStream()->GetNumberOfChannels() == 1); } -XnStatus XnAudioProcessor::DeleteChannelChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XnAudioProcessor::DeleteChannelChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnAudioProcessor* pThis = (XnAudioProcessor*)pCookie; pThis->CalcDeleteChannel(); diff --git a/Source/XnDeviceSensorV2/XnAudioProcessor.h b/Source/XnDeviceSensorV2/XnAudioProcessor.h index 4395240..da28d7c 100644 --- a/Source/XnDeviceSensorV2/XnAudioProcessor.h +++ b/Source/XnDeviceSensorV2/XnAudioProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_AUDIO_PROCESSOR_H__ #define __XN_AUDIO_PROCESSOR_H__ @@ -40,7 +35,7 @@ class XnAudioProcessor : public XnWholePacketProcessor { public: - XnAudioProcessor(XnSensorAudioStream* pStream, XnSensorStreamHelper* pHelper, XnUInt32 nInputPacketSize); + XnAudioProcessor(XnSensorAudioStream* pStream, XnSensorStreamHelper* pHelper, XnDeviceAudioBuffer* pBuffer, XnUInt32 nInputPacketSize); ~XnAudioProcessor(); XnStatus Init(); @@ -64,9 +59,10 @@ class XnAudioProcessor : public XnWholePacketProcessor static XnStatus XN_CALLBACK_TYPE DeleteChannelChangedCallback(const XnProperty* pSender, void* pCookie); /** Used to dump Audio In data. */ - XnDump m_AudioInDump; + XnDumpFile* m_AudioInDump; XnBool m_bDeleteChannel; XnSensorAudioStream* m_pStream; + XnDeviceAudioBuffer* m_pBuffer; XnSensorStreamHelper* m_pHelper; XnCallbackHandle m_hNumChannelsCallback; diff --git a/Source/XnDeviceSensorV2/XnBayerImageProcessor.cpp b/Source/XnDeviceSensorV2/XnBayerImageProcessor.cpp index 20a5d15..17700f9 100644 --- a/Source/XnDeviceSensorV2/XnBayerImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnBayerImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,8 +31,8 @@ // Code //--------------------------------------------------------------------------- -XnBayerImageProcessor::XnBayerImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnBayerImageProcessor::XnBayerImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) { } @@ -109,7 +103,7 @@ void XnBayerImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolRespon XnUInt32 nActualRead = 0; XnBool bLastPart = pHeader->nType == XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END && (nDataOffset + nDataSize) == pHeader->nBufSize; XnStatus nRetVal = XnStreamUncompressImageNew(pBuf, nBufSize, pWriteBuffer->GetUnsafeWritePointer(), - &nWrittenOutput, GetActualXRes(), &nActualRead, bLastPart); + &nWrittenOutput, (XnUInt16)GetActualXRes(), &nActualRead, bLastPart); if (nRetVal != XN_STATUS_OK) { diff --git a/Source/XnDeviceSensorV2/XnBayerImageProcessor.h b/Source/XnDeviceSensorV2/XnBayerImageProcessor.h index a779587..4a327eb 100644 --- a/Source/XnDeviceSensorV2/XnBayerImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnBayerImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_BAYER_IMAGE_PROCESSOR_H__ #define __XN_BAYER_IMAGE_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnBayerImageProcessor : public XnImageProcessor { public: - XnBayerImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnBayerImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnBayerImageProcessor(); XnStatus Init(); diff --git a/Source/XnDeviceSensorV2/XnCmosInfo.cpp b/Source/XnDeviceSensorV2/XnCmosInfo.cpp index 6e5b243..7af09b6 100644 --- a/Source/XnDeviceSensorV2/XnCmosInfo.cpp +++ b/Source/XnDeviceSensorV2/XnCmosInfo.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -36,7 +30,9 @@ XnCmosInfo::XnCmosInfo(XnSensorFirmware* pFirmware, XnDevicePrivateData* pDevicePrivateData) : m_pFirmware(pFirmware), m_pDevicePrivateData(pDevicePrivateData) -{} +{ + xnOSMemSet(m_pCurrCmosBlankingInfo, 0, sizeof(m_pCurrCmosBlankingInfo)); +} XnCmosInfo::~XnCmosInfo() { @@ -52,7 +48,7 @@ XnStatus XnCmosInfo::SetCmosConfig(XnCMOSType nCmos, XnResolutions nResolution, XnCmosBlankingInformation* pInfo = NULL; // search the list if we already have this info - for (XnCmosBlankingDataList::Iterator it = m_CmosBlankingInfo.begin(); it != m_CmosBlankingInfo.end(); ++it) + for (XnCmosBlankingDataList::Iterator it = m_CmosBlankingInfo.Begin(); it != m_CmosBlankingInfo.End(); ++it) { XnCmosBlankingData& data = *it; if (data.nRes == nResolution && data.nFPS == nFPS) @@ -69,7 +65,7 @@ XnStatus XnCmosInfo::SetCmosConfig(XnCMOSType nCmos, XnResolutions nResolution, data.nRes = nResolution; data.nFPS = nFPS; - nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_BLANKING, &data.BlankingInfo, sizeof(XnCmosBlankingInformation), nResolution, nFPS); + nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_BLANKING, &data.BlankingInfo, sizeof(XnCmosBlankingInformation), nResolution, (XnUInt16)nFPS); XN_IS_STATUS_OK(nRetVal); // add to list @@ -77,7 +73,7 @@ XnStatus XnCmosInfo::SetCmosConfig(XnCMOSType nCmos, XnResolutions nResolution, XN_IS_STATUS_OK(nRetVal); // take its info (take a pointer to the object in the list, and not to the one on the stack) - pInfo = &m_CmosBlankingInfo.begin()->BlankingInfo; + pInfo = &m_CmosBlankingInfo.Begin()->BlankingInfo; } m_pCurrCmosBlankingInfo[nCmos] = &pInfo->Coefficients[nCmos]; diff --git a/Source/XnDeviceSensorV2/XnCmosInfo.h b/Source/XnDeviceSensorV2/XnCmosInfo.h index 588c3e4..0f21147 100644 --- a/Source/XnDeviceSensorV2/XnCmosInfo.h +++ b/Source/XnDeviceSensorV2/XnCmosInfo.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_CMOS_INFO_H__ #define __XN_CMOS_INFO_H__ @@ -31,6 +26,7 @@ // Includes //--------------------------------------------------------------------------- #include "XnSensorFirmware.h" +#include //--------------------------------------------------------------------------- // Types @@ -53,7 +49,7 @@ class XnCmosInfo inline const XnCmosBlankingCoefficients* GetBlankingCoefficients(XnCMOSType nCmos) const { return m_pCurrCmosBlankingInfo[nCmos]; } private: - XN_DECLARE_LIST(XnCmosBlankingData, XnCmosBlankingDataList) + typedef XnListT XnCmosBlankingDataList; XnSensorFirmware* m_pFirmware; XnDevicePrivateData* m_pDevicePrivateData; diff --git a/Source/XnDeviceSensorV2/XnDataProcessor.cpp b/Source/XnDeviceSensorV2/XnDataProcessor.cpp index 49fd1a0..601038e 100644 --- a/Source/XnDeviceSensorV2/XnDataProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnDataProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -39,10 +33,12 @@ XnDataProcessor::XnDataProcessor(XnDevicePrivateData* pDevicePrivateData, const m_pDevicePrivateData(pDevicePrivateData), m_csName(csName), m_nLastPacketID(0), - m_nBytesReceived(0) + m_nBytesReceived(0), + m_bUseHostTimestamps(FALSE) { m_TimeStampData.csStreamName = csName; m_TimeStampData.bFirst = TRUE; + m_bUseHostTimestamps = pDevicePrivateData->pSensor->ShouldUseHostTimestamps(); } XnDataProcessor::~XnDataProcessor() @@ -64,18 +60,18 @@ void XnDataProcessor::ProcessData(const XnSensorProtocolResponseHeader* pHeader, if (nDataOffset == 0) { // make sure no packet was lost - if (pHeader->nReserve != m_nLastPacketID+1 && pHeader->nReserve != 0) + if (pHeader->nPacketID != m_nLastPacketID+1 && pHeader->nPacketID != 0) { - xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "%s: Expected %x, got %x", m_csName, m_nLastPacketID+1, pHeader->nReserve); + xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "%s: Expected %x, got %x", m_csName, m_nLastPacketID+1, pHeader->nPacketID); OnPacketLost(); } - m_nLastPacketID = pHeader->nReserve; + m_nLastPacketID = pHeader->nPacketID; // log packet arrival XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - xnDumpWriteString(m_pDevicePrivateData->MiniPacketsDump, "%llu,0x%hx,0x%hx,0x%hx,%u\n", nNow, pHeader->nType, pHeader->nReserve, pHeader->nBufSize, pHeader->nTimeStamp); + xnDumpFileWriteString(m_pDevicePrivateData->MiniPacketsDump, "%llu,0x%hx,0x%hx,0x%hx,%u\n", nNow, pHeader->nType, pHeader->nPacketID, pHeader->nBufSize, pHeader->nTimeStamp); } ProcessPacketChunk(pHeader, pData, nDataOffset, nDataSize); @@ -86,18 +82,11 @@ void XnDataProcessor::ProcessData(const XnSensorProtocolResponseHeader* pHeader, void XnDataProcessor::OnPacketLost() {} -XnUInt64 XnDataProcessor::GetTimeStamp(XnUInt32 nDeviceTimeStamp) +XnUInt64 XnDataProcessor::CreateTimestampFromDevice(XnUInt32 nDeviceTimeStamp) { - const XnUInt64 nWrapPoint = ((XnUInt64)XN_MAX_UINT32) + 1; - XnUInt64 nResultInTicks; - XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - XnChar csDumpComment[200] = ""; - - XnBool bCheckSanity = TRUE; - // we register the first TS calculated as time-zero. Every stream's TS data will be // synchronized with it if (m_pDevicePrivateData->nGlobalReferenceTS == 0) @@ -111,22 +100,59 @@ XnUInt64 XnDataProcessor::GetTimeStamp(XnUInt32 nDeviceTimeStamp) xnOSLeaveCriticalSection(&m_pDevicePrivateData->hEndPointsCS); } + const XnUInt64 nWrapPoint = ((XnUInt64)XN_MAX_UINT32) + 1; + XnUInt64 nResultInTicks; + const XnUInt32 nDumpCommentMaxLength = 200; + XnChar csDumpComment[nDumpCommentMaxLength] = ""; + XnBool bCheckSanity = TRUE; + if (m_TimeStampData.bFirst) { - // check how much OS time passed since global reference was taken + /* + This is a bit tricky, as we need to synchronize the first timestamp of different streams. + We somehow need to translate 32-bit tick counts to 64-bit timestamps. The device timestamps + wrap-around every ~71.5 seconds (for PS1080 @ 60 MHz). + Lets assume the first packet of the first stream got timestamp X. Now we get the first packet of another + stream with a timestamp Y. + We need to figure out what is the relation between X and Y. + We do that by analyzing the following scenarios: + 1. Y is after X, in the same period (no wraparound yet). + 2. Y is after X, in a different period (one or more wraparounds occurred). + 3. Y is before X, in the same period (might happen due to race condition). + 4. Y is before X, in a different period (this can happen if X is really small, and Y is almost at wraparound). + + The following code tried to handle all those cases. It uses an OS timer to try and figure out how + many wraparounds occurred. + */ + + // estimate the number of wraparound that occurred using OS time XnUInt64 nOSTime = nNow - m_pDevicePrivateData->nGlobalReferenceOSTime; - // check how many full wrap-arounds occurred (according to OS time) - XnFloat fWrapAroundInMicroseconds = nWrapPoint / (XnDouble)m_pDevicePrivateData->fDeviceFrequency; - XnUInt32 nWraps = nOSTime / fWrapAroundInMicroseconds; // floor + // calculate wraparound length + XnDouble fWrapAroundInMicroseconds = nWrapPoint / (XnDouble)m_pDevicePrivateData->fDeviceFrequency; + + // perform a rough estimation + XnInt32 nWraps = (XnInt32)(nOSTime / fWrapAroundInMicroseconds); + + // now fix the estimation by clipping TS to the correct wraparounds + XnInt64 nEstimatedTicks = + nWraps * nWrapPoint + // wraps time + nDeviceTimeStamp - m_pDevicePrivateData->nGlobalReferenceTS; - // now check, if current timestamp is less than global, then we have one more wrap-around - // (make sure it's significant - we allow up to 10 ms before - otherwise it could just be a - // matter of race-condition) - if (m_pDevicePrivateData->nGlobalReferenceTS > nDeviceTimeStamp && - nOSTime > XN_SENSOR_TIMESTAMP_SANITY_DIFF*1000) + XnInt64 nEstimatedTime = (XnInt64)(nEstimatedTicks / (XnDouble)m_pDevicePrivateData->fDeviceFrequency); + + if (nEstimatedTime < nOSTime - 0.5 * fWrapAroundInMicroseconds) + nWraps++; + else if (nEstimatedTime > nOSTime + 0.5 * fWrapAroundInMicroseconds) + nWraps--; + + // handle the two special cases - 3 & 4 in which we get a timestamp which is + // *before* global TS (meaning before time 0) + if (nWraps < 0 || // case 4 + (nWraps == 0 && nDeviceTimeStamp < m_pDevicePrivateData->nGlobalReferenceTS)) // case 3 { - ++nWraps; + nDeviceTimeStamp = m_pDevicePrivateData->nGlobalReferenceTS; + nWraps = 0; } m_TimeStampData.nReferenceTS = m_pDevicePrivateData->nGlobalReferenceTS; @@ -168,14 +194,14 @@ XnUInt64 XnDataProcessor::GetTimeStamp(XnUInt32 nDeviceTimeStamp) if (bCheckSanity && (nResultTimeMilliSeconds > (m_TimeStampData.nLastResultTime + XN_SENSOR_TIMESTAMP_SANITY_DIFF*1000))) { bIsSane = FALSE; - sprintf(csDumpComment, "%s,Didn't pass sanity. Will try to re-sync.", csDumpComment); + xnOSStrAppend(csDumpComment, ",Didn't pass sanity. Will try to re-sync.", nDumpCommentMaxLength); } // calc result XnUInt64 nResult = (m_pDevicePrivateData->pSensor->IsHighResTimestamps() ? (XnUInt64)dResultTimeMicroSeconds : nResultTimeMilliSeconds); // dump it - xnDumpWriteString(m_pDevicePrivateData->TimestampsDump, "%llu,%s,%u,%llu,%s\n", nNow, m_TimeStampData.csStreamName, nDeviceTimeStamp, nResult, csDumpComment); + xnDumpFileWriteString(m_pDevicePrivateData->TimestampsDump, "%llu,%s,%u,%llu,%s\n", nNow, m_TimeStampData.csStreamName, nDeviceTimeStamp, nResult, csDumpComment); if (bIsSane) { @@ -186,8 +212,29 @@ XnUInt64 XnDataProcessor::GetTimeStamp(XnUInt32 nDeviceTimeStamp) { // sanity failed. We lost sync. restart m_TimeStampData.bFirst = TRUE; - return GetTimeStamp(nDeviceTimeStamp); + return CreateTimestampFromDevice(nDeviceTimeStamp); } } +XnUInt64 XnDataProcessor::GetHostTimestamp() +{ + XnUInt64 nNow; + xnOSGetHighResTimeStamp(&nNow); + + // we register the first TS calculated as time-zero. Every stream's TS data will be + // synchronized with it + if (m_pDevicePrivateData->nGlobalReferenceTS == 0) + { + xnOSEnterCriticalSection(&m_pDevicePrivateData->hEndPointsCS); + if (m_pDevicePrivateData->nGlobalReferenceTS == 0) + { + m_pDevicePrivateData->nGlobalReferenceTS = nNow; + m_pDevicePrivateData->nGlobalReferenceOSTime = nNow; + } + xnOSLeaveCriticalSection(&m_pDevicePrivateData->hEndPointsCS); + } + XnUInt64 nResultTimeMicroseconds = nNow - m_pDevicePrivateData->nGlobalReferenceOSTime; + XnUInt64 nResultTimeMilliseconds = nResultTimeMicroseconds / 1000; + return (m_pDevicePrivateData->pSensor->IsHighResTimestamps() ? nResultTimeMicroseconds : nResultTimeMilliseconds); +} diff --git a/Source/XnDeviceSensorV2/XnDataProcessor.h b/Source/XnDeviceSensorV2/XnDataProcessor.h index 9bb915e..39aeb14 100644 --- a/Source/XnDeviceSensorV2/XnDataProcessor.h +++ b/Source/XnDeviceSensorV2/XnDataProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DATA_PROCESSOR_H__ #define __XN_DATA_PROCESSOR_H__ @@ -65,6 +60,8 @@ class XnDataProcessor */ void ProcessData(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); + inline XnBool ShouldUseHostTimestamps() { return m_bUseHostTimestamps; } + //--------------------------------------------------------------------------- // Virtual Functions //--------------------------------------------------------------------------- @@ -81,7 +78,9 @@ class XnDataProcessor * * @param nDeviceTimeStamp [in] The device TS to translate. */ - XnUInt64 GetTimeStamp(XnUInt32 nDeviceTimeStamp); + virtual XnUInt64 CreateTimestampFromDevice(XnUInt32 nDeviceTimeStamp); + + XnUInt64 GetHostTimestamp(); //--------------------------------------------------------------------------- // Class Members @@ -91,13 +90,15 @@ class XnDataProcessor /* The number of bytes received so far (since last time this member was reset). */ XnUInt32 m_nBytesReceived; /* Stores last packet ID */ - XnUInt16 m_nLastPacketID; + // --avin mod-- + XnUInt8 m_nLastPacketID; /* The name of the stream. */ const XnChar* m_csName; private: /* Data used for calculating timestamps. */ XnTimeStampData m_TimeStampData; + XnBool m_bUseHostTimestamps; }; #endif //__XN_DATA_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnDataProcessorHolder.cpp b/Source/XnDeviceSensorV2/XnDataProcessorHolder.cpp index 2da1dc6..433200f 100644 --- a/Source/XnDeviceSensorV2/XnDataProcessorHolder.cpp +++ b/Source/XnDeviceSensorV2/XnDataProcessorHolder.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnDataProcessorHolder.h b/Source/XnDeviceSensorV2/XnDataProcessorHolder.h index fa7a03a..d26cf85 100644 --- a/Source/XnDeviceSensorV2/XnDataProcessorHolder.h +++ b/Source/XnDeviceSensorV2/XnDataProcessorHolder.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_PROCESSOR_HOLDER_H__ #define __XN_STREAM_PROCESSOR_HOLDER_H__ @@ -50,6 +45,8 @@ class XnDataProcessorHolder void ProcessData(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); private: + XN_DISABLE_COPY_AND_ASSIGN(XnDataProcessorHolder); + XN_CRITICAL_SECTION_HANDLE m_hLock; XnDataProcessor* m_pProcessor; }; diff --git a/Source/XnDeviceSensorV2/XnDepthProcessor.cpp b/Source/XnDeviceSensorV2/XnDepthProcessor.cpp index 5b15c37..2b75f0f 100644 --- a/Source/XnDeviceSensorV2/XnDepthProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnDepthProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -40,11 +34,12 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnDepthProcessor::XnDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper) : - XnFrameStreamProcessor(pStream, pHelper, XN_SENSOR_PROTOCOL_RESPONSE_DEPTH_START, XN_SENSOR_PROTOCOL_RESPONSE_DEPTH_END), +XnDepthProcessor::XnDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnFrameStreamProcessor(pStream, pHelper, pBufferManager, XN_SENSOR_PROTOCOL_RESPONSE_DEPTH_START, XN_SENSOR_PROTOCOL_RESPONSE_DEPTH_END), m_pShiftToDepthTable(pStream->GetShiftToDepthTable()), m_nPaddingPixelsOnEnd(0), - m_bShiftToDepthAllocated(FALSE) + m_bShiftToDepthAllocated(FALSE), + m_nExpectedFrameSize(0) { } @@ -73,7 +68,7 @@ XnStatus XnDepthProcessor::Init() XN_VALIDATE_ALLOC_PTR(m_pShiftToDepthTable); for (XnUInt32 i = 0; i < XN_DEVICE_SENSOR_MAX_SHIFT_VALUE; ++i) { - m_pShiftToDepthTable[i] = i; + m_pShiftToDepthTable[i] = (XnDepthPixel)i; } m_bShiftToDepthAllocated = TRUE; } @@ -92,6 +87,8 @@ void XnDepthProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* pHea // call base XnFrameStreamProcessor::OnStartOfFrame(pHeader); + m_nExpectedFrameSize = CalculateExpectedSize(); + if (m_pDevicePrivateData->FWInfo.nFWVer >= XN_SENSOR_FW_VER_5_1 && pHeader->nTimeStamp != 0) { // PATCH: starting with v5.1, the timestamp field of the SOF packet, is the number of pixels @@ -127,13 +124,15 @@ void XnDepthProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeade m_nPaddingPixelsOnEnd = 0 ; } - XnUInt32 nExpectedSize = CalculateExpectedSize(); - if (GetWriteBuffer()->GetSize() != nExpectedSize) + if (GetWriteBuffer()->GetSize() != GetExpectedSize()) { - xnLogWarning(XN_MASK_SENSOR_READ, "Read: Depth buffer is corrupt. Size is %u (!= %u)", GetWriteBuffer()->GetSize(), nExpectedSize); + xnLogWarning(XN_MASK_SENSOR_READ, "Read: Depth buffer is corrupt. Size is %u (!= %u)", GetWriteBuffer()->GetSize(), GetExpectedSize()); FrameIsCorrupted(); } + // now add the size of the shifts map (appended at the end) + GetWriteBuffer()->UnsafeUpdateSize(GetWriteBuffer()->GetSize()); + // call base XnFrameStreamProcessor::OnEndOfFrame(pHeader); } @@ -148,12 +147,15 @@ void XnDepthProcessor::PadPixels(XnUInt32 nPixels) return; } - XnDepthPixel* pWrite = (XnDepthPixel*)pWriteBuffer->GetUnsafeWritePointer(); + XnDepthPixel* pDepth = GetDepthOutputBuffer(); + XnDepthPixel* pShift = GetShiftsOutputBuffer(); // place the no-depth value - for (XnUInt32 i = 0; i < nPixels; ++i, ++pWrite) - *pWrite = GetStream()->GetNoDepthValue(); - + for (XnUInt32 i = 0; i < nPixels; ++i, ++pDepth, ++pShift) + { + *pDepth = GetStream()->GetNoDepthValue(); + *pShift = 0; + } pWriteBuffer->UnsafeUpdateSize(nPixels * sizeof(XnDepthPixel)); } @@ -163,34 +165,3 @@ void XnDepthProcessor::OnFrameReady(XnUInt32 nFrameID, XnUInt64 nFrameTS) m_pDevicePrivateData->pSensor->GetFPSCalculator()->MarkInputDepth(nFrameID, nFrameTS); } - -void XnDepthProcessor::WriteShifts(XnUInt16* pShifts, XnUInt32 nCount) -{ - XnBuffer* pWriteBuffer = GetWriteBuffer(); - - XnUInt32 nOutputSize = nCount * sizeof(XnDepthPixel); - - // make sure we have enough room - if (CheckWriteBufferForOverflow(nOutputSize)) - { - UnsafeWriteShifts(pShifts, nCount); - } -} - -void XnDepthProcessor::UnsafeWriteShifts(XnUInt16* pShifts, XnUInt32 nCount) -{ - XnBuffer* pWriteBuffer = GetWriteBuffer(); - - XnDepthPixel* pWriteBuf = (XnDepthPixel*)pWriteBuffer->GetUnsafeWritePointer(); - XnUInt16* pRaw = pShifts; - XnUInt16* pRawEnd = pShifts + nCount; - - while (pRaw != pRawEnd) - { - *pWriteBuf = m_pShiftToDepthTable[*pRaw]; - ++pRaw; - ++pWriteBuf; - } - - pWriteBuffer->UnsafeUpdateSize(nCount * sizeof(XnDepthPixel)); -} diff --git a/Source/XnDeviceSensorV2/XnDepthProcessor.h b/Source/XnDeviceSensorV2/XnDepthProcessor.h index 09ccd6b..f3ecc64 100644 --- a/Source/XnDeviceSensorV2/XnDepthProcessor.h +++ b/Source/XnDeviceSensorV2/XnDepthProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEPTH_PROCESSOR_H__ #define __XN_DEPTH_PROCESSOR_H__ @@ -52,7 +47,7 @@ class XnDepthProcessor : public XnFrameStreamProcessor { public: - XnDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper); + XnDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); virtual ~XnDepthProcessor(); XnStatus Init(); @@ -78,14 +73,38 @@ class XnDepthProcessor : public XnFrameStreamProcessor return m_pShiftToDepthTable[nShift]; } - void WriteShifts(XnUInt16* pShifts, XnUInt32 nCount); - void UnsafeWriteShifts(XnUInt16* pShifts, XnUInt32 nCount); - XnUInt32 CalculateExpectedSize(); + inline XnUInt32 GetExpectedSize() + { + return m_nExpectedFrameSize; + } + + inline XnDepthPixel* GetDepthOutputBuffer() + { + return (XnDepthPixel*)GetWriteBuffer()->GetUnsafeWritePointer(); + } + + inline XnUInt16* GetShiftsOutputBuffer() + { + return (XnUInt16*)(GetWriteBuffer()->GetUnsafeWritePointer() + GetExpectedSize()); + } + + inline XnBool CheckDepthBufferForOverflow(XnUInt32 nWriteSize) + { + // Check there is enough room for current depth pixels + the entire shift map + return CheckWriteBufferForOverflow(nWriteSize + GetExpectedSize()); + } + + inline XnUInt32 GetFreeSpaceInDepthBuffer() + { + return GetWriteBuffer()->GetFreeSpaceInBuffer() - GetExpectedSize(); + } private: void PadPixels(XnUInt32 nPixels); + XnUInt32 CalculateExpectedSize(); XnUInt32 m_nPaddingPixelsOnEnd; + XnUInt32 m_nExpectedFrameSize; XnBool m_bShiftToDepthAllocated; XnDepthPixel* m_pShiftToDepthTable; }; diff --git a/Source/XnDeviceSensorV2/XnDeviceSensor.cpp b/Source/XnDeviceSensorV2/XnDeviceSensor.cpp index 2f1fe5d..95db25e 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensor.cpp +++ b/Source/XnDeviceSensorV2/XnDeviceSensor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnDeviceSensor.h b/Source/XnDeviceSensorV2/XnDeviceSensor.h index 9c3a17d..0a581dc 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensor.h +++ b/Source/XnDeviceSensorV2/XnDeviceSensor.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICESENSOR_H_ #define _XN_DEVICESENSOR_H_ @@ -54,8 +48,9 @@ //--------------------------------------------------------------------------- #define XN_DEVICE_MAJORVERSION 1 #define XN_DEVICE_MINORVERSION 0 -#define XN_DEVICE_NAME "SensorV2" -#define XN_DEVICE_DESCRIPTION "Xiron I/O Prime Sensor v2/v3/v4 Device" +// --avin mod-- +#define XN_DEVICE_NAME "SensorKinect" +#define XN_DEVICE_DESCRIPTION "Xiron I/O Kinect Device" #define XN_DEVICE_SENSOR_THREAD_KILL_TIMEOUT 5000 @@ -167,27 +162,19 @@ class XnCmosInfo; typedef struct XnSensorObjects { - XnSensorObjects(XnSensorFirmware* pFirmware, XnDevicePrivateData* pDevicePrivateData, XnSensorFixedParams* pFixedParams, XnSensorFPS* pFPS, XnCmosInfo* pCmosInfo) : + XnSensorObjects(XnSensorFirmware* pFirmware, XnDevicePrivateData* pDevicePrivateData, XnSensorFPS* pFPS, XnCmosInfo* pCmosInfo) : pFirmware(pFirmware), pDevicePrivateData(pDevicePrivateData), - pFixedParams(pFixedParams), pFPS(pFPS), pCmosInfo(pCmosInfo) {} XnSensorFirmware* pFirmware; XnDevicePrivateData* pDevicePrivateData; - XnSensorFixedParams* pFixedParams; XnSensorFPS* pFPS; XnCmosInfo* pCmosInfo; } XnSensorObjects; -typedef struct XnSensorInfo -{ - XnSensorVer nSensorVer; -// XnChar cSensorID[XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH+1]; -} XnSensorInfo; - typedef struct XnHWInfo { XnHWVer nHWVer; @@ -249,11 +236,38 @@ typedef struct XnCmosBlankingInformation XnCmosBlankingCoefficients Coefficients[2]; } XnCmosBlankingInformation; +typedef struct XnDeviceInformation +{ + XnChar strDeviceName[128]; + XnChar strVendorData[128]; +} XnDeviceInformation; + typedef XnStatus (XN_CALLBACK_TYPE* NewAudioDataCallback)(void* pCookie); struct XnSpecificUsbDevice; // Forward Declaration class XnSensor; // Forward Declaration +typedef struct XnDeviceAudioBuffer +{ + XN_CRITICAL_SECTION_HANDLE hLock; + /** A single (big) buffer for audio. */ + XN_AUDIO_TYPE* pAudioBuffer; + /** An array of pointers into the audio buffer. */ + XnUInt64* pAudioPacketsTimestamps; + /** The index of the next packet that should be written. */ + volatile XnUInt32 nAudioWriteIndex; + /** The index of the next packet that can be read. */ + volatile XnUInt32 nAudioReadIndex; + /** Size of the audio buffer, in packets. */ + XnUInt32 nAudioBufferNumOfPackets; + /** Size of the audio buffer, in bytes. */ + XnUInt32 nAudioBufferSize; + XnUInt32 nAudioPacketSize; + /** A callback for new data */ + NewAudioDataCallback pAudioCallback; + void* pAudioCallbackCookie; +} XnDeviceAudioBuffer; + typedef struct XnDevicePrivateData { XnVersions Version; @@ -263,13 +277,10 @@ typedef struct XnDevicePrivateData XnChar cpSensorID[XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH+1]; XnUInt8 nBoardID; XN_SENSOR_HANDLE SensorHandle; - XnSensorInfo SensorInfo; XnFirmwareInfo FWInfo; XnHWInfo HWInfo; XnChipInfo ChipInfo; - XN_CRITICAL_SECTION_HANDLE hAudioBufferCriticalSection; - XnSpecificUsbDevice* pSpecificDepthUsb; XnSpecificUsbDevice* pSpecificImageUsb; XnSpecificUsbDevice* pSpecificMiscUsb; @@ -278,25 +289,6 @@ typedef struct XnDevicePrivateData XnCropping IRCropping; - /** A single (big) buffer for audio. */ - XN_AUDIO_TYPE* pAudioBuffer; - /** An array of pointers into the audio buffer. */ - XnUInt64* pAudioPacketsTimestamps; - /** The index of the next packet that should be written. */ - volatile XnUInt32 nAudioWriteIndex; - /** The index of the next packet that can be read. */ - volatile XnUInt32 nAudioReadIndex; - /** Size of the audio buffer, in packets. */ - XnUInt32 nAudioBufferNumOfPackets; - /** Size of the audio buffer, in bytes. */ - XnUInt32 nAudioBufferSize; - XnUInt32 nAudioPacketSize; - /** When true, when reading from device, if frames were lost, their audio will also be dropped. */ - XnBool bSyncAudio; - /** A callback for new data */ - NewAudioDataCallback pAudioCallback; - void* pAudioCallbackCookie; - XnFloat fDeviceFrequency; /** Keeps the global reference TS (the one marking time-zero). */ @@ -317,11 +309,11 @@ typedef struct XnDevicePrivateData XnUInt16 nFrameSync; /** Used to dump timestamps data. */ - XnDump TimestampsDump; + XnDumpFile* TimestampsDump; /** Used to dump bandwidth data. */ - XnDump BandwidthDump; + XnDumpFile* BandwidthDump; /** Used to dump MiniPackets data. */ - XnDump MiniPacketsDump; + XnDumpFile* MiniPacketsDump; XnBool bDepthMirror; XnBool bImageMirror; diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp b/Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp index 45313db..8f741eb 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp +++ b/Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp @@ -1,51 +1,36 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnDeviceSensorIO.h" #include "XnDeviceSensor.h" +#include //--------------------------------------------------------------------------- // Defines //--------------------------------------------------------------------------- -#define XN_SENSOR_VENDOR_ID 0x1D27 -#define XN_SENSOR_2_0_PRODUCT_ID 0x0200 -#define XN_SENSOR_5_0_PRODUCT_ID 0x0500 -#define XN_SENSOR_6_0_PRODUCT_ID 0x0600 - -#if XN_PLATFORM == XN_PLATFORM_WIN32 - #include - DEFINE_GUID(GUID_CLASS_PSDRV_USB, 0xc3b5f022, 0x5a42, 0x1980, 0x19, 0x09, 0xea, 0x72, 0x09, 0x56, 0x01, 0xb1); - #define USB_DEVICE_EXTRA_PARAM (void*)&GUID_CLASS_PSDRV_USB -#else - #define USB_DEVICE_EXTRA_PARAM NULL -#endif +// --avin mod-- +#define XN_SENSOR_VENDOR_ID 0x045E //--------------------------------------------------------------------------- // Enums @@ -57,18 +42,33 @@ typedef enum } XnFWUsbInterface; //--------------------------------------------------------------------------- -// Code +// Globals //--------------------------------------------------------------------------- +// --avin mod-- +XnUInt16 XnSensorIO::ms_supportedProducts[] = +{ + 0x02AE, + 0x02BF, +}; +XnUInt32 XnSensorIO::ms_supportedProductsCount = sizeof(XnSensorIO::ms_supportedProducts) / sizeof(XnSensorIO::ms_supportedProducts[0]); + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- XnSensorIO::XnSensorIO(XN_SENSOR_HANDLE* pSensorHandle) : m_pSensorHandle(pSensorHandle), - m_bMiscSupported(FALSE) + m_bMiscSupported(FALSE), + m_bIsLowBandwidth(FALSE) { } XnSensorIO::~XnSensorIO() { - + for (XnUInt32 i = 0; i < m_aRegistrationHandles.GetSize(); ++i) + { + xnUSBUnregisterFromConnectivityEvents(m_aRegistrationHandles[i]); + } } XnStatus XnSensorIO::OpenDevice(const XnChar* strPath) @@ -82,27 +82,23 @@ XnStatus XnSensorIO::OpenDevice(const XnChar* strPath) xnLogVerbose(XN_MASK_DEVICE_IO, "Connecting to USB device..."); - if (strstr(strPath, "\\\\?\\usb") == NULL) + if (strPath == NULL || strcmp(strPath, "*:0") == 0) { - strPath = NULL; - } + // support old style API + XnConnectionString aConnections[1]; + XnUInt32 nCount = 1; + nRetVal = EnumerateSensors(aConnections, &nCount); + if (nRetVal != XN_STATUS_OK && nRetVal != XN_STATUS_OUTPUT_BUFFER_OVERFLOW) + { + return nRetVal; + } - // try to open a 6.0 device - xnLogVerbose(XN_MASK_DEVICE_IO, "Trying to open a 6.0 sensor..."); - nRetVal = xnUSBOpenDevice(XN_SENSOR_VENDOR_ID, XN_SENSOR_6_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, (void*)strPath, &m_pSensorHandle->USBDevice); - if (nRetVal == XN_STATUS_USB_DEVICE_NOT_FOUND) - { - // if not found, see if we have a 5.0 device - xnLogVerbose(XN_MASK_DEVICE_IO, "Can't find 6.0. Trying to open a 5.0 sensor..."); - nRetVal = xnUSBOpenDevice(XN_SENSOR_VENDOR_ID, XN_SENSOR_5_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, (void*)strPath, &m_pSensorHandle->USBDevice); - } - if (nRetVal == XN_STATUS_USB_DEVICE_NOT_FOUND) - { - // if not found, see if we have a 2.0 - 4.0 devices - xnLogVerbose(XN_MASK_DEVICE_IO, "Can't find 5.0. Trying to open an older sensor..."); - nRetVal = xnUSBOpenDevice(XN_SENSOR_VENDOR_ID, XN_SENSOR_2_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, (void*)strPath, &m_pSensorHandle->USBDevice); + strPath = aConnections[0]; } - + + // try to open the device + xnLogVerbose(XN_MASK_DEVICE_IO, "Trying to open sensor '%s'...", strPath); + nRetVal = xnUSBOpenDeviceByPath(strPath, &m_pSensorHandle->USBDevice); XN_IS_STATUS_OK(nRetVal); nRetVal = xnUSBGetDeviceSpeed(m_pSensorHandle->USBDevice, &DevSpeed); @@ -132,35 +128,45 @@ XnStatus XnSensorIO::OpenDevice(const XnChar* strPath) m_pSensorHandle->ControlConnection.bIsBulk = TRUE; } - xnLogInfo(XN_MASK_DEVICE_IO, "Connected to USB device"); + nRetVal = IsSensorLowBandwidth(strPath, &m_bIsLowBandwidth); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_DEVICE_IO, "Connected to USB device%s", m_bIsLowBandwidth ? " (LowBand)" : ""); + + strcpy(m_strDeviceName, strPath); return XN_STATUS_OK; } -XnStatus XnSensorIO::OpenDataEndPoints(XnSensorUsbInterface nInterface) +XnStatus XnSensorIO::OpenDataEndPoints(XnSensorUsbInterface nInterface, const XnFirmwareInfo& fwInfo) { XnStatus nRetVal = XN_STATUS_OK; +// --avin mod-- +/* // try to set requested interface if (nInterface != XN_SENSOR_USB_INTERFACE_DEFAULT) { - XnFWUsbInterface nFWInterface; + XnUInt8 nAlternativeInterface = 0; + switch (nInterface) { case XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS: - nFWInterface = XN_FW_USB_INTERFACE_ISO; + nAlternativeInterface = fwInfo.nISOAlternativeInterface; break; case XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS: - nFWInterface = XN_FW_USB_INTERFACE_BULK; + nAlternativeInterface = fwInfo.nBulkAlternativeInterface; break; default: + XN_ASSERT(FALSE); XN_LOG_WARNING_RETURN(XN_STATUS_USB_INTERFACE_NOT_SUPPORTED, XN_MASK_DEVICE_IO, "Unknown interface type: %d", nInterface); } - xnLogVerbose(XN_MASK_DEVICE_IO, "Setting USB interface to %d...", nFWInterface); - nRetVal = xnUSBSetInterface(m_pSensorHandle->USBDevice, 0, nFWInterface); + xnLogVerbose(XN_MASK_DEVICE_IO, "Setting USB alternative interface to %d...", nAlternativeInterface); + nRetVal = xnUSBSetInterface(m_pSensorHandle->USBDevice, 0, nAlternativeInterface); XN_IS_STATUS_OK(nRetVal); } +*/ xnLogVerbose(XN_MASK_DEVICE_IO, "Opening endpoints..."); @@ -170,39 +176,24 @@ XnStatus XnSensorIO::OpenDataEndPoints(XnSensorUsbInterface nInterface) XnBool bNewUSB = TRUE; // Depth - m_pSensorHandle->DepthConnection.bIsISO = FALSE; + + // --avin mod-- + m_pSensorHandle->DepthConnection.bIsISO = TRUE; + bNewUSB = TRUE; xnLogVerbose(XN_MASK_DEVICE_IO, "Opening endpoint 0x81 for depth..."); - nRetVal = xnUSBOpenEndPoint(m_pSensorHandle->USBDevice, 0x81, XN_USB_EP_BULK, XN_USB_DIRECTION_IN, &m_pSensorHandle->DepthConnection.UsbEp); + nRetVal = xnUSBOpenEndPoint(m_pSensorHandle->USBDevice, 0x81, XN_USB_EP_ISOCHRONOUS, XN_USB_DIRECTION_IN, &m_pSensorHandle->DepthConnection.UsbEp); if (nRetVal == XN_STATUS_USB_ENDPOINT_NOT_FOUND) { - bNewUSB = FALSE; - xnLogVerbose(XN_MASK_DEVICE_IO, "Endpoint 0x81 does not exist. Trying old USB: Opening 0x82 for depth..."); - nRetVal = xnUSBOpenEndPoint(m_pSensorHandle->USBDevice, 0x82, XN_USB_EP_BULK, XN_USB_DIRECTION_IN, &m_pSensorHandle->DepthConnection.UsbEp); + nRetVal = xnUSBSetInterface(m_pSensorHandle->USBDevice, 0, 1); XN_IS_STATUS_OK(nRetVal); - } - else - { - if (nRetVal == XN_STATUS_USB_WRONG_ENDPOINT_TYPE) - { - nRetVal = xnUSBOpenEndPoint(m_pSensorHandle->USBDevice, 0x81, XN_USB_EP_ISOCHRONOUS, XN_USB_DIRECTION_IN, &m_pSensorHandle->DepthConnection.UsbEp); - - m_pSensorHandle->DepthConnection.bIsISO = TRUE; - } - - bNewUSB = TRUE; + nRetVal = xnUSBOpenEndPoint(m_pSensorHandle->USBDevice, 0x81, XN_USB_EP_ISOCHRONOUS, XN_USB_DIRECTION_IN, &m_pSensorHandle->DepthConnection.UsbEp); XN_IS_STATUS_OK(nRetVal); - - if (m_pSensorHandle->DepthConnection.bIsISO == TRUE) - { - xnLogVerbose(XN_MASK_DEVICE_IO, "Depth endpoint is isochronous."); - } - else - { - xnLogVerbose(XN_MASK_DEVICE_IO, "Depth endpoint is bulk."); - } } + + xnLogVerbose(XN_MASK_DEVICE_IO, "Depth endpoint is isochronous."); + m_pSensorHandle->DepthConnection.bIsOpen = TRUE; nRetVal = xnUSBGetEndPointMaxPacketSize(m_pSensorHandle->DepthConnection.UsbEp, &m_pSensorHandle->DepthConnection.nMaxPacketSize); @@ -366,56 +357,143 @@ XnStatus XnSensorIO::CloseDevice() return (XN_STATUS_OK); } -XnStatus XnSensorIO::GetNumOfSensors(XnUInt32* pnNumSensors) +XnStatus Enumerate(XnUInt16 nProduct, XnStringsSet& devicesSet) { XnStatus nRetVal = XN_STATUS_OK; - XnBool bIsPresent = FALSE; + + const XnUSBConnectionString* astrDevicePaths; + XnUInt32 nCount; - *pnNumSensors = 0; + nRetVal = xnUSBEnumerateDevices(XN_SENSOR_VENDOR_ID, nProduct, &astrDevicePaths, &nCount); + XN_IS_STATUS_OK(nRetVal); + + for (XnUInt32 i = 0; i < nCount; ++i) + { + nRetVal = devicesSet.Set(astrDevicePaths[i]); + XN_IS_STATUS_OK(nRetVal); + } + + xnUSBFreeDevicesList(astrDevicePaths); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorIO::EnumerateSensors(XnConnectionString* aConnectionStrings, XnUInt32* pnCount) +{ + XnStatus nRetVal = XN_STATUS_OK; nRetVal = xnUSBInit(); if (nRetVal != XN_STATUS_OK && nRetVal != XN_STATUS_USB_ALREADY_INIT) return nRetVal; - // search for a v6.0 device - nRetVal = xnUSBIsDevicePresent(XN_SENSOR_VENDOR_ID, XN_SENSOR_6_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, &bIsPresent); - XN_IS_STATUS_OK(nRetVal); - - if (!bIsPresent) +// Temporary patch: "Cache" the devices since running USB enum on the MacOSX platform takes several seconds due to problems in libusb! +#if (XN_PLATFORM == XN_PLATFORM_MACOSX) + static XnStringsSet devicesSet; + + if (devicesSet.Size() == 0) { - // search for a v5.0 device - nRetVal = xnUSBIsDevicePresent(XN_SENSOR_VENDOR_ID, XN_SENSOR_5_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, &bIsPresent); - XN_IS_STATUS_OK(nRetVal); + // search for supported devices + for (XnUInt32 i = 0; i < ms_supportedProductsCount; ++i) + { + nRetVal = Enumerate(ms_supportedProducts[i], devicesSet); + XN_IS_STATUS_OK(nRetVal); + } } +#else + XnStringsSet devicesSet; - if (!bIsPresent) + // search for supported devices + for (XnUInt32 i = 0; i < ms_supportedProductsCount; ++i) { - // try searching for an older device - nRetVal = xnUSBIsDevicePresent(XN_SENSOR_VENDOR_ID, XN_SENSOR_2_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, &bIsPresent); + nRetVal = Enumerate(ms_supportedProducts[i], devicesSet); XN_IS_STATUS_OK(nRetVal); } +#endif + + // now copy back + XnUInt32 nCount = 0; + for (XnStringsSet::ConstIterator it = devicesSet.Begin(); it != devicesSet.End(); ++it, ++nCount) + { + if (nCount < *pnCount) + { + strcpy(aConnectionStrings[nCount], it->Key()); + } + } - if (bIsPresent == TRUE) + if (nCount > *pnCount) { - *pnNumSensors = 1; + *pnCount = nCount; + return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; } // All is good... + *pnCount = nCount; return (XN_STATUS_OK); } +XnStatus XnSensorIO::IsSensorLowBandwidth(const XnConnectionString connectionString, XnBool* pbIsLowBandwidth) +{ + XnConnectionString cpMatchString; + + *pbIsLowBandwidth = FALSE; + +#if (XN_PLATFORM == XN_PLATFORM_WIN32) + // WAVI Detection: + // Normal USB string: \\?\usb#vid_1d27&pid_0600#6&XXXXXXXX&0&2 + // WAVI USB String: \\?\usb#vid_1d27&pid_0600#1&1d270600&2&3 + // ^^^^^^^^ - VID/PID is always repeated here with the WAVI. + // Regular USB devices will have the port/hub chain instead. + if ((xnOSStrCaseCmp(connectionString, "\\\\?\\usb#vid_") >= 0) && (xnOSStrLen(connectionString) > 25)) + { + strncpy(&cpMatchString[0], &connectionString[12], 4); //VID + strncpy(&cpMatchString[4], &connectionString[21], 4); //PID + cpMatchString[8] = 0; + + if (strstr ((char*)connectionString,cpMatchString) != 0) + { + *pbIsLowBandwidth = TRUE; + } + } +#endif + + return (XN_STATUS_OK); +} + +void XN_CALLBACK_TYPE XnSensorIO::OnConnectivityEvent(XnUSBEventArgs* pArgs, void* pCookie) +{ + XnSensorIO* pThis = (XnSensorIO*)pCookie; + if (strcmp(pThis->m_strDeviceName, pArgs->strDevicePath) == 0) + { + pThis->m_pCallbackPtr(pArgs->eventType, const_cast(pArgs->strDevicePath), pThis->m_pCallbackData); + } +} + XnStatus XnSensorIO::SetCallback(XnUSBEventCallbackFunctionPtr pCallbackPtr, void* pCallbackData) { - //TODO: Support multiple sensors - this won't work for more than one. XnStatus nRetVal = XN_STATUS_OK; - // try to register callback to a 5.0 device - nRetVal = xnUSBSetCallbackHandler(XN_SENSOR_VENDOR_ID, XN_SENSOR_5_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, pCallbackPtr, pCallbackData); - if (nRetVal == XN_STATUS_USB_DEVICE_NOT_FOUND) + if (m_aRegistrationHandles.GetSize() == 0) { - // if not found, see if we have a 2.0 - 4.0 devices - nRetVal = xnUSBSetCallbackHandler(XN_SENSOR_VENDOR_ID, XN_SENSOR_2_0_PRODUCT_ID, USB_DEVICE_EXTRA_PARAM, pCallbackPtr, pCallbackData); + // register for USB events + for (XnUInt32 i = 0; i < ms_supportedProductsCount; ++i) + { + XnRegistrationHandle hRegistration = NULL; + nRetVal = xnUSBRegisterToConnectivityEvents(XN_SENSOR_VENDOR_ID, ms_supportedProducts[i], OnConnectivityEvent, this, &hRegistration); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_aRegistrationHandles.AddLast(hRegistration); + XN_IS_STATUS_OK(nRetVal); + } } + // set callbacks + m_pCallbackPtr = pCallbackPtr; + m_pCallbackData = pCallbackData; + return nRetVal; } + +const XnChar* XnSensorIO::GetDevicePath() +{ + return m_strDeviceName; +} diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorIO.h b/Source/XnDeviceSensorV2/XnDeviceSensorIO.h index 4b43c3e..7f491b9 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorIO.h +++ b/Source/XnDeviceSensorV2/XnDeviceSensorIO.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_DEVICE_SENSOR_I_O_H__ #define __XN_DEVICE_SENSOR_I_O_H__ @@ -33,7 +27,10 @@ //--------------------------------------------------------------------------- #include #include +#include #include +#include +#include "XnFirmwareInfo.h" //--------------------------------------------------------------------------- // Structures & Enums @@ -67,7 +64,6 @@ typedef struct XN_SENSOR_HANDLE XnUsbConnection DepthConnection; XnUsbConnection ImageConnection; XnUsbConnection MiscConnection; -// XnSensorRes SensorRes; XnUInt8 nBoardVer; } XN_SENSOR_HANDLE; @@ -80,24 +76,37 @@ class XnSensorIO XnSensorIO(XN_SENSOR_HANDLE* pSensorHandle); ~XnSensorIO(); + static XnStatus EnumerateSensors(XnConnectionString* aConnectionStrings, XnUInt32* pnCount); + static XnStatus IsSensorLowBandwidth(const XnConnectionString connectionString, XnBool* pbIsLowband); + XnStatus OpenDevice(const XnChar* strPath); - XnStatus OpenDataEndPoints(XnSensorUsbInterface nInterface); + XnStatus OpenDataEndPoints(XnSensorUsbInterface nInterface, const XnFirmwareInfo& fwInfo); XnSensorUsbInterface GetCurrentInterface() { return m_interface; } XnStatus CloseDevice(); - static XnStatus GetNumOfSensors(XnUInt32* pnNumSensors); - inline XnBool IsMiscEndpointSupported() const { return m_bMiscSupported; } + inline XnBool IsLowBandwidth() const { return m_bIsLowBandwidth; } XnStatus SetCallback(XnUSBEventCallbackFunctionPtr pCallbackPtr, void* pCallbackData); + const XnChar* GetDevicePath(); + private: + static void XN_CALLBACK_TYPE OnConnectivityEvent(XnUSBEventArgs* pArgs, void* pCookie); + XN_SENSOR_HANDLE* m_pSensorHandle; XnBool m_bMiscSupported; XnSensorUsbInterface m_interface; + XnChar m_strDeviceName[XN_DEVICE_MAX_STRING_LENGTH]; + XnBool m_bIsLowBandwidth; + XnArray m_aRegistrationHandles; + XnUSBEventCallbackFunctionPtr m_pCallbackPtr; + void* m_pCallbackData; + static XnUInt16 ms_supportedProducts[]; + static XnUInt32 ms_supportedProductsCount; }; #endif //__XN_DEVICE_SENSOR_I_O_H__ diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorInit.cpp b/Source/XnDeviceSensorV2/XnDeviceSensorInit.cpp index b82f633..f05393c 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorInit.cpp +++ b/Source/XnDeviceSensorV2/XnDeviceSensorInit.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,7 +31,7 @@ #include #include "XnSensor.h" -#define XN_HOST_PROTOCOL_MUTEX_NAME "HostProtocolMutex" +#define XN_HOST_PROTOCOL_MUTEX_NAME_PREFIX "HostProtocolMutex" //--------------------------------------------------------------------------- // Code @@ -49,24 +43,29 @@ XnStatus XnDeviceSensorInit(XnDevicePrivateData* pDevicePrivateData) nRetVal = XnDeviceSensorAllocateBuffers(pDevicePrivateData); XN_IS_STATUS_OK(nRetVal); - nRetVal = xnOSCreateNamedMutex(&pDevicePrivateData->hExecuteMutex, XN_HOST_PROTOCOL_MUTEX_NAME); +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + nRetVal = xnOSCreateMutex(&pDevicePrivateData->hExecuteMutex); + XN_IS_STATUS_OK(nRetVal); +#else + XnChar strMutexName[XN_FILE_MAX_PATH]; + XnUInt32 nCharsWritten = 0; + nRetVal = xnOSStrFormat(strMutexName, XN_FILE_MAX_PATH, &nCharsWritten, "%s%s", XN_HOST_PROTOCOL_MUTEX_NAME_PREFIX, pDevicePrivateData->pSensor->GetUSBPath()); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateNamedMutex(&pDevicePrivateData->hExecuteMutex, strMutexName); XN_IS_STATUS_OK(nRetVal); +#endif nRetVal = XnDeviceSensorConfigureVersion(pDevicePrivateData); XN_IS_STATUS_OK(nRetVal); BayerUpdateGamma(1.0); - nRetVal = xnOSCreateCriticalSection(&pDevicePrivateData->hAudioBufferCriticalSection); - XN_IS_STATUS_OK(nRetVal); - return (XN_STATUS_OK); } XnStatus XnDeviceSensorOpenInputThreads(XnDevicePrivateData* pDevicePrivateData, XnBool bOpen1, XnBool bOpen2, XnBool bOpen3) { - XnStatus nRetVal = XN_STATUS_OK; - if (bOpen2) { // Depth @@ -77,11 +76,22 @@ XnStatus XnDeviceSensorOpenInputThreads(XnDevicePrivateData* pDevicePrivateData, if (pDevicePrivateData->pSpecificDepthUsb->pUsbConnection->bIsISO == TRUE) { - pDevicePrivateData->pSpecificDepthUsb->nChunkReadBytes = XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.DepthConnection.nMaxPacketSize; + if (pDevicePrivateData->pSensor->IsLowBandwidth()) + { + pDevicePrivateData->pSpecificDepthUsb->nChunkReadBytes = XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO * pDevicePrivateData->SensorHandle.DepthConnection.nMaxPacketSize; + } + else + { + pDevicePrivateData->pSpecificDepthUsb->nChunkReadBytes = XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.DepthConnection.nMaxPacketSize; + } + + pDevicePrivateData->pSpecificDepthUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_ISO; } else { pDevicePrivateData->pSpecificDepthUsb->nChunkReadBytes = XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_BULK * pDevicePrivateData->SensorHandle.DepthConnection.nMaxPacketSize; + + pDevicePrivateData->pSpecificDepthUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_BULK; } pDevicePrivateData->pSpecificDepthUsb->nIgnoreBytes = (pDevicePrivateData->FWInfo.nFWVer >= XN_SENSOR_FW_VER_5_0) ? 0 : pDevicePrivateData->pSpecificDepthUsb->nChunkReadBytes; @@ -97,11 +107,22 @@ XnStatus XnDeviceSensorOpenInputThreads(XnDevicePrivateData* pDevicePrivateData, if (pDevicePrivateData->pSpecificImageUsb->pUsbConnection->bIsISO == TRUE) { - pDevicePrivateData->pSpecificImageUsb->nChunkReadBytes = XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.ImageConnection.nMaxPacketSize; + if (pDevicePrivateData->pSensor->IsLowBandwidth()) + { + pDevicePrivateData->pSpecificImageUsb->nChunkReadBytes = XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO * pDevicePrivateData->SensorHandle.ImageConnection.nMaxPacketSize; + } + else + { + pDevicePrivateData->pSpecificImageUsb->nChunkReadBytes = XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.ImageConnection.nMaxPacketSize; + } + + pDevicePrivateData->pSpecificImageUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_ISO; } else { pDevicePrivateData->pSpecificImageUsb->nChunkReadBytes = XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_BULK * pDevicePrivateData->SensorHandle.ImageConnection.nMaxPacketSize; + + pDevicePrivateData->pSpecificImageUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_BULK; } pDevicePrivateData->pSpecificImageUsb->nIgnoreBytes = (pDevicePrivateData->FWInfo.nFWVer >= XN_SENSOR_FW_VER_5_0) ? 0 : pDevicePrivateData->pSpecificImageUsb->nChunkReadBytes; @@ -117,11 +138,22 @@ XnStatus XnDeviceSensorOpenInputThreads(XnDevicePrivateData* pDevicePrivateData, if (pDevicePrivateData->pSpecificMiscUsb->pUsbConnection->bIsISO == TRUE) { - pDevicePrivateData->pSpecificMiscUsb->nChunkReadBytes = XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.MiscConnection.nMaxPacketSize; + if (pDevicePrivateData->pSensor->IsLowBandwidth()) + { + pDevicePrivateData->pSpecificMiscUsb->nChunkReadBytes = XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO * pDevicePrivateData->SensorHandle.MiscConnection.nMaxPacketSize; + } + else + { + pDevicePrivateData->pSpecificMiscUsb->nChunkReadBytes = XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO * pDevicePrivateData->SensorHandle.MiscConnection.nMaxPacketSize; + } + + pDevicePrivateData->pSpecificMiscUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_ISO; } else { pDevicePrivateData->pSpecificMiscUsb->nChunkReadBytes = XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_BULK * pDevicePrivateData->SensorHandle.MiscConnection.nMaxPacketSize; + + pDevicePrivateData->pSpecificMiscUsb->nTimeout = XN_SENSOR_READ_THREAD_TIMEOUT_BULK; } pDevicePrivateData->pSpecificMiscUsb->nIgnoreBytes = (pDevicePrivateData->FWInfo.nFWVer >= XN_SENSOR_FW_VER_5_0) ? 0 : pDevicePrivateData->pSpecificMiscUsb->nChunkReadBytes; @@ -209,9 +241,14 @@ XnStatus XnDeviceSensorFreeBuffers(XnDevicePrivateData* pDevicePrivateData) XnStatus XnDeviceSensorConfigureVersion(XnDevicePrivateData* pDevicePrivateData) { - XnVersions Versions; XnStatus nRetVal = XN_STATUS_OK; + // GetVersion is exactly the same in all versions, except a change that was made in version 5.1. + // so, we'll start with that, and if doesn't work we'll try previous protocols + XnHostProtocolUsbCore usb = XN_USB_CORE_JANGO; + nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, 5, 1, 0, usb); + XN_IS_STATUS_OK(nRetVal); + nRetVal = XnHostProtocolGetVersion(pDevicePrivateData, pDevicePrivateData->Version); // Strange bug: sometimes, when sending first command to device, no reply is received, so try again @@ -221,13 +258,30 @@ XnStatus XnDeviceSensorConfigureVersion(XnDevicePrivateData* pDevicePrivateData) nRetVal = XnHostProtocolGetVersion(pDevicePrivateData, pDevicePrivateData->Version); } + // if command failed for any reason, try again with older protocol if (nRetVal != XN_STATUS_OK) { - return nRetVal; + nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, 5, 0, 0, usb); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = XnHostProtocolGetVersion(pDevicePrivateData, pDevicePrivateData->Version); } - // Sensor HW Version is always 1.0 now... - pDevicePrivateData->SensorInfo.nSensorVer = XN_SENSOR_VER_2_0; + // if it still fails, give up + XN_IS_STATUS_OK(nRetVal); + + // check which usb core is used (don't check error code. If this fails, assume JANGO + if (XN_STATUS_OK != XnHostProtocolGetUsbCoreType(pDevicePrivateData, usb)) + { + usb = XN_USB_CORE_JANGO; + } + + // Now that we have the actual version, configure protocol accordingly + nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, pDevicePrivateData->Version.nMajor, pDevicePrivateData->Version.nMinor, pDevicePrivateData->Version.nBuild, usb); + XN_IS_STATUS_OK(nRetVal); + + pDevicePrivateData->HWInfo.nHWVer = pDevicePrivateData->Version.HWVer; + pDevicePrivateData->ChipInfo.nChipVer = pDevicePrivateData->Version.ChipVer; return (XN_STATUS_OK); } diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorInit.h b/Source/XnDeviceSensorV2/XnDeviceSensorInit.h index 6894130..3de4773 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorInit.h +++ b/Source/XnDeviceSensorV2/XnDeviceSensorInit.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICESENSORINIT_H_ #define _XN_DEVICESENSORINIT_H_ @@ -39,17 +33,20 @@ //--------------------------------------------------------------------------- #if XN_PLATFORM == XN_PLATFORM_WIN32 - #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO 8*10 - #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_BULK 120 - #define XN_SENSOR_USB_IMAGE_BUFFERS 8 - - #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO 8*10 - #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_BULK 120 - #define XN_SENSOR_USB_DEPTH_BUFFERS 8 - - #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO 104 - #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_BULK 20 - #define XN_SENSOR_USB_MISC_BUFFERS 8 + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO 8*10 + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_BULK 120 + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 8*5 + #define XN_SENSOR_USB_IMAGE_BUFFERS 8 + + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO 8*10 + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_BULK 120 + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 8*5 + #define XN_SENSOR_USB_DEPTH_BUFFERS 8 + + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO 104 + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_BULK 20 + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 52 + #define XN_SENSOR_USB_MISC_BUFFERS 8 #elif XN_PLATFORM == XN_PLATFORM_PS3 #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_ISO 0x1E000 #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_BULK 0x4000 @@ -60,21 +57,25 @@ #define XN_SENSOR_USB_MISC_BUFFER_SIZE 0x1000 #define XN_SENSOR_USB_MISC_BUFFERS 1 -#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM) - #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO 32 - #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_BULK 40 - #define XN_SENSOR_USB_IMAGE_BUFFERS 16 - - #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO 32 - #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_BULK 40 - #define XN_SENSOR_USB_DEPTH_BUFFERS 16 - - #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO 104 - #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_BULK 20 - #define XN_SENSOR_USB_MISC_BUFFERS 5 +#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_MACOSX || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM) + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_ISO 32 + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_BULK 40 + #define XN_SENSOR_USB_IMAGE_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 16 + #define XN_SENSOR_USB_IMAGE_BUFFERS 16 + + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_ISO 32 + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_BULK 40 + #define XN_SENSOR_USB_DEPTH_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 16 + #define XN_SENSOR_USB_DEPTH_BUFFERS 16 + + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_ISO 104 + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_BULK 20 + #define XN_SENSOR_USB_MISC_BUFFER_SIZE_MULTIPLIER_LOWBAND_ISO 52 + #define XN_SENSOR_USB_MISC_BUFFERS 5 #endif -#define XN_SENSOR_READ_THREAD_TIMEOUT 100 +#define XN_SENSOR_READ_THREAD_TIMEOUT_ISO 100 +#define XN_SENSOR_READ_THREAD_TIMEOUT_BULK 1000 //--------------------------------------------------------------------------- // Functions Declaration diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.cpp b/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.cpp index 1b45e62..b460151 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.cpp +++ b/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -43,21 +37,6 @@ FILE* g_fUSBDump; //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnStatus XnDeviceSensorProtocolGetSensorInfo(XnDevicePrivateData* pDevicePrivateData, XnChar* csSensorID) -{ - // Local function variables - XnStatus nRetVal = XN_STATUS_OK; - - XnFixedParams FixedParams; - nRetVal = XnHostProtocolGetFixedParams(pDevicePrivateData, FixedParams); - XN_IS_STATUS_OK(nRetVal); - - sprintf(csSensorID, "%x", FixedParams.nSerialNumber); - - // All is good... - return (XN_STATUS_OK); -} - XnBool XN_CALLBACK_TYPE XnDeviceSensorProtocolUsbEpCb(XnUChar* pBuffer, XnUInt32 nBufferSize, void* pCallbackData) { XN_PROFILING_START_MT_SECTION("XnDeviceSensorProtocolUsbEpCb"); @@ -136,7 +115,9 @@ XnBool XN_CALLBACK_TYPE XnDeviceSensorProtocolUsbEpCb(XnUChar* pBuffer, XnUInt32 break; } else + { pBuffer++; + } } if (pBuffer == pBufEnd && // magic wasn't found @@ -160,7 +141,7 @@ XnBool XN_CALLBACK_TYPE XnDeviceSensorProtocolUsbEpCb(XnUChar* pBuffer, XnUInt32 // we have entire header. Fix it pCurrState->CurrHeader.nBufSize = XN_PREPARE_VAR16_IN_BUFFER(pCurrState->CurrHeader.nBufSize); pCurrState->CurrHeader.nMagic = XN_PREPARE_VAR16_IN_BUFFER(pCurrState->CurrHeader.nMagic); - pCurrState->CurrHeader.nReserve = XN_PREPARE_VAR16_IN_BUFFER(pCurrState->CurrHeader.nReserve); + pCurrState->CurrHeader.nPacketID = XN_PREPARE_VAR16_IN_BUFFER(pCurrState->CurrHeader.nPacketID); pCurrState->CurrHeader.nTimeStamp = XN_PREPARE_VAR32_IN_BUFFER(pCurrState->CurrHeader.nTimeStamp); pCurrState->CurrHeader.nType = XN_PREPARE_VAR16_IN_BUFFER(pCurrState->CurrHeader.nType); pCurrState->CurrHeader.nBufSize = xnOSEndianSwapUINT16(pCurrState->CurrHeader.nBufSize); diff --git a/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.h b/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.h index d8fbf9f..aca49b8 100644 --- a/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.h +++ b/Source/XnDeviceSensorV2/XnDeviceSensorProtocol.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_DEVICESENSORPROTOCOL_H_ #define _XN_DEVICESENSORPROTOCOL_H_ @@ -88,7 +82,9 @@ typedef struct XnSensorProtocolResponseHeader { XnUInt16 nMagic; XnUInt16 nType; - XnUInt16 nReserve; + // --avin mod-- + XnUInt8 nPacketID; + XnUInt8 nUnknown; XnUInt16 nBufSize; XnUInt32 nTimeStamp; } XnSensorProtocolResponseHeader; @@ -118,14 +114,13 @@ typedef struct XnSpecificUsbDevice XnUInt32 nIgnoreBytes; XnUInt32 nChunkReadBytes; XnSpecificUsbDeviceState CurrState; + XnUInt32 nTimeout; } XnSpecificUsbDevice; //--------------------------------------------------------------------------- // Functions Declaration //--------------------------------------------------------------------------- -XnStatus XnDeviceSensorProtocolGetSensorInfo(XnDevicePrivateData* pDevicePrivateData, XnChar* csSensorID); - XnBool XN_CALLBACK_TYPE XnDeviceSensorProtocolUsbEpCb(XnUChar* pBuffer, XnUInt32 nBufferSize, void* pCallbackData); XnStatus XnCalculateExpectedImageSize(XnDevicePrivateData* pDevicePrivateData, XnUInt32* pnExpectedSize); diff --git a/Source/XnDeviceSensorV2/XnExportedSensorDevice.cpp b/Source/XnDeviceSensorV2/XnExportedSensorDevice.cpp index bc627b9..6b7014a 100644 --- a/Source/XnDeviceSensorV2/XnExportedSensorDevice.cpp +++ b/Source/XnDeviceSensorV2/XnExportedSensorDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,9 +26,20 @@ #include #include "XnSensorDevice.h" #include -#include +#include #include "XnSensorServer.h" +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +// On weak platforms (like Arm), the default is not to use multi-process. +#if (XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM) + #define XN_SENSOR_DEFAULT_MULTI_PROCESS (FALSE) +#else + #define XN_SENSOR_DEFAULT_MULTI_PROCESS (TRUE) +#endif + + //--------------------------------------------------------------------------- // XnExportedSensorDevice class //--------------------------------------------------------------------------- @@ -58,7 +63,7 @@ void XnExportedSensorDevice::GetDescription(XnProductionNodeDescription* pDescri pDescription->Type = XN_NODE_TYPE_DEVICE; } -XnStatus XnExportedSensorDevice::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors) +XnStatus XnExportedSensorDevice::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* /*pErrors*/) { XnStatus nRetVal = XN_STATUS_OK; @@ -70,7 +75,7 @@ XnStatus XnExportedSensorDevice::EnumerateProductionTrees(xn::Context& context, if (nRetVal != XN_STATUS_OUTPUT_BUFFER_OVERFLOW) { // no sensor connected - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_NOT_CONNECTED, XN_MASK_DEVICE_SENSOR, "No PS sensor is connected!"); + return XN_STATUS_DEVICE_NOT_CONNECTED; } // allocate according to count @@ -87,23 +92,30 @@ XnStatus XnExportedSensorDevice::EnumerateProductionTrees(xn::Context& context, XnProductionNodeDescription Description; GetDescription(&Description); - // each connection string is a sensor. return it for (XnUInt32 i = 0; i < nCount; ++i) { - nRetVal = TreesList.Add(Description, pConnStrings[i], NULL); - if (nRetVal != XN_STATUS_OK) + // Each connection string is a sensor. Return it if it wasn't created already. + if (FindCreatedDevice(context.GetUnderlyingObject(), pConnStrings[i]) == m_createdDevices.End()) { - xnOSFree(pConnStrings); - return (nRetVal); + nRetVal = TreesList.Add(Description, pConnStrings[i], NULL); + if (nRetVal != XN_STATUS_OK) + { + xnOSFree(pConnStrings); + return (nRetVal); + } } } xnOSFree(pConnStrings); - return (XN_STATUS_OK); } -XnStatus XnExportedSensorDevice::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* strCreationInfo, xn::NodeInfoList* pNeededTrees, const XnChar* strConfigurationDir, xn::ModuleProductionNode** ppInstance) +XnStatus XnExportedSensorDevice::Create(xn::Context& context, + const XnChar* strInstanceName, + const XnChar* strCreationInfo, + xn::NodeInfoList* /*pNeededTrees*/, + const XnChar* strConfigurationDir, + xn::ModuleProductionNode** ppInstance) { XnStatus nRetVal = XN_STATUS_OK; @@ -111,12 +123,17 @@ XnStatus XnExportedSensorDevice::Create(xn::Context& context, const XnChar* strI nRetVal = XnSensor::ResolveGlobalConfigFileName(strGlobalConfigFile, XN_FILE_MAX_PATH, strConfigurationDir); XN_IS_STATUS_OK(nRetVal); - XnBool bEnableMultiProcess = TRUE; + // multi-process is not supported on Mac +#if (XN_PLATFORM == XN_PLATFORM_MACOSX) + XnBool bEnableMultiProcess = FALSE; +#else + XnBool bEnableMultiProcess = XN_SENSOR_DEFAULT_MULTI_PROCESS; XnUInt32 nValue; - if (XN_STATUS_OK == xnOSReadIntFromINI(strGlobalConfigFile, XN_CONFIG_FILE_SERVER_SECTION, XN_MODULE_PROPERTY_ENABLE_MULTI_PROCESS, &nValue)) + if (XN_STATUS_OK == xnOSReadIntFromINI(strGlobalConfigFile, XN_SENSOR_SERVER_CONFIG_FILE_SECTION, XN_MODULE_PROPERTY_ENABLE_MULTI_PROCESS, &nValue)) { bEnableMultiProcess = (nValue == TRUE); } +#endif XnDeviceBase* pSensor = NULL; @@ -166,6 +183,15 @@ XnStatus XnExportedSensorDevice::Create(xn::Context& context, const XnChar* strI nRetVal = pDevice->Init(); if (nRetVal != XN_STATUS_OK) { + XN_DELETE(pDevice); + XN_DELETE(pSensor); + return (nRetVal); + } + + nRetVal = m_createdDevices.AddLast(DeviceKey(context.GetUnderlyingObject(), strCreationInfo)); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pDevice); XN_DELETE(pSensor); return (nRetVal); } @@ -177,9 +203,52 @@ XnStatus XnExportedSensorDevice::Create(xn::Context& context, const XnChar* strI void XnExportedSensorDevice::Destroy(xn::ModuleProductionNode* pInstance) { + XnStatus nRetVal = XN_STATUS_OK; XnSensorDevice* pDevice = dynamic_cast(pInstance); + XnChar strConnStr[XN_MAX_CREATION_INFO_LENGTH]; + nRetVal = pDevice->GetStringProperty(XN_MODULE_PROPERTY_USB_PATH, strConnStr, sizeof(strConnStr)); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_DEVICE_SENSOR, "Couldn't get usb path property ?! :("); + XN_ASSERT(FALSE); + } + XnContext* pContext = pDevice->GetContext().GetUnderlyingObject(); + CreatedDevices::Iterator it = FindCreatedDevice(pContext, strConnStr); + if (it == m_createdDevices.End()) + { + xnLogWarning(XN_MASK_DEVICE_SENSOR, "Couldn't find device in created devices ?! :("); + XN_ASSERT(FALSE); + } + else + { + m_createdDevices.Remove(it); + } + XnDeviceBase* pSensor = pDevice->GetSensor(); pSensor->Destroy(); XN_DELETE(pSensor); XN_DELETE(pDevice); + } + +XnExportedSensorDevice::DeviceKey::DeviceKey(XnContext* pContext, const XnChar* strConnStr) +{ + m_pContext = pContext; + xnOSStrCopy(m_strConnStr, strConnStr, sizeof(m_strConnStr)); +} + +XnExportedSensorDevice::CreatedDevices::Iterator XnExportedSensorDevice::FindCreatedDevice(XnContext* pContext, + const XnChar* strConnStr) +{ + CreatedDevices::Iterator it = m_createdDevices.Begin(); + for (; it != m_createdDevices.End(); it++) + { + if ((it->m_pContext == pContext) && + (xnOSStrCmp(it->m_strConnStr, strConnStr) == 0)) + { + break; + } + } + + return it; +} \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnExportedSensorDevice.h b/Source/XnDeviceSensorV2/XnExportedSensorDevice.h index 7bd9d81..953d16c 100644 --- a/Source/XnDeviceSensorV2/XnExportedSensorDevice.h +++ b/Source/XnDeviceSensorV2/XnExportedSensorDevice.h @@ -1,38 +1,33 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_EXPORTED_SENSOR_DEVICE_H__ #define __XN_EXPORTED_SENSOR_DEVICE_H__ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- -#include #include "XnSensor.h" +#include +#include //--------------------------------------------------------------------------- // Types @@ -46,6 +41,22 @@ class XnExportedSensorDevice : public xn::ModuleExportedProductionNode XnStatus EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors); XnStatus Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* strCreationInfo, xn::NodeInfoList* pNeededTrees, const XnChar* strConfigurationDir, xn::ModuleProductionNode** ppInstance); void Destroy(xn::ModuleProductionNode* pInstance); + +private: + struct DeviceKey + { + DeviceKey() {} + DeviceKey(XnContext* pContext, const XnChar* strConnStr); + + XnContext* m_pContext; + XnChar m_strConnStr[XN_MAX_CREATION_INFO_LENGTH]; + }; + + typedef XnListT CreatedDevices; + + CreatedDevices::Iterator FindCreatedDevice(XnContext* pContext, const XnChar* strConnStr); + + CreatedDevices m_createdDevices; }; #endif // __XN_EXPORTED_SENSOR_DEVICE_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnExportedSensorGenerator.cpp b/Source/XnDeviceSensorV2/XnExportedSensorGenerator.cpp index 2f4f8e0..e874797 100644 --- a/Source/XnDeviceSensorV2/XnExportedSensorGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnExportedSensorGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,13 +26,14 @@ #include "XnExportedSensorDevice.h" #include #include "XnSensorGenerator.h" -#include +#include //--------------------------------------------------------------------------- // XnExportedSensorGenerator class //--------------------------------------------------------------------------- -XnExportedSensorGenerator::XnExportedSensorGenerator(XnProductionNodeType Type, const XnChar* strStreamType) : -m_Type(Type) +XnExportedSensorGenerator::XnExportedSensorGenerator(XnProductionNodeType Type, const XnChar* strStreamType, XnBool isAvailbaleInLowBand /* = TRUE */) : + m_Type(Type), + m_bIsAvailableInLowBand(isAvailbaleInLowBand) { strcpy(m_strStreamType, strStreamType); } @@ -56,16 +51,52 @@ XnStatus XnExportedSensorGenerator::EnumerateProductionTrees(xn::Context& contex XnProductionNodeDescription Description; GetDescription(&Description); + // perform a query to be sure the device we'll find is the same one exported from this DLL. xn::Query query; query.SetVendor(XN_VENDOR_PRIMESENSE); - - nRetVal = context.AutoEnumerateOverSingleInput(TreesList, Description, NULL, XN_NODE_TYPE_DEVICE, pErrors, &query); + query.SetName(XN_DEVICE_NAME); + query.SetMinVersion(Description.Version); + query.SetMaxVersion(Description.Version); + + // check which devices are currently connected + xn::NodeInfoList devices; + nRetVal = context.EnumerateProductionTrees(XN_NODE_TYPE_DEVICE, &query, devices, pErrors); + if (nRetVal == XN_STATUS_NO_NODE_PRESENT) + { + // the error was already added to the EnumerationErrors object + return XN_STATUS_OK; + } XN_IS_STATUS_OK(nRetVal); + + // now check each one, to find out if it supports our generator + for (xn::NodeInfoList::Iterator it = devices.Begin(); it != devices.End(); ++it) + { + xn::NodeInfo deviceInfo = *it; + + XnBool bIsGeneratorSupported = TRUE; + nRetVal = IsSupportedForDevice(context, deviceInfo, &bIsGeneratorSupported); + XN_IS_STATUS_OK(nRetVal); + + if (bIsGeneratorSupported) + { + xn::NodeInfoList neededNodes; + nRetVal = neededNodes.AddNode(deviceInfo); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = TreesList.Add(Description, NULL, &neededNodes); + XN_IS_STATUS_OK(nRetVal); + } + } + + if (TreesList.IsEmpty()) + { + return XN_STATUS_NO_NODE_PRESENT; + } return (XN_STATUS_OK); } -XnStatus XnExportedSensorGenerator::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* strCreationInfo, xn::NodeInfoList* pNeededTrees, const XnChar* strConfigurationDir, xn::ModuleProductionNode** ppInstance) +XnStatus XnExportedSensorGenerator::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* /*strCreationInfo*/, xn::NodeInfoList* pNeededTrees, const XnChar* /*strConfigurationDir*/, xn::ModuleProductionNode** ppInstance) { XnStatus nRetVal = XN_STATUS_OK; @@ -123,3 +154,55 @@ void XnExportedSensorGenerator::Destroy(xn::ModuleProductionNode* pInstance) XN_DELETE(pGenerator); } +XnStatus XnExportedSensorGenerator::IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported) +{ + XnStatus nRetVal = XN_STATUS_OK; + + *pbSupported = FALSE; + + // first of all, make sure there isn't already a generator of that type from this device (not supported) + // Do this by searching in OpenNI + xn::Device sensor; + nRetVal = sensorInfo.GetInstance(sensor); + XN_IS_STATUS_OK(nRetVal); + + if (sensor.IsValid()) + { + xn::NodeInfoList existingGenerators; + nRetVal = context.EnumerateExistingNodes(existingGenerators, m_Type); + XN_IS_STATUS_OK(nRetVal); + + // now leave only the ones needing our device + xn::Query query; + nRetVal = query.AddNeededNode(sensorInfo.GetInstanceName()); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = existingGenerators.FilterList(context, query); + XN_IS_STATUS_OK(nRetVal); + + // if there's anything left, then this device already has that generator + if (!existingGenerators.IsEmpty()) + { + *pbSupported = FALSE; + return XN_STATUS_OK; + } + } + + // now, check if this is a low-bandwidth device + if (!m_bIsAvailableInLowBand) + { + XnBool bIsLowBand; + nRetVal = XnSensorIO::IsSensorLowBandwidth(sensorInfo.GetCreationInfo(), &bIsLowBand); + XN_IS_STATUS_OK(nRetVal); + + if (bIsLowBand) + { + *pbSupported = FALSE; + return XN_STATUS_OK; + } + } + + *pbSupported = TRUE; + + return (XN_STATUS_OK); +} diff --git a/Source/XnDeviceSensorV2/XnExportedSensorGenerator.h b/Source/XnDeviceSensorV2/XnExportedSensorGenerator.h index db271c1..6197a64 100644 --- a/Source/XnDeviceSensorV2/XnExportedSensorGenerator.h +++ b/Source/XnDeviceSensorV2/XnExportedSensorGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_EXPORTED_SENSOR_GENERATOR_H__ #define __XN_EXPORTED_SENSOR_GENERATOR_H__ @@ -41,7 +35,7 @@ class XnExportedSensorGenerator : public xn::ModuleExportedProductionNode { public: - XnExportedSensorGenerator(XnProductionNodeType Type, const XnChar* strStreamType); + XnExportedSensorGenerator(XnProductionNodeType Type, const XnChar* strStreamType, XnBool isAvailbaleInLowBand = TRUE); void GetDescription(XnProductionNodeDescription* pDescription); XnStatus EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* pErrors); @@ -49,11 +43,13 @@ class XnExportedSensorGenerator : public xn::ModuleExportedProductionNode void Destroy(xn::ModuleProductionNode* pInstance); protected: + virtual XnStatus IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported); virtual XnSensorGenerator* CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) = 0; private: XnProductionNodeType m_Type; XnChar m_strStreamType[XN_DEVICE_MAX_STRING_LENGTH]; + XnBool m_bIsAvailableInLowBand; }; #endif // __XN_EXPORTED_SENSOR_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnFirmwareCommands.cpp b/Source/XnDeviceSensorV2/XnFirmwareCommands.cpp index a46ac34..0c453d0 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareCommands.cpp +++ b/Source/XnDeviceSensorV2/XnFirmwareCommands.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -51,5 +45,5 @@ XnStatus XnFirmwareCommands::SetFirmwareParam(XnUInt16 nParam, XnUInt16 nValue) XnStatus XnFirmwareCommands::SetMultipleFirmwareParams(XnInnerParamData* aParams, XnUInt32 nCount) { - return XnHostProtocolSetMultipleParams(m_pDevicePrivateData, nCount, aParams); + return XnHostProtocolSetMultipleParams(m_pDevicePrivateData, (XnUInt16)nCount, aParams); } diff --git a/Source/XnDeviceSensorV2/XnFirmwareCommands.h b/Source/XnDeviceSensorV2/XnFirmwareCommands.h index d85b5c0..bd4ffd0 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareCommands.h +++ b/Source/XnDeviceSensorV2/XnFirmwareCommands.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FIRMWARE_COMMANDS_H__ #define __XN_FIRMWARE_COMMANDS_H__ diff --git a/Source/XnDeviceSensorV2/XnFirmwareInfo.cpp b/Source/XnDeviceSensorV2/XnFirmwareInfo.cpp index 3cb366e..b4a4293 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareInfo.cpp +++ b/Source/XnDeviceSensorV2/XnFirmwareInfo.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnFirmwareInfo.h b/Source/XnDeviceSensorV2/XnFirmwareInfo.h index 9177cac..21119e3 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareInfo.h +++ b/Source/XnDeviceSensorV2/XnFirmwareInfo.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FIRMWARE_INFO_H__ #define __XN_FIRMWARE_INFO_H__ @@ -31,6 +26,7 @@ // Includes //--------------------------------------------------------------------------- #include +#include //--------------------------------------------------------------------------- // Types @@ -47,6 +43,8 @@ class XnFirmwareInfo XnParamCurrentMode nCurrMode; XnBool bAudioSupported; + XnBool bGetPresetsSupported; + XnBool bDeviceInfoSupported; XnUInt16 nOpcodeGetVersion; XnUInt16 nOpcodeKeepAlive; @@ -59,6 +57,17 @@ class XnFirmwareInfo XnUInt16 nOpcodeReset; XnUInt16 nOpcodeSetCmosBlanking; XnUInt16 nOpcodeGetCmosBlanking; + XnUInt16 nOpcodeGetCmosPresets; + XnUInt16 nOpcodeGetSerialNumber; + XnUInt16 nOpcodeGetFastConvergenceTEC; + XnUInt16 nOpcodeGetCMOSReg; + XnUInt16 nOpcodeSetCMOSReg; + XnUInt16 nOpcodeWriteI2C; + XnUInt16 nOpcodeReadI2C; + XnUInt16 nOpcodeReadAHB; + XnUInt16 nOpcodeWriteAHB; + XnUInt16 nOpcodeGetPlatformString; + XnUInt16 nOpcodeGetUsbCore; XnBool bMirrorSupported; @@ -71,6 +80,17 @@ class XnFirmwareInfo XnUInt16 nUSBDelaySetParamStream0Mode; XnUInt16 nUSBDelaySetParamStream1Mode; XnUInt16 nUSBDelaySetParamStream2Mode; + + XnUInt8 nISOAlternativeInterface; + XnUInt8 nBulkAlternativeInterface; + + XnBool bGetImageCmosTypeSupported; + XnBool bImageSupported; + + XnArray depthModes; + XnArray imageBulkModes; + XnArray imageIsoModes; + XnArray irModes; }; #endif //__XN_FIRMWARE_INFO_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnFirmwareStreams.cpp b/Source/XnDeviceSensorV2/XnFirmwareStreams.cpp index 54b3b44..ca864bd 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareStreams.cpp +++ b/Source/XnDeviceSensorV2/XnFirmwareStreams.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -93,7 +87,7 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution XnStatus nRetVal = XN_STATUS_OK; // first of all, make sure this stream isn't claimed already - XnFirmwareStreamData* pStreamData; + XnFirmwareStreamData* pStreamData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pStreamData); XN_IS_STATUS_OK(nRetVal); @@ -105,7 +99,7 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution if (strcmp(strType, XN_STREAM_TYPE_DEPTH) == 0) { // check if IR stream is configured - XnFirmwareStreamData* pIRStreamData; + XnFirmwareStreamData* pIRStreamData = NULL; nRetVal = m_FirmwareStreams.Get(XN_STREAM_TYPE_IR, pIRStreamData); XN_IS_STATUS_OK(nRetVal); @@ -117,17 +111,21 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Cannot set depth stream to resolution %d when IR is set to resolution %d!", nRes, pIRStreamData->nRes); } + // --avin mod-- + // Removed to enable 1280x1024 IR + /* // check FPS if (pIRStreamData->nFPS != nFPS) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Depth and IR streams must have the same FPS!"); } + */ } } else if (strcmp(strType, XN_STREAM_TYPE_IR) == 0) { // check if image is configured - XnFirmwareStreamData* pImageStreamData; + XnFirmwareStreamData* pImageStreamData = NULL; nRetVal = m_FirmwareStreams.Get(XN_STREAM_TYPE_IMAGE, pImageStreamData); XN_IS_STATUS_OK(nRetVal); @@ -137,7 +135,7 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution } // check if depth is configured - XnFirmwareStreamData* pDepthStreamData; + XnFirmwareStreamData* pDepthStreamData = NULL; nRetVal = m_FirmwareStreams.Get(XN_STREAM_TYPE_DEPTH, pDepthStreamData); XN_IS_STATUS_OK(nRetVal); @@ -146,14 +144,22 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution // check res if (pDepthStreamData->nRes != nRes && (nRes != XN_RESOLUTION_SXGA || pDepthStreamData->nRes != XN_RESOLUTION_VGA)) { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Cannot set IR stream to resolution %d when Depth is set to resolution %d!", nRes, pDepthStreamData->nRes); + if (m_pDevicePrivateData->FWInfo.nFWVer < XN_SENSOR_FW_VER_5_6) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Cannot set IR stream to resolution %d when Depth is set to resolution %d!", nRes, pDepthStreamData->nRes); + } } // check FPS + // --avin mod-- + // Removed to enable 1280x1024 IR + /* + if (pDepthStreamData->nFPS != nFPS) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Depth and IR streams must have the same FPS!"); } + */ } } else if (strcmp(strType, XN_STREAM_TYPE_IMAGE) == 0) @@ -181,7 +187,7 @@ XnStatus XnFirmwareStreams::ClaimStream(const XnChar* strType, XnResolutions nRe XN_IS_STATUS_OK(nRetVal); // get stream data - XnFirmwareStreamData* pData; + XnFirmwareStreamData* pData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pData); XN_IS_STATUS_OK(nRetVal); @@ -200,7 +206,7 @@ XnStatus XnFirmwareStreams::ReleaseStream(const XnChar* strType, XnDeviceStream* XnStatus nRetVal = XN_STATUS_OK; // get stream data - XnFirmwareStreamData* pData; + XnFirmwareStreamData* pData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pData); XN_IS_STATUS_OK(nRetVal); @@ -223,7 +229,7 @@ XnStatus XnFirmwareStreams::LockStreamProcessor(const XnChar* strType, XnDeviceS XnStatus nRetVal = XN_STATUS_OK; // get stream data - XnFirmwareStreamData* pData; + XnFirmwareStreamData* pData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pData); XN_IS_STATUS_OK(nRetVal); @@ -242,7 +248,7 @@ XnStatus XnFirmwareStreams::UnlockStreamProcessor(const XnChar* strType, XnDevic XnStatus nRetVal = XN_STATUS_OK; // get stream data - XnFirmwareStreamData* pData; + XnFirmwareStreamData* pData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pData); XN_IS_STATUS_OK(nRetVal); @@ -261,7 +267,7 @@ XnStatus XnFirmwareStreams::ReplaceStreamProcessor(const XnChar* strType, XnDevi XnStatus nRetVal = XN_STATUS_OK; // get stream data - XnFirmwareStreamData* pData; + XnFirmwareStreamData* pData = NULL; nRetVal = m_FirmwareStreams.Get(strType, pData); XN_IS_STATUS_OK(nRetVal); diff --git a/Source/XnDeviceSensorV2/XnFirmwareStreams.h b/Source/XnDeviceSensorV2/XnFirmwareStreams.h index be747c8..3e6c6a8 100644 --- a/Source/XnDeviceSensorV2/XnFirmwareStreams.h +++ b/Source/XnDeviceSensorV2/XnFirmwareStreams.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FIRMWARE_STREAMS_H__ #define __XN_FIRMWARE_STREAMS_H__ @@ -31,7 +26,7 @@ // Includes //--------------------------------------------------------------------------- #include "XnDataProcessorHolder.h" -#include +#include #include //--------------------------------------------------------------------------- @@ -74,7 +69,7 @@ class XnFirmwareStreams XnDeviceStream* pOwner; }; - XN_DECLARE_STRINGS_HASH(XnFirmwareStreamData, XnFirmwareStreamsHash) + typedef XnStringsHashT XnFirmwareStreamsHash; XnFirmwareStreamsHash m_FirmwareStreams; diff --git a/Source/XnDeviceSensorV2/XnFrameStreamProcessor.cpp b/Source/XnDeviceSensorV2/XnFrameStreamProcessor.cpp index cad4799..485cc12 100644 --- a/Source/XnDeviceSensorV2/XnFrameStreamProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnFrameStreamProcessor.cpp @@ -1,52 +1,50 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnFrameStreamProcessor.h" +#include "XnSensor.h" #include //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnFrameStreamProcessor::XnFrameStreamProcessor(XnFrameStream* pStream, XnSensorStreamHelper* pHelper, XnUInt16 nTypeSOF, XnUInt16 nTypeEOF) : +XnFrameStreamProcessor::XnFrameStreamProcessor(XnFrameStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager, XnUInt16 nTypeSOF, XnUInt16 nTypeEOF) : XnStreamProcessor(pStream, pHelper), m_nTypeSOF(nTypeSOF), m_nTypeEOF(nTypeEOF), - m_pTripleBuffer(pStream->GetTripleBuffer()), - m_InDump(XN_DUMP_CLOSED), - m_InternalDump(XN_DUMP_CLOSED), - m_bFrameCorrupted(FALSE) + m_pTripleBuffer(pBufferManager), + m_InDump(NULL), + m_InternalDump(NULL), + m_bFrameCorrupted(FALSE), + m_bAllowDoubleSOF(FALSE), + m_nLastSOFPacketID(0), + m_nFirstPacketTimestamp(0) { sprintf(m_csInDumpMask, "%sIn", pStream->GetType()); sprintf(m_csInternalDumpMask, "Internal%s", pStream->GetType()); - xnDumpInit(&m_InDump, m_csInDumpMask, NULL, "%s_0.raw", m_csInDumpMask); - xnDumpInit(&m_InternalDump, m_csInternalDumpMask, NULL, "%s_0.raw", m_csInternalDumpMask); + m_InDump = xnDumpFileOpen(m_csInDumpMask, "%s_0.raw", m_csInDumpMask); + m_InternalDump = xnDumpFileOpen(m_csInternalDumpMask, "%s_0.raw", m_csInternalDumpMask); } XnFrameStreamProcessor::~XnFrameStreamProcessor() @@ -55,17 +53,21 @@ XnFrameStreamProcessor::~XnFrameStreamProcessor() void XnFrameStreamProcessor::ProcessPacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) { - XN_PROFILING_START_SECTION("XnFrameStreamProcessor::ProcessPacketChunk") + XN_PROFILING_START_SECTION("XnFrameStreamProcessor::ProcessPacketChunk"); // if first data from SOF packet if (pHeader->nType == m_nTypeSOF && nDataOffset == 0) { - OnStartOfFrame(pHeader); + if (!m_bAllowDoubleSOF || pHeader->nPacketID != (m_nLastSOFPacketID + 1)) + { + m_nLastSOFPacketID = pHeader->nPacketID; + OnStartOfFrame(pHeader); + } } if (!m_bFrameCorrupted) { - xnDumpWriteBuffer(m_InDump, pData, nDataSize); + xnDumpFileWriteBuffer(m_InDump, pData, nDataSize); ProcessFramePacketChunk(pHeader, pData, nDataOffset, nDataSize); } @@ -83,24 +85,39 @@ void XnFrameStreamProcessor::OnPacketLost() FrameIsCorrupted(); } -void XnFrameStreamProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader) +void XnFrameStreamProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* /*pHeader*/) { m_bFrameCorrupted = FALSE; m_pTripleBuffer->GetWriteBuffer()->Reset(); + if (m_pDevicePrivateData->pSensor->ShouldUseHostTimestamps()) + { + m_nFirstPacketTimestamp = GetHostTimestamp(); + } } void XnFrameStreamProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) { // write dump XnBuffer* pCurWriteBuffer = m_pTripleBuffer->GetWriteBuffer(); - xnDumpWriteBuffer(m_InternalDump, pCurWriteBuffer->GetData(), pCurWriteBuffer->GetSize()); - xnDumpClose(&m_InternalDump); - xnDumpClose(&m_InDump); + xnDumpFileWriteBuffer(m_InternalDump, pCurWriteBuffer->GetData(), pCurWriteBuffer->GetSize()); + xnDumpFileClose(m_InternalDump); + xnDumpFileClose(m_InDump); if (!m_bFrameCorrupted) { // mark the buffer as stable - XnUInt64 nTimestamp = GetTimeStamp(pHeader->nTimeStamp); + XnUInt64 nTimestamp; + if (m_pDevicePrivateData->pSensor->ShouldUseHostTimestamps()) + { + // use the host timestamp of the first packet + nTimestamp = m_nFirstPacketTimestamp; + } + else + { + // use timestamp in last packet + nTimestamp = CreateTimestampFromDevice(pHeader->nTimeStamp); + } + XnUInt32 nFrameID; m_pTripleBuffer->MarkWriteBufferAsStable(nTimestamp, &nFrameID); @@ -116,12 +133,12 @@ void XnFrameStreamProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* // log bandwidth XnUInt64 nSysTime; xnOSGetTimeStamp(&nSysTime); - xnDumpWriteString(m_pDevicePrivateData->BandwidthDump, "%llu,%s,%d,%d\n", + xnDumpFileWriteString(m_pDevicePrivateData->BandwidthDump, "%llu,%s,%d,%d\n", nSysTime, m_csName, GetCurrentFrameID(), m_nBytesReceived); // re-init dumps - xnDumpInit(&m_InDump, m_csInDumpMask, NULL, "%s_%d.raw", m_csInDumpMask, GetCurrentFrameID()); - xnDumpInit(&m_InternalDump, m_csInternalDumpMask, NULL, "%s_%d.raw", m_csInternalDumpMask, GetCurrentFrameID()); + m_InDump = xnDumpFileOpen(m_csInDumpMask, "%s_%d.raw", m_csInDumpMask, GetCurrentFrameID()); + m_InternalDump = xnDumpFileOpen(m_csInternalDumpMask, "%s_%d.raw", m_csInternalDumpMask, GetCurrentFrameID()); m_nBytesReceived = 0; } diff --git a/Source/XnDeviceSensorV2/XnFrameStreamProcessor.h b/Source/XnDeviceSensorV2/XnFrameStreamProcessor.h index 459ae88..4d8d406 100644 --- a/Source/XnDeviceSensorV2/XnFrameStreamProcessor.h +++ b/Source/XnDeviceSensorV2/XnFrameStreamProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_FRAME_STREAM_PROCESSOR_H__ #define __XN_FRAME_STREAM_PROCESSOR_H__ @@ -51,7 +46,7 @@ class XnFrameStreamProcessor : public XnStreamProcessor * @param nTypeSOF [in] The packet type that signifies start-of-frame. * @param nTypeEOF [in] The packet type that signifies end-of-frame. */ - XnFrameStreamProcessor(XnFrameStream* pStream, XnSensorStreamHelper* pHelper, XnUInt16 nTypeSOF, XnUInt16 nTypeEOF); + XnFrameStreamProcessor(XnFrameStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager, XnUInt16 nTypeSOF, XnUInt16 nTypeEOF); /** * Destroys a frame-based stream processor @@ -99,7 +94,7 @@ class XnFrameStreamProcessor : public XnStreamProcessor * @param nFrameID [in] ID of this frame. * @param nFrameTS [in] Timestamp of this frame. */ - virtual void OnFrameReady(XnUInt32 nFrameID, XnUInt64 nFrameTS) {} + virtual void OnFrameReady(XnUInt32 /*nFrameID*/, XnUInt64 /*nFrameTS*/) {} //--------------------------------------------------------------------------- // Utility Functions @@ -158,6 +153,8 @@ class XnFrameStreamProcessor : public XnStreamProcessor */ void FrameIsCorrupted(); + void SetAllowDoubleSOFPackets(XnBool bAllow) { m_bAllowDoubleSOF = bAllow; } + private: //--------------------------------------------------------------------------- // Class Members @@ -171,9 +168,12 @@ class XnFrameStreamProcessor : public XnStreamProcessor XnChar m_csInDumpMask[100]; XnChar m_csInternalDumpMask[100]; - XnDump m_InDump; - XnDump m_InternalDump; + XnDumpFile* m_InDump; + XnDumpFile* m_InternalDump; XnBool m_bFrameCorrupted; + XnBool m_bAllowDoubleSOF; + XnUInt16 m_nLastSOFPacketID; + XnUInt64 m_nFirstPacketTimestamp; }; #endif //__XN_FRAME_STREAM_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnHostProtocol.cpp b/Source/XnDeviceSensorV2/XnHostProtocol.cpp index 6c4079b..2dec8a0 100644 --- a/Source/XnDeviceSensorV2/XnHostProtocol.cpp +++ b/Source/XnDeviceSensorV2/XnHostProtocol.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #include "XnDeviceSensorProtocol.h" #include "XnHostProtocol.h" #include @@ -51,44 +45,236 @@ #define MAX_PACKET_SIZE 512 -XnStatus XnHostProtocolInitFWParams(XnDevicePrivateData* pDevicePrivateData, XnFWVer nFWVer) +inline XnInt32 CompareVersion(XnUInt8 nMajor1, XnUInt8 nMinor1, XnUInt16 nBuild1, XnUInt8 nMajor2, XnUInt8 nMinor2, XnUInt16 nBuild2) { - XnStatus nRetVal = XN_STATUS_OK; + XnInt32 nResult = nMajor1 - nMajor2; - switch (nFWVer) + if (nResult == 0) { - case XN_SENSOR_FW_VER_5_3: - nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_2); - XN_IS_STATUS_OK(nRetVal); + nResult = nMinor1 - nMinor2; + } - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - break; + if (nResult == 0) + { + nResult = nBuild1 - nBuild2; + } - case XN_SENSOR_FW_VER_5_2: - nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_1); - XN_IS_STATUS_OK(nRetVal); + return (nResult); +} - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - break; +static XnFWVer GetFWVersion(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nBuild) +{ + if (CompareVersion(nMajor, nMinor, nBuild, 5, 7, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_7; + } + if (CompareVersion(nMajor, nMinor, nBuild, 5, 6, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_6; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 5, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_5; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 4, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_4; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_3; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 2, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_2; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 1, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_1; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 0, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_0; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 4, 0, 0) >= 0) + { + return XN_SENSOR_FW_VER_4_0; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 3, 0, 0) >= 0) + { + return XN_SENSOR_FW_VER_3_0; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 1, 2, 0) >= 0) + { + return XN_SENSOR_FW_VER_1_2; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 1, 2, 0) >= 0) + { + return XN_SENSOR_FW_VER_1_2; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 1, 1, 0) >= 0) + { + return XN_SENSOR_FW_VER_1_1; + } + else + { + return XN_SENSOR_FW_VER_0_17; + } +} - case XN_SENSOR_FW_VER_5_1: - nRetVal = XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_0); - XN_IS_STATUS_OK(nRetVal); +XnStatus XnHostProtocolInitFWParams(XnDevicePrivateData* pDevicePrivateData, XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nBuild, XnHostProtocolUsbCore usb) +{ + XnStatus nRetVal = XN_STATUS_OK; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_GET_CMOS_BLANKING; - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - break; + // we start with oldest settings (FW version 0.17), and change them for newer versions + pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_25; + pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_25; + pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV25); + pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; + pDevicePrivateData->FWInfo.bAudioSupported = FALSE; + pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; + pDevicePrivateData->FWInfo.bGetPresetsSupported = FALSE; + pDevicePrivateData->FWInfo.bDeviceInfoSupported = FALSE; + + pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V017_GET_VERSION; + pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V017_KEEP_ALIVE; + pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V017_GET_PARAM; + pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V017_SET_PARAM; + pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V017_GET_FIXED_PARAMS; + pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V017_ALGORITM_PARAMS; + pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_V017_RESET; + pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetFastConvergenceTEC = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCMOSReg = OPCODE_V017_GET_CMOS_REGISTER; + pDevicePrivateData->FWInfo.nOpcodeSetCMOSReg = OPCODE_V017_SET_CMOS_REGISTER; + pDevicePrivateData->FWInfo.nOpcodeWriteI2C = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeReadI2C = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeReadAHB = OPCODE_V017_READ_AHB; + pDevicePrivateData->FWInfo.nOpcodeWriteAHB = OPCODE_V017_WRITE_AHB; + pDevicePrivateData->FWInfo.nOpcodeGetPlatformString = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetUsbCore = OPCODE_GET_USB_CORE_TYPE; + + // --avin mod-- + pDevicePrivateData->FWInfo.nUSBDelayReceive = 1; + pDevicePrivateData->FWInfo.nUSBDelayExecutePreSend = 0; + pDevicePrivateData->FWInfo.nUSBDelayExecutePostSend = 0; + pDevicePrivateData->FWInfo.nUSBDelaySoftReset = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 300; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream0Mode = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream1Mode = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream2Mode = 1; + + pDevicePrivateData->FWInfo.bGetImageCmosTypeSupported = FALSE; + pDevicePrivateData->FWInfo.bImageSupported = TRUE; + + // depth cmos modes + pDevicePrivateData->FWInfo.depthModes.Clear(); + XnCmosPreset depthModes[] = + { + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_VGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_VGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_VGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_VGA, 30 }, + }; + nRetVal = pDevicePrivateData->FWInfo.depthModes.AddLast(depthModes, sizeof(depthModes)/sizeof(depthModes[0])); + XN_IS_STATUS_OK(nRetVal); - case XN_SENSOR_FW_VER_5_0: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; + // image cmos modes + pDevicePrivateData->FWInfo.imageBulkModes.Clear(); + pDevicePrivateData->FWInfo.imageIsoModes.Clear(); + + XnCmosPreset imageCommonModes[] = + { + { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_VGA, 30 }, + }; + nRetVal = pDevicePrivateData->FWInfo.imageBulkModes.AddLast(imageCommonModes, sizeof(imageCommonModes)/sizeof(imageCommonModes[0])); + XN_IS_STATUS_OK(nRetVal); + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageCommonModes, sizeof(imageCommonModes)/sizeof(imageCommonModes[0])); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset imageIsoModes[] = + { + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_VGA, 30 }, + // --avin mod-- + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_SXGA, 15 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_QVGA, 30 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_QVGA, 60 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER, XN_RESOLUTION_VGA, 30 }, + }; + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageIsoModes, sizeof(imageIsoModes)/sizeof(imageIsoModes[0])); + XN_IS_STATUS_OK(nRetVal); + + // IR cmos modes + pDevicePrivateData->FWInfo.irModes.Clear(); + XnCmosPreset irModes[] = + { + { 0, XN_RESOLUTION_QVGA, 30 }, + { 0, XN_RESOLUTION_QVGA, 60 }, + { 0, XN_RESOLUTION_VGA, 30 }, + { 0, XN_RESOLUTION_SXGA, 30 }, + // --avin mod-- + { 0, XN_RESOLUTION_SXGA, 15 }, + }; + nRetVal = pDevicePrivateData->FWInfo.irModes.AddLast(irModes, sizeof(irModes)/sizeof(irModes[0])); + XN_IS_STATUS_OK(nRetVal); + + if (CompareVersion(nMajor, nMinor, nBuild, 1, 1, 0) >= 0) + { + // opcodes were changed + pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V110_GET_VERSION; + pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V110_KEEP_ALIVE; + pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V110_GET_PARAM; + pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V110_SET_PARAM; + pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V110_GET_FIXED_PARAMS; + pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_V110_GET_MODE; + pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_V110_SET_MODE; + pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V110_ALGORITHM_PARAMS; + pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetFastConvergenceTEC = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCMOSReg = OPCODE_V110_GET_CMOS_REGISTER; + pDevicePrivateData->FWInfo.nOpcodeSetCMOSReg = OPCODE_V110_SET_CMOS_REGISTER; + pDevicePrivateData->FWInfo.nOpcodeWriteI2C = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeReadI2C = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeReadAHB = OPCODE_V110_READ_AHB; + pDevicePrivateData->FWInfo.nOpcodeWriteAHB = OPCODE_V110_WRITE_AHB; + + } + + if (CompareVersion(nMajor, nMinor, nBuild, 1, 2, 0) >= 0) + { + // protocol header was changed pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_26; pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_26; pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV26); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V5_0; - pDevicePrivateData->FWInfo.bAudioSupported = TRUE; + } - pDevicePrivateData->FWInfo.bMirrorSupported = TRUE; + if (CompareVersion(nMajor, nMinor, nBuild, 3, 0, 0) >= 0) + { + // audio support! + pDevicePrivateData->FWInfo.bAudioSupported = TRUE; + // opcodes were changed pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_GET_VERSION; pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_KEEP_ALIVE; pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_GET_PARAM; @@ -98,132 +284,212 @@ XnStatus XnHostProtocolInitFWParams(XnDevicePrivateData* pDevicePrivateData, XnF pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_SET_MODE; pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_ALGORITM_PARAMS; pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_SET_CMOS_BLANKING; + pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetFastConvergenceTEC = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeGetCMOSReg = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeSetCMOSReg = OPCODE_INVALID; + pDevicePrivateData->FWInfo.nOpcodeWriteI2C = OPCODE_I2C_WRITE; + pDevicePrivateData->FWInfo.nOpcodeReadI2C = OPCODE_I2C_READ; + pDevicePrivateData->FWInfo.nOpcodeReadAHB = OPCODE_READ_AHB; + pDevicePrivateData->FWInfo.nOpcodeWriteAHB = OPCODE_WRITE_AHB; + } - break; - - case XN_SENSOR_FW_VER_4_0: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_26; - pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_26; - pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV26); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; + if (CompareVersion(nMajor, nMinor, nBuild, 4, 0, 0) >= 0) + { + // audio removed... pDevicePrivateData->FWInfo.bAudioSupported = FALSE; - pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; - - pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V400_GET_VERSION; - pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V400_KEEP_ALIVE; - pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V400_GET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V400_SET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V400_GET_FIXED_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_V400_GET_MODE; - pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_V400_SET_MODE; - pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V400_ALGORITM_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; - break; - case XN_SENSOR_FW_VER_3_0: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_26; - pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_26; - pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV26); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 0, 0) >= 0) + { + // max packet size changed + pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V5_0; + // audio is back on pDevicePrivateData->FWInfo.bAudioSupported = TRUE; - pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; - - pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V300_GET_VERSION; - pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V300_KEEP_ALIVE; - pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V300_GET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V300_SET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V300_GET_FIXED_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_V300_GET_MODE; - pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_V300_SET_MODE; - pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V300_ALGORITM_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + // mirror supported + pDevicePrivateData->FWInfo.bMirrorSupported = TRUE; - break; - case XN_SENSOR_FW_VER_1_2: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_26; - pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_26; - pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV26); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; - pDevicePrivateData->FWInfo.bAudioSupported = FALSE; - pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; + // opcodes changes + pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_SET_CMOS_BLANKING; - pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V110_GET_VERSION; - pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V110_KEEP_ALIVE; - pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V110_GET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V110_SET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V110_GET_FIXED_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_V110_GET_MODE; - pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_V110_SET_MODE; - pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V110_ALGORITHM_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + // ISO endpoints interface was added + pDevicePrivateData->FWInfo.nISOAlternativeInterface = 0; + pDevicePrivateData->FWInfo.nBulkAlternativeInterface = 1; + } - break; - case XN_SENSOR_FW_VER_1_1: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_25; - pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_25; - pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV25); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; - pDevicePrivateData->FWInfo.bAudioSupported = FALSE; - pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; + if (CompareVersion(nMajor, nMinor, nBuild, 5, 1, 0) >= 0) + { + // added high-res IR + XnCmosPreset irHighResMode = { 0, XN_RESOLUTION_SXGA, 30 }; + nRetVal = pDevicePrivateData->FWInfo.irModes.AddLast(irHighResMode); + XN_IS_STATUS_OK(nRetVal); - pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V110_GET_VERSION; - pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V110_KEEP_ALIVE; - pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V110_GET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V110_SET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V110_GET_FIXED_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_V110_GET_MODE; - pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_V110_SET_MODE; - pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V110_ALGORITHM_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + // opcode added + pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_GET_CMOS_BLANKING; + } - break; - case XN_SENSOR_FW_VER_0_17: - pDevicePrivateData->FWInfo.nFWVer = nFWVer; - pDevicePrivateData->FWInfo.nFWMagic = XN_FW_MAGIC_25; - pDevicePrivateData->FWInfo.nHostMagic = XN_HOST_MAGIC_25; - pDevicePrivateData->FWInfo.nProtocolHeaderSize = sizeof(XnHostProtocolHeaderV25); - pDevicePrivateData->FWInfo.nProtocolMaxPacketSize = XN_PROTOCOL_MAX_PACKET_SIZE_V0_17; + if (CompareVersion(nMajor, nMinor, nBuild, 5, 2, 0) >= 0) + { + // 25 FPS modes were added + XnCmosPreset depthModes25FPS[] = + { + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_VGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_VGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_VGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_VGA, 25 }, + }; + nRetVal = pDevicePrivateData->FWInfo.depthModes.AddLast(depthModes, sizeof(depthModes)/sizeof(depthModes[0])); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset imageModes25FpsCommon[] = + { + { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_VGA, 25 }, + }; + nRetVal = pDevicePrivateData->FWInfo.imageBulkModes.AddLast(imageModes25FpsCommon, sizeof(imageModes25FpsCommon)/sizeof(imageModes25FpsCommon[0])); + XN_IS_STATUS_OK(nRetVal); + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageModes25FpsCommon, sizeof(imageModes25FpsCommon)/sizeof(imageModes25FpsCommon[0])); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset imageModes25FpsIso[] = + { + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_QVGA, 25 }, + { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_VGA, 25 }, + }; + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageModes25FpsIso, sizeof(imageModes25FpsIso)/sizeof(imageModes25FpsIso[0])); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset irModes25Fps[] = + { + { 0, XN_RESOLUTION_QVGA, 25 }, + { 0, XN_RESOLUTION_VGA, 25 }, + }; + nRetVal = pDevicePrivateData->FWInfo.irModes.AddLast(irModes25Fps, sizeof(irModes25Fps)/sizeof(irModes25Fps[0])); + XN_IS_STATUS_OK(nRetVal); + + // added high-res image modes (UXGA for 5.2, SXGA for 5.3 and newer) + XnCmosPreset imageHighResBayerMode = { XN_IO_IMAGE_FORMAT_BAYER, XN_RESOLUTION_UXGA, 30 }; + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 0) >= 0) + { + imageHighResBayerMode.nResolution = XN_RESOLUTION_SXGA; + } + nRetVal = pDevicePrivateData->FWInfo.imageBulkModes.AddLast(imageHighResBayerMode); + XN_IS_STATUS_OK(nRetVal); + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageHighResBayerMode); + XN_IS_STATUS_OK(nRetVal); + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 15) == 0) + { + pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 300; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 16) >= 0 && + !pDevicePrivateData->pSensor->IsLowBandwidth()) + { + if (usb == XN_USB_CORE_JANGO) + { + pDevicePrivateData->FWInfo.nUSBDelayReceive = 1; + pDevicePrivateData->FWInfo.nUSBDelayExecutePreSend = 0; + pDevicePrivateData->FWInfo.nUSBDelayExecutePostSend = 0; + } + + pDevicePrivateData->FWInfo.nUSBDelaySoftReset = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream0Mode = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream1Mode = 1; + pDevicePrivateData->FWInfo.nUSBDelaySetParamStream2Mode = 1; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 25) >= 0) + { + pDevicePrivateData->FWInfo.bDeviceInfoSupported = TRUE; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 28) >= 0) + { + // YUV is also supported in high-res + XnCmosPreset imageHighResYuvMode = { XN_IO_IMAGE_FORMAT_YUV422, XN_RESOLUTION_SXGA, 30 }; + nRetVal = pDevicePrivateData->FWInfo.imageBulkModes.AddLast(imageHighResYuvMode); + XN_IS_STATUS_OK(nRetVal); + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageHighResYuvMode); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset imageHighResYuvModeIso = { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_RESOLUTION_SXGA, 30 }; + nRetVal = pDevicePrivateData->FWInfo.imageIsoModes.AddLast(imageHighResYuvModeIso); + XN_IS_STATUS_OK(nRetVal); + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 3, 29) >= 0) + { + pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets = OPCODE_GET_CMOS_PRESETS; + pDevicePrivateData->FWInfo.bGetPresetsSupported = TRUE; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 4, 0) >= 0) + { + pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber = OPCODE_GET_SERIAL_NUMBER; + pDevicePrivateData->FWInfo.nOpcodeGetFastConvergenceTEC = OPCODE_GET_FAST_CONVERGENCE_TEC; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 5, 0) >= 0) + { + // only difference is the interfaces order + pDevicePrivateData->FWInfo.nBulkAlternativeInterface = 0; + pDevicePrivateData->FWInfo.nISOAlternativeInterface = 1; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 6, 0) >= 0) + { + // audio is no longer supported - switched to UAC pDevicePrivateData->FWInfo.bAudioSupported = FALSE; - pDevicePrivateData->FWInfo.bMirrorSupported = FALSE; - - pDevicePrivateData->FWInfo.nOpcodeGetVersion = OPCODE_V017_GET_VERSION; - pDevicePrivateData->FWInfo.nOpcodeKeepAlive = OPCODE_V017_KEEP_ALIVE; - pDevicePrivateData->FWInfo.nOpcodeGetParam = OPCODE_V017_GET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeSetParam = OPCODE_V017_SET_PARAM; - pDevicePrivateData->FWInfo.nOpcodeGetFixedParams = OPCODE_V017_GET_FIXED_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeGetMode = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeSetMode = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams = OPCODE_V017_ALGORITM_PARAMS; - pDevicePrivateData->FWInfo.nOpcodeReset = OPCODE_V017_RESET; - pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking = OPCODE_INVALID; - pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking = OPCODE_INVALID; + } - break; - default: - return (XN_STATUS_IO_DEVICE_WRONG_VERSION); + if (CompareVersion(nMajor, nMinor, nBuild, 5, 6, 2) >= 0) + { + // add QQVGA depth modes + XnCmosPreset aQQmodes[] = + { + { XN_IO_DEPTH_FORMAT_COMPRESSED_PS, XN_RESOLUTION_QQVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT, XN_RESOLUTION_QQVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT, XN_RESOLUTION_QQVGA, 30 }, + { XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT, XN_RESOLUTION_QQVGA, 30 }, + }; + nRetVal = pDevicePrivateData->FWInfo.depthModes.AddLast(aQQmodes, sizeof(aQQmodes)/sizeof(aQQmodes[0])); + XN_IS_STATUS_OK(nRetVal); + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 6, 9) >= 0) + { + pDevicePrivateData->FWInfo.bGetImageCmosTypeSupported = TRUE; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 7, 0) >= 0) + { + pDevicePrivateData->FWInfo.nOpcodeGetPlatformString = OPCODE_GET_PLATFORM_STRING; + } + + if (CompareVersion(nMajor, nMinor, nBuild, 5, 8, 0) >= 0) + { + xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "Sensor version %d.%d.%x is newer than latest known. Trying to use 5.7 protocol...", nMajor, nMinor, nBuild); } pDevicePrivateData->FWInfo.nCurrMode = XN_MODE_PS; + pDevicePrivateData->FWInfo.nFWVer = GetFWVersion(nMajor, nMinor, nBuild); return (XN_STATUS_OK); } -XnStatus XnHostProtocolInitHeader(XnDevicePrivateData* pDevicePrivateData, void* pBuffer, void* pDataBuf, XnUInt32 nSize, XnUInt16 nOpcode) +XnStatus XnHostProtocolInitHeader(const XnDevicePrivateData* pDevicePrivateData, void* pBuffer, XnUInt32 nSize, XnUInt16 nOpcode) { static XnUInt16 nId = 0; @@ -248,12 +514,12 @@ XnStatus XnHostProtocolInitHeader(XnDevicePrivateData* pDevicePrivateData, void* return (XN_STATUS_OK); } -XnStatus XnHostProtocolUSBSend(XnDevicePrivateData* pDevicePrivateData, - XnUChar* pBuffer, XnUInt16 nSize, XnUInt32& nRead, XnUInt32 nTimeOut, XnBool bForceBulk) +XnStatus XnHostProtocolUSBSend(const XnDevicePrivateData* pDevicePrivateData, + XnUChar* pBuffer, XnUInt16 nSize, XnUInt32 nTimeOut, XnBool bForceBulk) { - XnStatus nRetVal; + XnStatus nRetVal = XN_STATUS_OK; - XnUsbControlConnection* pCtrlConnection = &pDevicePrivateData->SensorHandle.ControlConnection; + const XnUsbControlConnection* pCtrlConnection = &pDevicePrivateData->SensorHandle.ControlConnection; XnUInt32 nCounter = XN_USB_HOST_PROTOCOL_SEND_RETRIES; while (nCounter-- != 0) @@ -274,19 +540,19 @@ XnStatus XnHostProtocolUSBSend(XnDevicePrivateData* pDevicePrivateData, return nRetVal; } -XnStatus XnHostProtocolUSBReceive(XnDevicePrivateData* pDevicePrivateData, +XnStatus XnHostProtocolUSBReceive(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt nSize, XnUInt32& nRead, XnUInt32 nTimeOut, XnBool bForceBulk, XnUInt32 nFailTimeout) { XnStatus nRetVal; XnUInt64 nMaxTime; XnUInt64 nCurrTime; - XnUsbControlConnection* pCtrlConnection = &pDevicePrivateData->SensorHandle.ControlConnection; + const XnUsbControlConnection* pCtrlConnection = &pDevicePrivateData->SensorHandle.ControlConnection; xnOSGetHighResTimeStamp(&nMaxTime); nMaxTime += (nTimeOut * 1000); - while (TRUE) + for (;;) { xnOSGetHighResTimeStamp(&nCurrTime); if (nCurrTime > nMaxTime) @@ -324,7 +590,7 @@ XnStatus XnHostProtocolUSBReceive(XnDevicePrivateData* pDevicePrivateData, return nRetVal; } -XnStatus ValidateReplyV26(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt16 nExpectedOpcode, XnUInt16 nRequestId, XnUInt16& nDataSize, XnUChar** pDataBuf) +XnStatus ValidateReplyV26(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt16 nExpectedOpcode, XnUInt16 nRequestId, XnUInt16& nDataSize, XnUChar** pDataBuf) { XnUInt16 nHeaderOffset = 0; XnHostProtocolHeaderV26* pHeader = (XnHostProtocolHeaderV26*)pBuffer; @@ -396,7 +662,7 @@ XnStatus ValidateReplyV26(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuf return XN_STATUS_OK; } -XnStatus ValidateReplyV25(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt16 nExpectedOpcode, XnUInt16 nRequestId, XnUInt16& nDataSize, XnUChar** pDataBuf) +XnStatus ValidateReplyV25(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt16 nExpectedOpcode, XnUInt16 nRequestId, XnUInt16& nDataSize, XnUChar** pDataBuf) { XnUInt16 nHeaderOffset = 0; XnHostProtocolHeaderV25* pHeader = (XnHostProtocolHeaderV25*)pBuffer; @@ -466,7 +732,7 @@ XnStatus ValidateReplyV25(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuf return XN_STATUS_OK; } -XnUInt32 XnHostProtocolGetTimeOut(XnDevicePrivateData* pDevicePrivateData, XnUInt16 nOpcode) +XnUInt32 XnHostProtocolGetTimeOut(const XnDevicePrivateData* pDevicePrivateData, XnUInt16 nOpcode) { if (nOpcode == pDevicePrivateData->FWInfo.nOpcodeKeepAlive) return XN_USB_HOST_PROTOCOL_TIMEOUT_KEEP_ALIVE; @@ -492,7 +758,7 @@ XnUInt32 XnHostProtocolGetSetParamRecvTimeOut(XnDevicePrivateData* pDevicePrivat return 0; } -XnStatus XnHostProtocolGetRequestID(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt16* pnRequestId) +XnStatus XnHostProtocolGetRequestID(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt16* pnRequestId) { XnUInt16 nRequestId; @@ -509,14 +775,14 @@ XnStatus XnHostProtocolGetRequestID(XnDevicePrivateData* pDevicePrivateData, XnU return XN_STATUS_OK; } -XnStatus XnHostProtocolReceiveReply(XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt16 nBufferSize, XnUInt32 nTimeOut, XnUInt16 nOpcode, XnUInt16 nRequestId, XnUInt32* pnReadBytes, XnUInt16* pnDataSize, XnUChar** ppRelevantBuffer, XnBool bForceBulk, XnUInt32 nRecvTimeout, XnUInt32 nFailTimeout) +XnStatus XnHostProtocolReceiveReply(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt32 nTimeOut, XnUInt16 nOpcode, XnUInt16 nRequestId, XnUInt32* pnReadBytes, XnUInt16* pnDataSize, XnUChar** ppRelevantBuffer, XnBool bForceBulk, XnUInt32 nRecvTimeout, XnUInt32 nFailTimeout) { XnStatus rc = XN_STATUS_OK; XnUInt64 nStartWaitingTime; xnOSGetTimeStamp(&nStartWaitingTime); - while (TRUE) // loop until timeout expires + for (;;) // loop until timeout expires { do // loop until right reply ID is received { @@ -567,7 +833,7 @@ XnStatus XnHostProtocolReceiveReply(XnDevicePrivateData* pDevicePrivateData, XnU return rc; } -XnStatus XnHostProtocolExecute(XnDevicePrivateData* pDevicePrivateData, +XnStatus XnHostProtocolExecute(const XnDevicePrivateData* pDevicePrivateData, XnUChar* pBuffer, XnUInt16 nSize, XnUInt16 nOpcode, XnUChar** ppRelevantBuffer, XnUInt16& nDataSize, XnUInt32 nRecvTimeout = 0) { @@ -602,7 +868,7 @@ XnStatus XnHostProtocolExecute(XnDevicePrivateData* pDevicePrivateData, xnOSSleep(pDevicePrivateData->FWInfo.nUSBDelayExecutePreSend); // Send request - rc = XnHostProtocolUSBSend(pDevicePrivateData, request, nSize, nRead, nTimeOut, bForceBulk); + rc = XnHostProtocolUSBSend(pDevicePrivateData, request, nSize, nTimeOut, bForceBulk); if (rc != XN_STATUS_OK) { xnOSUnLockMutex(pDevicePrivateData->hExecuteMutex); @@ -613,7 +879,7 @@ XnStatus XnHostProtocolExecute(XnDevicePrivateData* pDevicePrivateData, xnOSSleep(pDevicePrivateData->FWInfo.nUSBDelayExecutePostSend); // receive reply - rc = XnHostProtocolReceiveReply(pDevicePrivateData, pBuffer, nSize, nTimeOut, nOpcode, nRequestId, &nRead, &nDataSize, ppRelevantBuffer, bForceBulk, nRecvTimeout, nFailTimeout); + rc = XnHostProtocolReceiveReply(pDevicePrivateData, pBuffer, nTimeOut, nOpcode, nRequestId, &nRead, &nDataSize, ppRelevantBuffer, bForceBulk, nRecvTimeout, nFailTimeout); if (rc == XN_STATUS_DEVICE_PROTOCOL_NOT_READY || rc == XN_STATUS_OK) { @@ -665,34 +931,23 @@ XnStatus XnHostProtocolExecute(XnDevicePrivateData* pDevicePrivateData, } -XnStatus XnHostProtocolGetVersion(XnDevicePrivateData* pDevicePrivateData, XnVersions& Version) +XnStatus XnHostProtocolGetVersion(const XnDevicePrivateData* pDevicePrivateData, XnVersions& Version) { XnUChar buffer[MAX_PACKET_SIZE] = {0}; - XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; XnUInt16 nDataSize; XnVersions *pVersion = NULL; xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Getting hardware versions..."); - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_1); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, 0, pDevicePrivateData->FWInfo.nOpcodeGetVersion); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeGetVersion); XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize, pDevicePrivateData->FWInfo.nOpcodeGetVersion, (XnUChar**)(&pVersion), nDataSize); if (rc != XN_STATUS_OK) { - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_1_1); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, 0, pDevicePrivateData->FWInfo.nOpcodeGetVersion); - rc = XnHostProtocolExecute(pDevicePrivateData, - buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize, pDevicePrivateData->FWInfo.nOpcodeGetVersion, - (XnUChar**)(&pVersion), nDataSize); - - if (rc != XN_STATUS_OK) - { - xnLogError(XN_MASK_SENSOR_PROTOCOL, "Get version failed: %s", xnGetStatusString(rc)); + xnLogError(XN_MASK_SENSOR_PROTOCOL, "Get version failed: %s", xnGetStatusString(rc)); - return rc; - } + return rc; } xnOSMemCopy(&Version, pVersion, sizeof(XnVersions)); @@ -704,125 +959,127 @@ XnStatus XnHostProtocolGetVersion(XnDevicePrivateData* pDevicePrivateData, XnVer *((XnUInt16*)&Version) = xnOSEndianSwapUINT16(*((XnUInt16*)pVersion)); - if (Version.nMajor > 5 || (Version.nMajor == 5 && Version.nMinor > 3)) - { - xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "Sensor version %d.%d is newer than latest known. Trying to use 5.3 protocol...", Version.nMajor, Version.nMinor); - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_3); - } - else if (Version.nMajor == 5 && Version.nMinor == 3) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_3); - else if (Version.nMajor == 5 && Version.nMinor == 2) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_2); - else if (Version.nMajor == 5 && Version.nMinor == 1) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_1); - else if (Version.nMajor == 5 && Version.nMinor == 0) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_5_0); - else if (Version.nMajor >= 4) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_4_0); - else if (Version.nMajor == 3 && Version.nMinor == 0) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_3_0); - else if (Version.nMajor == 1 && Version.nMinor == 2) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_1_2); - else if (Version.nMajor == 1 && Version.nMinor == 1) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_1_1); - else if (Version.nMajor == 0) - XnHostProtocolInitFWParams(pDevicePrivateData, XN_SENSOR_FW_VER_0_17); + if (Version.nMajor >= 5) + { + XnChar cpBuffer[XN_MAX_OS_NAME_LENGTH]; + sprintf(cpBuffer, "%x", Version.nBuild); + Version.nBuild = (XnUInt16)atoi(cpBuffer); + } Version.SDK.nMajor = XN_PS_MAJOR_VERSION; Version.SDK.nMinor = XN_PS_MINOR_VERSION; Version.SDK.nMaintenance = XN_PS_MAINTENANCE_VERSION; Version.SDK.nBuild = XN_PS_BUILD_VERSION; + // find out hardware version (for pre-RD boards) if (Version.nFPGA == XN_FPGA_VER_FPDB_26) { - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_FPDB_10; + Version.HWVer = XN_SENSOR_HW_VER_FPDB_10; } else if (Version.nFPGA == XN_FPGA_VER_FPDB_25) { - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_FPDB_10; + Version.HWVer = XN_SENSOR_HW_VER_FPDB_10; + } + else if (Version.nFPGA == XN_FPGA_VER_CDB) + { + Version.HWVer = XN_SENSOR_HW_VER_CDB_10; } else if (Version.nFPGA == XN_FPGA_VER_CDB) { - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_CDB_10; + Version.HWVer = XN_SENSOR_HW_VER_CDB_10; + } + else if (Version.nFPGA == XN_FPGA_VER_RD3) + { + Version.HWVer = XN_SENSOR_HW_VER_RD_3; } + else if (Version.nFPGA == XN_FPGA_VER_RD5) + { + Version.HWVer = XN_SENSOR_HW_VER_RD_5; + } + else if (Version.nFPGA == XN_FPGA_VER_RD1081) + { + Version.HWVer = XN_SENSOR_HW_VER_RD1081; + } + else if (Version.nFPGA == XN_FPGA_VER_RD1082) + { + Version.HWVer = XN_SENSOR_HW_VER_RD1082; + } else { - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_UNKNOWN; + Version.HWVer = XN_SENSOR_HW_VER_UNKNOWN; } + // find out chip version if (Version.nChip == XN_CHIP_VER_PS1000) { - pDevicePrivateData->ChipInfo.nChipVer = XN_SENSOR_CHIP_VER_PS1000; + Version.ChipVer = XN_SENSOR_CHIP_VER_PS1000; } else if (Version.nChip == XN_CHIP_VER_PS1080) { - pDevicePrivateData->ChipInfo.nChipVer = XN_SENSOR_CHIP_VER_PS1080; + Version.ChipVer = XN_SENSOR_CHIP_VER_PS1080; } + else if (Version.nChip == XN_CHIP_VER_PS1080A6) + { + Version.ChipVer = XN_SENSOR_CHIP_VER_PS1080A6; + } else { - pDevicePrivateData->ChipInfo.nChipVer = XN_SENSOR_CHIP_VER_UNKNOWN; + Version.ChipVer = XN_SENSOR_CHIP_VER_UNKNOWN; } - if (pDevicePrivateData->FWInfo.nFWVer == XN_SENSOR_FW_VER_4_0) + // find out sensor version + Version.SensorVer = XN_SENSOR_VER_UNKNOWN; + + Version.FWVer = GetFWVersion(Version.nMajor, Version.nMinor, Version.nBuild); + + if (Version.FWVer == XN_SENSOR_FW_VER_5_0) { - pDevicePrivateData->SensorInfo.nSensorVer = XN_SENSOR_VER_4_0; + Version.HWVer = XN_SENSOR_HW_VER_RD_5; } - else if (pDevicePrivateData->FWInfo.nFWVer == XN_SENSOR_FW_VER_3_0) + else if (Version.FWVer == XN_SENSOR_FW_VER_5_1) { - pDevicePrivateData->SensorInfo.nSensorVer = XN_SENSOR_VER_3_0; - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_RD_3; + Version.HWVer = XN_SENSOR_HW_VER_RD_5; } - else if (pDevicePrivateData->FWInfo.nFWVer == XN_SENSOR_FW_VER_5_0 || pDevicePrivateData->FWInfo.nFWVer == XN_SENSOR_FW_VER_5_1) + else if (Version.FWVer == XN_SENSOR_FW_VER_5_2) { - pDevicePrivateData->SensorInfo.nSensorVer = XN_SENSOR_VER_5_0; - pDevicePrivateData->HWInfo.nHWVer = XN_SENSOR_HW_VER_RD_5; + Version.HWVer = XN_SENSOR_HW_VER_RD_5; } - else + else if (Version.FWVer == XN_SENSOR_FW_VER_5_3) { - pDevicePrivateData->SensorInfo.nSensorVer = XN_SENSOR_VER_2_0; + Version.HWVer = XN_SENSOR_HW_VER_RD1081; } - - Version.FWVer = pDevicePrivateData->FWInfo.nFWVer; - Version.HWVer = pDevicePrivateData->HWInfo.nHWVer; - Version.SensorVer = pDevicePrivateData->SensorInfo.nSensorVer; - Version.ChipVer = pDevicePrivateData->ChipInfo.nChipVer; - - if (Version.nMajor >= 5) + else if (Version.FWVer == XN_SENSOR_FW_VER_5_4) { - XnChar cpBuffer[XN_MAX_OS_NAME_LENGTH]; - sprintf(cpBuffer, "%x", Version.nBuild); - Version.nBuild = atoi(cpBuffer); + Version.HWVer = XN_SENSOR_HW_VER_RD1082; } - - if ((Version.nMajor >= 5) && (Version.nMinor >= 3) && (Version.nBuild >= 16)) + else if (Version.FWVer == XN_SENSOR_FW_VER_5_5) { - pDevicePrivateData->FWInfo.nUSBDelayReceive = 1; - pDevicePrivateData->FWInfo.nUSBDelayExecutePreSend = 0; - pDevicePrivateData->FWInfo.nUSBDelayExecutePostSend = 0; - pDevicePrivateData->FWInfo.nUSBDelaySoftReset = 1; - pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 1; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream0Mode = 1; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream1Mode = 1; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream2Mode = 1; + Version.HWVer = XN_SENSOR_HW_VER_RD1082; } - else + else if (Version.FWVer == XN_SENSOR_FW_VER_5_6) { - pDevicePrivateData->FWInfo.nUSBDelayReceive = 100; - pDevicePrivateData->FWInfo.nUSBDelayExecutePreSend = 1; - pDevicePrivateData->FWInfo.nUSBDelayExecutePostSend = 10; - pDevicePrivateData->FWInfo.nUSBDelaySoftReset = 800; - pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 3000; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream0Mode = 1; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream1Mode = 300; - pDevicePrivateData->FWInfo.nUSBDelaySetParamStream2Mode = 1; - - if ((Version.nMajor == 5) && (Version.nMinor == 3) && (Version.nBuild == 15)) + if (CompareVersion(Version.nMajor, Version.nMinor, Version.nBuild, 5, 6, 6) >= 0) + { + if (Version.nFPGA == 0) + { + Version.HWVer = XN_SENSOR_HW_VER_RD1081; + } + else if (Version.nFPGA == 1) + { + Version.HWVer = XN_SENSOR_HW_VER_RD1082; + } + } + else { - pDevicePrivateData->FWInfo.nUSBDelaySetParamFlicker = 300; - } + Version.HWVer = XN_SENSOR_HW_VER_RD1082; + } } - xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Hardware versions: FW=%d.%d.%d (%d) HW=%d Chip=%d Sensor=%d SYS=%d", Version.nMajor, Version.nMinor, Version.nBuild, Version.FWVer, Version.HWVer, Version.ChipVer, Version.SensorVer, Version.nSystemVersion); + xnLogInfo(XN_MASK_SENSOR_PROTOCOL, + "Hardware versions: FW=%d.%d.%d (%d) HW=%d Chip=%d Sensor=%d SYS=%d", + Version.nMajor, Version.nMinor, Version.nBuild, + Version.FWVer, Version.HWVer, Version.ChipVer, + Version.SensorVer, Version.nSystemVersion); return XN_STATUS_OK; } @@ -830,11 +1087,10 @@ XnStatus XnHostProtocolGetVersion(XnDevicePrivateData* pDevicePrivateData, XnVer XnStatus XnHostProtocolKeepAlive(XnDevicePrivateData* pDevicePrivateData) { XnUChar buffer[MAX_PACKET_SIZE] = {0}; - XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Requesting KeepAlive..."); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, 0, pDevicePrivateData->FWInfo.nOpcodeKeepAlive); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeKeepAlive); XnUInt16 nDataSize; @@ -850,6 +1106,52 @@ XnStatus XnHostProtocolKeepAlive(XnDevicePrivateData* pDevicePrivateData) return rc; } +XnStatus XnHostProtocolReadAHB(XnDevicePrivateData* pDevicePrivateData, XnUInt32 nAddress, XnUInt32 &nValue) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + *(XnUInt32*)pDataBuf = XN_PREPARE_VAR32_IN_BUFFER(nAddress); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt32), pDevicePrivateData->FWInfo.nOpcodeReadAHB); + + XnUInt16 nDataSize; + XnUInt32* pValue = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt32), pDevicePrivateData->FWInfo.nOpcodeReadAHB, + (XnUChar**)(&pValue), nDataSize); + if (rc != XN_STATUS_OK) + { + return rc; + } + + nValue = XN_PREPARE_VAR32_IN_BUFFER(*pValue); + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolWriteAHB(XnDevicePrivateData* pDevicePrivateData, XnUInt32 nAddress, XnUInt32 nValue, + XnUInt32 nMask) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Write AHB: 0x%08x 0x%08x 0x%08x", nAddress, nValue, nMask); + + *(XnUInt32*)pDataBuf = XN_PREPARE_VAR32_IN_BUFFER(nAddress); + *(((XnUInt32*)pDataBuf)+1) = XN_PREPARE_VAR32_IN_BUFFER(nValue); + *(((XnUInt32*)pDataBuf)+2) = XN_PREPARE_VAR32_IN_BUFFER(nMask); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt32)*3, pDevicePrivateData->FWInfo.nOpcodeWriteAHB); + + XnUInt16 nDataSize; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt32)*3, pDevicePrivateData->FWInfo.nOpcodeWriteAHB, + NULL, nDataSize); + return rc; +} XnStatus XnHostProtocolGetParam(XnDevicePrivateData* pDevicePrivateData, XnUInt16 nParam, XnUInt16& nValue) { @@ -860,7 +1162,7 @@ XnStatus XnHostProtocolGetParam(XnDevicePrivateData* pDevicePrivateData, XnUInt1 *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(nParam); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetParam); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetParam); XnUInt16 nDataSize; XnUInt16* pValue = NULL; @@ -890,7 +1192,7 @@ XnStatus XnHostProtocolSetParam(XnDevicePrivateData* pDevicePrivateData, XnUInt1 *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(nParam); *(((XnUInt16*)pDataBuf)+1) = XN_PREPARE_VAR16_IN_BUFFER(nValue); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16)*2, pDevicePrivateData->FWInfo.nOpcodeSetParam); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16)*2, pDevicePrivateData->FWInfo.nOpcodeSetParam); XnUInt16 nDataSize; @@ -975,7 +1277,7 @@ XnStatus XnHostProtocolGetFixedParams(XnDevicePrivateData* pDevicePrivateData, X while (nDataRead < nFixedParamSize) { *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(XnUInt16(nDataRead/sizeof(XnUInt32))); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetFixedParams); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetFixedParams); XnUInt16 nDataSize; @@ -998,7 +1300,7 @@ XnStatus XnHostProtocolGetFixedParams(XnDevicePrivateData* pDevicePrivateData, X xnOSMemCopy(pData + nDataRead, pRelevantBuffer, nReadNow); - nDataRead += nReadNow; + nDataRead += (XnUInt16)nReadNow; } for (XnUInt32 i = 0; i < nFixedParamSize/sizeof(XnUInt32); i ++) @@ -1030,9 +1332,8 @@ XnStatus XnHostProtocolGetFixedParams(XnDevicePrivateData* pDevicePrivateData, X XnStatus XnHostProtocolGetMode(XnDevicePrivateData* pDevicePrivateData, XnUInt16& nMode) { XnUChar buffer[MAX_PACKET_SIZE] = {0}; - XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, 0, pDevicePrivateData->FWInfo.nOpcodeGetMode); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeGetMode); XnUInt16 nDataSize; XnUInt16* pMode = NULL; @@ -1062,7 +1363,7 @@ XnStatus XnHostProtocolReset(XnDevicePrivateData* pDevicePrivateData, XnUInt16 n *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(nResetType); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeReset); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeReset); XnUInt16 nDataSize; @@ -1121,11 +1422,11 @@ XnStatus XnHostProtocolSetMode(XnDevicePrivateData* pDevicePrivateData, XnUInt16 xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Setting mode to %d...", nMode); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeSetMode); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeSetMode); XnUInt16 nDataSize; - XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + XnHostProtocolExecute(pDevicePrivateData, buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeSetMode, NULL, nDataSize); @@ -1133,6 +1434,182 @@ XnStatus XnHostProtocolSetMode(XnDevicePrivateData* pDevicePrivateData, XnUInt16 return XN_STATUS_OK; } +XnStatus XnHostProtocolGetCMOSRegister(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, + XnUInt16& nValue) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)nCMOS); + *(((XnUInt16*)pDataBuf)+1) = XN_PREPARE_VAR16_IN_BUFFER(nAddress); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16)*2, pDevicePrivateData->FWInfo.nOpcodeGetCMOSReg); + + XnUInt16 nDataSize; + XnUInt16* pValue = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt16)*2, + pDevicePrivateData->FWInfo.nOpcodeGetCMOSReg, (XnUChar**)(&pValue), nDataSize); + if (rc != XN_STATUS_OK) + { + return rc; + } + + nValue = XN_PREPARE_VAR16_IN_BUFFER(*pValue); + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolSetCMOSRegister(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, + XnUInt16 nValue) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)nCMOS); + *(((XnUInt16*)pDataBuf)+1) = XN_PREPARE_VAR16_IN_BUFFER(nAddress); + *(((XnUInt16*)pDataBuf)+2) = XN_PREPARE_VAR16_IN_BUFFER(nValue); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16)*3, pDevicePrivateData->FWInfo.nOpcodeSetCMOSReg); + + XnUInt16 nDataSize; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt16)*3, + pDevicePrivateData->FWInfo.nOpcodeSetCMOSReg, NULL, nDataSize); + + return rc; +} + +XnStatus XnHostProtocolReadI2C(XnDevicePrivateData* pDevicePrivateData, XnI2CReadData* pI2CReadData) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(pI2CReadData->nBus); + *(((XnUInt16*)pDataBuf)+1) = XN_PREPARE_VAR16_IN_BUFFER(pI2CReadData->nSlaveAddress); + *(((XnUInt16*)pDataBuf)+2) = XN_PREPARE_VAR16_IN_BUFFER(pI2CReadData->nReadSize); + for (int i = 0; i < pI2CReadData->nWriteSize; i++) + *((XnUInt16*)pDataBuf+3+i) = XN_PREPARE_VAR16_IN_BUFFER(pI2CReadData->cpWriteBuffer[i]); + + XnUInt16 nOpSize = sizeof(XnUInt16)*3 + (pI2CReadData->nWriteSize * sizeof(XnUInt16)); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, nOpSize, pDevicePrivateData->FWInfo.nOpcodeReadI2C); + + XnUInt16 nDataSize; + XnUInt16* pValue = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+nOpSize, + pDevicePrivateData->FWInfo.nOpcodeReadI2C, (XnUChar**)(&pValue), nDataSize); + + if (rc != XN_STATUS_OK) + { + return rc; + } + + for (int i = 0; i < nDataSize; i++) + pI2CReadData->cpReadBuffer[i] = XN_PREPARE_VAR16_IN_BUFFER(*(pValue+i)); + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolWriteI2C(XnDevicePrivateData* pDevicePrivateData, const XnI2CWriteData* pI2CWriteData) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER(pI2CWriteData->nBus); + *(((XnUInt16*)pDataBuf)+1) = XN_PREPARE_VAR16_IN_BUFFER(pI2CWriteData->nSlaveAddress); + for (int i = 0; i < pI2CWriteData->nWriteSize; i++) + *((XnUInt16*)pDataBuf+2+i) = XN_PREPARE_VAR16_IN_BUFFER(pI2CWriteData->cpWriteBuffer[i]); + + XnUInt16 nOpSize = sizeof(XnUInt16)*2 + (pI2CWriteData->nWriteSize * sizeof(XnUInt16)); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, nOpSize, pDevicePrivateData->FWInfo.nOpcodeWriteI2C); + + XnUInt16 nDataSize; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+nOpSize, + pDevicePrivateData->FWInfo.nOpcodeWriteI2C, NULL, nDataSize); + if (rc != XN_STATUS_OK) + { + return rc; + } + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolGetCMOSRegisterI2C(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, + XnUInt16& nValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + XnI2CReadData I2CReadData; + + nValue = 0; + I2CReadData.cpReadBuffer[0] = 0; + I2CReadData.cpReadBuffer[1] = 0; + + I2CReadData.nReadSize = XN_PREPARE_VAR16_IN_BUFFER(2); + I2CReadData.nWriteSize = XN_PREPARE_VAR16_IN_BUFFER(1); + I2CReadData.cpWriteBuffer[0]=XN_PREPARE_VAR16_IN_BUFFER(nAddress); + + if (nCMOS == XN_CMOS_TYPE_IMAGE) + { + I2CReadData.nBus = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetImageCmosI2CBus()); + I2CReadData.nSlaveAddress = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetImageCmosI2CSlaveAddress()); + } + else if (nCMOS == XN_CMOS_TYPE_DEPTH) + { + I2CReadData.nBus = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetDepthCmosI2CBus()); + I2CReadData.nSlaveAddress = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetDepthCmosI2CSlaveAddress()); + } + else + { + return (XN_STATUS_ERROR); + } + + nRetVal = XnHostProtocolReadI2C(pDevicePrivateData, &I2CReadData); + XN_IS_STATUS_OK(nRetVal); + + nValue = XN_PREPARE_VAR16_IN_BUFFER((I2CReadData.cpReadBuffer[0] << 8) + I2CReadData.cpReadBuffer[1]); + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolSetCMOSRegisterI2C(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, + XnUInt16 nValue) + +{ + XnStatus nRetVal = XN_STATUS_OK; + XnI2CWriteData I2CWriteData; + + I2CWriteData.cpWriteBuffer[0] = XN_PREPARE_VAR16_IN_BUFFER(nAddress); + I2CWriteData.cpWriteBuffer[1] = XN_PREPARE_VAR16_IN_BUFFER((nValue >> 8) & 0xff); + I2CWriteData.cpWriteBuffer[2] = XN_PREPARE_VAR16_IN_BUFFER(nValue & 0xff); + I2CWriteData.nWriteSize = XN_PREPARE_VAR16_IN_BUFFER(3); + + if (nCMOS == XN_CMOS_TYPE_IMAGE) + { + I2CWriteData.nBus = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetImageCmosI2CBus()); + I2CWriteData.nSlaveAddress = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetImageCmosI2CSlaveAddress()); + } + else if (nCMOS == XN_CMOS_TYPE_DEPTH) + { + I2CWriteData.nBus = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetDepthCmosI2CBus()); + I2CWriteData.nSlaveAddress = XN_PREPARE_VAR16_IN_BUFFER(pDevicePrivateData->pSensor->GetFixedParams()->GetDepthCmosI2CSlaveAddress()); + } + else + { + return (XN_STATUS_ERROR); + } + + nRetVal = XnHostProtocolWriteI2C(pDevicePrivateData, &I2CWriteData); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + #pragma pack (push, 1) typedef struct XnAlgorithmParamRequest @@ -1166,6 +1643,15 @@ XnStatus XnHostProtocolAlgorithmParams(XnDevicePrivateData* pDevicePrivateData, XnInt16 nDataRead = 0; XnUInt16 nRequestSize = 0; + if (eAlgorithmType == XN_HOST_PROTOCOL_ALGORITHM_DEVICE_INFO && + !pDevicePrivateData->FWInfo.bDeviceInfoSupported) + { + XnDeviceInformation* pDeviceInfo = (XnDeviceInformation*)pAlgorithmInformation; + strcpy(pDeviceInfo->strDeviceName, "PrimeSense Sensor"); + strcpy(pDeviceInfo->strVendorData, ""); + return XN_STATUS_OK; + } + xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Getting algorithm params 0x%x for resolution %d and fps %d....", eAlgorithmType, nResolution, nFPS); XnStatus rc; @@ -1174,9 +1660,9 @@ XnStatus XnHostProtocolAlgorithmParams(XnDevicePrivateData* pDevicePrivateData, if (pDevicePrivateData->FWInfo.nFWVer >= XN_SENSOR_FW_VER_5_1) { XnAlgorithmParamRequest* pRequest = (XnAlgorithmParamRequest*)pDataBuf; - pRequest->nParamID = XN_PREPARE_VAR16_IN_BUFFER(eAlgorithmType); + pRequest->nParamID = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)eAlgorithmType); pRequest->nFormat = 0; - pRequest->nResolution = XN_PREPARE_VAR16_IN_BUFFER(nResolution); + pRequest->nResolution = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)nResolution); pRequest->nFPS = XN_PREPARE_VAR16_IN_BUFFER(nFPS); pRequest->nOffset = XN_PREPARE_VAR16_IN_BUFFER(nDataRead / sizeof(XnUInt16)); nRequestSize = sizeof(XnAlgorithmParamRequest); @@ -1184,15 +1670,15 @@ XnStatus XnHostProtocolAlgorithmParams(XnDevicePrivateData* pDevicePrivateData, else { XnAlgorithmParamRequestV4* pRequest = (XnAlgorithmParamRequestV4*)pDataBuf; - pRequest->nParamID = eAlgorithmType; + pRequest->nParamID = (XnUInt8)eAlgorithmType; pRequest->nFormat = 0; - pRequest->nResolution = nResolution; + pRequest->nResolution = (XnUInt8)nResolution; pRequest->nFPS = 0; pRequest->nOffset = XN_PREPARE_VAR16_IN_BUFFER(nDataRead / sizeof(XnUInt16)); nRequestSize = sizeof(XnAlgorithmParamRequestV4); } - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, nRequestSize, pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, nRequestSize, pDevicePrivateData->FWInfo.nOpcodeAlgorithmParams); XnUInt16 nDataSize; rc = XnHostProtocolExecute(pDevicePrivateData, @@ -1203,7 +1689,7 @@ XnStatus XnHostProtocolAlgorithmParams(XnDevicePrivateData* pDevicePrivateData, if (rc != XN_STATUS_OK) return rc; - XnUInt32 nReadNow = nDataSize*sizeof(XnUInt16); + XnUInt16 nReadNow = (XnUInt16)(nDataSize*sizeof(XnUInt16)); if (nReadNow == 0) { break; @@ -1260,7 +1746,7 @@ XnStatus XnHostProtocolSetAudioSampleRate(XnDevicePrivateData* pDevicePrivateDat return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } - return XnHostProtocolSetParam(pDevicePrivateData, PARAM_AUDIO_SAMPLE_RATE, nSample); + return XnHostProtocolSetParam(pDevicePrivateData, PARAM_AUDIO_SAMPLE_RATE, (XnUInt16)nSample); } XnStatus XnHostProtocolGetAudioSampleRate(XnDevicePrivateData* pDevicePrivateData, XnSampleRate* pSampleRate) @@ -1320,7 +1806,7 @@ XnStatus XnHostProtocolSetMultipleParams(XnDevicePrivateData* pDevicePrivateData *pCurData++ = XN_PREPARE_VAR16_IN_BUFFER(anParams[nIndex].nValue); } - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnUInt16)*nNumOfParams*2, pDevicePrivateData->FWInfo.nOpcodeSetParam); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16)*nNumOfParams*2, pDevicePrivateData->FWInfo.nOpcodeSetParam); XnUInt16 nDataSize; @@ -1369,7 +1855,7 @@ XnStatus XnHostProtocolSetIRCropping(XnDevicePrivateData* pDevicePrivateData, Xn } // commit - rc = XnHostProtocolSetParam(pDevicePrivateData, PARAM_IR_CROP_ENABLE, pCropping->bEnabled); + rc = XnHostProtocolSetParam(pDevicePrivateData, PARAM_IR_CROP_ENABLE, (XnUInt16)pCropping->bEnabled); return rc; } @@ -1461,7 +1947,7 @@ XnStatus XnHostProtocolSetCmosBlanking(XnDevicePrivateData* pDevicePrivateData, { XnVSyncRequest* pRequest = (XnVSyncRequest*)pDataBuf; pRequest->nUnits = XN_PREPARE_VAR16_IN_BUFFER(nUnits); - pRequest->nCmosID = XN_PREPARE_VAR16_IN_BUFFER(nCMOSID); + pRequest->nCmosID = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)nCMOSID); pRequest->nNumberOfFrames = XN_PREPARE_VAR16_IN_BUFFER(nNumberOfFrames); nRequestSize = sizeof(XnVSyncRequest); } @@ -1472,11 +1958,11 @@ XnStatus XnHostProtocolSetCmosBlanking(XnDevicePrivateData* pDevicePrivateData, xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Chaning CMOS %d Blanking to %hd (NumberOfFrames=%hu)...", nCMOSID, nUnits, nNumberOfFrames); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, nRequestSize, pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, nRequestSize, pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking); XnUInt16 nDataSize; XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, - buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize + nRequestSize, pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize + (XnUInt16)nRequestSize, pDevicePrivateData->FWInfo.nOpcodeSetCmosBlanking, NULL, nDataSize); if (rc != XN_STATUS_OK) @@ -1507,11 +1993,11 @@ XnStatus XnHostProtocolGetCmosBlanking(XnDevicePrivateData* pDevicePrivateData, XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; XnGetCmosBlankingRequest* pRequest = (XnGetCmosBlankingRequest*)pDataBuf; - pRequest->nCmosID = nCMOSID; + pRequest->nCmosID = (XnUInt16)nCMOSID; xnLogVerbose(XN_MASK_SENSOR_PROTOCOL, "Getting Cmos %d VBlanking...", nCMOSID); - XnHostProtocolInitHeader(pDevicePrivateData, buffer, pDataBuf, sizeof(XnGetCmosBlankingRequest), pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking); + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnGetCmosBlankingRequest), pDevicePrivateData->FWInfo.nOpcodeGetCmosBlanking); XnGetCmosBlankingReply* pReply; XnUInt16 nDataSize; @@ -1526,7 +2012,143 @@ XnStatus XnHostProtocolGetCmosBlanking(XnDevicePrivateData* pDevicePrivateData, xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Cmos %d VBlanking: %u", nCMOSID, pReply->nUnits); - *pnLines = pReply->nUnits; + *pnLines = (XnUInt16)pReply->nUnits; return (XN_STATUS_OK); } + +XnStatus XnHostProtocolGetCmosPresets(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOSID, XnCmosPreset* aPresets, XnUInt32& nCount) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Reading CMOS %d supported presets...", nCMOSID); + + *(XnUInt16*)pDataBuf = XN_PREPARE_VAR16_IN_BUFFER((XnUInt16)nCMOSID); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets); + + XnUInt16 nDataSize; + XnCmosPreset* pValue = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize+sizeof(XnUInt16), pDevicePrivateData->FWInfo.nOpcodeGetCmosPresets, + (XnUChar**)(&pValue), nDataSize); + if (rc != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_PROTOCOL, "Failed getting CMOS %d presets: %s", nCMOSID, xnGetStatusString(rc)); + return rc; + } + + XnUInt32 nReturnedCount = nDataSize * 2 / sizeof(XnCmosPreset); + if (nReturnedCount > nCount) + { + return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; + } + + XnCmosPreset* pValueEnd = pValue + nReturnedCount; + + nCount = 0; + + while (pValue < pValueEnd) + { + // workaround a FW bug - an extra preset arrives with FPS 0. Ignore it. + if (pValue->nFPS != 0) + { + aPresets[nCount].nFormat = XN_PREPARE_VAR16_IN_BUFFER(pValue->nFormat); + aPresets[nCount].nResolution = XN_PREPARE_VAR16_IN_BUFFER(pValue->nResolution); + aPresets[nCount].nFPS = XN_PREPARE_VAR16_IN_BUFFER(pValue->nFPS); + ++nCount; + } + + ++pValue; + } + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolGetSerialNumber (XnDevicePrivateData* pDevicePrivateData, XnChar* cpSerialNumber) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + + xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Reading sensor serial number..."); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber); + + XnUInt16 nDataSize; + XnUChar *serialNumberBuffer = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize, pDevicePrivateData->FWInfo.nOpcodeGetSerialNumber, + (XnUChar**)(&serialNumberBuffer), nDataSize); + if (rc != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_PROTOCOL, "Failed getting the sensor serial number: %s", xnGetStatusString(rc)); + return rc; + } + + serialNumberBuffer[nDataSize*2]=0; + + strcpy(cpSerialNumber, (XnChar*)serialNumberBuffer); + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolGetPlatformString(XnDevicePrivateData* pDevicePrivateData, XnChar* cpPlatformString) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + + cpPlatformString[0] = '\0'; + + if (pDevicePrivateData->FWInfo.nOpcodeGetPlatformString == OPCODE_INVALID) + { + // for FW that doesn't support this opcode, we just return an empty string + return XN_STATUS_OK; + } + + xnLogInfo(XN_MASK_SENSOR_PROTOCOL, "Reading sensor platform string..."); + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeGetPlatformString); + + XnUInt16 nDataSize; + XnChar *platformStringBuffer = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize, pDevicePrivateData->FWInfo.nOpcodeGetPlatformString, + (XnUChar**)(&platformStringBuffer), nDataSize); + if (rc != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_PROTOCOL, "Failed getting the sensor platform string: %s", xnGetStatusString(rc)); + return rc; + } + + XnUInt32 nBufferUsed = 0; + for (XnUInt32 i = 0; i < nDataSize*2; ++i) + { + cpPlatformString[nBufferUsed++] = platformStringBuffer[i*2]; + } + + cpPlatformString[nBufferUsed++] = '\0'; + + return XN_STATUS_OK; +} + +XnStatus XnHostProtocolGetUsbCoreType(XnDevicePrivateData* pDevicePrivateData, XnHostProtocolUsbCore& nValue) +{ + XnUChar buffer[MAX_PACKET_SIZE] = {0}; + XnUChar* pDataBuf = buffer + pDevicePrivateData->FWInfo.nProtocolHeaderSize; + + XnHostProtocolInitHeader(pDevicePrivateData, buffer, 0, pDevicePrivateData->FWInfo.nOpcodeGetUsbCore); + + XnUInt16 nDataSize; + XnUInt16* pValue = NULL; + + XnStatus rc = XnHostProtocolExecute(pDevicePrivateData, + buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize, pDevicePrivateData->FWInfo.nOpcodeGetUsbCore, + (XnUChar**)(&pValue), nDataSize); + XN_IS_STATUS_OK(rc); + + nValue = (XnHostProtocolUsbCore)XN_PREPARE_VAR16_IN_BUFFER(*pValue); + + return XN_STATUS_OK; +} diff --git a/Source/XnDeviceSensorV2/XnHostProtocol.h b/Source/XnDeviceSensorV2/XnHostProtocol.h index 8c1497a..ca3843a 100644 --- a/Source/XnDeviceSensorV2/XnHostProtocol.h +++ b/Source/XnDeviceSensorV2/XnHostProtocol.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef HOST_PROTOCOL_H #define HOST_PROTOCOL_H @@ -41,9 +35,14 @@ #define XN_FPGA_VER_FPDB_26 0x21 #define XN_FPGA_VER_FPDB_25 0x0 #define XN_FPGA_VER_CDB 0x1 +#define XN_FPGA_VER_RD3 0x2 +#define XN_FPGA_VER_RD5 0x3 +#define XN_FPGA_VER_RD1081 0x4 +#define XN_FPGA_VER_RD1082 0x5 #define XN_CHIP_VER_PS1000 0x00101010 #define XN_CHIP_VER_PS1080 0x00202020 +#define XN_CHIP_VER_PS1080A6 0x00212020 enum EPsProtocolOpCodes { @@ -54,34 +53,21 @@ enum EPsProtocolOpCodes OPCODE_GET_FIXED_PARAMS = 4, OPCODE_GET_MODE = 5, OPCODE_SET_MODE = 6, + OPCODE_I2C_WRITE = 10, + OPCODE_I2C_READ = 11, + OPCODE_READ_AHB = 20, + OPCODE_WRITE_AHB = 21, OPCODE_ALGORITM_PARAMS = 22, OPCODE_SET_CMOS_BLANKING = 34, OPCODE_GET_CMOS_BLANKING = 35, + OPCODE_GET_CMOS_PRESETS = 36, + OPCODE_GET_SERIAL_NUMBER = 37, + OPCODE_GET_FAST_CONVERGENCE_TEC = 38, + OPCODE_GET_PLATFORM_STRING = 39, + OPCODE_GET_USB_CORE_TYPE = 40, + OPCODE_KILL = 999, }; -enum EPsProtocolOpCodes_V400 -{ - OPCODE_V400_GET_VERSION = 0, - OPCODE_V400_KEEP_ALIVE = 1, - OPCODE_V400_GET_PARAM = 2, - OPCODE_V400_SET_PARAM = 3, - OPCODE_V400_GET_FIXED_PARAMS = 4, - OPCODE_V400_GET_MODE = 5, - OPCODE_V400_SET_MODE = 6, - OPCODE_V400_ALGORITM_PARAMS = 22, -}; - -enum EPsProtocolOpCodes_V300 -{ - OPCODE_V300_GET_VERSION = 0, - OPCODE_V300_KEEP_ALIVE = 1, - OPCODE_V300_GET_PARAM = 2, - OPCODE_V300_SET_PARAM = 3, - OPCODE_V300_GET_FIXED_PARAMS = 4, - OPCODE_V300_GET_MODE = 5, - OPCODE_V300_SET_MODE = 6, - OPCODE_V300_ALGORITM_PARAMS = 22, -}; enum XnHostProtocolOpcodes_V110 { @@ -92,6 +78,10 @@ enum XnHostProtocolOpcodes_V110 OPCODE_V110_GET_FIXED_PARAMS = 4, OPCODE_V110_GET_MODE = 5, OPCODE_V110_SET_MODE = 6, + OPCODE_V110_GET_CMOS_REGISTER = 8, + OPCODE_V110_SET_CMOS_REGISTER = 9, + OPCODE_V110_READ_AHB = 20, + OPCODE_V110_WRITE_AHB = 21, OPCODE_V110_ALGORITHM_PARAMS = 22, }; @@ -103,6 +93,10 @@ enum EPsProtocolOpCodes_V017 OPCODE_V017_SET_PARAM = 3, OPCODE_V017_GET_FIXED_PARAMS = 4, OPCODE_V017_RESET = 5, + OPCODE_V017_GET_CMOS_REGISTER = 7, + OPCODE_V017_SET_CMOS_REGISTER = 8, + OPCODE_V017_READ_AHB = 19, + OPCODE_V017_WRITE_AHB = 20, OPCODE_V017_ALGORITM_PARAMS = 21, }; @@ -111,9 +105,11 @@ enum EPsProtocolOpCodes_V017 typedef enum { XN_HOST_PROTOCOL_ALGORITHM_DEPTH_INFO = 0x00, - XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION = 0x02, - XN_HOST_PROTOCOL_ALGORITHM_PADDING = 0x03, + // --avin mod-- + XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION = 0x40, + XN_HOST_PROTOCOL_ALGORITHM_PADDING = 0x41, XN_HOST_PROTOCOL_ALGORITHM_BLANKING = 0x06, + XN_HOST_PROTOCOL_ALGORITHM_DEVICE_INFO = 0x07, XN_HOST_PROTOCOL_ALGORITHM_FREQUENCY = 0x80 } XnHostProtocolAlgorithmType; @@ -159,6 +155,12 @@ typedef enum A2D_NUM_OF_SAMPLE_RATES } EA2d_SampleRate; +typedef enum XnHostProtocolUsbCore +{ + XN_USB_CORE_JANGO = 0, + XN_USB_CORE_GADGETFS = 1, +} XnHostProtocolUsbCore; + #pragma pack(push,1) typedef struct { @@ -190,8 +192,10 @@ typedef struct // All implemented protocol commands // Init +XnStatus XnHostProtocolInitFWParams(XnDevicePrivateData* pDevicePrivateData, XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nBuild, XnHostProtocolUsbCore usb); + XnStatus XnHostProtocolKeepAlive (XnDevicePrivateData* pDevicePrivateData); -XnStatus XnHostProtocolGetVersion (XnDevicePrivateData* pDevicePrivateData, XnVersions& Version); +XnStatus XnHostProtocolGetVersion (const XnDevicePrivateData* pDevicePrivateData, XnVersions& Version); XnStatus XnHostProtocolAlgorithmParams (XnDevicePrivateData* pDevicePrivateData, XnHostProtocolAlgorithmType eAlgorithmType, void* pAlgorithmInformation, XnUInt16 nAlgInfoSize, XnResolutions nResolution, XnUInt16 nFPS); @@ -218,5 +222,18 @@ XnStatus XnHostProtocolGetDepthAGCBin(XnDevicePrivateData* pDevicePrivateData, X XnStatus XnHostProtocolSetCmosBlanking (XnDevicePrivateData* pDevicePrivateData, XnUInt16 nLines, XnCMOSType nCMOSID, XnUInt16 nNumberOfFrames); XnStatus XnHostProtocolGetCmosBlanking (XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOSID, XnUInt16* pnLines); +XnStatus XnHostProtocolGetCmosPresets (XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOSID, XnCmosPreset* aPresets, XnUInt32& nCount); + +XnStatus XnHostProtocolGetSerialNumber (XnDevicePrivateData* pDevicePrivateData, XnChar* cpSerialNumber); +XnStatus XnHostProtocolGetPlatformString(XnDevicePrivateData* pDevicePrivateData, XnChar* cpPlatformString); + +XnStatus XnHostProtocolGetCMOSRegister(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, XnUInt16& nValue); +XnStatus XnHostProtocolSetCMOSRegister (XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, XnUInt16 nValue); +XnStatus XnHostProtocolGetCMOSRegisterI2C(XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, XnUInt16& nValue); +XnStatus XnHostProtocolSetCMOSRegisterI2C (XnDevicePrivateData* pDevicePrivateData, XnCMOSType nCMOS, XnUInt16 nAddress, XnUInt16 nValue); +XnStatus XnHostProtocolReadAHB (XnDevicePrivateData* pDevicePrivateData, XnUInt32 nAddress, XnUInt32 &nValue); +XnStatus XnHostProtocolWriteAHB (XnDevicePrivateData* pDevicePrivateData, XnUInt32 nAddress, XnUInt32 nValue, XnUInt32 nMask); +XnStatus XnHostProtocolGetUsbCoreType (XnDevicePrivateData* pDevicePrivateData, XnHostProtocolUsbCore& nValue); + #endif diff --git a/Source/XnDeviceSensorV2/XnIRProcessor.cpp b/Source/XnDeviceSensorV2/XnIRProcessor.cpp index 6170b9a..f7766e7 100644 --- a/Source/XnDeviceSensorV2/XnIRProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnIRProcessor.cpp @@ -1,35 +1,30 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnIRProcessor.h" #include +#include "XnSensor.h" //--------------------------------------------------------------------------- // Defines @@ -44,8 +39,9 @@ // Code //--------------------------------------------------------------------------- -XnIRProcessor::XnIRProcessor(XnSensorIRStream* pStream, XnSensorStreamHelper* pHelper) : - XnFrameStreamProcessor(pStream, pHelper, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_START, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END) +XnIRProcessor::XnIRProcessor(XnSensorIRStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnFrameStreamProcessor(pStream, pHelper, pBufferManager, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_START, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END), + m_nRefTimestamp(0) { } @@ -134,12 +130,12 @@ XnStatus XnIRProcessor::Unpack10to16(const XnUInt8* pcInput, const XnUInt32 nInp pcInput++; } - *pnActualRead = pcInput - pOrigInput; + *pnActualRead = (XnUInt32)(pcInput - pOrigInput); *pnOutputSize = nNeededOutput; return XN_STATUS_OK; } -void XnIRProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnIRProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnIRProcessor::ProcessFramePacketChunk") @@ -202,7 +198,7 @@ void IRto888(XnUInt16* pInput, XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* while (pInput != pInputEnd && pOutput < pOutputEnd) { - *pOutput = (*pInput)>>2; + *pOutput = (XnUInt8)((*pInput)>>2); *(pOutput+1) = *pOutput; *(pOutput+2) = *pOutput; @@ -210,7 +206,7 @@ void IRto888(XnUInt16* pInput, XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pInput++; } - *pnOutputSize = pOutput - pOutputOrig; + *pnOutputSize = (XnUInt32)(pOutput - pOutputOrig); } XnUInt32 XnIRProcessor::CalculateExpectedSize() @@ -271,3 +267,30 @@ void XnIRProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) XN_PROFILING_END_SECTION } + +XnUInt64 XnIRProcessor::CreateTimestampFromDevice(XnUInt32 nDeviceTimeStamp) +{ + XnUInt64 nNow; + xnOSGetHighResTimeStamp(&nNow); + + // There's a firmware bug, causing IR timestamps not to advance if depth stream is off. + // If so, we need to create our own timestamps. + if (m_pDevicePrivateData->pSensor->GetFirmware()->GetParams()->m_Stream1Mode.GetValue() != XN_VIDEO_STREAM_DEPTH) + { + if (m_nRefTimestamp == 0) + { + m_nRefTimestamp = nNow; + } + + return nNow - m_nRefTimestamp; + } + else + { + XnUInt64 nResult = XnFrameStreamProcessor::CreateTimestampFromDevice(nDeviceTimeStamp); + + // keep it as ref so that if depth is turned off, we'll continue from there + m_nRefTimestamp = nNow - nResult; + + return nResult; + } +} \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnIRProcessor.h b/Source/XnDeviceSensorV2/XnIRProcessor.h index 3df8f59..19deb5f 100644 --- a/Source/XnDeviceSensorV2/XnIRProcessor.h +++ b/Source/XnDeviceSensorV2/XnIRProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IR_PROCESSOR_H__ #define __XN_IR_PROCESSOR_H__ @@ -40,7 +35,7 @@ class XnIRProcessor : public XnFrameStreamProcessor { public: - XnIRProcessor(XnSensorIRStream* pStream, XnSensorStreamHelper* pHelper); + XnIRProcessor(XnSensorIRStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); virtual ~XnIRProcessor(); XnStatus Init(); @@ -51,6 +46,7 @@ class XnIRProcessor : public XnFrameStreamProcessor //--------------------------------------------------------------------------- virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); virtual void OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader); + virtual XnUInt64 CreateTimestampFromDevice(XnUInt32 nDeviceTimeStamp); //--------------------------------------------------------------------------- // Internal Functions @@ -70,6 +66,7 @@ class XnIRProcessor : public XnFrameStreamProcessor /* A buffer to store bytes till we have enough to unpack. */ XnBuffer m_ContinuousBuffer; XnBuffer m_UnpackedBuffer; + XnUInt64 m_nRefTimestamp; // needed for firmware bug workaround }; #endif //__XN_IR_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnImageProcessor.cpp b/Source/XnDeviceSensorV2/XnImageProcessor.cpp index 536fe0f..2fcd5e9 100644 --- a/Source/XnDeviceSensorV2/XnImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -36,8 +30,9 @@ // Code //--------------------------------------------------------------------------- -XnImageProcessor::XnImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnFrameStreamProcessor(pStream, pHelper, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_START, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END) +XnImageProcessor::XnImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager, XnBool bCompressedOutput /* = FALSE */) : + XnFrameStreamProcessor(pStream, pHelper, pBufferManager, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_START, XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END), + m_bCompressedOutput(bCompressedOutput) { } @@ -58,19 +53,19 @@ XnStatus XnImageProcessor::Init() nRetVal = XnFrameStreamProcessor::Init(); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->XResProperty().OnChangeEvent().Register(ActualResChangedCallback, this, &m_hXResCallback); + nRetVal = GetStream()->XResProperty().OnChangeEvent().Register(ActualResChangedCallback, this, m_hXResCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->YResProperty().OnChangeEvent().Register(ActualResChangedCallback, this, &m_hYResCallback); + nRetVal = GetStream()->YResProperty().OnChangeEvent().Register(ActualResChangedCallback, this, m_hYResCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->m_FirmwareCropSizeX.OnChangeEvent().Register(ActualResChangedCallback, this, &m_hXCropCallback); + nRetVal = GetStream()->m_FirmwareCropSizeX.OnChangeEvent().Register(ActualResChangedCallback, this, m_hXCropCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->m_FirmwareCropSizeY.OnChangeEvent().Register(ActualResChangedCallback, this, &m_hYCropCallback); + nRetVal = GetStream()->m_FirmwareCropSizeY.OnChangeEvent().Register(ActualResChangedCallback, this, m_hYCropCallback); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetStream()->m_FirmwareCropEnabled.OnChangeEvent().Register(ActualResChangedCallback, this, &m_hCropEnabledCallback); + nRetVal = GetStream()->m_FirmwareCropEnabled.OnChangeEvent().Register(ActualResChangedCallback, this, m_hCropEnabledCallback); XN_IS_STATUS_OK(nRetVal); CalcActualRes(); @@ -95,11 +90,15 @@ XnUInt32 XnImageProcessor::CalculateExpectedSize() void XnImageProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) { - XnUInt32 nExpectedSize = CalculateExpectedSize(); - if (GetWriteBuffer()->GetSize() != nExpectedSize) + if (!m_bCompressedOutput) { - xnLogWarning(XN_MASK_SENSOR_READ, "Read: Image buffer is corrupt. Size is %u (!= %u)", GetWriteBuffer()->GetSize(), nExpectedSize); - FrameIsCorrupted(); + // make sure data size is right + XnUInt32 nExpectedSize = CalculateExpectedSize(); + if (GetWriteBuffer()->GetSize() != nExpectedSize) + { + xnLogWarning(XN_MASK_SENSOR_READ, "Read: Image buffer is corrupt. Size is %u (!= %u)", GetWriteBuffer()->GetSize(), nExpectedSize); + FrameIsCorrupted(); + } } // call base @@ -127,7 +126,7 @@ void XnImageProcessor::CalcActualRes() } } -XnStatus XnImageProcessor::ActualResChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XnImageProcessor::ActualResChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnImageProcessor* pThis = (XnImageProcessor*)pCookie; pThis->CalcActualRes(); diff --git a/Source/XnDeviceSensorV2/XnImageProcessor.h b/Source/XnDeviceSensorV2/XnImageProcessor.h index 7d6c32e..cf1345d 100644 --- a/Source/XnDeviceSensorV2/XnImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_IMAGE_PROCESSOR_H__ #define __XN_IMAGE_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnImageProcessor : public XnFrameStreamProcessor { public: - XnImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager, XnBool bCompressedOutput = FALSE); virtual ~XnImageProcessor(); XnStatus Init(); @@ -75,6 +70,8 @@ class XnImageProcessor : public XnFrameStreamProcessor XnCallbackHandle m_hXCropCallback; XnCallbackHandle m_hYCropCallback; XnCallbackHandle m_hCropEnabledCallback; + + XnBool m_bCompressedOutput; }; #endif //__XN_IMAGE_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnJpegImageProcessor.cpp b/Source/XnDeviceSensorV2/XnJpegImageProcessor.cpp index 3d9b91b..523ad34 100644 --- a/Source/XnDeviceSensorV2/XnJpegImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnJpegImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -35,80 +29,29 @@ // Code //--------------------------------------------------------------------------- -XnJpegImageProcessor::XnJpegImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnJpegImageProcessor::XnJpegImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager, TRUE) { + SetAllowDoubleSOFPackets(TRUE); } XnJpegImageProcessor::~XnJpegImageProcessor() { - XnStreamFreeUncompressImageJ(&m_JPEGContext); -} - -XnStatus XnJpegImageProcessor::Init() -{ - XnStatus nRetVal = XN_STATUS_OK; - - nRetVal = XnImageProcessor::Init(); - XN_IS_STATUS_OK(nRetVal); - - XN_VALIDATE_BUFFER_ALLOCATE(m_RawData, GetExpectedOutputSize()); - - nRetVal = XnStreamInitUncompressImageJ(&m_JPEGContext); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -void XnJpegImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) -{ - XN_PROFILING_START_SECTION("XnJpegImageProcessor::ProcessFramePacketChunk") - - // append to raw buffer - if (m_RawData.GetFreeSpaceInBuffer() < nDataSize) - { - xnLogWarning(XN_MASK_SENSOR_PROTOCOL_IMAGE, "Bad overflow image! %d", m_RawData.GetSize()); - FrameIsCorrupted(); - m_RawData.Reset(); - } - else - { - m_RawData.UnsafeWrite(pData, nDataSize); - } - - XN_PROFILING_END_SECTION -} - -void XnJpegImageProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader) -{ - XnImageProcessor::OnStartOfFrame(pHeader); - m_RawData.Reset(); } -void XnJpegImageProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) +void XnJpegImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { - XN_PROFILING_START_SECTION("XnJpegImageProcessor::OnEndOfFrame") + XN_PROFILING_START_SECTION("XnJpegImageProcessor::ProcessFramePacketChunk"); + // when image is uncompressed, we can just copy it directly to write buffer XnBuffer* pWriteBuffer = GetWriteBuffer(); - XnUInt32 nOutputSize = pWriteBuffer->GetMaxSize(); - XnStatus nRetVal = XnStreamUncompressImageJ(&m_JPEGContext, m_RawData.GetData(), m_RawData.GetSize(), pWriteBuffer->GetUnsafeWritePointer(), &nOutputSize); - if (nRetVal != XN_STATUS_OK) + // make sure we have enough room + if (CheckWriteBufferForOverflow(nDataSize)) { - xnLogWarning(XN_MASK_SENSOR_PROTOCOL_IMAGE, "Failed to uncompress JPEG for frame %d: %s (%d)\n", GetCurrentFrameID(), xnGetStatusString(nRetVal), pWriteBuffer->GetSize()); - FrameIsCorrupted(); - - XnDump badImageDump = XN_DUMP_CLOSED; - xnDumpInit(&badImageDump, XN_DUMP_BAD_IMAGE, NULL, "BadImage_%d.jpeg", GetCurrentFrameID()); - xnDumpWriteBuffer(badImageDump, m_RawData.GetData(), m_RawData.GetSize()); - xnDumpClose(&badImageDump); + pWriteBuffer->UnsafeWrite(pData, nDataSize); } - pWriteBuffer->UnsafeUpdateSize(nOutputSize); - - m_RawData.Reset(); - XnImageProcessor::OnEndOfFrame(pHeader); - - XN_PROFILING_END_SECTION + XN_PROFILING_END_SECTION; } diff --git a/Source/XnDeviceSensorV2/XnJpegImageProcessor.h b/Source/XnDeviceSensorV2/XnJpegImageProcessor.h index b01356c..300acc4 100644 --- a/Source/XnDeviceSensorV2/XnJpegImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnJpegImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_JPEG_IMAGE_PROCESSOR_H__ #define __XN_JPEG_IMAGE_PROCESSOR_H__ @@ -40,25 +35,11 @@ class XnJpegImageProcessor : public XnImageProcessor { public: - XnJpegImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnJpegImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnJpegImageProcessor(); - XnStatus Init(); - - //--------------------------------------------------------------------------- - // Overridden Functions - //--------------------------------------------------------------------------- protected: virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); - virtual void OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader); - virtual void OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader); - - //--------------------------------------------------------------------------- - // Class Members - //--------------------------------------------------------------------------- -private: - XnBuffer m_RawData; - XnStreamUncompJPEGContext m_JPEGContext; }; -#endif +#endif // __XN_JPEG_IMAGE_PROCESSOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.cpp b/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.cpp new file mode 100644 index 0000000..2d50e9d --- /dev/null +++ b/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnJpegToRGBImageProcessor.h" +#include + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- + +XnJpegToRGBImageProcessor::XnJpegToRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) +{ + SetAllowDoubleSOFPackets(TRUE); +} + +XnJpegToRGBImageProcessor::~XnJpegToRGBImageProcessor() +{ + XnStreamFreeUncompressImageJ(&m_JPEGContext); +} + +XnStatus XnJpegToRGBImageProcessor::Init() +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnImageProcessor::Init(); + XN_IS_STATUS_OK(nRetVal); + + XN_VALIDATE_BUFFER_ALLOCATE(m_RawData, GetExpectedOutputSize()); + + nRetVal = XnStreamInitUncompressImageJ(&m_JPEGContext); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +void XnJpegToRGBImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) +{ + XN_PROFILING_START_SECTION("XnJpegToRGBImageProcessor::ProcessFramePacketChunk") + + // append to raw buffer + if (m_RawData.GetFreeSpaceInBuffer() < nDataSize) + { + xnLogWarning(XN_MASK_SENSOR_PROTOCOL_IMAGE, "Bad overflow image! %d", m_RawData.GetSize()); + FrameIsCorrupted(); + m_RawData.Reset(); + } + else + { + m_RawData.UnsafeWrite(pData, nDataSize); + } + + XN_PROFILING_END_SECTION +} + +void XnJpegToRGBImageProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader) +{ + XnImageProcessor::OnStartOfFrame(pHeader); + m_RawData.Reset(); +} + +void XnJpegToRGBImageProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) +{ + XN_PROFILING_START_SECTION("XnJpegToRGBImageProcessor::OnEndOfFrame") + +// xnOSSaveFile("c:\\temp\\fromSensor.jpeg", m_RawData.GetData(), m_RawData.GetSize()); + + XnBuffer* pWriteBuffer = GetWriteBuffer(); + + XnUInt32 nOutputSize = pWriteBuffer->GetMaxSize(); + XnStatus nRetVal = XnStreamUncompressImageJ(&m_JPEGContext, m_RawData.GetData(), m_RawData.GetSize(), pWriteBuffer->GetUnsafeWritePointer(), &nOutputSize); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_PROTOCOL_IMAGE, "Failed to uncompress JPEG for frame %d: %s (%d)\n", GetCurrentFrameID(), xnGetStatusString(nRetVal), pWriteBuffer->GetSize()); + FrameIsCorrupted(); + + XnDumpFile* badImageDump = xnDumpFileOpen(XN_DUMP_BAD_IMAGE, "BadImage_%d.jpeg", GetCurrentFrameID()); + xnDumpFileWriteBuffer(badImageDump, m_RawData.GetData(), m_RawData.GetSize()); + xnDumpFileClose(badImageDump); + } + + pWriteBuffer->UnsafeUpdateSize(nOutputSize); + + m_RawData.Reset(); + XnImageProcessor::OnEndOfFrame(pHeader); + + XN_PROFILING_END_SECTION +} + diff --git a/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.h b/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.h new file mode 100644 index 0000000..a9b360e --- /dev/null +++ b/Source/XnDeviceSensorV2/XnJpegToRGBImageProcessor.h @@ -0,0 +1,59 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ +#define __XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnImageProcessor.h" +#include + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- + +class XnJpegToRGBImageProcessor : public XnImageProcessor +{ +public: + XnJpegToRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); + ~XnJpegToRGBImageProcessor(); + + XnStatus Init(); + + //--------------------------------------------------------------------------- + // Overridden Functions + //--------------------------------------------------------------------------- +protected: + virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); + virtual void OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader); + virtual void OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader); + + //--------------------------------------------------------------------------- + // Class Members + //--------------------------------------------------------------------------- +private: + XnBuffer m_RawData; + XnStreamUncompJPEGContext m_JPEGContext; +}; + +#endif //__XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.cpp b/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.cpp index 44e9f9b..f7cb40d 100644 --- a/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.cpp +++ b/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -48,7 +42,7 @@ XnStatus XnMultiPropChangedHandler::AddProperty(const XnChar* strName) XnStatus nRetVal = XN_STATUS_OK; XnCallbackHandle hCallback; - nRetVal = m_pNode->GetSensor()->RegisterToPropertyChange(m_strModule, strName, PropertyChangedCallback, this, &hCallback); + nRetVal = m_pNode->GetSensor()->RegisterToPropertyChange(m_strModule, strName, PropertyChangedCallback, this, hCallback); XN_IS_STATUS_OK(nRetVal); nRetVal = m_Registered.Set(strName, hCallback); @@ -80,13 +74,13 @@ XnStatus XnMultiPropChangedHandler::AddProperties(const XnChar** strNames) void XnMultiPropChangedHandler::Unregister() { - for (XnPropertyHandleHash::Iterator it = m_Registered.begin(); it != m_Registered.end(); ++it) + for (XnPropertyHandleHash::Iterator it = m_Registered.Begin(); it != m_Registered.End(); ++it) { - m_pNode->GetSensor()->UnregisterFromPropertyChange(m_strModule, it.Key(), it.Value()); + m_pNode->GetSensor()->UnregisterFromPropertyChange(m_strModule, it->Key(), it->Value()); } } -void XnMultiPropChangedHandler::PropertyChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie) +void XnMultiPropChangedHandler::PropertyChangedCallback(XnDeviceHandle /*pDeviceHandle*/, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie) { XnMultiPropChangedHandler* pThis = (XnMultiPropChangedHandler*)pCookie; pThis->OnModulePropertyChanged(ModuleName, PropertyName); @@ -101,7 +95,7 @@ XnMultiPropStateChangedHandler::XnMultiPropStateChangedHandler(XnSensorProductio m_pCookie(pCookie) {} -void XnMultiPropStateChangedHandler::OnModulePropertyChanged(const XnChar* strModule, const XnChar* strProperty) +void XnMultiPropStateChangedHandler::OnModulePropertyChanged(const XnChar* /*strModule*/, const XnChar* /*strProperty*/) { m_pHandler(m_pCookie); } diff --git a/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.h b/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.h index 2ce68b5..ecae7bf 100644 --- a/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.h +++ b/Source/XnDeviceSensorV2/XnMultiPropChangedHandler.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_MULTI_PROP_CHANGED_HANDLER_H__ #define __XN_MULTI_PROP_CHANGED_HANDLER_H__ @@ -32,7 +26,7 @@ // Includes //--------------------------------------------------------------------------- #include -#include +#include #include "XnSensorProductionNode.h" #include @@ -56,7 +50,7 @@ class XnMultiPropChangedHandler private: static void XN_CALLBACK_TYPE PropertyChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); - XN_DECLARE_STRINGS_HASH(XnCallbackHandle, XnPropertyHandleHash); + typedef XnStringsHashT XnPropertyHandleHash; XnPropertyHandleHash m_Registered; XnSensorProductionNode* m_pNode; diff --git a/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.cpp b/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.cpp index 1ed1ad0..442c7d3 100644 --- a/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -35,8 +29,8 @@ // Code //--------------------------------------------------------------------------- -XnPSCompressedDepthProcessor::XnPSCompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper) : - XnDepthProcessor(pStream, pHelper) +XnPSCompressedDepthProcessor::XnPSCompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnDepthProcessor(pStream, pHelper, pBufferManager) { } @@ -66,10 +60,12 @@ XnPSCompressedDepthProcessor::~XnPSCompressedDepthProcessor() z = XN_DEVICE_SENSOR_NO_DEPTH_VALUE; \ } -#define XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nValue) \ - XN_CHECK_UNC_DEPTH_OUTPUT(pOutput, pOutputEnd, nValue) \ - *pOutput = GetOutput(nValue); \ - ++pOutput; +#define XN_DEPTH_OUTPUT(pDepthOutput, pShiftOutput, pOutputEnd, nValue) \ + XN_CHECK_UNC_DEPTH_OUTPUT(pDepthOutput, pOutputEnd, nValue) \ + *pShiftOutput = (((nValue) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (nValue) : 0); \ + *pDepthOutput = GetOutput(nValue); \ + ++pShiftOutput; \ + ++pDepthOutput; #define INIT_INPUT(pInput, nInputSize) \ const XnUInt8* __pInputOrig = pInput; \ @@ -106,20 +102,20 @@ XnPSCompressedDepthProcessor::~XnPSCompressedDepthProcessor() /** Gets a pointer to n elements before current input */ #define GET_PREV_INPUT(n) __pCurrInput - n/2; -#define GET_INPUT_READ_BYTES __pCurrInput - __pInputOrig; +#define GET_INPUT_READ_BYTES (__pCurrInput - __pInputOrig); XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, const XnUInt32 nInputSize, - XnUInt16* pOutput, XnUInt32* pnOutputSize, + XnUInt16* pDepthOutput, XnUInt16* pShiftOutput, XnUInt32* pnOutputSize, XnUInt32* pnActualRead, XnBool bLastPart) { // Input is made of 4-bit elements. INIT_INPUT(pInput, nInputSize); - XnUInt16* pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16)); + XnUInt16* pOutputEnd = pDepthOutput + (*pnOutputSize / sizeof(XnDepthPixel)); XnUInt16 nLastValue = 0; const XnUInt8* pInputOrig = pInput; - XnUInt16* pOutputOrig = pOutput; + XnUInt16* pOutputOrig = pDepthOutput; const XnUInt8* pInputLastPossibleStop = pInputOrig; XnUInt16* pOutputLastPossibleStop = pOutputOrig; @@ -129,7 +125,7 @@ XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, XnUInt32 nLargeValue; XnBool bCanStop; - while (TRUE) + for (;;) { bCanStop = CAN_INPUT_STOP_HERE; GET_NEXT_INPUT(nInput); @@ -147,7 +143,7 @@ XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, nInput++; while (nInput != 0) { - XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue); + XN_DEPTH_OUTPUT(pDepthOutput, pShiftOutput, pOutputEnd, nLastValue); --nInput; } break; @@ -167,7 +163,7 @@ XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, nLargeValue |= nInput; // diff values are from -64 to 63 (0x00 to 0x7f) - nLastValue += nLargeValue - 64; + nLastValue += ((XnInt16)nLargeValue - 64); } else // Full value (15-bit) { @@ -175,7 +171,7 @@ XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, { // We can stop here. First input is a full value pInputLastPossibleStop = GET_PREV_INPUT(2); - pOutputLastPossibleStop = pOutput; + pOutputLastPossibleStop = pDepthOutput; } nLargeValue = (nInput << 12); @@ -188,28 +184,28 @@ XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, nLargeValue |= nInput << 4; GET_NEXT_INPUT(nInput); - nLastValue = (nLargeValue | nInput); + nLastValue = (XnUInt16)(nLargeValue | nInput); } - XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue); + XN_DEPTH_OUTPUT(pDepthOutput, pShiftOutput, pOutputEnd, nLastValue); break; default: // all rest (smaller than 0xd) are diffs // diff values are from -6 to 6 (0x0 to 0xc) - nLastValue += nInput - 6; - XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue); + nLastValue += ((XnInt16)nInput - 6); + XN_DEPTH_OUTPUT(pDepthOutput, pShiftOutput, pOutputEnd, nLastValue); } } if (bLastPart == TRUE) { - *pnOutputSize = (pOutput - pOutputOrig) * sizeof(XnUInt16); - *pnActualRead = GET_INPUT_READ_BYTES; + *pnOutputSize = (XnUInt32)(pDepthOutput - pOutputOrig) * sizeof(XnUInt16); + *pnActualRead = (XnUInt32)GET_INPUT_READ_BYTES; } else { - *pnOutputSize = (pOutputLastPossibleStop - pOutputOrig) * sizeof(XnUInt16); - *pnActualRead = (pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); + *pnOutputSize = (XnUInt32)(pOutputLastPossibleStop - pOutputOrig) * sizeof(XnUInt16); + *pnActualRead = (XnUInt32)(pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8); } // All is good... @@ -249,12 +245,12 @@ void XnPSCompressedDepthProcessor::ProcessFramePacketChunk(const XnSensorProtoco nBufSize = nDataSize; } - XnUInt32 nOutputSize = pWriteBuffer->GetFreeSpaceInBuffer(); + XnUInt32 nOutputSize = GetFreeSpaceInDepthBuffer(); XnUInt32 nWrittenOutput = nOutputSize; XnUInt32 nActualRead = 0; XnBool bLastPart = pHeader->nType == XN_SENSOR_PROTOCOL_RESPONSE_DEPTH_END && (nDataOffset + nDataSize) == pHeader->nBufSize; - XnStatus nRetVal = UncompressDepthPS(pBuf, nBufSize, (XnUInt16*)pWriteBuffer->GetUnsafeWritePointer(), - &nWrittenOutput, &nActualRead, bLastPart); + XnStatus nRetVal = UncompressDepthPS(pBuf, nBufSize, GetDepthOutputBuffer(), + GetShiftsOutputBuffer(), &nWrittenOutput, &nActualRead, bLastPart); if (nRetVal != XN_STATUS_OK) { diff --git a/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.h b/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.h index b1e162a..01bd39a 100644 --- a/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.h +++ b/Source/XnDeviceSensorV2/XnPSCompressedDepthProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PS_COMPRESSED_DEPTH_PROCESSOR_H__ #define __XN_PS_COMPRESSED_DEPTH_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnPSCompressedDepthProcessor : public XnDepthProcessor { public: - XnPSCompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper); + XnPSCompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); virtual ~XnPSCompressedDepthProcessor(); XnStatus Init(); @@ -56,7 +51,7 @@ class XnPSCompressedDepthProcessor : public XnDepthProcessor // Internal Functions //--------------------------------------------------------------------------- XnStatus UncompressDepthPS(const XnUInt8* pInput, const XnUInt32 nInputSize, - XnUInt16* pOutput, XnUInt32* pnOutputSize, + XnUInt16* pDepthOutput, XnUInt16* pShiftOutput, XnUInt32* pnOutputSize, XnUInt32* pnActualRead, XnBool bLastPart); private: diff --git a/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.cpp b/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.cpp index 912c615..262a4e6 100644 --- a/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,8 +31,8 @@ // Code //--------------------------------------------------------------------------- -XnPSCompressedImageProcessor::XnPSCompressedImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnPSCompressedImageProcessor::XnPSCompressedImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) { } @@ -110,7 +104,7 @@ void XnPSCompressedImageProcessor::ProcessFramePacketChunk(const XnSensorProtoco XnUInt32 nActualRead = 0; XnBool bLastPart = pHeader->nType == XN_SENSOR_PROTOCOL_RESPONSE_IMAGE_END && (nDataOffset + nDataSize) == pHeader->nBufSize; XnStatus nRetVal = XnStreamUncompressYUVImagePS(pBuf, nBufSize, pWriteBuffer->GetUnsafeWritePointer(), - &nWrittenOutput, GetActualXRes()*2, &nActualRead, bLastPart); + &nWrittenOutput, (XnUInt16)(GetActualXRes()*2), &nActualRead, bLastPart); if (nRetVal != XN_STATUS_OK) { diff --git a/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.h b/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.h index 7eb9293..e9a973e 100644 --- a/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnPSCompressedImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PS_COMPRESSED_IMAGE_PROCESSOR_H__ #define __XN_PS_COMPRESSED_IMAGE_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnPSCompressedImageProcessor : public XnImageProcessor { public: - XnPSCompressedImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnPSCompressedImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnPSCompressedImageProcessor(); XnStatus Init(); diff --git a/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.cpp b/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.cpp index 3f2f419..e760131 100644 --- a/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.cpp @@ -1,35 +1,32 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnPacked11DepthProcessor.h" #include +#ifdef XN_NEON +#include +#endif //--------------------------------------------------------------------------- // Defines @@ -61,8 +58,8 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnPacked11DepthProcessor::XnPacked11DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper) : - XnDepthProcessor(pStream, pHelper) +XnPacked11DepthProcessor::XnPacked11DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnDepthProcessor(pStream, pHelper, pBufferManager) { } @@ -92,12 +89,21 @@ XnStatus XnPacked11DepthProcessor::Unpack11to16(const XnUInt8* pcInput, const Xn *pnActualRead = 0; XnBuffer* pWriteBuffer = GetWriteBuffer(); - if (!CheckWriteBufferForOverflow(nNeededOutput)) + // Check there is enough room for the depth pixels + if (!CheckDepthBufferForOverflow(nNeededOutput)) { return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; } - XnUInt16* pnOutput = (XnUInt16*)pWriteBuffer->GetUnsafeWritePointer(); + XnUInt16* pShiftOut = GetShiftsOutputBuffer(); + XnUInt16* pnOutput = GetDepthOutputBuffer(); + + XnUInt16 a0,a1,a2,a3,a4,a5,a6,a7; +#ifdef XN_NEON + XnUInt16 shift[8]; + XnUInt16 depth[8]; + uint16x8_t Q0; +#endif // Convert the 11bit packed data into 16bit shorts for (XnUInt32 nElem = 0; nElem < nElements; ++nElem) @@ -108,33 +114,82 @@ XnStatus XnPacked11DepthProcessor::Unpack11to16(const XnUInt8* pcInput, const Xn // ---,---,-----,---,---,-----,---,--- // output: 0, 1, 2, 3, 4, 5, 6, 7 - pnOutput[0] = GetOutput((XN_TAKE_BITS(pcInput[0],8,0) << 3) | XN_TAKE_BITS(pcInput[1],3,5)); - pnOutput[1] = GetOutput((XN_TAKE_BITS(pcInput[1],5,0) << 6) | XN_TAKE_BITS(pcInput[2],6,2)); - pnOutput[2] = GetOutput((XN_TAKE_BITS(pcInput[2],2,0) << 9) | (XN_TAKE_BITS(pcInput[3],8,0) << 1) | XN_TAKE_BITS(pcInput[4],1,7)); - pnOutput[3] = GetOutput((XN_TAKE_BITS(pcInput[4],7,0) << 4) | XN_TAKE_BITS(pcInput[5],4,4)); - pnOutput[4] = GetOutput((XN_TAKE_BITS(pcInput[5],4,0) << 7) | XN_TAKE_BITS(pcInput[6],7,1)); - pnOutput[5] = GetOutput((XN_TAKE_BITS(pcInput[6],1,0) << 10) | (XN_TAKE_BITS(pcInput[7],8,0) << 2) | XN_TAKE_BITS(pcInput[8],2,6)); - pnOutput[6] = GetOutput((XN_TAKE_BITS(pcInput[8],6,0) << 5) | XN_TAKE_BITS(pcInput[9],5,3)); - pnOutput[7] = GetOutput((XN_TAKE_BITS(pcInput[9],3,0) << 8) | XN_TAKE_BITS(pcInput[10],8,0)); + a0 = (XN_TAKE_BITS(pcInput[0],8,0) << 3) | XN_TAKE_BITS(pcInput[1],3,5); + a1 = (XN_TAKE_BITS(pcInput[1],5,0) << 6) | XN_TAKE_BITS(pcInput[2],6,2); + a2 = (XN_TAKE_BITS(pcInput[2],2,0) << 9) | (XN_TAKE_BITS(pcInput[3],8,0) << 1) | XN_TAKE_BITS(pcInput[4],1,7); + a3 = (XN_TAKE_BITS(pcInput[4],7,0) << 4) | XN_TAKE_BITS(pcInput[5],4,4); + a4 = (XN_TAKE_BITS(pcInput[5],4,0) << 7) | XN_TAKE_BITS(pcInput[6],7,1); + a5 = (XN_TAKE_BITS(pcInput[6],1,0) << 10) | (XN_TAKE_BITS(pcInput[7],8,0) << 2) | XN_TAKE_BITS(pcInput[8],2,6); + a6 = (XN_TAKE_BITS(pcInput[8],6,0) << 5) | XN_TAKE_BITS(pcInput[9],5,3); + a7 = (XN_TAKE_BITS(pcInput[9],3,0) << 8) | XN_TAKE_BITS(pcInput[10],8,0); + + +#ifdef XN_NEON + shift[0] = (((a0) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a0) : 0); + shift[1] = (((a1) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a1) : 0); + shift[2] = (((a2) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a2) : 0); + shift[3] = (((a3) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a3) : 0); + shift[4] = (((a4) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a4) : 0); + shift[5] = (((a5) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a5) : 0); + shift[6] = (((a6) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a6) : 0); + shift[7] = (((a7) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a7) : 0); + + depth[0] = GetOutput(a0); + depth[1] = GetOutput(a1); + depth[2] = GetOutput(a2); + depth[3] = GetOutput(a3); + depth[4] = GetOutput(a4); + depth[5] = GetOutput(a5); + depth[6] = GetOutput(a6); + depth[7] = GetOutput(a7); + + // Load + Q0 = vld1q_u16(depth); + // Store + vst1q_u16(pnOutput, Q0); + + // Load + Q0 = vld1q_u16(shift); + // Store + vst1q_u16(pShiftOut, Q0); +#else + pShiftOut[0] = (((a0) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a0) : 0); + pShiftOut[1] = (((a1) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a1) : 0); + pShiftOut[2] = (((a2) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a2) : 0); + pShiftOut[3] = (((a3) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a3) : 0); + pShiftOut[4] = (((a4) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a4) : 0); + pShiftOut[5] = (((a5) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a5) : 0); + pShiftOut[6] = (((a6) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a6) : 0); + pShiftOut[7] = (((a7) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (a7) : 0); + + pnOutput[0] = GetOutput(a0); + pnOutput[1] = GetOutput(a1); + pnOutput[2] = GetOutput(a2); + pnOutput[3] = GetOutput(a3); + pnOutput[4] = GetOutput(a4); + pnOutput[5] = GetOutput(a5); + pnOutput[6] = GetOutput(a6); + pnOutput[7] = GetOutput(a7); + +#endif pcInput += XN_INPUT_ELEMENT_SIZE; pnOutput += 8; + pShiftOut += 8; } - *pnActualRead = pcInput - pOrigInput; + *pnActualRead = (XnUInt32)(pcInput - pOrigInput); pWriteBuffer->UnsafeUpdateSize(nNeededOutput); return XN_STATUS_OK; } -void XnPacked11DepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnPacked11DepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnPacked11DepthProcessor::ProcessFramePacketChunk") XnStatus nRetVal = XN_STATUS_OK; - XnBuffer* pWriteBuffer = GetWriteBuffer(); - // check if we have data from previous packet if (m_ContinuousBuffer.GetSize() != 0) { @@ -148,7 +203,6 @@ void XnPacked11DepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolRes { // process it XnUInt32 nActualRead = 0; - XnUInt32 nOutputSize = pWriteBuffer->GetFreeSpaceInBuffer(); Unpack11to16(m_ContinuousBuffer.GetData(), XN_INPUT_ELEMENT_SIZE, &nActualRead); m_ContinuousBuffer.Reset(); } diff --git a/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.h b/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.h index e7c634c..56b3102 100644 --- a/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.h +++ b/Source/XnDeviceSensorV2/XnPacked11DepthProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_PACKED_11_DEPTH_PROCESSOR_H__ #define __XN_PACKED_11_DEPTH_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnPacked11DepthProcessor : public XnDepthProcessor { public: - XnPacked11DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper); + XnPacked11DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); virtual ~XnPacked11DepthProcessor(); XnStatus Init(); diff --git a/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.cpp b/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.cpp new file mode 100644 index 0000000..9437063 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnPacked12DepthProcessor.h" +#include +#ifdef XN_NEON +#include +#endif + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +/* The size of an input element in the stream. */ +#define XN_INPUT_ELEMENT_SIZE 24 +/* The size of an output element in the stream. */ +#define XN_OUTPUT_ELEMENT_SIZE 32 + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/* Returns a set of bits. For example XN_ON_BITS(4) returns 0xF */ +#define XN_ON_BITS(count) ((1 << count)-1) + +/* Creates a mask of bits in offset */ +#define XN_CREATE_MASK(count, offset) (XN_ON_BITS(count) << offset) + +/* Takes the bits in offset from . +* For example: +* If we want 3 bits located in offset 2 from 0xF4: +* 11110100 +* --- +* we get 101, which is 0x5. +* and so, XN_TAKE_BITS(0xF4,3,2) == 0x5. +*/ +#define XN_TAKE_BITS(source, count, offset) ((source & XN_CREATE_MASK(count, offset)) >> offset) + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnPacked12DepthProcessor::XnPacked12DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnDepthProcessor(pStream, pHelper, pBufferManager) +{ +} + +XnStatus XnPacked12DepthProcessor::Init() +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnDepthProcessor::Init(); + XN_IS_STATUS_OK(nRetVal); + + XN_VALIDATE_BUFFER_ALLOCATE(m_ContinuousBuffer, XN_INPUT_ELEMENT_SIZE); + + return (XN_STATUS_OK); +} + +XnPacked12DepthProcessor::~XnPacked12DepthProcessor() +{ +} + +XnStatus XnPacked12DepthProcessor::Unpack12to16(const XnUInt8* pcInput, const XnUInt32 nInputSize, XnUInt32* pnActualRead) +{ + const XnUInt8* pOrigInput = pcInput; + + XnUInt32 nElements = nInputSize / XN_INPUT_ELEMENT_SIZE; // floored + XnUInt32 nNeededOutput = nElements * XN_OUTPUT_ELEMENT_SIZE; + + *pnActualRead = 0; + XnBuffer* pWriteBuffer = GetWriteBuffer(); + + if (!CheckDepthBufferForOverflow(nNeededOutput)) + { + return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; + } + + XnUInt16* pnOutput = GetDepthOutputBuffer(); + XnUInt16* pShiftOut = GetShiftsOutputBuffer(); + XnUInt16 shift[16]; +#ifdef XN_NEON + XnUInt16 depth[16]; + uint8x8x3_t inD3; + uint8x8_t rshft4D, lshft4D; + uint16x8_t rshft4Q, lshft4Q; + uint16x8_t depthQ; + uint16x8x2_t shiftQ2; +#endif + + // Convert the 11bit packed data into 16bit shorts + for (XnUInt32 nElem = 0; nElem < nElements; ++nElem) + { +#ifndef XN_NEON + // input: 0, 1,2,3, 4,5,6, 7,8,9, 10,11,12, 13,14,15, 16,17,18, 19,20,21, 22,23 + // -,---,-,-,---,-,-,---,-,-,---,--,--,---,--,--,---,--,--,---,--,--,---,-- + // bits: 8,4,4,8,8,4,4,8,8,4,4,8,8,4,4, 8, 8,4,4, 8, 8,4,4, 8, 8,4,4, 8, 8,4,4, 8 + // ---,---,---,---,---,---,---,----,----,----,----,----,----,----,----,---- + // output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + + shift[0] = (XN_TAKE_BITS(pcInput[0],8,0) << 4) | XN_TAKE_BITS(pcInput[1],4,4); + shift[1] = (XN_TAKE_BITS(pcInput[1],4,0) << 8) | XN_TAKE_BITS(pcInput[2],8,0); + shift[2] = (XN_TAKE_BITS(pcInput[3],8,0) << 4) | XN_TAKE_BITS(pcInput[4],4,4); + shift[3] = (XN_TAKE_BITS(pcInput[4],4,0) << 8) | XN_TAKE_BITS(pcInput[5],8,0); + shift[4] = (XN_TAKE_BITS(pcInput[6],8,0) << 4) | XN_TAKE_BITS(pcInput[7],4,4); + shift[5] = (XN_TAKE_BITS(pcInput[7],4,0) << 8) | XN_TAKE_BITS(pcInput[8],8,0); + shift[6] = (XN_TAKE_BITS(pcInput[9],8,0) << 4) | XN_TAKE_BITS(pcInput[10],4,4); + shift[7] = (XN_TAKE_BITS(pcInput[10],4,0) << 8) | XN_TAKE_BITS(pcInput[11],8,0); + shift[8] = (XN_TAKE_BITS(pcInput[12],8,0) << 4) | XN_TAKE_BITS(pcInput[13],4,4); + shift[9] = (XN_TAKE_BITS(pcInput[13],4,0) << 8) | XN_TAKE_BITS(pcInput[14],8,0); + shift[10] = (XN_TAKE_BITS(pcInput[15],8,0) << 4) | XN_TAKE_BITS(pcInput[16],4,4); + shift[11] = (XN_TAKE_BITS(pcInput[16],4,0) << 8) | XN_TAKE_BITS(pcInput[17],8,0); + shift[12] = (XN_TAKE_BITS(pcInput[18],8,0) << 4) | XN_TAKE_BITS(pcInput[19],4,4); + shift[13] = (XN_TAKE_BITS(pcInput[19],4,0) << 8) | XN_TAKE_BITS(pcInput[20],8,0); + shift[14] = (XN_TAKE_BITS(pcInput[21],8,0) << 4) | XN_TAKE_BITS(pcInput[22],4,4); + shift[15] = (XN_TAKE_BITS(pcInput[22],4,0) << 8) | XN_TAKE_BITS(pcInput[23],8,0); + + pShiftOut[0] = (((shift[0]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[0]) : 0); + pShiftOut[1] = (((shift[1]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[1]) : 0); + pShiftOut[2] = (((shift[2]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[2]) : 0); + pShiftOut[3] = (((shift[3]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[3]) : 0); + pShiftOut[4] = (((shift[4]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[4]) : 0); + pShiftOut[5] = (((shift[5]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[5]) : 0); + pShiftOut[6] = (((shift[6]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[6]) : 0); + pShiftOut[7] = (((shift[7]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[7]) : 0); + pShiftOut[8] = (((shift[0]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[8]) : 0); + pShiftOut[9] = (((shift[1]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[9]) : 0); + pShiftOut[10] = (((shift[2]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[10]) : 0); + pShiftOut[11] = (((shift[3]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[11]) : 0); + pShiftOut[12] = (((shift[4]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[12]) : 0); + pShiftOut[13] = (((shift[5]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[13]) : 0); + pShiftOut[14] = (((shift[6]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[14]) : 0); + pShiftOut[15] = (((shift[7]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[15]) : 0); + + pnOutput[0] = GetOutput(shift[0]); + pnOutput[1] = GetOutput(shift[1]); + pnOutput[2] = GetOutput(shift[2]); + pnOutput[3] = GetOutput(shift[3]); + pnOutput[4] = GetOutput(shift[4]); + pnOutput[5] = GetOutput(shift[5]); + pnOutput[6] = GetOutput(shift[6]); + pnOutput[7] = GetOutput(shift[7]); + pnOutput[8] = GetOutput(shift[8]); + pnOutput[9] = GetOutput(shift[9]); + pnOutput[10] = GetOutput(shift[10]); + pnOutput[11] = GetOutput(shift[11]); + pnOutput[12] = GetOutput(shift[12]); + pnOutput[13] = GetOutput(shift[13]); + pnOutput[14] = GetOutput(shift[14]); + pnOutput[15] = GetOutput(shift[15]); + +#else + // input: 0, 1,2 (X8) + // -,---,- + // bits: 8,4,4,8 (X8) + // ---,--- + // output: 0, 1 (X8) + + // Split 24 bytes into 3 vectors (64 bit each) + inD3 = vld3_u8(pcInput); + + // rshft4D0 contains 4 MSB of second vector (placed at offset 0) + rshft4D = vshr_n_u8(inD3.val[1], 4); + // lshft4D0 contains 4 LSB of second vector (placed at offset 4) + lshft4D = vshl_n_u8(inD3.val[1], 4); + + // Expand 64 bit vectors to 128 bit (8 values of 16 bits) + shiftQ2.val[0] = vmovl_u8(inD3.val[0]); + shiftQ2.val[1] = vmovl_u8(inD3.val[2]); + rshft4Q = vmovl_u8(rshft4D); + lshft4Q = vmovl_u8(lshft4D); + + // Even indexed shift = 8 bits from first vector + 4 MSB bits of second vector + shiftQ2.val[0] = vshlq_n_u16(shiftQ2.val[0], 4); + shiftQ2.val[0] = vorrq_u16(shiftQ2.val[0], rshft4Q); + + // Odd indexed shift = 4 LSB bits of second vector + 8 bits from third vector + lshft4Q = vshlq_n_u16(lshft4Q, 4); + shiftQ2.val[1] = vorrq_u16(shiftQ2.val[1], lshft4Q); + + // Interleave shift values to a single vector + vst2q_u16(shift, shiftQ2); + + shift[0] = (((shift[0]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[0]) : 0); + shift[1] = (((shift[1]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[1]) : 0); + shift[2] = (((shift[2]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[2]) : 0); + shift[3] = (((shift[3]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[3]) : 0); + shift[4] = (((shift[4]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[4]) : 0); + shift[5] = (((shift[5]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[5]) : 0); + shift[6] = (((shift[6]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[6]) : 0); + shift[7] = (((shift[7]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[7]) : 0); + shift[8] = (((shift[0]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[8]) : 0); + shift[9] = (((shift[1]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[9]) : 0); + shift[10] = (((shift[2]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[10]) : 0); + shift[11] = (((shift[3]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[11]) : 0); + shift[12] = (((shift[4]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[12]) : 0); + shift[13] = (((shift[5]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[13]) : 0); + shift[14] = (((shift[6]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[14]) : 0); + shift[15] = (((shift[7]) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (shift[15]) : 0); + + depth[0] = GetOutput(shift[0]); + depth[1] = GetOutput(shift[1]); + + depth[2] = GetOutput(shift[2]); + depth[3] = GetOutput(shift[3]); + + depth[4] = GetOutput(shift[4]); + depth[5] = GetOutput(shift[5]); + + depth[6] = GetOutput(shift[6]); + depth[7] = GetOutput(shift[7]); + + // Load + depthQ = vld1q_u16(depth); + //Store + vst1q_u16(pnOutput, depthQ); + + // Load + depthQ = vld1q_u16(shift); + // Store + vst1q_u16(pShiftOut, depthQ); + + depth[8] = GetOutput(shift[8]); + depth[9] = GetOutput(shift[9]); + + depth[10] = GetOutput(shift[10]); + depth[11] = GetOutput(shift[11]); + + depth[12] = GetOutput(shift[12]); + depth[13] = GetOutput(shift[13]); + + depth[14] = GetOutput(shift[14]); + depth[15] = GetOutput(shift[15]); + + // Load + depthQ = vld1q_u16(depth + 8); + // Store + vst1q_u16(pnOutput + 8, depthQ); + + // Load + depthQ = vld1q_u16(shift + 8); + // Store + vst1q_u16(pShiftOut + 8, depthQ); + +#endif + + pcInput += XN_INPUT_ELEMENT_SIZE; + pnOutput += 16; + pShiftOut += 16; + } + + + *pnActualRead = (XnUInt32)(pcInput - pOrigInput); + pWriteBuffer->UnsafeUpdateSize(nNeededOutput); + + return XN_STATUS_OK; +} + +void XnPacked12DepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) +{ + XN_PROFILING_START_SECTION("XnPacked12DepthProcessor::ProcessFramePacketChunk") + + XnStatus nRetVal = XN_STATUS_OK; + + // check if we have data from previous packet + if (m_ContinuousBuffer.GetSize() != 0) + { + // fill in to a whole element + XnUInt32 nReadBytes = XN_MIN(nDataSize, XN_INPUT_ELEMENT_SIZE - m_ContinuousBuffer.GetSize()); + m_ContinuousBuffer.UnsafeWrite(pData, nReadBytes); + pData += nReadBytes; + nDataSize -= nReadBytes; + + if (m_ContinuousBuffer.GetSize() == XN_INPUT_ELEMENT_SIZE) + { + // process it + XnUInt32 nActualRead = 0; + Unpack12to16(m_ContinuousBuffer.GetData(), XN_INPUT_ELEMENT_SIZE, &nActualRead); + m_ContinuousBuffer.Reset(); + } + } + + // find out the number of input elements we have + XnUInt32 nActualRead = 0; + nRetVal = Unpack12to16(pData, nDataSize, &nActualRead); + if (nRetVal == XN_STATUS_OK) + { + pData += nActualRead; + nDataSize -= nActualRead; + + // if we have any bytes left, store them for next packet. + if (nDataSize > 0) + { + // no need to check for overflow. there can not be a case in which more than XN_INPUT_ELEMENT_SIZE + // are left. + m_ContinuousBuffer.UnsafeWrite(pData, nDataSize); + } + } + + XN_PROFILING_END_SECTION +} + +void XnPacked12DepthProcessor::OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader) +{ + XnDepthProcessor::OnStartOfFrame(pHeader); + m_ContinuousBuffer.Reset(); +} + +void XnPacked12DepthProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader) +{ + XnDepthProcessor::OnEndOfFrame(pHeader); + m_ContinuousBuffer.Reset(); +} diff --git a/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.h b/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.h new file mode 100644 index 0000000..aa379f6 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnPacked12DepthProcessor.h @@ -0,0 +1,63 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_PACKED_12_DEPTH_PROCESSOR_H__ +#define __XN_PACKED_12_DEPTH_PROCESSOR_H__ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnDepthProcessor.h" + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- + +class XnPacked12DepthProcessor : public XnDepthProcessor +{ +public: + XnPacked12DepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); + virtual ~XnPacked12DepthProcessor(); + + XnStatus Init(); + +protected: + //--------------------------------------------------------------------------- + // Overridden Functions + //--------------------------------------------------------------------------- + virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); + virtual void OnStartOfFrame(const XnSensorProtocolResponseHeader* pHeader); + virtual void OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader); + + //--------------------------------------------------------------------------- + // Internal Functions + //--------------------------------------------------------------------------- + XnStatus Unpack12to16(const XnUInt8* pcInput, const XnUInt32 nInputSize, XnUInt32* pnActualRead); + + //--------------------------------------------------------------------------- + // Class Members + //--------------------------------------------------------------------------- +private: + /* A buffer used for storing some left-over bytes for the next packet. */ + XnBuffer m_ContinuousBuffer; +}; + +#endif //__XN_PACKED_12_DEPTH_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnParams.h b/Source/XnDeviceSensorV2/XnParams.h index 3352f38..222fcd3 100644 --- a/Source/XnDeviceSensorV2/XnParams.h +++ b/Source/XnDeviceSensorV2/XnParams.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef XN_PARAMS_H #define XN_PARAMS_H @@ -106,7 +100,14 @@ typedef enum PARAM_IMAGE_MIRROR = 71, PARAM_IR_MIRROR = 72, - + PARAM_IMAGE_SHARPNESS = 76, + PARAM_IMAGE_AUTO_WHITE_BALANCE_MODE = 77, + PARAM_IMAGE_COLOR_TEMPERATURE = 78, + PARAM_IMAGE_BACK_LIGHT_COMPENSATION = 79, + PARAM_IMAGE_AUTO_EXPOSURE_MODE = 80, + PARAM_IMAGE_EXPOSURE_BAR = 81, + PARAM_IMAGE_LOW_LIGHT_COMPENSATION_MODE = 82, + PARAM_DEPTH_CLOSE_RANGE = 84, } EConfig_Params; typedef enum XnExecuter diff --git a/Source/XnDeviceSensorV2/XnSensor.cpp b/Source/XnDeviceSensorV2/XnSensor.cpp index cdc4541..e73acca 100644 --- a/Source/XnDeviceSensorV2/XnSensor.cpp +++ b/Source/XnDeviceSensorV2/XnSensor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -45,7 +39,16 @@ #define XN_SENSOR_MAX_STREAM_COUNT 5 #define XN_SENSOR_FRAME_SYNC_MAX_DIFF 3 #define XN_SENSOR_DEFAULT_CLOSE_STREAMS_ON_SHUTDOWN TRUE -#define XN_GLOBAL_CONFIG_FILE_NAME "GlobalDefaults.ini" +#define XN_SENSOR_DEFAULT_HOST_TIMESTAMPS FALSE +// --avin mod-- +#define XN_GLOBAL_CONFIG_FILE_NAME "GlobalDefaultsKinect.ini" + +// on weak platforms (Arm), we prefer to use BULK +#if (XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM) + #define XN_SENSOR_DEFAULT_USB_INTERFACE XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS +#else + #define XN_SENSOR_DEFAULT_USB_INTERFACE XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS +#endif //--------------------------------------------------------------------------- // Types @@ -60,12 +63,12 @@ typedef struct XnWaitForSycnhedFrameData //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnSensor::XnSensor() : +XnSensor::XnSensor(XnBool bResetOnStartup /* = TRUE */, XnBool bLeanInit /* = FALSE */) : XnDeviceBase(XN_DEVICE_NAME, TRUE), m_ErrorState(XN_MODULE_PROPERTY_ERROR_STATE, XN_STATUS_OK), - m_ResetSensorOnStartup(XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP, TRUE), - m_Interface(XN_MODULE_PROPERTY_USB_INTERFACE, XN_SENSOR_USB_INTERFACE_DEFAULT), - m_NumberOfBuffers(XN_MODULE_PROPERTY_NUMBER_OF_BUFFERS, 6), + m_ResetSensorOnStartup(XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP, bResetOnStartup), + m_LeanInit(XN_MODULE_PROPERTY_LEAN_INIT, bLeanInit), + m_Interface(XN_MODULE_PROPERTY_USB_INTERFACE, bResetOnStartup ? XN_SENSOR_DEFAULT_USB_INTERFACE : XN_SENSOR_USB_INTERFACE_DEFAULT), m_ReadFromEP1(XN_MODULE_PROPERTY_READ_ENDPOINT_1, TRUE), m_ReadFromEP2(XN_MODULE_PROPERTY_READ_ENDPOINT_2, TRUE), m_ReadFromEP3(XN_MODULE_PROPERTY_READ_ENDPOINT_3, TRUE), @@ -79,16 +82,24 @@ XnSensor::XnSensor() : m_Version(XN_MODULE_PROPERTY_VERSION, &m_DevicePrivateData.Version, sizeof(m_DevicePrivateData.Version), NULL), m_FixedParam(XN_MODULE_PROPERTY_FIXED_PARAMS, NULL), m_CloseStreamsOnShutdown(XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN, XN_SENSOR_DEFAULT_CLOSE_STREAMS_ON_SHUTDOWN), + m_HostTimestamps(XN_MODULE_PROPERTY_HOST_TIMESTAMPS, XN_SENSOR_DEFAULT_HOST_TIMESTAMPS), m_ID(XN_MODULE_PROPERTY_ID), - m_pThis(this), - m_InstancePointer(XN_SENSOR_PROPERTY_INSTANCE_POINTER, &m_pThis, sizeof(m_pThis), NULL), + m_InstancePointer(XN_SENSOR_PROPERTY_INSTANCE_POINTER), + m_USBPath(XN_MODULE_PROPERTY_USB_PATH), + m_DeviceName(XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME), + m_VendorSpecificData(XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA), + m_PlatformString(XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING), + m_AudioSupported(XN_MODULE_PROPERTY_AUDIO_SUPPORTED), + m_ImageSupported(XN_MODULE_PROPERTY_IMAGE_SUPPORTED), + m_ImageControl(XN_MODULE_PROPERTY_IMAGE_CONTROL, NULL), + m_DepthControl(XN_MODULE_PROPERTY_DEPTH_CONTROL, NULL), + m_AHB(XN_MODULE_PROPERTY_AHB, NULL), m_Firmware(&m_DevicePrivateData), - m_FixedParams(&m_Firmware, &m_DevicePrivateData), m_SensorIO(&m_DevicePrivateData.SensorHandle), m_FPS(), m_CmosInfo(&m_Firmware, &m_DevicePrivateData), - m_Objects(&m_Firmware, &m_DevicePrivateData, &m_FixedParams, &m_FPS, &m_CmosInfo), - m_FrameSyncDump(XN_DUMP_CLOSED), + m_Objects(&m_Firmware, &m_DevicePrivateData, &m_FPS, &m_CmosInfo), + m_FrameSyncDump(NULL), m_bInitialized(FALSE) { // reset all data @@ -96,8 +107,8 @@ XnSensor::XnSensor() : m_strGlobalConfigFile[0] = '\0'; m_ResetSensorOnStartup.UpdateSetCallbackToDefault(); + m_LeanInit.UpdateSetCallbackToDefault(); m_Interface.UpdateSetCallback(SetInterfaceCallback, this); - m_NumberOfBuffers.UpdateSetCallback(SetNumberOfBuffersCallback, this); m_ReadFromEP1.UpdateSetCallback(SetReadEndpoint1Callback, this); m_ReadFromEP2.UpdateSetCallback(SetReadEndpoint2Callback, this); m_ReadFromEP3.UpdateSetCallback(SetReadEndpoint3Callback, this); @@ -114,6 +125,16 @@ XnSensor::XnSensor() : m_FirmwareMode.UpdateGetCallback(GetFirmwareModeCallback, this); m_FixedParam.UpdateGetCallback(GetFixedParamsCallback, this); m_CloseStreamsOnShutdown.UpdateSetCallbackToDefault(); + m_HostTimestamps.UpdateSetCallbackToDefault(); + m_AudioSupported.UpdateGetCallback(GetAudioSupportedCallback, this); + m_ImageSupported.UpdateGetCallback(GetImageSupportedCallback, this); + m_InstancePointer.UpdateGetCallback(GetInstanceCallback, this); + m_ImageControl.UpdateSetCallback(SetImageCmosRegisterCallback, this); + m_ImageControl.UpdateGetCallback(GetImageCmosRegisterCallback, this); + m_DepthControl.UpdateSetCallback(SetDepthCmosRegisterCallback, this); + m_DepthControl.UpdateGetCallback(GetDepthCmosRegisterCallback, this); + m_AHB.UpdateSetCallback(WriteAHBCallback, this); + m_AHB.UpdateGetCallback(ReadAHBCallback, this); } @@ -138,36 +159,11 @@ XnStatus XnSensor::GetDefinition(XnDeviceDefinition* pDeviceDefinition) XnStatus XnSensor::Enumerate(XnConnectionString* aConnectionStrings, XnUInt32* pnCount) { XnStatus nRetVal = XN_STATUS_OK; - XnUInt32 nNumSensors = 0; - XnUInt32 nSensorIndex = 0; - XnChar cpBoardID[16]; - XnDevicePrivateData DevicePrivateData; - XnVersions Versions; - XnChar* pCurrConnectionString; - XN_VALIDATE_INPUT_PTR(pnCount); - xnOSMemSet(&DevicePrivateData, 0, sizeof(DevicePrivateData)); - - nRetVal = XnSensorIO::GetNumOfSensors(&nNumSensors); + nRetVal = XnSensorIO::EnumerateSensors(aConnectionStrings, pnCount); XN_IS_STATUS_OK(nRetVal); - XnUInt32 nArraySize = *pnCount; - - *pnCount = nNumSensors; - if (nArraySize < nNumSensors) - { - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } - - // for now, the driver only supports telling if we have a sensor or not (and not how many), - // so result is always 0 or 1. - if (nNumSensors != 0) - { - XN_ASSERT(nNumSensors == 1); - strcpy(aConnectionStrings[0], "*:0"); - } - return (XN_STATUS_OK); } @@ -180,17 +176,18 @@ XnStatus XnSensor::InitImpl(const XnDeviceConfig *pDeviceConfig) // Frame Sync XnCallbackHandle hCallbackDummy; - nRetVal = m_FrameSync.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, &hCallbackDummy); + nRetVal = m_FrameSync.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetFirmware()->GetParams()->m_Stream0Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, &hCallbackDummy); + nRetVal = GetFirmware()->GetParams()->m_Stream0Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); - nRetVal = GetFirmware()->GetParams()->m_Stream1Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, &hCallbackDummy); + nRetVal = GetFirmware()->GetParams()->m_Stream1Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); // other stuff - xnDumpInit(&m_FrameSyncDump, XN_DUMP_FRAME_SYNC, "HostTime(us),DepthNewData,DepthTimestamp(ms),ImageNewData,ImageTimestamp(ms),Diff(ms),Action\n", "FrameSync.csv"); + m_FrameSyncDump = xnDumpFileOpen(XN_DUMP_FRAME_SYNC, "FrameSync.csv"); + xnDumpFileWriteString(m_FrameSyncDump, "HostTime(us),DepthNewData,DepthTimestamp(ms),ImageNewData,ImageTimestamp(ms),Diff(ms),Action\n"); nRetVal = XnDeviceBase::InitImpl(pDeviceConfig); XN_IS_STATUS_OK(nRetVal); @@ -221,8 +218,6 @@ XnStatus XnSensor::InitSensor(const XnDeviceConfig* pDeviceConfig) xnOSMemSet(pDevicePrivateData->cpSensorID, 0, XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH); - pDevicePrivateData->bSyncAudio = TRUE; - switch (pDeviceConfig->DeviceMode) { case XN_DEVICE_MODE_READ: @@ -243,29 +238,44 @@ XnStatus XnSensor::InitSensor(const XnDeviceConfig* pDeviceConfig) nRetVal = m_SensorIO.OpenDevice(pDeviceConfig->cpConnectionString); XN_IS_STATUS_OK(nRetVal); + nRetVal = m_USBPath.UnsafeUpdateValue(m_SensorIO.GetDevicePath()); + XN_IS_STATUS_OK(nRetVal); + // initialize nRetVal = XnDeviceSensorInit(pDevicePrivateData); XN_IS_STATUS_OK(nRetVal); // init firmware - nRetVal = m_Firmware.Init((XnBool)m_ResetSensorOnStartup.GetValue()); + nRetVal = m_Firmware.Init((XnBool)m_ResetSensorOnStartup.GetValue(), (XnBool)m_LeanInit.GetValue()); XN_IS_STATUS_OK(nRetVal); m_bInitialized = TRUE; m_ResetSensorOnStartup.UpdateSetCallback(NULL, NULL); + m_LeanInit.UpdateSetCallback(NULL, NULL); - // Init modules - nRetVal = m_FixedParams.Init(); + // update device info properties + nRetVal = m_DeviceName.UnsafeUpdateValue(GetFixedParams()->GetDeviceName()); XN_IS_STATUS_OK(nRetVal); - - // update serial number - nRetVal = m_ID.UnsafeUpdateValue(m_FixedParams.GetSensorSerial()); + nRetVal = m_VendorSpecificData.UnsafeUpdateValue(GetFixedParams()->GetVendorData()); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_ID.UnsafeUpdateValue(GetFixedParams()->GetSensorSerial()); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_PlatformString.UnsafeUpdateValue(GetFixedParams()->GetPlatformString()); XN_IS_STATUS_OK(nRetVal); + // Add supported streams AddSupportedStream(XN_STREAM_TYPE_DEPTH); - AddSupportedStream(XN_STREAM_TYPE_IMAGE); AddSupportedStream(XN_STREAM_TYPE_IR); - AddSupportedStream(XN_STREAM_TYPE_AUDIO); + + if (GetFirmware()->GetInfo()->bImageSupported) + { + AddSupportedStream(XN_STREAM_TYPE_IMAGE); + } + + if (GetFirmware()->GetInfo()->bAudioSupported) + { + AddSupportedStream(XN_STREAM_TYPE_AUDIO); + } return XN_STATUS_OK; } @@ -289,13 +299,6 @@ XnStatus XnSensor::Destroy() m_bInitialized = FALSE; - // close critical sections - if (pDevicePrivateData->hAudioBufferCriticalSection != NULL) - { - xnOSCloseCriticalSection(&pDevicePrivateData->hAudioBufferCriticalSection); - pDevicePrivateData->hAudioBufferCriticalSection = NULL; - } - if (pDevicePrivateData->hEndPointsCS != NULL) { xnOSCloseCriticalSection(&pDevicePrivateData->hEndPointsCS); @@ -311,13 +314,19 @@ XnStatus XnSensor::Destroy() pDevicePrivateData->hExecuteMutex = NULL; } + // Register USB event callback +#if WIN32 + nRetVal = m_SensorIO.SetCallback(NULL, this); + XN_IS_STATUS_OK(nRetVal); +#endif + XnDeviceBase::Destroy(); // close dumps - xnDumpClose(&pDevicePrivateData->TimestampsDump); - xnDumpClose(&pDevicePrivateData->BandwidthDump); - xnDumpClose(&pDevicePrivateData->MiniPacketsDump); - xnDumpClose(&m_FrameSyncDump); + xnDumpFileClose(pDevicePrivateData->TimestampsDump); + xnDumpFileClose(pDevicePrivateData->BandwidthDump); + xnDumpFileClose(pDevicePrivateData->MiniPacketsDump); + xnDumpFileClose(m_FrameSyncDump); m_Firmware.Free(); @@ -336,10 +345,12 @@ XnStatus XnSensor::CreateDeviceModule(XnDeviceModuleHolder** ppModuleHolder) XnDeviceModule* pModule = (*ppModuleHolder)->GetModule(); XnProperty* pProps[] = { - &m_ErrorState, &m_ResetSensorOnStartup, &m_Interface, &m_ReadFromEP1, - &m_ReadFromEP2, &m_ReadFromEP3, &m_ReadData, &m_NumberOfBuffers, &m_FirmwareParam, + &m_ErrorState, &m_ResetSensorOnStartup, &m_LeanInit, &m_Interface, &m_ReadFromEP1, + &m_ReadFromEP2, &m_ReadFromEP3, &m_ReadData, &m_FirmwareParam, &m_CmosBlankingUnits, &m_CmosBlankingTime, &m_Reset, &m_FirmwareMode, &m_Version, &m_FixedParam, &m_FrameSync, &m_CloseStreamsOnShutdown, &m_InstancePointer, &m_ID, + &m_USBPath, &m_DeviceName, &m_VendorSpecificData, &m_AudioSupported, &m_ImageSupported, + &m_ImageControl, &m_DepthControl, &m_AHB, &m_HostTimestamps, &m_PlatformString, }; nRetVal = pModule->AddProperties(pProps, sizeof(pProps)/sizeof(XnProperty*)); @@ -392,28 +403,34 @@ XnStatus XnSensor::CreateStreamModule(const XnChar* StreamType, const XnChar* St if (strcmp(StreamType, XN_STREAM_TYPE_DEPTH) == 0) { XnSensorDepthStream* pDepthStream; - XN_VALIDATE_NEW(pDepthStream, XnSensorDepthStream, StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); + XN_VALIDATE_NEW(pDepthStream, XnSensorDepthStream, StreamName, &m_Objects); pStream = pDepthStream; pHelper = pDepthStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IMAGE) == 0) { XnSensorImageStream* pImageStream; - XN_VALIDATE_NEW(pImageStream, XnSensorImageStream, StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); + XN_VALIDATE_NEW(pImageStream, XnSensorImageStream, StreamName, &m_Objects); pStream = pImageStream; pHelper = pImageStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IR) == 0) { XnSensorIRStream* pIRStream; - XN_VALIDATE_NEW(pIRStream, XnSensorIRStream, StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); + XN_VALIDATE_NEW(pIRStream, XnSensorIRStream, StreamName, &m_Objects); pStream = pIRStream; pHelper = pIRStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_AUDIO) == 0) { + if (!m_Firmware.GetInfo()->bAudioSupported) + { + XN_LOG_WARNING_RETURN(XN_STATUS_UNSUPPORTED_STREAM, XN_MASK_DEVICE_SENSOR, "Audio is not supported by this FW!"); + } + + // TODO: use the allow other users property when constructing the audio stream XnSensorAudioStream* pAudioStream; - XN_VALIDATE_NEW(pAudioStream, XnSensorAudioStream, StreamName, &m_Objects); + XN_VALIDATE_NEW(pAudioStream, XnSensorAudioStream, GetUSBPath(), StreamName, &m_Objects, FALSE); pStream = pAudioStream; pHelper = pAudioStream->GetHelper(); } @@ -524,7 +541,7 @@ XnStatus XnSensor::ReadStream(XnStreamData* pStreamOutput) return (XN_STATUS_OK); } -XnStatus XnSensor::GetSharedBufferPool(const XnChar* strStream, XnSharedMemoryBufferPool** ppBufferPool) +XnStatus XnSensor::GetBufferPool(const XnChar* strStream, XnBufferPool** ppBufferPool) { XnStatus nRetVal = XN_STATUS_OK; @@ -533,11 +550,38 @@ XnStatus XnSensor::GetSharedBufferPool(const XnChar* strStream, XnSharedMemoryBu XN_IS_STATUS_OK(nRetVal); XnSensorStreamHolder* pSensorStreamHolder = (XnSensorStreamHolder*)(pHolder); - *ppBufferPool = pSensorStreamHolder->GetSharedBufferPool(); + XnDeviceStream* pStream = pSensorStreamHolder->GetStream(); + + XnUInt64 nFrameBased; + nRetVal = pStream->GetProperty(XN_STREAM_PROPERTY_IS_FRAME_BASED, &nFrameBased); + XN_IS_STATUS_OK(nRetVal); + + if (nFrameBased == 0) + { + return XN_STATUS_BAD_TYPE; + } + + XnFrameStream* pFrameStream = (XnFrameStream*)pStream; + *ppBufferPool = pFrameStream->GetBufferPool(); return (XN_STATUS_OK); } + +XnStatus XnSensor::GetStream(const XnChar* strStream, XnDeviceStream** ppStream) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnDeviceModuleHolder* pHolder; + nRetVal = FindStream(strStream, &pHolder); + XN_IS_STATUS_OK(nRetVal); + + XnSensorStreamHolder* pSensorStreamHolder = (XnSensorStreamHolder*)(pHolder); + *ppStream = pSensorStreamHolder->GetStream(); + + return XN_STATUS_OK; +} + XnBool XnSensor::HasSynchedFrameArrived(const XnChar* strDepthStream, const XnChar* strImageStream) { // find both streams @@ -567,7 +611,7 @@ XnBool XnSensor::HasSynchedFrameArrived(const XnChar* strDepthStream, const XnCh { XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - xnDumpWriteString(m_FrameSyncDump, "%llu,%u,%llu,%u,%llu,%s\n", + xnDumpFileWriteString(m_FrameSyncDump, "%llu,%u,%llu,%u,%llu,%s\n", nNow, pDepth->IsNewDataAvailable(), pDepth->GetLastTimestamp(), @@ -663,22 +707,22 @@ XnStatus XnSensor::Read(XnStreamDataSet* pStreamOutputSet) return (XN_STATUS_OK); } -XnStatus XnSensor::WriteStream(const XnStreamData* pStreamOutput) +XnStatus XnSensor::WriteStream(XnStreamData* /*pStreamOutput*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } -XnStatus XnSensor::Write(const XnStreamDataSet* pStreamOutputSet) +XnStatus XnSensor::Write(XnStreamDataSet* /*pStreamOutputSet*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } -XnStatus XnSensor::Seek(XnUInt64 nTimestamp) +XnStatus XnSensor::Seek(XnUInt64 /*nTimestamp*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } -XnStatus XnSensor::SeekFrame(XnUInt32 nFrameID) +XnStatus XnSensor::SeekFrame(XnUInt32 /*nFrameID*/) { return (XN_STATUS_IO_DEVICE_FUNCTION_NOT_SUPPORTED); } @@ -694,9 +738,6 @@ XnStatus XnSensor::LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* nRetVal = m_Interface.ReadValueFromFile(csINIFilePath, XN_MODULE_NAME_DEVICE); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_NumberOfBuffers.ReadValueFromFile(csINIFilePath, XN_MODULE_NAME_DEVICE); - XN_IS_STATUS_OK(nRetVal); - nRetVal = m_ReadFromEP1.ReadValueFromFile(csINIFilePath, XN_MODULE_NAME_DEVICE); XN_IS_STATUS_OK(nRetVal); @@ -719,7 +760,7 @@ XnStatus XnSensor::LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* nRetVal = GetStreamsList(streams); XN_IS_STATUS_OK(nRetVal); - for (XnDeviceModuleHolderList::Iterator it = streams.begin(); it != streams.end(); ++it) + for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it) { XnDeviceModuleHolder* pHolder = *it; nRetVal = pHolder->GetModule()->LoadConfigFromFile(csINIFilePath); @@ -739,7 +780,10 @@ XnStatus XnSensor::InitReading() XnStatus nRetVal = XN_STATUS_OK; // open data endpoints - nRetVal = m_SensorIO.OpenDataEndPoints((XnSensorUsbInterface)m_Interface.GetValue()); + nRetVal = m_SensorIO.OpenDataEndPoints((XnSensorUsbInterface)m_Interface.GetValue(), *m_Firmware.GetInfo()); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_Interface.UnsafeUpdateValue(m_SensorIO.GetCurrentInterface()); XN_IS_STATUS_OK(nRetVal); // take frequency information @@ -752,12 +796,12 @@ XnStatus XnSensor::InitReading() m_DevicePrivateData.fDeviceFrequency = XN_PREPARE_VAR_FLOAT_IN_BUFFER(FrequencyInformation.fDeviceFrequency); // Init Dumps - m_DevicePrivateData.BandwidthDump = XN_DUMP_CLOSED; - xnDumpInit(&m_DevicePrivateData.BandwidthDump, XN_DUMP_BANDWIDTH, "Timestamp,Frame Type,Frame ID,Size\n", "Bandwidth.csv"); - m_DevicePrivateData.TimestampsDump = XN_DUMP_CLOSED; - xnDumpInit(&m_DevicePrivateData.TimestampsDump, XN_DUMP_TIMESTAMPS, "Host Time (us),Stream,Device TS,Time (ms),Comments\n", "Timestamps.csv"); - m_DevicePrivateData.MiniPacketsDump = XN_DUMP_CLOSED; - xnDumpInit(&m_DevicePrivateData.MiniPacketsDump, XN_DUMP_MINI_PACKETS, "HostTS,Type,ID,Size,Timestamp\n", "MiniPackets.csv"); + m_DevicePrivateData.BandwidthDump = xnDumpFileOpen(XN_DUMP_BANDWIDTH, "Bandwidth.csv"); + xnDumpFileWriteString(m_DevicePrivateData.BandwidthDump, "Timestamp,Frame Type,Frame ID,Size\n"); + m_DevicePrivateData.TimestampsDump = xnDumpFileOpen(XN_DUMP_TIMESTAMPS, "Timestamps.csv"); + xnDumpFileWriteString(m_DevicePrivateData.TimestampsDump, "Host Time (us),Stream,Device TS,Time (ms),Comments\n"); + m_DevicePrivateData.MiniPacketsDump = xnDumpFileOpen(XN_DUMP_MINI_PACKETS, "MiniPackets.csv"); + xnDumpFileWriteString(m_DevicePrivateData.MiniPacketsDump, "HostTS,Type,ID,Size,Timestamp\n"); m_DevicePrivateData.nGlobalReferenceTS = 0; nRetVal = xnOSCreateCriticalSection(&m_DevicePrivateData.hEndPointsCS); @@ -776,32 +820,8 @@ XnStatus XnSensor::InitReading() } -XnStatus XnSensor::ParseConnectionString(const XnChar* csConnectionString, XnChar* csSensorID, XnUInt32* pnBoardID) -{ - XnStatus nRetVal = XN_STATUS_OK; - -/* const XnChar* cpSepPos = strstr(csConnectionString, XN_DEVICE_SENSOR_BOARDID_SEP); - if (cpSepPos == NULL) - { - return (XN_STATUS_IO_INVALID_CONNECTION_STRING); - } - - XnUInt32 nSepPos = cpSepPos - csConnectionString; - - xnOSMemSet(csSensorID, 0, XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH); - - nRetVal = xnOSStrNCopy(csSensorID, csConnectionString, nSepPos, XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH); - XN_IS_STATUS_OK(nRetVal); - - *pnBoardID = atoi(cpSepPos + 1); -*/ - return (XN_STATUS_OK); -} - XnStatus XnSensor::ValidateSensorID(XnChar* csSensorID) { - XnStatus nRetVal = XN_STATUS_OK; - if (strcmp(csSensorID, XN_DEVICE_SENSOR_DEFAULT_ID) != 0) { if (strcmp(csSensorID, GetFixedParams()->GetSensorSerial()) != 0) @@ -862,6 +882,26 @@ XnStatus XnSensor::GetFirmwareParam(XnInnerParamData* pParam) return (XN_STATUS_OK); } +XnStatus XnSensor::ReadAHB(XnAHBData* pAHB) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnHostProtocolReadAHB(&m_DevicePrivateData, pAHB->nRegister, pAHB->nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensor::WriteAHB(const XnAHBData* pAHB) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnHostProtocolWriteAHB(&m_DevicePrivateData, pAHB->nRegister, pAHB->nValue, pAHB->nMask); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + XnStatus XnSensor::GetCmosBlankingUnits(XnCmosBlankingUnits* pBlanking) { @@ -937,6 +977,42 @@ XnStatus XnSensor::GetFirmwareMode(XnParamCurrentMode* pnMode) return (XN_STATUS_OK); } +XnStatus XnSensor::GetDepthCmosRegister(XnControlProcessingData* pRegister) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_Firmware.GetInfo()->nFWVer >= XN_SENSOR_FW_VER_3_0) + { + nRetVal = XnHostProtocolGetCMOSRegisterI2C(&m_DevicePrivateData, XN_CMOS_TYPE_DEPTH, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + else + { + nRetVal = XnHostProtocolGetCMOSRegister(&m_DevicePrivateData, XN_CMOS_TYPE_DEPTH, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnSensor::GetImageCmosRegister(XnControlProcessingData* pRegister) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_Firmware.GetInfo()->nFWVer >= XN_SENSOR_FW_VER_3_0) + { + nRetVal = XnHostProtocolGetCMOSRegisterI2C(&m_DevicePrivateData, XN_CMOS_TYPE_IMAGE, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + else + { + nRetVal = XnHostProtocolGetCMOSRegister(&m_DevicePrivateData, XN_CMOS_TYPE_IMAGE, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + XnStatus XnSensor::GetFixedParams(XnDynamicSizeBuffer* pBuffer) { @@ -998,25 +1074,20 @@ XnStatus XnSensor::SetInterface(XnSensorUsbInterface nInterface) return (XN_STATUS_OK); } -XnStatus XnSensor::SetNumberOfBuffers(XnUInt32 nCount) +XnStatus XnSensor::SetHostTimestamps(XnBool bHostTimestamps) { XnStatus nRetVal = XN_STATUS_OK; - // This is a special func. It can only be changed BEFORE reading starts - if (m_ReadData.GetValue() == FALSE) - { - nRetVal = m_NumberOfBuffers.UnsafeUpdateValue(nCount); - XN_IS_STATUS_OK(nRetVal); - } - else + // we don't allow change if requested value is specific and different than current + if (m_ReadData.GetValue() == TRUE && + bHostTimestamps != m_HostTimestamps.GetValue()) { - // check it's the same value - if (nCount != m_NumberOfBuffers.GetValue()) - { - return (XN_STATUS_DEVICE_PROPERTY_READ_ONLY); - } + return (XN_STATUS_DEVICE_PROPERTY_READ_ONLY); } + nRetVal = m_HostTimestamps.UnsafeUpdateValue(bHostTimestamps); + XN_IS_STATUS_OK(nRetVal); + return (XN_STATUS_OK); } @@ -1109,6 +1180,42 @@ XnStatus XnSensor::SetReadData(XnBool bRead) return (XN_STATUS_OK); } +XnStatus XnSensor::SetDepthCmosRegister(const XnControlProcessingData* pRegister) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_Firmware.GetInfo()->nFWVer >= XN_SENSOR_FW_VER_3_0) + { + nRetVal = XnHostProtocolSetCMOSRegisterI2C(&m_DevicePrivateData, XN_CMOS_TYPE_DEPTH, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + else + { + nRetVal = XnHostProtocolSetCMOSRegister(&m_DevicePrivateData, XN_CMOS_TYPE_DEPTH, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnSensor::SetImageCmosRegister(const XnControlProcessingData* pRegister) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_Firmware.GetInfo()->nFWVer >= XN_SENSOR_FW_VER_3_0) + { + nRetVal = XnHostProtocolSetCMOSRegisterI2C(&m_DevicePrivateData, XN_CMOS_TYPE_IMAGE, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + else + { + nRetVal = XnHostProtocolSetCMOSRegister(&m_DevicePrivateData, XN_CMOS_TYPE_IMAGE, pRegister->nRegister, pRegister->nValue); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + XnStatus XnSensor::SetFirmwareParam(const XnInnerParamData* pParam) { @@ -1165,7 +1272,7 @@ XnStatus XnSensor::Reset(XnParamResetType nType) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = XnHostProtocolReset(&m_DevicePrivateData, nType); + nRetVal = XnHostProtocolReset(&m_DevicePrivateData, (XnUInt16)nType); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -1195,7 +1302,7 @@ XnStatus XnSensor::SetFirmwareMode(XnParamCurrentMode nMode) return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } - nRetVal = XnHostProtocolSetMode(&m_DevicePrivateData, nActualValue); + nRetVal = XnHostProtocolSetMode(&m_DevicePrivateData, (XnUInt16)nActualValue); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -1222,97 +1329,97 @@ XnStatus XnSensor::OnFrameSyncPropertyChanged() return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetInterfaceCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetInterfaceCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->XnSensor::SetInterface((XnSensorUsbInterface)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetNumberOfBuffersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetHostTimestampsCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; - return pThis->SetNumberOfBuffers((XnUInt32)nValue); + return pThis->XnSensor::SetHostTimestamps(nValue == 1); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint1Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint1Callback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->XnSensor::SetReadEndpoint1((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint2Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint2Callback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->XnSensor::SetReadEndpoint2((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint3Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetReadEndpoint3Callback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->XnSensor::SetReadEndpoint3((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetReadDataCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetReadDataCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->XnSensor::SetReadData((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetFirmwareParamCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetFirmwareParamCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnInnerParamData); XnSensor* pThis = (XnSensor*)pCookie; return pThis->SetFirmwareParam((const XnInnerParamData*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetCmosBlankingUnitsCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetCmosBlankingUnitsCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnCmosBlankingUnits); XnSensor* pThis = (XnSensor*)pCookie; return pThis->SetCmosBlankingUnits((const XnCmosBlankingUnits*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetCmosBlankingTimeCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetCmosBlankingTimeCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnCmosBlankingTime); XnSensor* pThis = (XnSensor*)pCookie; return pThis->SetCmosBlankingTime((const XnCmosBlankingTime*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::ResetCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::ResetCallback(XnIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->Reset((XnParamResetType)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::SetFirmwareModeCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::SetFirmwareModeCallback(XnIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->SetFirmwareMode((XnParamCurrentMode)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensor::GetFirmwareParamCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetFirmwareParamCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnInnerParamData); XnSensor* pThis = (XnSensor*)pCookie; return pThis->GetFirmwareParam((XnInnerParamData*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::GetCmosBlankingUnitsCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetCmosBlankingUnitsCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnCmosBlankingUnits); XnSensor* pThis = (XnSensor*)pCookie; return pThis->GetCmosBlankingUnits((XnCmosBlankingUnits*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::GetCmosBlankingTimeCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetCmosBlankingTimeCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnCmosBlankingTime); XnSensor* pThis = (XnSensor*)pCookie; return pThis->GetCmosBlankingTime((XnCmosBlankingTime*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensor::GetFirmwareModeCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetFirmwareModeCallback(const XnIntProperty* /*pSender*/, XnUInt64* pnValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; XnParamCurrentMode nMode; @@ -1323,13 +1430,27 @@ XnStatus XN_CALLBACK_TYPE XnSensor::GetFirmwareModeCallback(const XnIntProperty* return XN_STATUS_OK; } -XnStatus XN_CALLBACK_TYPE XnSensor::FrameSyncPropertyChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetAudioSupportedCallback(const XnIntProperty* /*pSender*/, XnUInt64* pnValue, void* pCookie) +{ + XnSensor* pThis = (XnSensor*)pCookie; + *pnValue = pThis->m_Firmware.GetInfo()->bAudioSupported; + return XN_STATUS_OK; +} + +XnStatus XN_CALLBACK_TYPE XnSensor::GetImageSupportedCallback(const XnIntProperty* /*pSender*/, XnUInt64* pnValue, void* pCookie) +{ + XnSensor* pThis = (XnSensor*)pCookie; + *pnValue = pThis->m_Firmware.GetInfo()->bImageSupported; + return XN_STATUS_OK; +} + +XnStatus XN_CALLBACK_TYPE XnSensor::FrameSyncPropertyChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; return pThis->OnFrameSyncPropertyChanged(); } -XnStatus XN_CALLBACK_TYPE XnSensor::GetFixedParamsCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensor::GetFixedParamsCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnDynamicSizeBuffer); XnSensor* pThis = (XnSensor*)pCookie; @@ -1337,7 +1458,7 @@ XnStatus XN_CALLBACK_TYPE XnSensor::GetFixedParamsCallback(const XnGeneralProper return pThis->GetFixedParams(pBuffer); } -XnBool XN_CALLBACK_TYPE XnSensor::USBEventCallback(XnUSBEventType USBEventType, XnChar* cpDevPath, void* pCallbackData) +XnBool XN_CALLBACK_TYPE XnSensor::USBEventCallback(XnUSBEventType USBEventType, XnChar* /*cpDevPath*/, void* pCallbackData) { XnSensor* pXnSensor = (XnSensor*)pCallbackData; if (USBEventType == XN_USB_EVENT_DEVICE_DISCONNECT) @@ -1353,3 +1474,57 @@ XnBool XN_CALLBACK_TYPE XnSensor::USBEventCallback(XnUSBEventType USBEventType, return TRUE; } + +XnStatus XN_CALLBACK_TYPE XnSensor::GetInstanceCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + if (gbValue.nDataSize != sizeof(void*)) + { + return XN_STATUS_DEVICE_PROPERTY_SIZE_DONT_MATCH; + } + + *(void**)gbValue.pData = pCookie; + return XN_STATUS_OK; +} + +XnStatus XN_CALLBACK_TYPE XnSensor::SetDepthCmosRegisterCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnControlProcessingData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->SetDepthCmosRegister((const XnControlProcessingData*)gbValue.pData); +} + +XnStatus XN_CALLBACK_TYPE XnSensor::SetImageCmosRegisterCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnControlProcessingData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->SetImageCmosRegister((const XnControlProcessingData*)gbValue.pData); +} + +XnStatus XN_CALLBACK_TYPE XnSensor::GetDepthCmosRegisterCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnControlProcessingData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->GetDepthCmosRegister((XnControlProcessingData*)gbValue.pData); +} + +XnStatus XN_CALLBACK_TYPE XnSensor::GetImageCmosRegisterCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnControlProcessingData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->GetImageCmosRegister((XnControlProcessingData*)gbValue.pData); +} + +XnStatus XN_CALLBACK_TYPE XnSensor::WriteAHBCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnAHBData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->WriteAHB((const XnAHBData*)gbValue.pData); +} + +XnStatus XN_CALLBACK_TYPE XnSensor::ReadAHBCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XN_VALIDATE_GENERAL_BUFFER_TYPE(gbValue, XnAHBData); + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->ReadAHB((XnAHBData*)gbValue.pData); +} + diff --git a/Source/XnDeviceSensorV2/XnSensor.h b/Source/XnDeviceSensorV2/XnSensor.h index 5465f71..1c3ab51 100644 --- a/Source/XnDeviceSensorV2/XnSensor.h +++ b/Source/XnDeviceSensorV2/XnSensor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_H__ #define __XN_SENSOR_H__ @@ -52,10 +47,10 @@ //--------------------------------------------------------------------------- class XnSensor : public XnDeviceBase { - friend class XnSensorServer; + friend class XnServerSensorInvoker; public: - XnSensor(); + XnSensor(XnBool bResetOnStartup = TRUE, XnBool bLeanInit = FALSE); ~XnSensor(); static XnStatus GetDefinition(XnDeviceDefinition* pDeviceDefinition); @@ -66,14 +61,14 @@ class XnSensor : public XnDeviceBase virtual XnStatus OpenAllStreams(); virtual XnStatus ReadStream(XnStreamData* pStreamOutput); virtual XnStatus Read(XnStreamDataSet* pStreamOutputSet); - virtual XnStatus WriteStream(const XnStreamData* pStreamOutput); - virtual XnStatus Write(const XnStreamDataSet* pStreamOutputSet); + virtual XnStatus WriteStream(XnStreamData* pStreamOutput); + virtual XnStatus Write(XnStreamDataSet* pStreamOutputSet); virtual XnStatus Seek(XnUInt64 nTimestamp); virtual XnStatus SeekFrame(XnUInt32 nFrameID); virtual XnStatus LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName); public: - inline const XnSensorFixedParams* GetFixedParams() const { return &m_FixedParams; } + inline XnSensorFixedParams* GetFixedParams() { return GetFirmware()->GetFixedParams(); } inline XnSensorFirmware* GetFirmware() { return &m_Firmware; } inline XnSensorFPS* GetFPSCalculator() { return &m_FPS; } @@ -85,8 +80,10 @@ class XnSensor : public XnDeviceBase XnStatus ConfigPropertyFromFile(XnIntProperty* pProperty, const XnChar* csINIFilePath, const XnChar* csSectionName); inline XnBool IsMiscSupported() const { return m_SensorIO.IsMiscEndpointSupported(); } + inline XnBool IsLowBandwidth() const { return m_SensorIO.IsLowBandwidth(); } - XnStatus GetSharedBufferPool(const XnChar* strStream, XnSharedMemoryBufferPool** ppBufferPool); + XnStatus GetBufferPool(const XnChar* strStream, XnBufferPool** ppBufferPool); + XnStatus GetStream(const XnChar* strStream, XnDeviceStream** ppStream); inline XnStatus GetErrorState() { return (XnStatus)m_ErrorState.GetValue(); } XnStatus SetErrorState(XnStatus errorState); @@ -95,6 +92,10 @@ class XnSensor : public XnDeviceBase XnStatus SetGlobalConfigFile(const XnChar* strConfigFile); XnStatus ConfigureModuleFromGlobalFile(const XnChar* strModule, const XnChar* strSection = NULL); + const XnChar* GetUSBPath() { return m_USBPath.GetValue(); } + XnBool ShouldUseHostTimestamps() { return (m_HostTimestamps.GetValue() == TRUE); } + XnBool HasReadingStarted() { return (m_ReadData.GetValue() == TRUE); } + protected: virtual XnStatus CreateStreamImpl(const XnChar* strType, const XnChar* strName, const XnActualPropertiesHash* pInitialSet); @@ -107,7 +108,6 @@ class XnSensor : public XnDeviceBase private: XnStatus InitSensor(const XnDeviceConfig* pDeviceConfig); - XnStatus ParseConnectionString(const XnChar* csConnectionString, XnChar* csSensorID, XnUInt32* pnBoardID); XnStatus ValidateSensorID(XnChar* csSensorID); XnStatus ReadFromStreamImpl(XnDeviceStream* pStream, XnStreamData* pStreamOutput); XnStatus SetMirrorForModule(XnDeviceModule* pModule, XnUInt64 nValue); @@ -117,6 +117,8 @@ class XnSensor : public XnDeviceBase XnBool HasSynchedFrameArrived(const XnChar* strDepthStream, const XnChar* strImageStream); XnStatus OnFrameSyncPropertyChanged(); + static XnStatus XN_CALLBACK_TYPE GetInstanceCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + //--------------------------------------------------------------------------- // Getters @@ -127,12 +129,16 @@ class XnSensor : public XnDeviceBase XnStatus GetFirmwareMode(XnParamCurrentMode* pnMode); XnStatus GetLastRawFrame(const XnChar* strStream, XnUChar* pBuffer, XnUInt32 nDataSize); XnStatus GetFixedParams(XnDynamicSizeBuffer* pBuffer); + XnStatus GetDepthCmosRegister(XnControlProcessingData* pRegister); + XnStatus GetImageCmosRegister(XnControlProcessingData* pRegister); + XnStatus ReadAHB(XnAHBData* pData); //--------------------------------------------------------------------------- // Setters //--------------------------------------------------------------------------- XnStatus SetInterface(XnSensorUsbInterface nInterface); + XnStatus SetHostTimestamps(XnBool bHostTimestamps); XnStatus SetNumberOfBuffers(XnUInt32 nCount); XnStatus SetReadEndpoint1(XnBool bRead); XnStatus SetReadEndpoint2(XnBool bRead); @@ -143,11 +149,16 @@ class XnSensor : public XnDeviceBase XnStatus SetCmosBlankingTime(const XnCmosBlankingTime* pBlanking); XnStatus Reset(XnParamResetType nType); XnStatus SetFirmwareMode(XnParamCurrentMode nMode); + XnStatus SetDepthCmosRegister(const XnControlProcessingData* pRegister); + XnStatus SetImageCmosRegister(const XnControlProcessingData* pRegister); + XnStatus WriteAHB(const XnAHBData* pData); + //--------------------------------------------------------------------------- // Callbacks //--------------------------------------------------------------------------- static XnStatus XN_CALLBACK_TYPE SetInterfaceCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetHostTimestampsCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetNumberOfBuffersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetReadEndpoint1Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetReadEndpoint2Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); @@ -166,6 +177,14 @@ class XnSensor : public XnDeviceBase static XnStatus XN_CALLBACK_TYPE GetCmosBlankingUnitsCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE GetCmosBlankingTimeCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE GetFirmwareModeCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetAudioSupportedCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetImageSupportedCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetDepthCmosRegisterCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetImageCmosRegisterCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetDepthCmosRegisterCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetImageCmosRegisterCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE ReadAHBCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE WriteAHBCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); //--------------------------------------------------------------------------- @@ -173,14 +192,15 @@ class XnSensor : public XnDeviceBase //--------------------------------------------------------------------------- XnActualIntProperty m_ErrorState; XnActualIntProperty m_ResetSensorOnStartup; + XnActualIntProperty m_LeanInit; XnActualIntProperty m_Interface; - XnActualIntProperty m_NumberOfBuffers; XnActualIntProperty m_ReadFromEP1; XnActualIntProperty m_ReadFromEP2; XnActualIntProperty m_ReadFromEP3; XnActualIntProperty m_ReadData; XnActualIntProperty m_FrameSync; XnActualIntProperty m_CloseStreamsOnShutdown; + XnActualIntProperty m_HostTimestamps; XnGeneralProperty m_FirmwareParam; XnGeneralProperty m_CmosBlankingUnits; XnGeneralProperty m_CmosBlankingTime; @@ -189,13 +209,21 @@ class XnSensor : public XnDeviceBase XnVersions m_VersionData; XnActualGeneralProperty m_Version; XnGeneralProperty m_FixedParam; - XnSensor* m_pThis; - XnActualGeneralProperty m_InstancePointer; + XnGeneralProperty m_InstancePointer; XnActualStringProperty m_ID; + XnActualStringProperty m_USBPath; + XnActualStringProperty m_DeviceName; + XnActualStringProperty m_VendorSpecificData; + XnActualStringProperty m_PlatformString; + XnIntProperty m_AudioSupported; + XnIntProperty m_ImageSupported; + XnGeneralProperty m_ImageControl; + XnGeneralProperty m_DepthControl; + XnGeneralProperty m_AHB; + XnSensorFirmware m_Firmware; XnDevicePrivateData m_DevicePrivateData; - XnSensorFixedParams m_FixedParams; XnSensorFPS m_FPS; XnCmosInfo m_CmosInfo; XnSensorIO m_SensorIO; @@ -203,7 +231,7 @@ class XnSensor : public XnDeviceBase XnSensorObjects m_Objects; - XnDump m_FrameSyncDump; + XnDumpFile* m_FrameSyncDump; XnBool m_bInitialized; XnIntPropertySynchronizer m_PropSynchronizer; diff --git a/Source/XnDeviceSensorV2/XnSensorAudioGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorAudioGenerator.cpp index 7828258..1dd25ac 100644 --- a/Source/XnDeviceSensorV2/XnSensorAudioGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorAudioGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -87,7 +81,7 @@ XnStatus XnSensorAudioGenerator::Init() XnBool XnSensorAudioGenerator::IsCapabilitySupported(const XnChar* strCapabilityName) { - return FALSE; + return XnSensorGenerator::IsCapabilitySupported(strCapabilityName); } XnUChar* XnSensorAudioGenerator::GetAudioBuffer() @@ -102,8 +96,6 @@ XnUInt32 XnSensorAudioGenerator::GetSupportedWaveOutputModesCount() XnStatus XnSensorAudioGenerator::GetSupportedWaveOutputModes(XnWaveOutputMode aSupportedModes[], XnUInt32& nCount) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(aSupportedModes); if (nCount < m_SupportedModes.Size()) @@ -112,7 +104,7 @@ XnStatus XnSensorAudioGenerator::GetSupportedWaveOutputModes(XnWaveOutputMode aS } XnUInt32 i = 0; - for (XnWaveOutputModeList::Iterator it = m_SupportedModes.begin(); it != m_SupportedModes.end(); ++it, ++i) + for (XnWaveOutputModeList::Iterator it = m_SupportedModes.Begin(); it != m_SupportedModes.End(); ++it, ++i) { aSupportedModes[i] = *it; } @@ -182,9 +174,57 @@ void XnSensorAudioGenerator::FilterProperties(XnActualPropertiesHash* pHash) // XnExportedSensorAudioGenerator class //--------------------------------------------------------------------------- XnExportedSensorAudioGenerator::XnExportedSensorAudioGenerator() : - XnExportedSensorGenerator(XN_NODE_TYPE_AUDIO, XN_STREAM_TYPE_AUDIO) + XnExportedSensorGenerator(XN_NODE_TYPE_AUDIO, XN_STREAM_TYPE_AUDIO, FALSE) {} +XnStatus XnExportedSensorAudioGenerator::IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnExportedSensorGenerator::IsSupportedForDevice(context, sensorInfo, pbSupported); + XN_IS_STATUS_OK(nRetVal); + + if (*pbSupported == FALSE) + { + return XN_STATUS_OK; + } + + xn::Device sensor; + nRetVal = sensorInfo.GetInstance(sensor); + XN_IS_STATUS_OK(nRetVal); + + XnUInt64 nAudioSupported = FALSE; + + if (sensor.IsValid()) + { + nRetVal = sensor.GetIntProperty(XN_MODULE_PROPERTY_AUDIO_SUPPORTED, nAudioSupported); + XN_IS_STATUS_OK(nRetVal); + } + else + { + // Don't create sensor through OpenNI. This will cause it to soft-reset. + // instead, "talk" directly to the sensor class + XnSensor lowLevelSensor(FALSE); + XnDeviceConfig config; + config.DeviceMode = XN_DEVICE_MODE_READ; + config.cpConnectionString = sensorInfo.GetCreationInfo(); + config.SharingMode = XN_DEVICE_EXCLUSIVE; + config.pInitialValues = NULL; + nRetVal = lowLevelSensor.Init(&config); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = lowLevelSensor.GetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_AUDIO_SUPPORTED, &nAudioSupported); + XN_IS_STATUS_OK(nRetVal); + } + + if (nAudioSupported != TRUE) + { + *pbSupported = FALSE; + } + + return (XN_STATUS_OK); +} + XnSensorGenerator* XnExportedSensorAudioGenerator::CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) { return XN_NEW(XnSensorAudioGenerator, context, sensor, pSensor, strStreamName); diff --git a/Source/XnDeviceSensorV2/XnSensorAudioGenerator.h b/Source/XnDeviceSensorV2/XnSensorAudioGenerator.h index 682c2c3..8fcb083 100644 --- a/Source/XnDeviceSensorV2/XnSensorAudioGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorAudioGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_AUDIO_GENERATOR_H__ #define __XN_SENSOR_AUDIO_GENERATOR_H__ @@ -33,11 +27,15 @@ //--------------------------------------------------------------------------- #include "XnSensorGenerator.h" #include "XnExportedSensorGenerator.h" -#include +#include //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorAudioGenerator : public XnSensorGenerator, virtual public xn::ModuleAudioGenerator @@ -49,6 +47,7 @@ class XnSensorAudioGenerator : XnBool IsCapabilitySupported(const XnChar* strCapabilityName); + const void* GetData() { return XnSensorGenerator::GetData(); } XnUChar* GetAudioBuffer(); XnUInt32 GetSupportedWaveOutputModesCount(); XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode aSupportedModes[], XnUInt32& nCount); @@ -61,7 +60,7 @@ class XnSensorAudioGenerator : virtual void FilterProperties(XnActualPropertiesHash* pHash); private: - XN_DECLARE_LIST(XnWaveOutputMode, XnWaveOutputModeList); + typedef XnListT XnWaveOutputModeList; XnWaveOutputModeList m_SupportedModes; }; @@ -70,7 +69,12 @@ class XnExportedSensorAudioGenerator : public XnExportedSensorGenerator { public: XnExportedSensorAudioGenerator(); + +protected: + virtual XnStatus IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported); virtual XnSensorGenerator* CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); }; +#pragma warning (pop) + #endif // __XN_SENSOR_AUDIO_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorAudioStream.cpp b/Source/XnDeviceSensorV2/XnSensorAudioStream.cpp index 23173f7..049944a 100644 --- a/Source/XnDeviceSensorV2/XnSensorAudioStream.cpp +++ b/Source/XnDeviceSensorV2/XnSensorAudioStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -34,27 +28,30 @@ #include "XnAudioProcessor.h" #include +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- #define XN_AUDIO_MAX_SAMPLE_RATE 48000 #define XN_AUDIO_MAX_NUMBER_OF_CHANNELS 2 -#define XN_AUDIO_STREAM_DEFAULT_VOLUME 12 -#define XN_AUDIO_STREAM_DEFAULT_SAMPLE_RATE 48000 -#define XN_AUDIO_STREAM_DEFAULT_NUMBER_OF_CHANNELS 2 -#define XN_AUDIO_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_PCM -#define XN_AUDIO_STREAM_DEFAULT_CHUNK_SIZE 2120 - #define XN_SENSOR_PROTOCOL_AUDIO_PACKET_SIZE_BULK 424 #define XN_SENSOR_PROTOCOL_AUDIO_PACKET_SIZE_ISO 180 -XnSensorAudioStream::XnSensorAudioStream(const XnChar* StreamName, XnSensorObjects* pObjects) : +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnSensorAudioStream::XnSensorAudioStream(const XnChar* strDeviceName, const XnChar* StreamName, XnSensorObjects* pObjects, XnBool bAllowOtherUsers) : XnAudioStream(StreamName, XN_AUDIO_MAX_NUMBER_OF_CHANNELS), + m_strDeviceName(strDeviceName), m_Helper(pObjects), + m_bAllowOtherUsers(bAllowOtherUsers), m_LeftChannelVolume(XN_STREAM_PROPERTY_LEFT_CHANNEL_VOLUME, XN_AUDIO_STREAM_DEFAULT_VOLUME), m_RightChannelVolume(XN_STREAM_PROPERTY_RIGHT_CHANNEL_VOLUME, XN_AUDIO_STREAM_DEFAULT_VOLUME), m_SharedBufferName(XN_STREAM_PROPERTY_SHARED_BUFFER_NAME), m_ActualRead(XN_STREAM_PROPERTY_ACTUAL_READ_DATA, FALSE), m_hSharedMemory(NULL), - m_pSharedHeader(NULL) + m_pSharedHeader(NULL), + m_nFrameID(0) { m_LeftChannelVolume.UpdateSetCallback(SetLeftChannelVolumeCallback, this); m_RightChannelVolume.UpdateSetCallback(SetRightChannelVolumeCallback, this); @@ -73,6 +70,9 @@ XnStatus XnSensorAudioStream::Init() nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); + nRetVal = xnOSCreateCriticalSection(&m_buffer.hLock); + XN_IS_STATUS_OK(nRetVal); + nRetVal = SetReadChunkSize(XN_AUDIO_STREAM_DEFAULT_CHUNK_SIZE); XN_IS_STATUS_OK(nRetVal); @@ -89,8 +89,8 @@ XnStatus XnSensorAudioStream::Init() nRetVal = ReallocBuffer(); XN_IS_STATUS_OK(nRetVal); - m_Helper.GetPrivateData()->pAudioCallback = NewDataCallback; - m_Helper.GetPrivateData()->pAudioCallbackCookie = this; + m_buffer.pAudioCallback = NewDataCallback; + m_buffer.pAudioCallbackCookie = this; // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(NumberOfChannelsProperty()); @@ -108,6 +108,14 @@ XnStatus XnSensorAudioStream::Free() xnOSCloseSharedMemory(m_hSharedMemory); m_hSharedMemory = NULL; } + + // close critical sections + if (m_buffer.hLock != NULL) + { + xnOSCloseCriticalSection(&m_buffer.hLock); + m_buffer.hLock = NULL; + } + return (XN_STATUS_OK); } @@ -115,10 +123,14 @@ XnStatus XnSensorAudioStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(SampleRateProperty(), GetFirmwareParams()->m_AudioSampleRate, FALSE, ConvertSampleRateToFirmwareRate)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(NumberOfChannelsProperty(), GetFirmwareParams()->m_AudioStereo, FALSE, ConvertNumberOfChannelsToStereo)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_LeftChannelVolume, GetFirmwareParams()->m_AudioLeftChannelGain, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_RightChannelVolume, GetFirmwareParams()->m_AudioRightChannelGain, TRUE)); + nRetVal = m_Helper.MapFirmwareProperty(SampleRateProperty(), GetFirmwareParams()->m_AudioSampleRate, FALSE, ConvertSampleRateToFirmwareRate); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(NumberOfChannelsProperty(), GetFirmwareParams()->m_AudioStereo, FALSE, ConvertNumberOfChannelsToStereo); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_LeftChannelVolume, GetFirmwareParams()->m_AudioLeftChannelGain, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_RightChannelVolume, GetFirmwareParams()->m_AudioRightChannelGain, TRUE); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -132,10 +144,14 @@ XnStatus XnSensorAudioStream::ConfigureStreamImpl() nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(SampleRateProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(NumberOfChannelsProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_LeftChannelVolume)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_RightChannelVolume)); + nRetVal = m_Helper.ConfigureFirmware(SampleRateProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(NumberOfChannelsProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_LeftChannelVolume); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_RightChannelVolume); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -149,7 +165,8 @@ XnStatus XnSensorAudioStream::SetActualRead(XnBool bRead) if (bRead) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB audio read thread..."); - nRetVal = xnUSBInitReadThread(GetHelper()->GetPrivateData()->pSpecificMiscUsb->pUsbConnection->UsbEp, GetHelper()->GetPrivateData()->pSpecificMiscUsb->nChunkReadBytes, XN_SENSOR_USB_MISC_BUFFERS, XN_SENSOR_READ_THREAD_TIMEOUT, XnDeviceSensorProtocolUsbEpCb, GetHelper()->GetPrivateData()->pSpecificMiscUsb); + XnSpecificUsbDevice* pUSB = GetHelper()->GetPrivateData()->pSpecificMiscUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, XN_SENSOR_USB_MISC_BUFFERS, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); XN_IS_STATUS_OK(nRetVal); } else @@ -196,10 +213,8 @@ XnStatus XnSensorAudioStream::CloseStreamImpl() XnStatus XnSensorAudioStream::CreateDataProcessor(XnDataProcessor** ppProcessor) { - XnStatus nRetVal = XN_STATUS_OK; - XnDataProcessor* pAudioProcessor; - XN_VALIDATE_NEW_AND_INIT(pAudioProcessor, XnAudioProcessor, this, &m_Helper, m_nOrigAudioPacketSize); + XN_VALIDATE_NEW_AND_INIT(pAudioProcessor, XnAudioProcessor, this, &m_Helper, &m_buffer, m_nOrigAudioPacketSize); *ppProcessor = pAudioProcessor; @@ -228,7 +243,7 @@ XnStatus XnSensorAudioStream::SetSampleRate(XnSampleRate nSampleRate) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.BeforeSettingFirmwareParam(SampleRateProperty(), nSampleRate); + nRetVal = m_Helper.BeforeSettingFirmwareParam(SampleRateProperty(), (XnUInt16)nSampleRate); XN_IS_STATUS_OK(nRetVal); nRetVal = XnAudioStream::SetSampleRate(nSampleRate); @@ -244,7 +259,7 @@ XnStatus XnSensorAudioStream::SetNumberOfChannels(XnUInt32 nNumberOfChannels) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.BeforeSettingFirmwareParam(NumberOfChannelsProperty(), nNumberOfChannels); + nRetVal = m_Helper.BeforeSettingFirmwareParam(NumberOfChannelsProperty(), (XnUInt16)nNumberOfChannels); XN_IS_STATUS_OK(nRetVal); nRetVal = XnAudioStream::SetNumberOfChannels(nNumberOfChannels); @@ -261,21 +276,17 @@ XnStatus XnSensorAudioStream::SetNumberOfChannels(XnUInt32 nNumberOfChannels) XnStatus XnSensorAudioStream::NewData() { - XnStatus nRetVal = XN_STATUS_OK; - - XnDevicePrivateData* pDevicePrivateData = m_Helper.GetPrivateData(); - // check how many buffers we have - XnInt32 nAvailbalePackets = pDevicePrivateData->nAudioWriteIndex - pDevicePrivateData->nAudioReadIndex; + XnInt32 nAvailbalePackets = m_buffer.nAudioWriteIndex - m_buffer.nAudioReadIndex; if (nAvailbalePackets < 0) - nAvailbalePackets += pDevicePrivateData->nAudioBufferNumOfPackets; + nAvailbalePackets += m_buffer.nAudioBufferNumOfPackets; - if ((XnUInt32)nAvailbalePackets * pDevicePrivateData->nAudioPacketSize >= GetReadChunkSize()) + if ((XnUInt32)nAvailbalePackets * m_buffer.nAudioPacketSize >= GetReadChunkSize()) { // update last write index (the last written byte) - m_pSharedHeader->nWritePacketIndex = pDevicePrivateData->nAudioWriteIndex; + m_pSharedHeader->nWritePacketIndex = m_buffer.nAudioWriteIndex; // take first packet timestamp - NewDataAvailable(pDevicePrivateData->pAudioPacketsTimestamps[pDevicePrivateData->nAudioReadIndex], 0); + NewDataAvailable(m_buffer.pAudioPacketsTimestamps[m_buffer.nAudioReadIndex], 0); } return XN_STATUS_OK; @@ -283,49 +294,48 @@ XnStatus XnSensorAudioStream::NewData() XnStatus XnSensorAudioStream::ReadImpl(XnStreamData *pStreamOutput) { - XnStatus nRetVal = XN_STATUS_OK; - - XnDevicePrivateData* pDevicePrivateData = m_Helper.GetPrivateData(); - pStreamOutput->nDataSize = 0; XN_AUDIO_TYPE* pAudioBuf = (XN_AUDIO_TYPE*)pStreamOutput->pData; - xnOSEnterCriticalSection(&pDevicePrivateData->hAudioBufferCriticalSection); + xnOSEnterCriticalSection(&m_buffer.hLock); // check how many buffers we have - XnInt32 nAvailbalePackets = pDevicePrivateData->nAudioWriteIndex - pDevicePrivateData->nAudioReadIndex; + XnInt32 nAvailbalePackets = m_buffer.nAudioWriteIndex - m_buffer.nAudioReadIndex; if (nAvailbalePackets < 0) - nAvailbalePackets += pDevicePrivateData->nAudioBufferNumOfPackets; + nAvailbalePackets += m_buffer.nAudioBufferNumOfPackets; // now check if stream frame buffer has enough space - if (GetRequiredDataSize() < (XnUInt32)nAvailbalePackets * pDevicePrivateData->nAudioPacketSize) + if (GetRequiredDataSize() < (XnUInt32)nAvailbalePackets * m_buffer.nAudioPacketSize) { - xnOSLeaveCriticalSection(&pDevicePrivateData->hAudioBufferCriticalSection); + xnOSLeaveCriticalSection(&m_buffer.hLock); return (XN_STATUS_IO_INVALID_STREAM_AUDIO_BUFFER_SIZE); } // take first packet timestamp - pStreamOutput->nTimestamp = pDevicePrivateData->pAudioPacketsTimestamps[pDevicePrivateData->nAudioReadIndex]; - XnUChar* pPacketData = pDevicePrivateData->pAudioBuffer + (pDevicePrivateData->nAudioReadIndex * pDevicePrivateData->nAudioPacketSize); + pStreamOutput->nTimestamp = m_buffer.pAudioPacketsTimestamps[m_buffer.nAudioReadIndex]; + XnUChar* pPacketData = m_buffer.pAudioBuffer + (m_buffer.nAudioReadIndex * m_buffer.nAudioPacketSize); // copy - while (pDevicePrivateData->nAudioReadIndex != pDevicePrivateData->nAudioWriteIndex) + while (m_buffer.nAudioReadIndex != m_buffer.nAudioWriteIndex) { - xnOSMemCopy(pAudioBuf, pPacketData, pDevicePrivateData->nAudioPacketSize); - pAudioBuf += pDevicePrivateData->nAudioPacketSize; - pStreamOutput->nDataSize += pDevicePrivateData->nAudioPacketSize; + xnOSMemCopy(pAudioBuf, pPacketData, m_buffer.nAudioPacketSize); + pAudioBuf += m_buffer.nAudioPacketSize; + pStreamOutput->nDataSize += m_buffer.nAudioPacketSize; - pDevicePrivateData->nAudioReadIndex++; - pPacketData += pDevicePrivateData->nAudioPacketSize; - if (pDevicePrivateData->nAudioReadIndex == pDevicePrivateData->nAudioBufferNumOfPackets) + m_buffer.nAudioReadIndex++; + pPacketData += m_buffer.nAudioPacketSize; + if (m_buffer.nAudioReadIndex == m_buffer.nAudioBufferNumOfPackets) { - pDevicePrivateData->nAudioReadIndex = 0; - pPacketData = pDevicePrivateData->pAudioBuffer; + m_buffer.nAudioReadIndex = 0; + pPacketData = m_buffer.pAudioBuffer; } } - xnOSLeaveCriticalSection(&pDevicePrivateData->hAudioBufferCriticalSection); + xnOSLeaveCriticalSection(&m_buffer.hLock); + + ++m_nFrameID; + pStreamOutput->nFrameID = m_nFrameID; return (XN_STATUS_OK); } @@ -422,7 +432,7 @@ XnStatus XnSensorAudioStream::SetLeftChannelVolume(XnUInt32 nVolume) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_LeftChannelVolume, nVolume); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_LeftChannelVolume, (XnUInt16)nVolume); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -432,7 +442,7 @@ XnStatus XnSensorAudioStream::SetRightChannelVolume(XnUInt32 nVolume) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_RightChannelVolume, nVolume); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_RightChannelVolume, (XnUInt16)nVolume); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -467,7 +477,7 @@ XnStatus XnSensorAudioStream::ReallocBuffer() XN_PROCESS_ID procID; xnOSGetCurrentProcessID(&procID); XnChar strSharedName[XN_DEVICE_MAX_STRING_LENGTH]; - sprintf(strSharedName, "%u_%s", procID, GetName()); + sprintf(strSharedName, "%u_%s_%s", (XnUInt32)procID, m_strDeviceName, GetName()); nRetVal = m_SharedBufferName.UnsafeUpdateValue(strSharedName); XN_IS_STATUS_OK(nRetVal); @@ -475,7 +485,7 @@ XnStatus XnSensorAudioStream::ReallocBuffer() nRetVal = RequiredSizeProperty().UnsafeUpdateValue(nMaxBufferSize); XN_IS_STATUS_OK(nRetVal); - nRetVal = xnOSCreateSharedMemory(strSharedName, nSharedBufferSize, XN_OS_FILE_READ | XN_OS_FILE_WRITE, &m_hSharedMemory); + nRetVal = xnOSCreateSharedMemoryEx(strSharedName, nSharedBufferSize, XN_OS_FILE_READ | XN_OS_FILE_WRITE, m_bAllowOtherUsers, &m_hSharedMemory); XN_IS_STATUS_OK(nRetVal); XnUChar* pAddress; @@ -483,48 +493,48 @@ XnStatus XnSensorAudioStream::ReallocBuffer() XN_IS_STATUS_OK(nRetVal); m_pSharedHeader = (XnAudioSharedBuffer*)pAddress; - pDevicePrivateData->pAudioPacketsTimestamps = (XnUInt64*)(pAddress + sizeof(XnAudioSharedBuffer)); - pDevicePrivateData->pAudioBuffer = (XN_AUDIO_TYPE*)(pAddress + sizeof(XnAudioSharedBuffer) + sizeof(XnUInt64) * nMaxPacketCount); - pDevicePrivateData->nAudioBufferSize = nMaxBufferSize; + m_buffer.pAudioPacketsTimestamps = (XnUInt64*)(pAddress + sizeof(XnAudioSharedBuffer)); + m_buffer.pAudioBuffer = (XN_AUDIO_TYPE*)(pAddress + sizeof(XnAudioSharedBuffer) + sizeof(XnUInt64) * nMaxPacketCount); + m_buffer.nAudioBufferSize = nMaxBufferSize; m_pSharedHeader->nTimestampsListOffset = sizeof(XnAudioSharedBuffer); - m_pSharedHeader->nBufferOffset = pDevicePrivateData->pAudioBuffer - pAddress; + m_pSharedHeader->nBufferOffset = (XnUInt32)(m_buffer.pAudioBuffer - pAddress); } // calculate current packet size - pDevicePrivateData->nAudioPacketSize = m_nOrigAudioPacketSize; + m_buffer.nAudioPacketSize = m_nOrigAudioPacketSize; if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_2 && GetNumberOfChannels() == 1) { - pDevicePrivateData->nAudioPacketSize /= 2; + m_buffer.nAudioPacketSize /= 2; } - pDevicePrivateData->nAudioBufferNumOfPackets = pDevicePrivateData->nAudioBufferSize / pDevicePrivateData->nAudioPacketSize; - pDevicePrivateData->nAudioBufferSize = pDevicePrivateData->nAudioBufferNumOfPackets * pDevicePrivateData->nAudioPacketSize; + m_buffer.nAudioBufferNumOfPackets = m_buffer.nAudioBufferSize / m_buffer.nAudioPacketSize; + m_buffer.nAudioBufferSize = m_buffer.nAudioBufferNumOfPackets * m_buffer.nAudioPacketSize; - m_pSharedHeader->nPacketCount = pDevicePrivateData->nAudioBufferNumOfPackets; - m_pSharedHeader->nPacketSize = pDevicePrivateData->nAudioPacketSize; + m_pSharedHeader->nPacketCount = m_buffer.nAudioBufferNumOfPackets; + m_pSharedHeader->nPacketSize = m_buffer.nAudioPacketSize; // set read and write indices - pDevicePrivateData->nAudioReadIndex = 0; - pDevicePrivateData->nAudioWriteIndex = 0; + m_buffer.nAudioReadIndex = 0; + m_buffer.nAudioWriteIndex = 0; return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetLeftChannelVolumeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetLeftChannelVolumeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorAudioStream* pThis = (XnSensorAudioStream*)pCookie; return pThis->SetLeftChannelVolume((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetRightChannelVolumeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetRightChannelVolumeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorAudioStream* pThis = (XnSensorAudioStream*)pCookie; return pThis->SetRightChannelVolume((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorAudioStream::SetActualReadCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorAudioStream* pThis = (XnSensorAudioStream*)pCookie; return pThis->SetActualRead(nValue == TRUE); diff --git a/Source/XnDeviceSensorV2/XnSensorAudioStream.h b/Source/XnDeviceSensorV2/XnSensorAudioStream.h index 0b4e1de..e3ec37e 100644 --- a/Source/XnDeviceSensorV2/XnSensorAudioStream.h +++ b/Source/XnDeviceSensorV2/XnSensorAudioStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_AUDIO_STREAM_H__ #define __XN_SENSOR_AUDIO_STREAM_H__ @@ -32,7 +27,15 @@ //--------------------------------------------------------------------------- #include #include "XnSensorStreamHelper.h" -#include "XnSharedMemoryBufferPool.h" + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_AUDIO_STREAM_DEFAULT_VOLUME 12 +#define XN_AUDIO_STREAM_DEFAULT_SAMPLE_RATE 48000 +#define XN_AUDIO_STREAM_DEFAULT_NUMBER_OF_CHANNELS 2 +#define XN_AUDIO_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_PCM +#define XN_AUDIO_STREAM_DEFAULT_CHUNK_SIZE 2120 //--------------------------------------------------------------------------- // XnSensorAudioStream class @@ -40,7 +43,7 @@ class XnSensorAudioStream : public XnAudioStream, public IXnSensorStream { public: - XnSensorAudioStream(const XnChar* StreamName, XnSensorObjects* pObjects); + XnSensorAudioStream(const XnChar* strDeviceName, const XnChar* StreamName, XnSensorObjects* pObjects, XnBool bAllowOtherUsers); ~XnSensorAudioStream() { Free(); } //--------------------------------------------------------------------------- @@ -65,11 +68,10 @@ class XnSensorAudioStream : public XnAudioStream, public IXnSensorStream XnStatus CreateDataProcessor(XnDataProcessor** ppProcessor); XnStatus MapPropertiesToFirmware(); void GetFirmwareStreamConfig(XnResolutions* pnRes, XnUInt32* pnFPS) { *pnRes = XN_RESOLUTION_CUSTOM; *pnFPS = 0; } - XnSharedMemoryBufferPool* GetSharedMemoryBuffer() { return NULL; } - XnStatus WriteImpl(XnStreamData* pStreamData) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } + XnStatus WriteImpl(XnStreamData* /*pStreamData*/) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } XnStatus ReadImpl(XnStreamData* pStreamOutput); - XnStatus Mirror(XnStreamData* pStreamOutput) const { return XN_STATUS_OK; } + XnStatus Mirror(XnStreamData* /*pStreamOutput*/) const { return XN_STATUS_OK; } //--------------------------------------------------------------------------- // Setters @@ -102,6 +104,10 @@ class XnSensorAudioStream : public XnAudioStream, public IXnSensorStream //--------------------------------------------------------------------------- XnSensorStreamHelper m_Helper; + XnDeviceAudioBuffer m_buffer; + + const XnChar* m_strDeviceName; + XnBool m_bAllowOtherUsers; XnActualStringProperty m_SharedBufferName; XnActualIntProperty m_LeftChannelVolume; XnActualIntProperty m_RightChannelVolume; @@ -112,6 +118,7 @@ class XnSensorAudioStream : public XnAudioStream, public IXnSensorStream XN_SHARED_MEMORY_HANDLE m_hSharedMemory; XnAudioSharedBuffer* m_pSharedHeader; + XnUInt32 m_nFrameID; }; #endif //__XN_SENSOR_AUDIO_STREAM_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorClient.cpp b/Source/XnDeviceSensorV2/XnSensorClient.cpp index 8bb6320..269ddda 100644 --- a/Source/XnDeviceSensorV2/XnSensorClient.cpp +++ b/Source/XnDeviceSensorV2/XnSensorClient.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -49,13 +43,6 @@ //--------------------------------------------------------------------------- // XnSensorClient class //--------------------------------------------------------------------------- -XnChar XnSensorClient::ms_strDir[XN_FILE_MAX_PATH]; - -XnStatus XnSensorClient::TakeServerLocation() -{ - return xnOSGetCurrentDir(ms_strDir, XN_FILE_MAX_PATH); -} - XnSensorClient::XnSensorClient() : XnStreamReaderDevice(XN_DEVICE_NAME, XN_SENSOR_SERVER_MAX_MESSAGE_SIZE), m_hSocket(NULL), @@ -64,12 +51,13 @@ XnSensorClient::XnSensorClient() : m_pOutgoingPacker(NULL), m_bShouldRun(TRUE), m_bConnected(TRUE), - m_pThis(this), - m_InstancePointer(XN_SENSOR_PROPERTY_INSTANCE_POINTER, &m_pThis, sizeof(m_pThis), NULL), + m_InstancePointer(XN_SENSOR_PROPERTY_INSTANCE_POINTER), m_ErrorState(XN_MODULE_PROPERTY_ERROR_STATE, XN_STATUS_OK), - m_hLock(NULL) + m_hLock(NULL), + m_bAllowServerFromOtherUser(FALSE) { strcpy(m_strConfigDir, "."); + m_InstancePointer.UpdateGetCallback(GetInstanceCallback, this); } XnSensorClient::~XnSensorClient() @@ -79,6 +67,7 @@ XnSensorClient::~XnSensorClient() void XnSensorClient::SetConfigDir(const XnChar* strConfigDir) { strcpy(m_strConfigDir, strConfigDir); + XnSensor::ResolveGlobalConfigFileName(m_strConfigFile, sizeof(m_strConfigFile), strConfigDir); } XnStatus XnSensorClient::GetDefinition(XnDeviceDefinition* pDeviceDefinition) @@ -98,8 +87,6 @@ XnStatus XnSensorClient::Init(const XnDeviceConfig* pDeviceConfig) nRetVal = XnStreamReaderDevice::Init(pDeviceConfig); XN_IS_STATUS_OK(nRetVal); - m_pThis = this; - return (XN_STATUS_OK); } @@ -109,10 +96,16 @@ XnStatus XnSensorClient::InitImpl(const XnDeviceConfig* pDeviceConfig) XN_MUTEX_HANDLE hServerRunningMutex = NULL; XnOSEvent serverRunningEvent; - nRetVal = serverRunningEvent.Open(XN_SENSOR_SERVER_RUNNING_EVENT_NAME); + XnUInt32 nValue; + if (XN_STATUS_OK == xnOSReadIntFromINI(m_strConfigFile, XN_SENSOR_SERVER_CONFIG_FILE_SECTION, XN_MODULE_PROPERTY_ENABLE_MULTI_USERS, &nValue)) + { + m_bAllowServerFromOtherUser = (nValue == TRUE); + } + + nRetVal = serverRunningEvent.Open(XN_SENSOR_SERVER_RUNNING_EVENT_NAME, m_bAllowServerFromOtherUser); if (nRetVal != XN_STATUS_OK) { - nRetVal = serverRunningEvent.Create(XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE); + nRetVal = serverRunningEvent.Create(XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE, m_bAllowServerFromOtherUser); if (nRetVal != XN_STATUS_OK) { xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to create server running event: %s", xnGetStatusString(nRetVal)); @@ -120,7 +113,7 @@ XnStatus XnSensorClient::InitImpl(const XnDeviceConfig* pDeviceConfig) } } - nRetVal = xnOSCreateNamedMutex(&hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME); + nRetVal = xnOSCreateNamedMutexEx(&hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME, m_bAllowServerFromOtherUser); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSLockMutex(hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT); @@ -739,7 +732,7 @@ XnStatus XnSensorClient::CreateIOStreamImpl(const XnChar *strConnectionString, X } // send server a request to open the sensor - nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR, strConnectionString, strlen(strConnectionString) + 1); + nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR, strConnectionString, (XnUInt32)strlen(strConnectionString) + 1); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pNetworkStream); @@ -785,13 +778,15 @@ XnStatus XnSensorClient::CreateDeviceModule(XnDeviceModuleHolder** ppModuleHolde XnStatus XnSensorClient::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { - XnStatus nRetVal = XN_STATUS_OK; - XnSensorClientStream* pStream; if (strcmp(StreamType, XN_STREAM_TYPE_AUDIO) == 0) { XN_VALIDATE_NEW(pStream, XnSensorClientAudioStream, this, StreamType, StreamName); } + else if (strcmp(StreamType, XN_STREAM_TYPE_DEPTH) == 0) + { + XN_VALIDATE_NEW(pStream, XnSensorClientDepthStream, this, StreamType, StreamName); + } else { XN_VALIDATE_NEW(pStream, XnSensorClientFrameStream, this, StreamType, StreamName); @@ -856,30 +851,52 @@ XN_THREAD_PROC XnSensorClient::ListenThread(XN_THREAD_PARAM pThreadParam) XN_THREAD_PROC_RETURN(nRetVal); } +#if (XN_PLATFORM == XN_PLATFORM_WIN32) +static XnStatus GetModuleDir(XnChar* strBuffer) +{ + // get current module handle + HMODULE hModule; + BOOL bRes = GetModuleHandleEx( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | // get by address + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, // don't increase refcount (so we don't need to release the handle) + (LPCSTR)GetModuleDir, // give any address inside this DLL + &hModule); + + if (bRes == 0) + { + return XN_STATUS_ERROR; + } + + XnChar strModuleFileName[XN_FILE_MAX_PATH]; + bRes = GetModuleFileName(hModule, strModuleFileName, XN_FILE_MAX_PATH); + if (bRes == 0) + { + return XN_STATUS_ERROR; + } + + return xnOSGetDirName(strModuleFileName, strBuffer, XN_FILE_MAX_PATH); +} +#endif + XnStatus XnSensorClient::StartServerProcess() { XnStatus nRetVal = XN_STATUS_OK; - const XnChar* strServerDir; + XnChar strServerDir[XN_FILE_MAX_PATH]; #if (XN_PLATFORM == XN_PLATFORM_WIN32) - strServerDir = ms_strDir; -#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM) - strServerDir = "/usr/bin"; + nRetVal = GetModuleDir(strServerDir); +#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_MACOSX) + sprintf(strServerDir, "/usr/bin"); #endif - // we'll start it in it's directory - XnChar strCurrDir[XN_FILE_MAX_PATH]; - nRetVal = xnOSGetCurrentDir(strCurrDir, XN_FILE_MAX_PATH); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = xnOSSetCurrentDir(strServerDir); - XN_IS_STATUS_OK(nRetVal); - XnChar strProcessName[XN_FILE_MAX_PATH]; sprintf(strProcessName, "%s%sXnSensorServer", strServerDir, XN_FILE_DIR_SEP); #if (XN_PLATFORM == XN_PLATFORM_WIN32) + #ifdef _M_X64 + XN_VALIDATE_STR_APPEND(strProcessName, "64", XN_FILE_MAX_PATH, nRetVal); + #endif XN_VALIDATE_STR_APPEND(strProcessName, ".exe", XN_FILE_MAX_PATH, nRetVal); #endif @@ -887,13 +904,19 @@ XnStatus XnSensorClient::StartServerProcess() XN_PROCESS_ID procID; nRetVal = xnOSCreateProcess(strProcessName, 1, strArguments, &procID); - - // in any case, return to working dir - xnOSSetCurrentDir(strCurrDir); - - // now check for errors XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } +XnStatus XN_CALLBACK_TYPE XnSensorClient::GetInstanceCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + if (gbValue.nDataSize != sizeof(void*)) + { + return XN_STATUS_DEVICE_PROPERTY_SIZE_DONT_MATCH; + } + + *(void**)gbValue.pData = pCookie; + return XN_STATUS_OK; +} + diff --git a/Source/XnDeviceSensorV2/XnSensorClient.h b/Source/XnDeviceSensorV2/XnSensorClient.h index 09b1fb6..161d346 100644 --- a/Source/XnDeviceSensorV2/XnSensorClient.h +++ b/Source/XnDeviceSensorV2/XnSensorClient.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_CLIENT_H__ #define __XN_SENSOR_CLIENT_H__ @@ -64,8 +59,7 @@ class XnSensorClient : public XnStreamReaderDevice XnStatus Read(XnStreamDataSet* pStreamOutputSet); void SetConfigDir(const XnChar* strConfigDir); - - static XnStatus TakeServerLocation(); + XnBool IsServerFromOtherUserAllowed() { return m_bAllowServerFromOtherUser; } protected: XnStatus SendBye(); @@ -92,6 +86,7 @@ class XnSensorClient : public XnStreamReaderDevice XnStatus StartServerProcess(); static XN_THREAD_PROC ListenThread(XN_THREAD_PARAM pThreadParam); + static XnStatus XN_CALLBACK_TYPE GetInstanceCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); XN_SOCKET_HANDLE m_hSocket; XN_EVENT_HANDLE m_hReplyEvent; @@ -101,14 +96,13 @@ class XnSensorClient : public XnStreamReaderDevice XnSensorClientServerReply m_LastReply; XnBool m_bConnected; - XnSensorClient* m_pThis; - XnActualGeneralProperty m_InstancePointer; + XnGeneralProperty m_InstancePointer; XnActualIntProperty m_ErrorState; XN_CRITICAL_SECTION_HANDLE m_hLock; XnChar m_strConfigDir[XN_FILE_MAX_PATH]; - - static XnChar ms_strDir[]; + XnChar m_strConfigFile[XN_FILE_MAX_PATH]; + XnBool m_bAllowServerFromOtherUser; }; #endif //__XN_SENSOR_CLIENT_H__ diff --git a/Source/XnDeviceSensorV2/XnSensorClientServer.h b/Source/XnDeviceSensorV2/XnSensorClientServer.h index cfb06c6..ea3579b 100644 --- a/Source/XnDeviceSensorV2/XnSensorClientServer.h +++ b/Source/XnDeviceSensorV2/XnSensorClientServer.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_CLIENT_SERVER_H__ #define __XN_SENSOR_CLIENT_SERVER_H__ @@ -45,6 +40,7 @@ #define XN_MASK_SENSOR_SERVER "SensorServer" #define XN_SENSOR_SERVER_RUNNING_EVENT_NAME "XnSensorServerRunningEvent" #define XN_SENSOR_SERVER_RUNNING_MUTEX_NAME "XnSensorServerRunningMutex" +#define XN_SENSOR_SERVER_CONFIG_FILE_SECTION "Server" //--------------------------------------------------------------------------- // Enums diff --git a/Source/XnDeviceSensorV2/XnSensorClientStream.cpp b/Source/XnDeviceSensorV2/XnSensorClientStream.cpp index c37bfe6..72b640d 100644 --- a/Source/XnDeviceSensorV2/XnSensorClientStream.cpp +++ b/Source/XnDeviceSensorV2/XnSensorClientStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -62,7 +56,7 @@ XnStatus XnSensorClientStream::OpenSharedMemory() nRetVal = GetProperty(XN_STREAM_PROPERTY_SHARED_BUFFER_NAME, strSharedMemoryName); XN_IS_STATUS_OK(nRetVal); - nRetVal = xnOSOpenSharedMemory(strSharedMemoryName, XN_OS_FILE_READ, &m_hSharedMemory); + nRetVal = xnOSOpenSharedMemoryEx(strSharedMemoryName, XN_OS_FILE_READ, m_pClient->IsServerFromOtherUserAllowed(), &m_hSharedMemory); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSSharedMemoryGetAddress(m_hSharedMemory, (void**)&m_pSharedMemory); @@ -75,7 +69,7 @@ XnStatus XnSensorClientStream::Open() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM, GetName(), strlen(GetName()) + 1); + nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM, GetName(), (XnUInt32)strlen(GetName()) + 1); XN_IS_STATUS_OK(nRetVal); // wait for reply @@ -93,7 +87,7 @@ XnStatus XnSensorClientStream::Close() XnStatus nRetVal = XN_STATUS_OK; // read data from server - nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM, GetName(), strlen(GetName()) + 1); + nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM, GetName(), (XnUInt32)strlen(GetName()) + 1); XN_IS_STATUS_OK(nRetVal); // wait for reply @@ -108,8 +102,6 @@ XnStatus XnSensorClientStream::Close() XnStatus XnSensorClientStream::Free() { - XnStatus nRetVal = XN_STATUS_OK; - if (m_hSharedMemory != NULL) { xnOSCloseSharedMemory(m_hSharedMemory); @@ -137,7 +129,7 @@ XnStatus XnSensorClientFrameStream::ReadImpl(XnStreamData* pStreamOutput) XnStatus nRetVal = XN_STATUS_OK; // read data from server - nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, pStreamOutput->StreamName, strlen(pStreamOutput->StreamName) + 1); + nRetVal = m_pClient->m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, pStreamOutput->StreamName, (XnUInt32)strlen(pStreamOutput->StreamName) + 1); XN_IS_STATUS_OK(nRetVal); // wait for reply @@ -173,6 +165,53 @@ XnStatus XnSensorClientFrameStream::CreateStreamData(XnStreamData** ppStreamData return (XN_STATUS_OK); } +//--------------------------------------------------------------------------- +// Client Depth Stream +//--------------------------------------------------------------------------- +XnSensorClientDepthStream::XnSensorClientDepthStream(XnSensorClient* pClient, const XnChar* strType, const XnChar* strName) : + XnSensorClientFrameStream(pClient, strType, strName) +{} + +XnSensorClientDepthStream::~XnSensorClientDepthStream() +{} + + +XnStatus XnSensorClientDepthStream::ReadImpl(XnStreamData* pStreamOutput) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnSensorClientFrameStream::ReadImpl(pStreamOutput); + XN_IS_STATUS_OK(nRetVal); + + m_pLastFrameShiftsMapOffset = (XnUInt16*)(((XnUInt8*)pStreamOutput->pData) + pStreamOutput->nDataSize); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorClientDepthStream::GetProperty(const XnChar* strName, const XnGeneralBuffer& gbValue) const +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (strcmp(strName, XN_STREAM_PROPERTY_SHIFTS_MAP) == 0) + { + // shifts-map is at the end of the depth map + if (gbValue.nDataSize != sizeof(m_pLastFrameShiftsMapOffset)) + { + return XN_STATUS_DEVICE_PROPERTY_SIZE_DONT_MATCH; + } + + const XnUInt16** ppShiftsMap = (const XnUInt16**)gbValue.pData; + *ppShiftsMap = m_pLastFrameShiftsMapOffset; + } + else + { + nRetVal = XnSensorClientFrameStream::GetProperty(strName, gbValue); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + //--------------------------------------------------------------------------- // Client Audio Stream //--------------------------------------------------------------------------- @@ -180,12 +219,44 @@ XnSensorClientAudioStream::XnSensorClientAudioStream(XnSensorClient* pClient, co XnSensorClientStream(pClient, strType, strName), m_pHeader(NULL), m_pBuffer(NULL), - m_nLastReadIndex(0) + m_nLastReadIndex(0), + m_hLock(NULL), + m_nFrameID(0), + m_pTimestamps(NULL) {} XnSensorClientAudioStream::~XnSensorClientAudioStream() {} +XnStatus XnSensorClientAudioStream::Init() +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnSensorClientStream::Init(); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateCriticalSection(&m_hLock); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorClientAudioStream::Free() +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_hLock != NULL) + { + xnOSCloseCriticalSection(&m_hLock); + m_hLock = NULL; + } + + nRetVal = XnSensorClientStream::Free(); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + XnStatus XnSensorClientAudioStream::OpenSharedMemory() { XnStatus nRetVal = XN_STATUS_OK; @@ -200,17 +271,26 @@ XnStatus XnSensorClientAudioStream::OpenSharedMemory() return (XN_STATUS_OK); } +void XnSensorClientAudioStream::NewDataAvailable(XnUInt64 /*nTimestamp*/, XnUInt32 /*nFrameID*/) +{ + // if a read is in progress, wait for it to complete + XnAutoCSLocker locker(m_hLock); + + // check if we still have new data + if (m_pHeader->nWritePacketIndex != m_nLastReadIndex) + { + XnSensorClientStream::NewDataAvailable(m_pTimestamps[m_nLastReadIndex], 0); + } +} + XnStatus XnSensorClientAudioStream::ReadImpl(XnStreamData* pStreamOutput) { - XnStatus nRetVal = XN_STATUS_OK; - pStreamOutput->nDataSize = 0; - // take last write index - XnUInt32 nWriteIndex = m_pHeader->nWritePacketIndex; + // take last write index (note: this is taken from shared memory) + XnAutoCSLocker locker(m_hLock); - // take timestamp - pStreamOutput->nTimestamp = m_pTimestamps[m_nLastReadIndex]; + XnUInt32 nWriteIndex = m_pHeader->nWritePacketIndex; // check how many buffers we have XnInt32 nAvailbalePackets = nWriteIndex - m_nLastReadIndex; @@ -224,6 +304,9 @@ XnStatus XnSensorClientAudioStream::ReadImpl(XnStreamData* pStreamOutput) nAvailbalePackets--; } + // take timestamp + pStreamOutput->nTimestamp = m_pTimestamps[m_nLastReadIndex]; + // now copy data from last read position to this one XnUChar* pAudioBuf = (XnUChar*)pStreamOutput->pData; @@ -240,5 +323,9 @@ XnStatus XnSensorClientAudioStream::ReadImpl(XnStreamData* pStreamOutput) m_nLastReadIndex = (m_nLastReadIndex + 1) % m_pHeader->nPacketCount; } + m_nFrameID++; + pStreamOutput->nFrameID = m_nFrameID; + return (XN_STATUS_OK); } + diff --git a/Source/XnDeviceSensorV2/XnSensorClientStream.h b/Source/XnDeviceSensorV2/XnSensorClientStream.h index 3e12afc..3029848 100644 --- a/Source/XnDeviceSensorV2/XnSensorClientStream.h +++ b/Source/XnDeviceSensorV2/XnSensorClientStream.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_CLIENT_STREAM_H__ #define __XN_SENSOR_CLIENT_STREAM_H__ @@ -74,6 +68,23 @@ class XnSensorClientFrameStream : public XnSensorClientStream XnUInt32 m_nFrameID; }; +//--------------------------------------------------------------------------- +// Client Depth Stream +//--------------------------------------------------------------------------- +class XnSensorClientDepthStream : public XnSensorClientFrameStream +{ +public: + XnSensorClientDepthStream(XnSensorClient* pClient, const XnChar* strType, const XnChar* strName); + ~XnSensorClientDepthStream(); + +protected: + XnStatus ReadImpl(XnStreamData* pStreamOutput); + virtual XnStatus GetProperty(const XnChar* strName, const XnGeneralBuffer& gbValue) const; + +private: + XnUInt16* m_pLastFrameShiftsMapOffset; +}; + //--------------------------------------------------------------------------- // Client Audio Stream //--------------------------------------------------------------------------- @@ -83,16 +94,23 @@ class XnSensorClientAudioStream : public XnSensorClientStream XnSensorClientAudioStream(XnSensorClient* pClient, const XnChar* strType, const XnChar* strName); ~XnSensorClientAudioStream(); + XnStatus Init(); + XnStatus Free(); + XnStatus OpenSharedMemory(); + virtual void NewDataAvailable(XnUInt64 nTimestamp, XnUInt32 nFrameID); + protected: XnStatus ReadImpl(XnStreamData* pStreamOutput); private: + XnUInt32 m_nFrameID; XnAudioSharedBuffer* m_pHeader; XnUChar* m_pBuffer; XnUInt32 m_nLastReadIndex; XnUInt64* m_pTimestamps; + XN_CRITICAL_SECTION_HANDLE m_hLock; }; #endif // __XN_SENSOR_CLIENT_STREAM_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp index 6c742d8..546b3f7 100644 --- a/Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,7 +26,7 @@ #include #include #include -#include +#include #include //--------------------------------------------------------------------------- @@ -40,13 +34,14 @@ //--------------------------------------------------------------------------- XnSensorDepthGenerator::XnSensorDepthGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) : - XnSensorMapGenerator(context, sensor, pSensor, strStreamName) + XnSensorMapGenerator(context, sensor, pSensor, strStreamName), + m_hRWPropCallback(NULL) { } XnSensorDepthGenerator::~XnSensorDepthGenerator() { - if (m_hRWPropCallback) + if (m_hRWPropCallback != NULL) { UnregisterFromProps(m_hRWPropCallback); } @@ -108,7 +103,7 @@ void XnSensorDepthGenerator::GetFieldOfView(XnFieldOfView& FOV) XnStatus XnSensorDepthGenerator::RegisterToFieldOfViewChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) { - return m_fovChangedEvent.Register(handler, pCookie, &hCallback); + return m_fovChangedEvent.Register(handler, pCookie, hCallback); } void XnSensorDepthGenerator::UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback) @@ -152,9 +147,9 @@ XnStatus XnSensorDepthGenerator::SetUserPosition(XnUInt32 nIndex, const XnBoundi { // set (we only support Z boxing for now) XnDepthAGCBin bin; - bin.nBin = nIndex; - bin.nMin = Position.LeftBottomNear.Z; - bin.nMax = Position.RightTopFar.Z; + bin.nBin = (XnUInt16)nIndex; + bin.nMin = (XnUInt16)Position.LeftBottomNear.Z; + bin.nMax = (XnUInt16)Position.RightTopFar.Z; return m_pSensor->SetProperty(m_strModule, XN_STREAM_PROPERTY_AGC_BIN, XN_PACK_GENERAL_BUFFER(bin)); } @@ -164,7 +159,7 @@ XnStatus XnSensorDepthGenerator::GetUserPosition(XnUInt32 nIndex, XnBoundingBox3 // get XnDepthAGCBin bin; - bin.nBin = nIndex; + bin.nBin = (XnUInt16)nIndex; nRetVal = m_pSensor->GetProperty(m_strModule, XN_STREAM_PROPERTY_AGC_BIN, XN_PACK_GENERAL_BUFFER(bin)); XN_IS_STATUS_OK(nRetVal); @@ -176,9 +171,9 @@ XnStatus XnSensorDepthGenerator::GetUserPosition(XnUInt32 nIndex, XnBoundingBox3 Position.LeftBottomNear.Z = bin.nMin; Position.RightTopFar.Z = bin.nMax; Position.LeftBottomNear.X = 0; - Position.RightTopFar.X = MapOutputMode.nXRes - 1; + Position.RightTopFar.X = (XnFloat)(MapOutputMode.nXRes - 1); Position.LeftBottomNear.Y = 0; - Position.RightTopFar.Y = MapOutputMode.nYRes - 1; + Position.RightTopFar.Y = (XnFloat)(MapOutputMode.nYRes - 1); return (XN_STATUS_OK); } @@ -295,8 +290,9 @@ XnStatus XnSensorDepthGenerator::FrameSyncWith(xn::ProductionNode& OtherNode) } } -XnStatus XnSensorDepthGenerator::StopFrameSyncWith(xn::ProductionNode& OtherNode) +XnStatus XnSensorDepthGenerator::StopFrameSyncWith(xn::ProductionNode& /*OtherNode*/) { + // we assume the other node is the image one (this is the only one we started) return m_pSensor->SetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, (XnUInt64)FALSE); } diff --git a/Source/XnDeviceSensorV2/XnSensorDepthGenerator.h b/Source/XnDeviceSensorV2/XnSensorDepthGenerator.h index 33b2ee7..66b6f50 100644 --- a/Source/XnDeviceSensorV2/XnSensorDepthGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorDepthGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_DEPTH_GENERATOR_H__ #define __XN_SENSOR_DEPTH_GENERATOR_H__ @@ -33,10 +27,15 @@ //--------------------------------------------------------------------------- #include "XnSensorMapGenerator.h" #include "XnExportedSensorGenerator.h" +#include //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorDepthGenerator : public XnSensorMapGenerator, virtual public xn::ModuleDepthGenerator, @@ -52,6 +51,7 @@ class XnSensorDepthGenerator : XnBool IsCapabilitySupported(const XnChar* strCapabilityName); + const void* GetData() { return XnSensorMapGenerator::GetData(); } XnDepthPixel* GetDepthMap(); XnDepthPixel GetDeviceMaxDepth(); void GetFieldOfView(XnFieldOfView& FOV); @@ -90,8 +90,7 @@ class XnSensorDepthGenerator : static void XN_CALLBACK_TYPE RealWorldTranslationPropChanged(void* pCookie); - XN_DECLARE_EVENT_0ARG(PropChangeEvent, PropChangeEventInterface); - PropChangeEvent m_fovChangedEvent; + XnEventNoArgs m_fovChangedEvent; XnCallbackHandle m_hRWPropCallback; @@ -105,5 +104,6 @@ class XnExportedSensorDepthGenerator : public XnExportedSensorGenerator virtual XnSensorGenerator* CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); }; +#pragma warning (pop) #endif // __XN_SENSOR_DEPTH_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorDepthStream.cpp b/Source/XnDeviceSensorV2/XnSensorDepthStream.cpp index 7a42535..c9a9688 100644 --- a/Source/XnDeviceSensorV2/XnSensorDepthStream.cpp +++ b/Source/XnDeviceSensorV2/XnSensorDepthStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -33,28 +27,18 @@ #include "XnUncompressedDepthProcessor.h" #include "XnPSCompressedDepthProcessor.h" #include "XnPacked11DepthProcessor.h" +#include "XnPacked12DepthProcessor.h" #include "Registration.h" #include "XnCmosInfo.h" #include #include #include +#include "XnSensor.h" //--------------------------------------------------------------------------- // Defines //--------------------------------------------------------------------------- -#define XN_DEPTH_STREAM_DEFAULT_INPUT_FORMAT XN_IO_DEPTH_FORMAT_COMPRESSED_PS -#define XN_DEPTH_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_QVGA -#define XN_DEPTH_STREAM_DEFAULT_FPS 30 -#define XN_DEPTH_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_DEPTH_VALUES -#define XN_DEPTH_STREAM_DEFAULT_REGISTRATION FALSE -#define XN_DEPTH_STREAM_DEFAULT_REGISTRATION_TYPE XN_PROCESSING_DONT_CARE -#define XN_DEPTH_STREAM_DEFAULT_HOLE_FILLER TRUE -#define XN_DEPTH_STREAM_DEFAULT_WHITE_BALANCE TRUE -#define XN_DEPTH_STREAM_DEFAULT_GAIN_OLD 50 -#define XN_DEPTH_STREAM_DEFAULT_GMC_MODE TRUE - - #define XN_SHIFTS_MAX_SHIFT 2047 #define XN_SHIFTS_PIXEL_SIZE_FACTOR 1 #define XN_SHIFTS_PARAM_COEFFICIENT 4 @@ -62,16 +46,12 @@ #define XN_DEPTH_STREAM_AGC_NUMBER_OF_BINS 4 -#define XN_DEPTH_MAX_BUFFER_SIZE (XN_VGA_X_RES * XN_VGA_Y_RES * sizeof(XnDepthPixel)) - //--------------------------------------------------------------------------- // XnSensorDepthStream class //--------------------------------------------------------------------------- -XnSensorDepthStream::XnSensorDepthStream(const XnChar* strName, XnSensorObjects* pObjects, XnUInt32 nBufferCount) : +XnSensorDepthStream::XnSensorDepthStream(const XnChar* strName, XnSensorObjects* pObjects) : XnDepthStream(strName, FALSE, XN_DEVICE_SENSOR_MAX_DEPTH, XN_SHIFTS_MAX_SHIFT), m_Helper(pObjects), - m_BufferPool(nBufferCount, strName, XN_DEPTH_MAX_BUFFER_SIZE), - m_SharedBufferName(XN_STREAM_PROPERTY_SHARED_BUFFER_NAME, m_BufferPool.GetSharedMemoryName()), m_InputFormat(XN_STREAM_PROPERTY_INPUT_FORMAT, XN_DEPTH_STREAM_DEFAULT_INPUT_FORMAT), m_DepthRegistration(XN_STREAM_PROPERTY_REGISTRATION, XN_DEPTH_STREAM_DEFAULT_REGISTRATION), m_HoleFilter(XN_STREAM_PROPERTY_HOLE_FILTER, XN_DEPTH_STREAM_DEFAULT_HOLE_FILLER), @@ -80,6 +60,9 @@ XnSensorDepthStream::XnSensorDepthStream(const XnChar* strName, XnSensorObjects* m_RegistrationType(XN_STREAM_PROPERTY_REGISTRATION_TYPE, XN_DEPTH_STREAM_DEFAULT_REGISTRATION_TYPE), m_AGCBin(XN_STREAM_PROPERTY_AGC_BIN, NULL, ReadAGCBinsFromFile), m_GMCMode(XN_STREAM_PROPERTY_GMC_MODE, XN_DEPTH_STREAM_DEFAULT_GMC_MODE), + m_CloseRange(XN_STREAM_PROPERTY_CLOSE_RANGE, XN_DEPTH_STREAM_DEFAULT_CLOSE_RANGE), + m_ShiftsMap(XN_STREAM_PROPERTY_SHIFTS_MAP), + m_pLastFrameShiftsMap(NULL), m_FirmwareMirror("FirmwareMirror", FALSE, strName), m_FirmwareRegistration("FirmwareRegistration", FALSE, strName), m_FirmwareCropSizeX("FirmwareCropSizeX", 0, strName), @@ -97,8 +80,8 @@ XnStatus XnSensorDepthStream::Init() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = SetBufferPool(&m_BufferPool); - XN_IS_STATUS_OK(nRetVal); +// nRetVal = SetBufferPool(&m_BufferPool); +// XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnDepthStream::Init(); @@ -113,12 +96,20 @@ XnStatus XnSensorDepthStream::Init() m_AGCBin.UpdateSetCallback(SetAGCBinCallback, this); m_AGCBin.UpdateGetCallback(GetAGCBinCallback, this); m_GMCMode.UpdateSetCallback(SetGMCModeCallback, this); + m_CloseRange.UpdateSetCallback(SetCloseRangeCallback, this); + m_ShiftsMap.UpdateGetCallback(GetShiftsMapCallback, this); XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_DepthRegistration, &m_HoleFilter, - &m_WhiteBalance, &m_Gain, &m_AGCBin, &m_SharedBufferName, &m_ActualRead, &m_GMCMode, - &m_RegistrationType, - ); + &m_WhiteBalance, &m_Gain, &m_AGCBin, &m_ActualRead, &m_GMCMode, + &m_CloseRange, &m_RegistrationType, &m_ShiftsMap); + + + if (m_Helper.GetPrivateData()->pSensor->IsLowBandwidth()) + { + nRetVal = m_InputFormat.UnsafeUpdateValue(XN_IO_DEPTH_FORMAT_COMPRESSED_PS); + XN_IS_STATUS_OK(nRetVal); + } // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_DEPTH_STREAM_DEFAULT_RESOLUTION); @@ -153,19 +144,24 @@ XnStatus XnSensorDepthStream::Init() nRetVal = EmitterDCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetEmitterDCmosDistance()); XN_IS_STATUS_OK(nRetVal); + nRetVal = GetDCmosRCmosDistanceProperty().UnsafeUpdateValue(m_Helper.GetFixedParams()->GetDCmosRCmosDistance()); + XN_IS_STATUS_OK(nRetVal); + // init helper nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_3_0) { - XN_IS_STATUS_OK(m_GMCMode.UnsafeUpdateValue(FALSE)); + nRetVal = m_GMCMode.UnsafeUpdateValue(FALSE); + XN_IS_STATUS_OK(nRetVal); } if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_4_0) { - XN_IS_STATUS_OK(m_WhiteBalance.UnsafeUpdateValue(FALSE)); + nRetVal = m_WhiteBalance.UnsafeUpdateValue(FALSE); + XN_IS_STATUS_OK(nRetVal); } // on old firmwares, the host decides on the default gain. On new firmwares, we read it from firmware @@ -177,7 +173,7 @@ XnStatus XnSensorDepthStream::Init() // registration XnCallbackHandle hCallbackDummy; - nRetVal = ResolutionProperty().OnChangeEvent().Register(DecideFirmwareRegistrationCallback, this, &hCallbackDummy); + nRetVal = ResolutionProperty().OnChangeEvent().Register(DecideFirmwareRegistrationCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = DecideFirmwareRegistration((XnBool)m_DepthRegistration.GetValue(), (XnProcessingType)m_RegistrationType.GetValue(), GetResolution()); @@ -191,13 +187,19 @@ XnStatus XnSensorDepthStream::Init() XN_IS_STATUS_OK(nRetVal); // pixel size factor - nRetVal = GetFirmwareParams()->m_ReferenceResolution.OnChangeEvent().Register(DecidePixelSizeFactorCallback, this, &m_hReferenceSizeChangedCallback); + nRetVal = GetFirmwareParams()->m_ReferenceResolution.OnChangeEvent().Register(DecidePixelSizeFactorCallback, this, m_hReferenceSizeChangedCallback); XN_IS_STATUS_OK(nRetVal); nRetVal = DecidePixelSizeFactor(); XN_IS_STATUS_OK(nRetVal); + // register supported modes + XnCmosPreset* pSupportedModes = m_Helper.GetPrivateData()->FWInfo.depthModes.GetData(); + XnUInt8 nSupportedModes = m_Helper.GetPrivateData()->FWInfo.depthModes.GetSize(); + nRetVal = AddSupportedModes(pSupportedModes, nSupportedModes); + XN_IS_STATUS_OK(nRetVal); + return (XN_STATUS_OK); } @@ -224,20 +226,36 @@ XnStatus XnSensorDepthStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_DepthFormat, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_DepthResolution, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_DepthFPS, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_HoleFilter, GetFirmwareParams()->m_DepthHoleFilter, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_DepthGain, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_WhiteBalance, GetFirmwareParams()->m_DepthWhiteBalance, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_DepthMirror, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareRegistration, GetFirmwareParams()->m_RegistrationEnabled, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_DepthCropSizeX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_DepthCropSizeY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_DepthCropOffsetX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_DepthCropOffsetY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_DepthCropEnabled, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_GMCMode, GetFirmwareParams()->m_GMCMode, TRUE)); + nRetVal = m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_DepthFormat, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_DepthResolution, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_DepthFPS, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_HoleFilter, GetFirmwareParams()->m_DepthHoleFilter, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_DepthGain, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_WhiteBalance, GetFirmwareParams()->m_DepthWhiteBalance, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_DepthMirror, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareRegistration, GetFirmwareParams()->m_RegistrationEnabled, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_DepthCropSizeX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_DepthCropSizeY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_DepthCropOffsetX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_DepthCropOffsetY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_DepthCropEnabled, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_GMCMode, GetFirmwareParams()->m_GMCMode, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_CloseRange, GetFirmwareParams()->m_DepthCloseRange, TRUE); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -251,11 +269,16 @@ XnStatus XnSensorDepthStream::ConfigureStreamImpl() nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_HoleFilter)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_Gain)); + nRetVal = m_Helper.ConfigureFirmware(m_InputFormat); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_HoleFilter); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_Gain); + XN_IS_STATUS_OK(nRetVal);; // we need to turn decimation on when resolution is QVGA, and FPS is different than 60 // NOTE: this is ugly as hell. This logic should be moved to firmware. @@ -263,14 +286,23 @@ XnStatus XnSensorDepthStream::ConfigureStreamImpl() nRetVal = GetFirmwareParams()->m_DepthDecimation.SetValue(bDecimation); XN_IS_STATUS_OK(nRetVal); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareRegistration)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_GMCMode)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_WhiteBalance)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareRegistration); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareMirror); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_GMCMode); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_WhiteBalance); + XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.GetCmosInfo()->SetCmosConfig(XN_CMOS_TYPE_DEPTH, GetResolution(), GetFPS()); XN_IS_STATUS_OK(nRetVal); + // --avin mod-- + //Turn off the IR projector anti-cover thingy. I find it annoying and It's off on the XBox360 so it must be safe :-) + //This is probably not the best way to do it, but adding it as a real param is too much work for me at the moment... + XnHostProtocolSetParam(GetHelper()->GetPrivateData(), 0x105, 0); + return XN_STATUS_OK; } @@ -283,7 +315,8 @@ XnStatus XnSensorDepthStream::SetActualRead(XnBool bRead) if (bRead) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB depth read thread..."); - nRetVal = xnUSBInitReadThread(GetHelper()->GetPrivateData()->pSpecificDepthUsb->pUsbConnection->UsbEp, GetHelper()->GetPrivateData()->pSpecificDepthUsb->nChunkReadBytes, XN_SENSOR_USB_DEPTH_BUFFERS, XN_SENSOR_READ_THREAD_TIMEOUT, XnDeviceSensorProtocolUsbEpCb, GetHelper()->GetPrivateData()->pSpecificDepthUsb); + XnSpecificUsbDevice* pUSB = GetHelper()->GetPrivateData()->pSpecificDepthUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, XN_SENSOR_USB_DEPTH_BUFFERS, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); XN_IS_STATUS_OK(nRetVal); } else @@ -306,15 +339,24 @@ XnStatus XnSensorDepthStream::OpenStreamImpl() nRetVal = GetFirmwareParams()->m_Stream1Mode.SetValue(XN_VIDEO_STREAM_DEPTH); XN_IS_STATUS_OK(nRetVal); + // CloseRange + nRetVal = m_Helper.ConfigureFirmware(m_CloseRange); + XN_IS_STATUS_OK(nRetVal); + // Cropping if (m_FirmwareCropEnabled.GetValue() == TRUE) { - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeY)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeY); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY); + XN_IS_STATUS_OK(nRetVal);; } - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropEnabled)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropEnabled); + XN_IS_STATUS_OK(nRetVal);; nRetVal = XnDepthStream::Open(); XN_IS_STATUS_OK(nRetVal); @@ -372,7 +414,7 @@ XnStatus XnSensorDepthStream::SetMirror(XnBool bIsMirrored) // set firmware mirror XnBool bFirmwareMirror = (bIsMirrored == TRUE && m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_0); - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareMirror, bFirmwareMirror); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareMirror, (XnUInt16)bFirmwareMirror); if (nRetVal != XN_STATUS_OK) { xnOSLeaveCriticalSection(GetLock()); @@ -391,7 +433,7 @@ XnStatus XnSensorDepthStream::SetFPS(XnUInt32 nFPS) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), nFPS); + nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), (XnUInt16)nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = XnDepthStream::SetFPS(nFPS); @@ -407,16 +449,7 @@ XnStatus XnSensorDepthStream::SetResolution(XnResolutions nResolution) { XnStatus nRetVal = XN_STATUS_OK; - switch (nResolution) - { - case XN_RESOLUTION_QVGA: - case XN_RESOLUTION_VGA: - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported depth resolution: %d", nResolution); - } - - nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), nResolution); + nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), (XnUInt16)nResolution); XN_IS_STATUS_OK(nRetVal); nRetVal = XnDepthStream::SetResolution(nResolution); @@ -443,11 +476,17 @@ XnStatus XnSensorDepthStream::SetInputFormat(XnIODepthFormats nInputFormat) XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_UNSUPPORTED_MODE, XN_MASK_DEVICE_SENSOR, "11-bit depth is not supported on this sensor!"); } break; + case XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT: + if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_4_0) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_UNSUPPORTED_MODE, XN_MASK_DEVICE_SENSOR, "12-bit depth is not supported on this sensor!"); + } + break; default: XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unknown depth input format: %d", nInputFormat); } - nRetVal = m_Helper.SimpleSetFirmwareParam(m_InputFormat, nInputFormat); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_InputFormat, (XnUInt16)nInputFormat); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -473,7 +512,7 @@ XnStatus XnSensorDepthStream::SetHoleFilter(XnBool bHoleFilter) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_HoleFilter, bHoleFilter); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_HoleFilter, (XnUInt16)bHoleFilter); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -483,7 +522,7 @@ XnStatus XnSensorDepthStream::SetWhiteBalance(XnBool bWhiteBalance) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_WhiteBalance, bWhiteBalance); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_WhiteBalance, (XnUInt16)bWhiteBalance); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -493,7 +532,7 @@ XnStatus XnSensorDepthStream::SetGain(XnUInt32 nGain) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_Gain, nGain); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_Gain, (XnUInt16)nGain); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -520,7 +559,17 @@ XnStatus XnSensorDepthStream::SetGMCMode(XnBool bGMCMode) XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_GMCMode, bGMCMode); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_GMCMode, (XnUInt16)bGMCMode); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorDepthStream::SetCloseRange(XnBool bCloseRange) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_Helper.SimpleSetFirmwareParam(m_CloseRange, (XnUInt16)bCloseRange); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -531,8 +580,10 @@ XnStatus XnSensorDepthStream::SetAGCBin(const XnDepthAGCBin* pBin) { XnStatus nRetVal = XN_STATUS_OK; - XN_IS_STATUS_OK(ValidateDepthValue(pBin->nMin)); - XN_IS_STATUS_OK(ValidateDepthValue(pBin->nMax)); + nRetVal = ValidateDepthValue(pBin->nMin); + XN_IS_STATUS_OK(nRetVal); + nRetVal = ValidateDepthValue(pBin->nMax); + XN_IS_STATUS_OK(nRetVal); // translate to shifts XnUInt16* pDepthToShift = GetDepthToShiftTable(); @@ -604,7 +655,9 @@ XnStatus XnSensorDepthStream::SetCropping(const XnCropping* pCropping) } if (nRetVal == XN_STATUS_OK) - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, pCropping->bEnabled); + { + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, (XnUInt16)pCropping->bEnabled); + } if (nRetVal != XN_STATUS_OK) { @@ -649,9 +702,27 @@ XnStatus XnSensorDepthStream::PostProcessFrame(XnStreamData* pFrameData) m_Helper.GetFPS()->MarkOutputDepth(pFrameData->nFrameID, pFrameData->nTimestamp); + // data size is only half (second half is the shifts map) + pFrameData->nDataSize /= 2; + + m_pLastFrameShiftsMap = (XnUInt16*)((XnUInt8*)pFrameData->pData + pFrameData->nDataSize); + return (XN_STATUS_OK); } +XnStatus XnSensorDepthStream::CalcRequiredSize(XnUInt32* pnRequiredSize) const +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnDepthStream::CalcRequiredSize(pnRequiredSize); + XN_IS_STATUS_OK(nRetVal); + + // we also store shifts + *pnRequiredSize *= 2; + + return XN_STATUS_OK; +} + XnStatus XnSensorDepthStream::ReallocTripleFrameBuffer() { XnStatus nRetVal = XN_STATUS_OK; @@ -712,18 +783,25 @@ XnStatus XnSensorDepthStream::CreateDataProcessor(XnDataProcessor** ppProcessor) { XnStatus nRetVal = XN_STATUS_OK; + XnFrameBufferManager* pBufferManager; + nRetVal = GetTripleBuffer(&pBufferManager); + XN_IS_STATUS_OK(nRetVal); + XnStreamProcessor* pNew; switch (m_InputFormat.GetValue()) { case XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT: - XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedDepthProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedDepthProcessor, this, &m_Helper, pBufferManager); break; case XN_IO_DEPTH_FORMAT_COMPRESSED_PS: - XN_VALIDATE_NEW_AND_INIT(pNew, XnPSCompressedDepthProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnPSCompressedDepthProcessor, this, &m_Helper, pBufferManager); break; case XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT: - XN_VALIDATE_NEW_AND_INIT(pNew, XnPacked11DepthProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnPacked11DepthProcessor, this, &m_Helper, pBufferManager); + break; + case XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT: + XN_VALIDATE_NEW_AND_INIT(pNew, XnPacked12DepthProcessor, this, &m_Helper, pBufferManager); break; default: return XN_STATUS_IO_INVALID_STREAM_DEPTH_FORMAT; @@ -756,9 +834,9 @@ XnStatus XnSensorDepthStream::DecideFirmwareRegistration(XnBool bRegistration, X } break; case XN_PROCESSING_SOFTWARE: - if (GetResolution() != XN_RESOLUTION_VGA) + if (GetFPS() == 60) { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Software registration is only supported for VGA resolution!"); + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Software registration is not supported in 60 FPS mode!"); } bFirmwareRegistration = FALSE; break; @@ -780,7 +858,7 @@ XnStatus XnSensorDepthStream::DecideFirmwareRegistration(XnBool bRegistration, X } } - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareRegistration, bFirmwareRegistration); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareRegistration, (XnUInt16)bFirmwareRegistration); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -820,50 +898,56 @@ XnStatus XnSensorDepthStream::DecidePixelSizeFactor() return (XN_STATUS_OK); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetInputFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetInputFormatCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetInputFormat((XnIODepthFormats)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetRegistrationCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetRegistrationCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetRegistration((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetHoleFilterCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetHoleFilterCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetHoleFilter((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetWhiteBalanceCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetWhiteBalanceCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetWhiteBalance((XnBool)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetGainCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetGainCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetGain((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetRegistrationTypeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetRegistrationTypeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetRegistrationType((XnProcessingType)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetGMCModeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetGMCModeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->SetGMCMode((XnBool)nValue); } +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetCloseRangeCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) +{ + XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; + return pStream->SetCloseRange((XnBool)nValue); +} + -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetAGCBinCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetAGCBinCallback(XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { if (gbValue.nDataSize != sizeof(XnDepthAGCBin)) { @@ -874,7 +958,7 @@ XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetAGCBinCallback(XnGeneralProper return pStream->SetAGCBin((XnDepthAGCBin*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::GetAGCBinCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::GetAGCBinCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) { if (gbValue.nDataSize != sizeof(XnDepthAGCBin)) { @@ -885,19 +969,19 @@ XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::GetAGCBinCallback(const XnGeneral return pStream->GetAGCBin((XnDepthAGCBin*)gbValue.pData); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::SetActualReadCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorDepthStream* pThis = (XnSensorDepthStream*)pCookie; return pThis->SetActualRead(nValue == TRUE); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::DecideFirmwareRegistrationCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::DecideFirmwareRegistrationCallback(const XnProperty* /*pSender*/, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->DecideFirmwareRegistration((XnBool)pStream->m_DepthRegistration.GetValue(), (XnProcessingType)pStream->m_RegistrationType.GetValue(), pStream->GetResolution()); } -XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::DecidePixelSizeFactorCallback(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::DecidePixelSizeFactorCallback(const XnProperty* /*pSender*/, void* pCookie) { XnSensorDepthStream* pStream = (XnSensorDepthStream*)pCookie; return pStream->DecidePixelSizeFactor(); @@ -913,25 +997,25 @@ XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::ReadAGCBinsFromFile(XnGeneralProp XnUInt32 nValue; XnDepthAGCBin bin; - bin.nBin = nBin; + bin.nBin = (XnUInt16)nBin; XnBool bHasMin = FALSE; XnBool bHasMax = FALSE; - sprintf(csKey, "AGCBin%dMinDepth", nBin); + sprintf(csKey, "AGCBin%uMinDepth", nBin); nRetVal = xnOSReadIntFromINI(csINIFile, csSection, csKey, &nValue); if (nRetVal == XN_STATUS_OK) { - bin.nMin = nValue; + bin.nMin = (XnUInt16)nValue; bHasMin = TRUE; } - sprintf(csKey, "AGCBin%dMaxDepth", nBin); + sprintf(csKey, "AGCBin%uMaxDepth", nBin); nRetVal = xnOSReadIntFromINI(csINIFile, csSection, csKey, &nValue); if (nRetVal == XN_STATUS_OK) { - bin.nMax = nValue; + bin.nMax = (XnUInt16)nValue; bHasMax = TRUE; } @@ -949,3 +1033,20 @@ XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::ReadAGCBinsFromFile(XnGeneralProp return XN_STATUS_OK; } + +XnStatus XN_CALLBACK_TYPE XnSensorDepthStream::GetShiftsMapCallback(const XnGeneralProperty* /*pSender*/, const XnGeneralBuffer& gbValue, void* pCookie) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnSensorDepthStream* pThis = (XnSensorDepthStream*)pCookie; + + if (gbValue.nDataSize != sizeof(XnSizeT)) + { + return XN_STATUS_DEVICE_PROPERTY_SIZE_DONT_MATCH; + } + + const XnUInt16** ppShiftsMap = (const XnUInt16**)gbValue.pData; + *ppShiftsMap = pThis->m_pLastFrameShiftsMap; + + return (XN_STATUS_OK); +} diff --git a/Source/XnDeviceSensorV2/XnSensorDepthStream.h b/Source/XnDeviceSensorV2/XnSensorDepthStream.h index 198e61b..b7ece6e 100644 --- a/Source/XnDeviceSensorV2/XnSensorDepthStream.h +++ b/Source/XnDeviceSensorV2/XnSensorDepthStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_DEPTH_STREAM_H__ #define __XN_SENSOR_DEPTH_STREAM_H__ @@ -34,7 +29,25 @@ #include "XnDeviceSensorProtocol.h" #include "Registration.h" #include "XnSensorStreamHelper.h" -#include "XnSharedMemoryBufferPool.h" + + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_DEPTH_STREAM_DEFAULT_INPUT_FORMAT XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT +// --avin mod-- +#define XN_DEPTH_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_VGA +#define XN_DEPTH_STREAM_DEFAULT_FPS 30 +#define XN_DEPTH_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_DEPTH_VALUES +#define XN_DEPTH_STREAM_DEFAULT_REGISTRATION FALSE +// --avin mod-- +#define XN_DEPTH_STREAM_DEFAULT_REGISTRATION_TYPE XN_PROCESSING_SOFTWARE +#define XN_DEPTH_STREAM_DEFAULT_HOLE_FILLER TRUE +#define XN_DEPTH_STREAM_DEFAULT_WHITE_BALANCE TRUE +#define XN_DEPTH_STREAM_DEFAULT_GAIN_OLD 50 +#define XN_DEPTH_STREAM_DEFAULT_GMC_MODE TRUE +#define XN_DEPTH_STREAM_DEFAULT_CLOSE_RANGE FALSE +#define XN_DEPTH_STREAM_DEFAULT_SHIFT_MAP_APPENDED TRUE //--------------------------------------------------------------------------- @@ -43,7 +56,7 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream { public: - XnSensorDepthStream(const XnChar* strName, XnSensorObjects* pObjects, XnUInt32 nBufferCount); + XnSensorDepthStream(const XnChar* strName, XnSensorObjects* pObjects); ~XnSensorDepthStream() { Free(); } //--------------------------------------------------------------------------- @@ -66,6 +79,7 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream XnStatus Open() { return m_Helper.Open(); } XnStatus Close() { return m_Helper.Close(); } XnStatus PostProcessFrame(XnStreamData* pFrameData); + XnStatus CalcRequiredSize(XnUInt32* pnRequiredSize) const; XnStatus ReallocTripleFrameBuffer(); XnStatus CropImpl(XnStreamData* pStreamOutput, const XnCropping* pCropping); XnStatus Mirror(XnStreamData* pStreamOutput) const; @@ -75,8 +89,7 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream XnStatus CreateDataProcessor(XnDataProcessor** ppProcessor); XnStatus MapPropertiesToFirmware(); void GetFirmwareStreamConfig(XnResolutions* pnRes, XnUInt32* pnFPS) { *pnRes = GetResolution(); *pnFPS = GetFPS(); } - XnStatus WriteImpl(XnStreamData* pStreamData) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } - XnSharedMemoryBufferPool* GetSharedMemoryBuffer() { return &m_BufferPool; } + XnStatus WriteImpl(XnStreamData* /*pStreamData*/) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } protected: @@ -98,6 +111,7 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream XnStatus SetCropping(const XnCropping* pCropping); XnStatus SetActualRead(XnBool bRead); virtual XnStatus SetGMCMode(XnBool bGMCMode); + virtual XnStatus SetCloseRange(XnBool bCloseRange); private: @@ -118,15 +132,14 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream static XnStatus XN_CALLBACK_TYPE DecidePixelSizeFactorCallback(const XnProperty* pSender, void* pCookie); static XnStatus XN_CALLBACK_TYPE ReadAGCBinsFromFile(XnGeneralProperty* pSender, const XnChar* csINIFile, const XnChar* csSection); static XnStatus XN_CALLBACK_TYPE SetGMCModeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetCloseRangeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetShiftsMapCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie); //--------------------------------------------------------------------------- // Members //--------------------------------------------------------------------------- XnSensorStreamHelper m_Helper; - XnSharedMemoryBufferPool m_BufferPool; - - XnActualStringProperty m_SharedBufferName; XnActualIntProperty m_InputFormat; XnActualIntProperty m_DepthRegistration; XnActualIntProperty m_HoleFilter; @@ -146,6 +159,9 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream XnActualIntProperty m_ActualRead; XnActualIntProperty m_GMCMode; + XnActualIntProperty m_CloseRange; + XnGeneralProperty m_ShiftsMap; + const XnUInt16* m_pLastFrameShiftsMap; XnRegistration m_Registration; diff --git a/Source/XnDeviceSensorV2/XnSensorDevice.cpp b/Source/XnDeviceSensorV2/XnSensorDevice.cpp index cce8aae..fcb301a 100644 --- a/Source/XnDeviceSensorV2/XnSensorDevice.cpp +++ b/Source/XnDeviceSensorV2/XnSensorDevice.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -44,7 +38,9 @@ XnSensorDevice::~XnSensorDevice() XnBool XnSensorDevice::IsCapabilitySupported(const XnChar* strCapabilityName) { - return (strcmp(strCapabilityName, XN_CAPABILITY_ERROR_STATE) == 0 || + return ( + strcmp(strCapabilityName, XN_CAPABILITY_ERROR_STATE) == 0 || + strcmp(strCapabilityName, XN_CAPABILITY_DEVICE_IDENTIFICATION) == 0 || XnSensorProductionNode::IsCapabilitySupported(strCapabilityName)); } @@ -73,3 +69,18 @@ void XnSensorDevice::UnregisterFromErrorStateChange(XnCallbackHandle hCallback) { UnregisterFromProps(hCallback); } + +XnStatus XnSensorDevice::GetDeviceName(XnChar* strBuffer, XnUInt32& nBufferSize) +{ + return GetStringProperty(XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME, strBuffer, nBufferSize); +} + +XnStatus XnSensorDevice::GetVendorSpecificData(XnChar* strBuffer, XnUInt32& nBufferSize) +{ + return GetStringProperty(XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA, strBuffer, nBufferSize); +} + +XnStatus XnSensorDevice::GetSerialNumber(XnChar* strBuffer, XnUInt32& nBufferSize) +{ + return GetStringProperty(XN_MODULE_PROPERTY_ID, strBuffer, nBufferSize); +} \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorDevice.h b/Source/XnDeviceSensorV2/XnSensorDevice.h index 5a8098e..b6579af 100644 --- a/Source/XnDeviceSensorV2/XnSensorDevice.h +++ b/Source/XnDeviceSensorV2/XnSensorDevice.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_DEVICE_H__ #define __XN_SENSOR_DEVICE_H__ @@ -36,10 +30,15 @@ //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorDevice : public XnSensorProductionNode, virtual public xn::ModuleDevice, - virtual public xn::ModuleErrorStateInterface + virtual public xn::ModuleErrorStateInterface, + virtual public xn::ModuleDeviceIdentificationInterface { public: XnSensorDevice(xn::Context& context, XnDeviceBase* pSensor, const XnChar* strInstanceName); @@ -51,6 +50,13 @@ class XnSensorDevice : virtual XnStatus GetErrorState(); virtual XnStatus RegisterToErrorStateChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback); virtual void UnregisterFromErrorStateChange(XnCallbackHandle hCallback); + + virtual ModuleDeviceIdentificationInterface* GetIdentificationInterface() { return this; } + virtual XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32& nBufferSize); + virtual XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32& nBufferSize); + virtual XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32& nBufferSize); }; +#pragma warning (pop) + #endif // __XN_SENSOR_DEVICE_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorFPS.cpp b/Source/XnDeviceSensorV2/XnSensorFPS.cpp index f6d8a05..83ef326 100644 --- a/Source/XnDeviceSensorV2/XnSensorFPS.cpp +++ b/Source/XnDeviceSensorV2/XnSensorFPS.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -42,7 +36,7 @@ // Code //--------------------------------------------------------------------------- XnSensorFPS::XnSensorFPS() : - m_FramesDump(XN_DUMP_CLOSED) + m_FramesDump(NULL) { xnFPSInit(&m_InputDepth, XN_SENSOR_FPS_FRAME_COUNT); xnFPSInit(&m_InputImage, XN_SENSOR_FPS_FRAME_COUNT); @@ -50,7 +44,8 @@ XnSensorFPS::XnSensorFPS() : xnFPSInit(&m_OutputDepth, XN_SENSOR_FPS_FRAME_COUNT); xnFPSInit(&m_OutputImage, XN_SENSOR_FPS_FRAME_COUNT); - xnDumpInit(&m_FramesDump, XN_MASK_SENSOR_FPS, "TS,Type,FrameID,FrameTS\n", "FramesTimes.csv"); + m_FramesDump = xnDumpFileOpen(XN_MASK_SENSOR_FPS, "FramesTimes.csv"); + xnDumpFileWriteString(m_FramesDump, "TS,Type,FrameID,FrameTS\n"); } XnSensorFPS::~XnSensorFPS() @@ -61,7 +56,7 @@ XnSensorFPS::~XnSensorFPS() xnFPSFree(&m_OutputDepth); xnFPSFree(&m_OutputImage); - xnDumpClose(&m_FramesDump); + xnDumpFileClose(m_FramesDump); } void XnSensorFPS::Mark(XnFPSData* pFPS, const XnChar* csName, XnUInt32 nFrameID, XnUInt64 nTS) @@ -74,7 +69,7 @@ void XnSensorFPS::Mark(XnFPSData* pFPS, const XnChar* csName, XnUInt32 nFrameID, xnFPSMarkFrame(pFPS, nNow); - xnDumpWriteString(m_FramesDump, "%llu,%s,%u,%llu\n", nNow, csName, nFrameID, nTS); + xnDumpFileWriteString(m_FramesDump, "%llu,%s,%u,%llu\n", nNow, csName, nFrameID, nTS); // get current time in seconds nNow /= 1000000; diff --git a/Source/XnDeviceSensorV2/XnSensorFPS.h b/Source/XnDeviceSensorV2/XnSensorFPS.h index 2ba26af..64abc7e 100644 --- a/Source/XnDeviceSensorV2/XnSensorFPS.h +++ b/Source/XnDeviceSensorV2/XnSensorFPS.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_FPS_H__ #define __XN_SENSOR_FPS_H__ @@ -63,7 +58,7 @@ class XnSensorFPS XnFPSData m_OutputImage; XnUInt64 m_nLastPrint; - XnDump m_FramesDump; + XnDumpFile* m_FramesDump; }; #endif //__XN_SENSOR_FPS_H__ diff --git a/Source/XnDeviceSensorV2/XnSensorFirmware.cpp b/Source/XnDeviceSensorV2/XnSensorFirmware.cpp index 8df69f4..e48c1af 100644 --- a/Source/XnDeviceSensorV2/XnSensorFirmware.cpp +++ b/Source/XnDeviceSensorV2/XnSensorFirmware.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -38,11 +32,12 @@ XnSensorFirmware::XnSensorFirmware(XnDevicePrivateData* pDevicePrivateData) : m_Commands(pDevicePrivateData), m_Params(m_pInfo, &m_Commands), m_Streams(pDevicePrivateData), + m_FixedParams(pDevicePrivateData), m_pDevicePrivateData(pDevicePrivateData) { } -XnStatus XnSensorFirmware::Init(XnBool bReset) +XnStatus XnSensorFirmware::Init(XnBool bReset, XnBool bLeanInit) { XnStatus nRetVal = XN_STATUS_OK; @@ -117,17 +112,37 @@ XnStatus XnSensorFirmware::Init(XnBool bReset) } } - nRetVal = m_Params.Init(); - XN_IS_STATUS_OK(nRetVal); - - if (nMode == XN_HOST_PROTOCOL_MODE_PS) + if (!bLeanInit) { - nRetVal = m_Params.UpdateAllProperties(); + nRetVal = m_FixedParams.Init(); XN_IS_STATUS_OK(nRetVal); - } - nRetVal = m_Streams.Init(); - XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Params.Init(); + XN_IS_STATUS_OK(nRetVal); + + if (nMode == XN_HOST_PROTOCOL_MODE_PS) + { + nRetVal = m_Params.UpdateAllProperties(); + XN_IS_STATUS_OK(nRetVal); + } + + // Check if image is supported + if (m_pInfo->bGetImageCmosTypeSupported) + { + m_pInfo->bImageSupported = (m_FixedParams.GetImageCmosType() != 0); + } + else + { + // This is an ugly patch to find out if this sensor has an image CMOS. It will be fixed + // in future firmwares so we can just ask. + XnUInt16 nLines; + nRetVal = XnHostProtocolGetCmosBlanking(m_pDevicePrivateData, XN_CMOS_TYPE_IMAGE, &nLines); + m_pInfo->bImageSupported = (nRetVal == XN_STATUS_OK && nLines > 0); + } + + nRetVal = m_Streams.Init(); + XN_IS_STATUS_OK(nRetVal); + } return (XN_STATUS_OK); } diff --git a/Source/XnDeviceSensorV2/XnSensorFirmware.h b/Source/XnDeviceSensorV2/XnSensorFirmware.h index be41869..6faee3a 100644 --- a/Source/XnDeviceSensorV2/XnSensorFirmware.h +++ b/Source/XnDeviceSensorV2/XnSensorFirmware.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_FIRMWARE_H__ #define __XN_SENSOR_FIRMWARE_H__ @@ -34,6 +29,7 @@ #include "XnFirmwareCommands.h" #include "XnSensorFirmwareParams.h" #include "XnFirmwareStreams.h" +#include "XnSensorFixedParams.h" //--------------------------------------------------------------------------- // Types @@ -42,19 +38,21 @@ class XnSensorFirmware { public: XnSensorFirmware(XnDevicePrivateData* pDevicePrivateData); - XnStatus Init(XnBool bReset); + XnStatus Init(XnBool bReset, XnBool bLeanInit); void Free(); inline XnFirmwareInfo* GetInfo() { return m_pInfo; } inline XnFirmwareCommands* GetCommands() { return &m_Commands; } inline XnSensorFirmwareParams* GetParams() { return &m_Params; } inline XnFirmwareStreams* GetStreams() { return &m_Streams; } + inline XnSensorFixedParams* GetFixedParams() { return &m_FixedParams; } private: XnFirmwareInfo* m_pInfo; XnFirmwareCommands m_Commands; XnSensorFirmwareParams m_Params; XnFirmwareStreams m_Streams; + XnSensorFixedParams m_FixedParams; XnDevicePrivateData* m_pDevicePrivateData; }; diff --git a/Source/XnDeviceSensorV2/XnSensorFirmwareParams.cpp b/Source/XnDeviceSensorV2/XnSensorFirmwareParams.cpp index d8f3997..b585458 100644 --- a/Source/XnDeviceSensorV2/XnSensorFirmwareParams.cpp +++ b/Source/XnDeviceSensorV2/XnSensorFirmwareParams.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -81,6 +75,15 @@ XnSensorFirmwareParams::XnSensorFirmwareParams(XnFirmwareInfo* pInfo, XnFirmware m_IRMirror("IRMirror"), m_ReferenceResolution("ReferenceResolution", 0, "Firmware"), m_GMCMode("GMCMode"), + m_ImageSharpness("ImageSharpness"), + m_ImageAutoWhiteBalance("ImageAutoWhiteBalance"), + m_ImageColorTemperature("ImageColorTemperature"), + m_ImageBacklightCompensation("ImageBacklightCompensation"), + m_ImageAutoExposure("ImageAutoExposure"), + m_ImageExposureBar("ImageExposureBar"), + m_ImageLowLightCompensation("ImageLowLightCompensation"), + m_ImageGain("ImageGain"), + m_DepthCloseRange("CloseRange"), m_pInfo(pInfo), m_pCommands(pCommands), m_bInTransaction(FALSE) @@ -96,68 +99,128 @@ XnStatus XnSensorFirmwareParams::Init() { XnStatus nRetVal = XN_STATUS_OK; - /* Property Param MinVersion MaxVersion ValueIfNotSupported */ - /* ====================== ======================================= ==================== ==================== =================== */ - XN_IS_STATUS_OK(AddFirmwareParam( m_FrameSyncEnabled, PARAM_GENERAL_FRAME_SYNC)); - XN_IS_STATUS_OK(AddFirmwareParam( m_RegistrationEnabled, PARAM_GENERAL_REGISTRATION_ENABLE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_Stream0Mode, PARAM_GENERAL_STREAM0_MODE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_Stream1Mode, PARAM_GENERAL_STREAM1_MODE)); - XN_IS_STATUS_OK(AddFirmwareAudioParam(m_Stream2Mode, PARAM_GENERAL_STREAM2_MODE)); - XN_IS_STATUS_OK(AddFirmwareAudioParam(m_AudioStereo, PARAM_AUDIO_STEREO_MODE)); - XN_IS_STATUS_OK(AddFirmwareAudioParam(m_AudioSampleRate, PARAM_AUDIO_SAMPLE_RATE)); - XN_IS_STATUS_OK(AddFirmwareAudioParam(m_AudioLeftChannelGain, PARAM_AUDIO_LEFT_CHANNEL_VOLUME_LEVEL)); - XN_IS_STATUS_OK(AddFirmwareAudioParam(m_AudioRightChannelGain, PARAM_AUDIO_RIGHT_CHANNEL_VOLUME_LEVEL)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageFormat, PARAM_IMAGE_FORMAT)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageResolution, PARAM_IMAGE_RESOLUTION)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageFPS, PARAM_IMAGE_FPS)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageQuality, PARAM_IMAGE_QUALITY)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageFlickerDetection, PARAM_IMAGE_FLICKER_DETECTION)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageCropSizeX, PARAM_IMAGE_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageCropSizeY, PARAM_IMAGE_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageCropOffsetX, PARAM_IMAGE_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageCropOffsetY, PARAM_IMAGE_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageCropEnabled, PARAM_IMAGE_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthFormat, PARAM_DEPTH_FORMAT)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthResolution, PARAM_DEPTH_RESOLUTION)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthFPS, PARAM_DEPTH_FPS)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthGain, PARAM_DEPTH_AGC)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthHoleFilter, PARAM_DEPTH_HOLE_FILTER)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthMirror, PARAM_DEPTH_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthDecimation, PARAM_DEPTH_DECIMATION)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthCropSizeX, PARAM_DEPTH_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthCropSizeY, PARAM_DEPTH_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthCropOffsetX, PARAM_DEPTH_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthCropOffsetY, PARAM_DEPTH_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthCropEnabled, PARAM_DEPTH_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRFormat, PARAM_IR_FORMAT)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRResolution, PARAM_IR_RESOLUTION)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRFPS, PARAM_IR_FPS)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRCropSizeX, PARAM_IR_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRCropSizeY, PARAM_IR_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRCropOffsetX, PARAM_IR_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRCropOffsetY, PARAM_IR_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRCropEnabled, PARAM_IR_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_DepthWhiteBalance, PARAM_DEPTH_WHITE_BALANCE_ENABLE, XN_SENSOR_FW_VER_4_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_ImageMirror, PARAM_IMAGE_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_IRMirror, PARAM_IR_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); - XN_IS_STATUS_OK(AddFirmwareParam( m_GMCMode, PARAM_DEPTH_GMC_MODE, XN_SENSOR_FW_VER_3_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE)); + /* Property Param MinVersion MaxVersion ValueIfNotSupported */ + /* ====================== ======================================= ==================== ==================== =================== */ + nRetVal = AddFirmwareParam( m_FrameSyncEnabled, PARAM_GENERAL_FRAME_SYNC); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_RegistrationEnabled, PARAM_GENERAL_REGISTRATION_ENABLE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_Stream0Mode, PARAM_GENERAL_STREAM0_MODE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_Stream1Mode, PARAM_GENERAL_STREAM1_MODE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareAudioParam(m_Stream2Mode, PARAM_GENERAL_STREAM2_MODE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareAudioParam(m_AudioStereo, PARAM_AUDIO_STEREO_MODE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareAudioParam(m_AudioSampleRate, PARAM_AUDIO_SAMPLE_RATE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareAudioParam(m_AudioLeftChannelGain, PARAM_AUDIO_LEFT_CHANNEL_VOLUME_LEVEL); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareAudioParam(m_AudioRightChannelGain, PARAM_AUDIO_RIGHT_CHANNEL_VOLUME_LEVEL); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageFormat, PARAM_IMAGE_FORMAT); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageResolution, PARAM_IMAGE_RESOLUTION); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageFPS, PARAM_IMAGE_FPS); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageQuality, PARAM_IMAGE_QUALITY); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageFlickerDetection, PARAM_IMAGE_FLICKER_DETECTION); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageCropSizeX, PARAM_IMAGE_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageCropSizeY, PARAM_IMAGE_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageCropOffsetX, PARAM_IMAGE_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageCropOffsetY, PARAM_IMAGE_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageCropEnabled, PARAM_IMAGE_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthFormat, PARAM_DEPTH_FORMAT); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthResolution, PARAM_DEPTH_RESOLUTION); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthFPS, PARAM_DEPTH_FPS); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthGain, PARAM_DEPTH_AGC); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthHoleFilter, PARAM_DEPTH_HOLE_FILTER); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthMirror, PARAM_DEPTH_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthDecimation, PARAM_DEPTH_DECIMATION); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCropSizeX, PARAM_DEPTH_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCropSizeY, PARAM_DEPTH_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCropOffsetX, PARAM_DEPTH_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCropOffsetY, PARAM_DEPTH_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCropEnabled, PARAM_DEPTH_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRFormat, PARAM_IR_FORMAT); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRResolution, PARAM_IR_RESOLUTION); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRFPS, PARAM_IR_FPS); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRCropSizeX, PARAM_IR_CROP_SIZE_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRCropSizeY, PARAM_IR_CROP_SIZE_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRCropOffsetX, PARAM_IR_CROP_OFFSET_X, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRCropOffsetY, PARAM_IR_CROP_OFFSET_Y, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRCropEnabled, PARAM_IR_CROP_ENABLE, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthWhiteBalance, PARAM_DEPTH_WHITE_BALANCE_ENABLE, XN_SENSOR_FW_VER_4_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageMirror, PARAM_IMAGE_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_IRMirror, PARAM_IR_MIRROR, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_GMCMode, PARAM_DEPTH_GMC_MODE, XN_SENSOR_FW_VER_3_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageSharpness, PARAM_IMAGE_SHARPNESS, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, 50); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageAutoWhiteBalance, PARAM_IMAGE_AUTO_WHITE_BALANCE_MODE, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageColorTemperature, PARAM_IMAGE_COLOR_TEMPERATURE, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageBacklightCompensation,PARAM_IMAGE_BACK_LIGHT_COMPENSATION, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageAutoExposure, PARAM_IMAGE_AUTO_EXPOSURE_MODE, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageExposureBar, PARAM_IMAGE_EXPOSURE_BAR, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageLowLightCompensation,PARAM_IMAGE_LOW_LIGHT_COMPENSATION_MODE, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_ImageGain, PARAM_IMAGE_AGC, XN_SENSOR_FW_VER_5_4, XN_SENSOR_FW_VER_UNKNOWN, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_DepthCloseRange, PARAM_DEPTH_CLOSE_RANGE, XN_SENSOR_FW_VER_5_6, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); // override some props - m_ImageResolution.UpdateSetCallback(SetImageResolutionCallback, this); m_ImageFormat.UpdateSetCallback(SetImageFormatCallback, this); // register for some interesting changes XnCallbackHandle hCallbackDummy; - nRetVal = m_Stream0Mode.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, &hCallbackDummy); + nRetVal = m_Stream0Mode.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_Stream1Mode.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, &hCallbackDummy); + nRetVal = m_Stream1Mode.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_IRResolution.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, &hCallbackDummy); + nRetVal = m_IRResolution.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); - nRetVal = m_DepthFPS.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, &hCallbackDummy); + nRetVal = m_DepthFPS.OnChangeEvent().Register(ReferenceResolutionPropertyValueChanged, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); nRetVal = RecalculateReferenceResolution(); @@ -214,9 +277,9 @@ XnStatus XnSensorFirmwareParams::UpdateAllProperties() xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Reading all params from firmware..."); - for (XnFirmwareParamsHash::Iterator it = m_AllFirmwareParams.begin(); it != m_AllFirmwareParams.end(); ++it) + for (XnFirmwareParamsHash::Iterator it = m_AllFirmwareParams.Begin(); it != m_AllFirmwareParams.End(); ++it) { - XnFirmwareParam& param = it.Value(); + XnFirmwareParam& param = it->Value(); nRetVal = UpdateProperty(¶m); XN_IS_STATUS_OK(nRetVal); } @@ -228,8 +291,6 @@ XnStatus XnSensorFirmwareParams::UpdateAllProperties() XnStatus XnSensorFirmwareParams::StartTransaction() { - XnStatus nRetVal = XN_STATUS_OK; - if (m_bInTransaction) { return XN_STATUS_ERROR; @@ -254,7 +315,7 @@ XnStatus XnSensorFirmwareParams::CommitTransaction() // we are no longer in transaction, even if we fail to commit. m_bInTransaction = FALSE; - for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.begin(); it != m_TransactionOrder.end(); ++it) + for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.Begin(); it != m_TransactionOrder.End(); ++it) { XnActualIntProperty* pProp = *it; @@ -299,7 +360,7 @@ XnStatus XnSensorFirmwareParams::CommitTransactionAsBatch() XnUInt32 nCount = 0; - for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.begin(); it != m_TransactionOrder.end(); ++it) + for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.Begin(); it != m_TransactionOrder.End(); ++it) { XnActualIntProperty* pProp = *it; @@ -338,7 +399,7 @@ XnStatus XnSensorFirmwareParams::CommitTransactionAsBatch() XN_IS_STATUS_OK(nRetVal); // and update their props - for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.begin(); it != m_TransactionOrder.end(); ++it) + for (XnActualIntPropertyList::Iterator it = m_TransactionOrder.Begin(); it != m_TransactionOrder.End(); ++it) { XnActualIntProperty* pProp = *it; @@ -359,8 +420,6 @@ XnStatus XnSensorFirmwareParams::CommitTransactionAsBatch() XnStatus XnSensorFirmwareParams::RollbackTransaction() { - XnStatus nRetVal = XN_STATUS_OK; - if (!m_bInTransaction) { return XN_STATUS_ERROR; @@ -441,41 +500,11 @@ XnStatus XnSensorFirmwareParams::SetFirmwareAudioParam(XnActualIntProperty* pPro return (XN_STATUS_OK); } -XnStatus XnSensorFirmwareParams::SetImageResolution(XnUInt64 nValue) -{ - XnStatus nRetVal = XN_STATUS_OK; - - switch (nValue) - { - case XN_RESOLUTION_QVGA: - case XN_RESOLUTION_VGA: - break; - case XN_RESOLUTION_SXGA: - if (m_pInfo->nFWVer < XN_SENSOR_FW_VER_5_3) - { - XN_LOG_WARNING_RETURN(XN_STATUS_IO_INVALID_STREAM_IMAGE_RESOLUTION, XN_MASK_DEVICE_SENSOR, "Image resolution is not supported by this firmware!"); - } - break; - case XN_RESOLUTION_UXGA: - if (m_pInfo->nFWVer < XN_SENSOR_FW_VER_5_1) - { - XN_LOG_WARNING_RETURN(XN_STATUS_IO_INVALID_STREAM_IMAGE_RESOLUTION, XN_MASK_DEVICE_SENSOR, "Image resolution is not supported by this firmware!"); - } - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported image resolution: %d", nValue); - } - - nRetVal = SetFirmwareParam(&m_ImageResolution, nValue); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - XnStatus XnSensorFirmwareParams::SetImageFormat(XnUInt64 nValue) { XnStatus nRetVal = XN_STATUS_OK; + // --avin mod-- if (nValue == XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER) { nValue = XN_IO_IMAGE_FORMAT_BAYER; @@ -592,13 +621,7 @@ XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::SetFirmwareAudioParamCallback( return pThis->SetFirmwareAudioParam(pSender, nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::SetImageResolutionCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) -{ - XnSensorFirmwareParams* pThis = (XnSensorFirmwareParams*)pCookie; - return pThis->SetImageResolution(nValue); -} - -XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::SetImageFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::SetImageFormatCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorFirmwareParams* pThis = (XnSensorFirmwareParams*)pCookie; return pThis->SetImageFormat(nValue); @@ -610,7 +633,7 @@ XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::SetStreamModeCallback(XnActual return pThis->SetStreamMode(pSender, nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::ReferenceResolutionPropertyValueChanged(const XnProperty* pSender, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorFirmwareParams::ReferenceResolutionPropertyValueChanged(const XnProperty* /*pSender*/, void* pCookie) { XnSensorFirmwareParams* pThis = (XnSensorFirmwareParams*)pCookie; return pThis->RecalculateReferenceResolution(); diff --git a/Source/XnDeviceSensorV2/XnSensorFirmwareParams.h b/Source/XnDeviceSensorV2/XnSensorFirmwareParams.h index 504003e..c3642e8 100644 --- a/Source/XnDeviceSensorV2/XnSensorFirmwareParams.h +++ b/Source/XnDeviceSensorV2/XnSensorFirmwareParams.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_FIRMWARE_PARAMS_H__ #define __XN_SENSOR_FIRMWARE_PARAMS_H__ @@ -32,9 +27,10 @@ //--------------------------------------------------------------------------- #include #include "XnParams.h" -#include +#include #include "XnFirmwareInfo.h" #include "XnFirmwareCommands.h" +#include //--------------------------------------------------------------------------- // Types @@ -104,6 +100,15 @@ class XnSensorFirmwareParams XnActualIntProperty m_ReferenceResolution; XnActualIntProperty m_DepthWhiteBalance; XnActualIntProperty m_GMCMode; + XnActualIntProperty m_ImageSharpness; + XnActualIntProperty m_ImageAutoWhiteBalance; + XnActualIntProperty m_ImageColorTemperature; + XnActualIntProperty m_ImageBacklightCompensation; + XnActualIntProperty m_ImageAutoExposure; + XnActualIntProperty m_ImageExposureBar; + XnActualIntProperty m_ImageLowLightCompensation; + XnActualIntProperty m_ImageGain; + XnActualIntProperty m_DepthCloseRange; private: typedef struct XnFirmwareParam @@ -115,9 +120,9 @@ class XnSensorFirmwareParams XnUInt16 nValueIfNotSupported; } XnFirmwareParam; - XN_DECLARE_DEFAULT_HASH(XnActualIntProperty*, XnFirmwareParam, XnFirmwareParamsHash) - XN_DECLARE_LIST(XnActualIntProperty*, XnActualIntPropertyList) - XN_DECLARE_DEFAULT_HASH(XnActualIntProperty*, XnUInt32, XnPropertyToValueHash) + typedef XnHashT XnFirmwareParamsHash; + typedef XnListT XnActualIntPropertyList; + typedef XnHashT XnPropertyToValueHash; XnStatus AddFirmwareParam(XnActualIntProperty& Property, XnUInt16 nFirmwareParam, XnFWVer nMinVer = XN_SENSOR_FW_VER_UNKNOWN, XnFWVer nMaxVer = XN_SENSOR_FW_VER_UNKNOWN, XnUInt16 nValueIfNotSupported = 0); XnStatus AddFirmwareAudioParam(XnActualIntProperty& Property, XnUInt16 nFirmwareParam, XnFWVer nMinVer = XN_SENSOR_FW_VER_3_0, XnFWVer nMaxVer = XN_SENSOR_FW_VER_UNKNOWN, XnUInt16 nValueIfNotSupported = 0); @@ -126,7 +131,6 @@ class XnSensorFirmwareParams XnStatus SetFirmwareParam(XnActualIntProperty* pProperty, XnUInt64 nValue); XnStatus SetFirmwareAudioParam(XnActualIntProperty* pProperty, XnUInt64 nValue); - XnStatus SetImageResolution(XnUInt64 nValue); XnStatus SetImageFormat(XnUInt64 nValue); XnStatus SetStreamMode(XnActualIntProperty* pProperty, XnUInt64 nValue); XnStatus RecalculateReferenceResolution(); @@ -137,7 +141,6 @@ class XnSensorFirmwareParams static XnStatus XN_CALLBACK_TYPE SetFirmwareParamCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetFirmwareAudioParamCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); - static XnStatus XN_CALLBACK_TYPE SetImageResolutionCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetImageFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetStreamModeCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE ReferenceResolutionPropertyValueChanged(const XnProperty* pSender, void* pCookie); diff --git a/Source/XnDeviceSensorV2/XnSensorFixedParams.cpp b/Source/XnDeviceSensorV2/XnSensorFixedParams.cpp index e9c8229..e6c1d97 100644 --- a/Source/XnDeviceSensorV2/XnSensorFixedParams.cpp +++ b/Source/XnDeviceSensorV2/XnSensorFixedParams.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -34,10 +28,22 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnSensorFixedParams::XnSensorFixedParams(XnSensorFirmware* pFirmware, XnDevicePrivateData* pDevicePrivateData) : - m_pFirmware(pFirmware), - m_pDevicePrivateData(pDevicePrivateData) +XnSensorFixedParams::XnSensorFixedParams(XnDevicePrivateData* pDevicePrivateData) : + m_pDevicePrivateData(pDevicePrivateData), + m_nSensorDepthCMOSI2CBus(0), + m_nSensorDepthCMOSI2CSlaveAddress(0), + m_nSensorImageCMOSI2CBus(0), + m_nSensorImageCMOSI2CSlaveAddress(0), + m_nZeroPlaneDistance(0), + m_dZeroPlanePixelSize(0), + m_dEmitterDCmosDistance(0), + m_dDCmosRCmosDistance(0), + m_nImageCmosType(0) { + m_strSensorSerial[0] = '\0'; + m_deviceInfo.strDeviceName[0] = '\0'; + m_deviceInfo.strVendorData[0] = '\0'; + m_strPlatformString[0] = '\0'; } XnStatus XnSensorFixedParams::Init() @@ -51,14 +57,41 @@ XnStatus XnSensorFixedParams::Init() { } - xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Sensor serial number: %d", FixedParams.nSerialNumber); + if (m_pDevicePrivateData->FWInfo.nFWVer < XN_SENSOR_FW_VER_5_4) + { + sprintf(m_strSensorSerial, "%d", FixedParams.nSerialNumber); + } + else + { + nRetVal = XnHostProtocolGetSerialNumber(m_pDevicePrivateData, m_strSensorSerial); + + if (nRetVal != XN_STATUS_OK) + { + return nRetVal; + } + } + + xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Sensor serial number: %s", m_strSensorSerial); // fill in properties m_nZeroPlaneDistance = (XnDepthPixel)FixedParams.fReferenceDistance; m_dZeroPlanePixelSize = FixedParams.fReferencePixelSize; m_dEmitterDCmosDistance = FixedParams.fDCmosEmitterDistance; - sprintf(m_strSensorSerial, "%x", FixedParams.nSerialNumber); + m_dDCmosRCmosDistance = FixedParams.fDCmosRCmosDistance; + + m_nSensorDepthCMOSI2CBus = (XnUInt16)FixedParams.nDepthCmosI2CBus; + m_nSensorDepthCMOSI2CSlaveAddress = (XnUInt16)FixedParams.nDepthCmosI2CAddress; + m_nSensorImageCMOSI2CBus = (XnUInt16)FixedParams.nImageCmosI2CBus; + m_nSensorImageCMOSI2CSlaveAddress = (XnUInt16)FixedParams.nImageCmosI2CAddress; + + m_nImageCmosType = (XnUInt32)FixedParams.nImageCmosType; + + nRetVal = XnHostProtocolAlgorithmParams(m_pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_DEVICE_INFO, + &m_deviceInfo, sizeof(m_deviceInfo), (XnResolutions)0, 0); + XN_IS_STATUS_OK(nRetVal); + nRetVal = XnHostProtocolGetPlatformString(m_pDevicePrivateData, m_strPlatformString); + XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorFixedParams.h b/Source/XnDeviceSensorV2/XnSensorFixedParams.h index 9075a39..692bbab 100644 --- a/Source/XnDeviceSensorV2/XnSensorFixedParams.h +++ b/Source/XnDeviceSensorV2/XnSensorFixedParams.h @@ -1,36 +1,39 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_FIXED_PARAMS_H__ #define __XN_SENSOR_FIXED_PARAMS_H__ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- -#include "XnSensorFirmware.h" +#include +#include "XnDeviceSensor.h" + +//--------------------------------------------------------------------------- +// Forward Declarations +//--------------------------------------------------------------------------- +class XnSensorFirmware; +struct XnDevicePrivateData; +typedef struct XnDevicePrivateData XnDevicePrivateData; //--------------------------------------------------------------------------- // XnSensorFixedParams class @@ -38,27 +41,46 @@ class XnSensorFixedParams { public: - XnSensorFixedParams(XnSensorFirmware* pFirmware, XnDevicePrivateData* pDevicePrivateData); + XnSensorFixedParams(XnDevicePrivateData* pDevicePrivateData); XnStatus Init(); + inline XnUInt16 GetDepthCmosI2CBus() const { return m_nSensorDepthCMOSI2CBus; } + inline XnUInt16 GetDepthCmosI2CSlaveAddress() const { return m_nSensorDepthCMOSI2CSlaveAddress; } + inline XnUInt16 GetImageCmosI2CBus() const { return m_nSensorImageCMOSI2CBus; } + inline XnUInt16 GetImageCmosI2CSlaveAddress() const { return m_nSensorImageCMOSI2CSlaveAddress; } inline XnDepthPixel GetZeroPlaneDistance() const { return m_nZeroPlaneDistance; } inline XnDouble GetZeroPlanePixelSize() const { return m_dZeroPlanePixelSize; } inline XnDouble GetEmitterDCmosDistance() const { return m_dEmitterDCmosDistance; } + inline XnDouble GetDCmosRCmosDistance() const { return m_dDCmosRCmosDistance; } inline const XnChar* GetSensorSerial() const { return m_strSensorSerial; } + inline XnUInt32 GetImageCmosType() const { return m_nImageCmosType; } + + inline const XnChar* GetDeviceName() const { return m_deviceInfo.strDeviceName; } + inline const XnChar* GetVendorData() const { return m_deviceInfo.strVendorData; } + inline const XnChar* GetPlatformString() const { return m_strPlatformString; } + private: - XnSensorFirmware* m_pFirmware; XnDevicePrivateData* m_pDevicePrivateData; + XnUInt16 m_nSensorDepthCMOSI2CBus; + XnUInt16 m_nSensorDepthCMOSI2CSlaveAddress; + XnUInt16 m_nSensorImageCMOSI2CBus; + XnUInt16 m_nSensorImageCMOSI2CSlaveAddress; XnDepthPixel m_nZeroPlaneDistance; XnDouble m_dZeroPlanePixelSize; XnDouble m_dEmitterDCmosDistance; + XnDouble m_dDCmosRCmosDistance; + + XnUInt32 m_nImageCmosType; XnChar m_strSensorSerial[XN_DEVICE_MAX_STRING_LENGTH]; + XnDeviceInformation m_deviceInfo; + XnChar m_strPlatformString[XN_DEVICE_MAX_STRING_LENGTH]; }; #endif //__XN_SENSOR_FIXED_PARAMS_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorGenerator.cpp index 8fe2f6e..0d31bf9 100644 --- a/Source/XnDeviceSensorV2/XnSensorGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -107,7 +101,7 @@ XnStatus XnSensorGenerator::RegisterToNewDataAvailable(XnModuleStateChangedHandl NewDataCallback* pNewDataCallback; XN_VALIDATE_NEW(pNewDataCallback, NewDataCallback, this, handler, pCookie); hCallback = pNewDataCallback; - nRetVal = m_pSensor->RegisterToNewStreamData(&OnDeviceNewStreamData, pNewDataCallback, &(pNewDataCallback->m_hCallback)); + nRetVal = m_pSensor->RegisterToNewStreamData(&OnDeviceNewStreamData, pNewDataCallback, pNewDataCallback->m_hCallback); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pNewDataCallback); @@ -193,11 +187,16 @@ void XnSensorGenerator::FilterProperties(XnActualPropertiesHash* pHash) pHash->Remove(XN_STREAM_PROPERTY_STATE); } -void XN_CALLBACK_TYPE XnSensorGenerator::OnDeviceNewStreamData(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, void* pCookie) +void XN_CALLBACK_TYPE XnSensorGenerator::OnDeviceNewStreamData(const XnNewStreamDataEventArgs& args, void* pCookie) { NewDataCallback *pNewDataCBParams = (NewDataCallback*)pCookie; - if (strcmp(pNewDataCBParams->m_pGenerator->m_strInstanceName, StreamName) == 0) + if (strcmp(pNewDataCBParams->m_pGenerator->m_strInstanceName, args.strStreamName) == 0) { pNewDataCBParams->m_handler(pNewDataCBParams->m_pCookie); } -} \ No newline at end of file +} + +const void* XnSensorGenerator::GetData() +{ + return m_pStreamData->pData; +} diff --git a/Source/XnDeviceSensorV2/XnSensorGenerator.h b/Source/XnDeviceSensorV2/XnSensorGenerator.h index 2b0dd90..882f714 100644 --- a/Source/XnDeviceSensorV2/XnSensorGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_GENERATOR_H__ #define __XN_SENSOR_GENERATOR_H__ @@ -36,6 +30,10 @@ //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorGenerator : public XnSensorProductionNode, virtual public xn::ModuleGenerator, @@ -58,6 +56,7 @@ class XnSensorGenerator : void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback); XnBool IsNewDataAvailable(XnUInt64& pnTimestamp); XnStatus UpdateData(); + const void* GetData(); XnUInt32 GetDataSize(); XnUInt64 GetTimestamp(); XnUInt32 GetFrameID(); @@ -87,7 +86,9 @@ class XnSensorGenerator : XnCallbackHandle m_hCallback; }; - static void XN_CALLBACK_TYPE OnDeviceNewStreamData(XnDeviceHandle pDeviceHandle, const XnChar* StreamName, void* pCookie); + static void XN_CALLBACK_TYPE OnDeviceNewStreamData(const XnNewStreamDataEventArgs& args, void* pCookie); }; +#pragma warning (pop) + #endif // __XN_SENSOR_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorIRGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorIRGenerator.cpp index 0e6b093..8f45f58 100644 --- a/Source/XnDeviceSensorV2/XnSensorIRGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorIRGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -58,14 +52,6 @@ XnStatus XnSensorIRGenerator::Init() nRetVal = RegisterToCroppingChange(OnResChangedCallback, this, m_hCroppingCallback); XN_IS_STATUS_OK(nRetVal); - // add SXGA 30 - XnMapOutputMode mode; - mode.nXRes = XN_SXGA_X_RES; - mode.nYRes = XN_SXGA_Y_RES; - mode.nFPS = 30; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); - OnResChanged(); return (XN_STATUS_OK); @@ -116,7 +102,7 @@ void XN_CALLBACK_TYPE XnSensorIRGenerator::OnResChangedCallback(void* pCookie) // XnExportedSensorIRGenerator class //--------------------------------------------------------------------------- XnExportedSensorIRGenerator::XnExportedSensorIRGenerator() : - XnExportedSensorGenerator(XN_NODE_TYPE_IR, XN_STREAM_TYPE_IR) + XnExportedSensorGenerator(XN_NODE_TYPE_IR, XN_STREAM_TYPE_IR, FALSE) {} XnSensorGenerator* XnExportedSensorIRGenerator::CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) diff --git a/Source/XnDeviceSensorV2/XnSensorIRGenerator.h b/Source/XnDeviceSensorV2/XnSensorIRGenerator.h index b3510eb..da753a6 100644 --- a/Source/XnDeviceSensorV2/XnSensorIRGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorIRGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_IR_GENERATOR_H__ #define __XN_SENSOR_IR_GENERATOR_H__ @@ -37,6 +31,10 @@ //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorIRGenerator: public XnSensorMapGenerator, virtual public xn::ModuleIRGenerator @@ -49,6 +47,7 @@ class XnSensorIRGenerator: virtual XnBool IsCapabilitySupported(const XnChar* strCapabilityName); virtual XnUInt32 GetDataSize(); + const void* GetData() { return XnSensorMapGenerator::GetData(); } virtual XnIRPixel* GetIRMap(); private: @@ -68,4 +67,6 @@ class XnExportedSensorIRGenerator : public XnExportedSensorGenerator virtual XnSensorGenerator* CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); }; +#pragma warning (pop) + #endif // __XN_SENSOR_IR_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorIRStream.cpp b/Source/XnDeviceSensorV2/XnSensorIRStream.cpp index 30ad6ec..f30ee1b 100644 --- a/Source/XnDeviceSensorV2/XnSensorIRStream.cpp +++ b/Source/XnDeviceSensorV2/XnSensorIRStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,21 +31,15 @@ //--------------------------------------------------------------------------- // Defines //--------------------------------------------------------------------------- -#define XN_IR_STREAM_DEFAULT_FPS 30 -#define XN_IR_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_QVGA -#define XN_IR_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_RGB24 -#define XN_IR_STREAM_DEFAULT_MIRROR FALSE - #define XN_IR_MAX_BUFFER_SIZE (XN_SXGA_X_RES * XN_SXGA_Y_RES * sizeof(XnRGB24Pixel)) //--------------------------------------------------------------------------- // XnSensorIRStream class //--------------------------------------------------------------------------- -XnSensorIRStream::XnSensorIRStream(const XnChar* StreamName, XnSensorObjects* pObjects, XnUInt32 nBufferCount) : +XnSensorIRStream::XnSensorIRStream(const XnChar* StreamName, XnSensorObjects* pObjects) : XnIRStream(StreamName, FALSE), m_Helper(pObjects), - m_BufferPool(nBufferCount, StreamName, XN_IR_MAX_BUFFER_SIZE), - m_SharedBufferName(XN_STREAM_PROPERTY_SHARED_BUFFER_NAME, m_BufferPool.GetSharedMemoryName()), + m_InputFormat(XN_STREAM_PROPERTY_INPUT_FORMAT, 0), m_FirmwareCropSizeX("FirmwareCropSizeX", 0, StreamName), m_FirmwareCropSizeY("FirmwareCropSizeY", 0, StreamName), m_FirmwareCropOffsetX("FirmwareCropOffsetX", 0, StreamName), @@ -66,15 +54,15 @@ XnStatus XnSensorIRStream::Init() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = SetBufferPool(&m_BufferPool); - XN_IS_STATUS_OK(nRetVal); +// nRetVal = SetBufferPool(&m_BufferPool); +// XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnIRStream::Init(); XN_IS_STATUS_OK(nRetVal); // add properties - XN_VALIDATE_ADD_PROPERTIES(this, &m_SharedBufferName, &m_ActualRead); + XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IR_STREAM_DEFAULT_RESOLUTION); @@ -90,13 +78,19 @@ XnStatus XnSensorIRStream::Init() nRetVal = m_Helper.Init(this, this); XN_IS_STATUS_OK(nRetVal); + // register supported modes + XnCmosPreset* pSupportedModes = m_Helper.GetPrivateData()->FWInfo.irModes.GetData(); + XnUInt8 nSupportedModes = m_Helper.GetPrivateData()->FWInfo.irModes.GetSize(); + nRetVal = AddSupportedModes(pSupportedModes, nSupportedModes); + XN_IS_STATUS_OK(nRetVal); + // data processor nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); // register for mirror XnCallbackHandle hCallbackDummy; - nRetVal = IsMirroredProperty().OnChangeEvent().Register(IsMirroredChangedCallback, this, &hCallbackDummy); + nRetVal = IsMirroredProperty().OnChangeEvent().Register(IsMirroredChangedCallback, this, hCallbackDummy); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -113,13 +107,20 @@ XnStatus XnSensorIRStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_IRResolution, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_IRFPS, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_IRCropSizeX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_IRCropSizeY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_IRCropOffsetX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_IRCropOffsetY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_IRCropEnabled, TRUE)); + nRetVal = m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_IRResolution, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_IRFPS, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_IRCropSizeX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_IRCropSizeY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_IRCropOffsetX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_IRCropOffsetY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_IRCropEnabled, TRUE); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -133,8 +134,10 @@ XnStatus XnSensorIRStream::ConfigureStreamImpl() nRetVal = SetActualRead(TRUE); XN_IS_STATUS_OK(nRetVal); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); + nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); + XN_IS_STATUS_OK(nRetVal);; // IR mirror is always off in firmware nRetVal = GetFirmwareParams()->m_IRMirror.SetValue(FALSE); @@ -159,7 +162,8 @@ XnStatus XnSensorIRStream::SetActualRead(XnBool bRead) if (bRead) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB IR read thread..."); - nRetVal = xnUSBInitReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp, GetHelper()->GetPrivateData()->pSpecificImageUsb->nChunkReadBytes, XN_SENSOR_USB_IMAGE_BUFFERS, XN_SENSOR_READ_THREAD_TIMEOUT, XnDeviceSensorProtocolUsbEpCb, GetHelper()->GetPrivateData()->pSpecificImageUsb); + XnSpecificUsbDevice* pUSB = GetHelper()->GetPrivateData()->pSpecificImageUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, XN_SENSOR_USB_DEPTH_BUFFERS, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); XN_IS_STATUS_OK(nRetVal); } else @@ -185,12 +189,17 @@ XnStatus XnSensorIRStream::OpenStreamImpl() // Cropping if (m_FirmwareCropEnabled.GetValue() == TRUE) { - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeY)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeY); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY); + XN_IS_STATUS_OK(nRetVal);; } - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropEnabled)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropEnabled); + XN_IS_STATUS_OK(nRetVal);; nRetVal = XnIRStream::Open(); @@ -245,7 +254,7 @@ XnStatus XnSensorIRStream::SetFPS(XnUInt32 nFPS) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), nFPS); + nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), (XnUInt16)nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = XnIRStream::SetFPS(nFPS); @@ -261,22 +270,7 @@ XnStatus XnSensorIRStream::SetResolution(XnResolutions nResolution) { XnStatus nRetVal = XN_STATUS_OK; - switch (nResolution) - { - case XN_RESOLUTION_QVGA: - case XN_RESOLUTION_VGA: - break; - case XN_RESOLUTION_SXGA: - if (m_Helper.GetFirmwareVersion() < XN_SENSOR_FW_VER_5_1) - { - XN_LOG_WARNING_RETURN(XN_STATUS_IO_INVALID_STREAM_IMAGE_RESOLUTION, XN_MASK_DEVICE_SENSOR, "IR resolution is not supported by this firmware!"); - } - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported IR resolution: %d", nResolution); - } - - nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), nResolution); + nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), (XnUInt16)nResolution); XN_IS_STATUS_OK(nRetVal); nRetVal = XnIRStream::SetResolution(nResolution); @@ -311,7 +305,7 @@ XnStatus XnSensorIRStream::SetCropping(const XnCropping* pCropping) XnUInt16 nXOffset = pCropping->nXOffset; if (IsMirrored()) { - nXOffset = GetXRes() - pCropping->nXOffset - pCropping->nXSize; + nXOffset = (XnUInt16)(GetXRes() - pCropping->nXOffset - pCropping->nXSize); } if (pCropping->bEnabled) @@ -329,7 +323,9 @@ XnStatus XnSensorIRStream::SetCropping(const XnCropping* pCropping) } if (nRetVal == XN_STATUS_OK) - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, pCropping->bEnabled); + { + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, (XnUInt16)pCropping->bEnabled); + } if (nRetVal != XN_STATUS_OK) { @@ -424,8 +420,12 @@ XnStatus XnSensorIRStream::CreateDataProcessor(XnDataProcessor** ppProcessor) { XnStatus nRetVal = XN_STATUS_OK; + XnFrameBufferManager* pBufferManager; + nRetVal = GetTripleBuffer(&pBufferManager); + XN_IS_STATUS_OK(nRetVal); + XnDataProcessor* pNew; - XN_VALIDATE_NEW_AND_INIT(pNew, XnIRProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnIRProcessor, this, &m_Helper, pBufferManager); *ppProcessor = pNew; @@ -447,13 +447,13 @@ XnStatus XnSensorIRStream::OnIsMirroredChanged() return (XN_STATUS_OK); } -XnStatus XnSensorIRStream::IsMirroredChangedCallback(const XnProperty* pSender, void* pCookie) +XnStatus XnSensorIRStream::IsMirroredChangedCallback(const XnProperty* /*pSender*/, void* pCookie) { XnSensorIRStream* pThis = (XnSensorIRStream*)pCookie; return pThis->OnIsMirroredChanged(); } -XnStatus XN_CALLBACK_TYPE XnSensorIRStream::SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorIRStream::SetActualReadCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorIRStream* pThis = (XnSensorIRStream*)pCookie; return pThis->SetActualRead(nValue == TRUE); diff --git a/Source/XnDeviceSensorV2/XnSensorIRStream.h b/Source/XnDeviceSensorV2/XnSensorIRStream.h index 68ab322..61b92c9 100644 --- a/Source/XnDeviceSensorV2/XnSensorIRStream.h +++ b/Source/XnDeviceSensorV2/XnSensorIRStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_IR_STREAM_H__ #define __XN_SENSOR_IR_STREAM_H__ @@ -32,7 +27,14 @@ //--------------------------------------------------------------------------- #include #include "XnSensorStreamHelper.h" -#include "XnSharedMemoryBufferPool.h" + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_IR_STREAM_DEFAULT_FPS 30 +#define XN_IR_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_QVGA +#define XN_IR_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_RGB24 +#define XN_IR_STREAM_DEFAULT_MIRROR FALSE //--------------------------------------------------------------------------- // XnSensorIRStream class @@ -40,7 +42,7 @@ class XnSensorIRStream : public XnIRStream, public IXnSensorStream { public: - XnSensorIRStream(const XnChar* StreamName, XnSensorObjects* pObjects, XnUInt32 nBufferCount); + XnSensorIRStream(const XnChar* StreamName, XnSensorObjects* pObjects); ~XnSensorIRStream() { Free(); } //--------------------------------------------------------------------------- @@ -71,8 +73,7 @@ class XnSensorIRStream : public XnIRStream, public IXnSensorStream XnStatus CreateDataProcessor(XnDataProcessor** ppProcessor); XnStatus MapPropertiesToFirmware(); void GetFirmwareStreamConfig(XnResolutions* pnRes, XnUInt32* pnFPS) { *pnRes = GetResolution(); *pnFPS = GetFPS(); } - XnStatus WriteImpl(XnStreamData* pStreamData) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } - XnSharedMemoryBufferPool* GetSharedMemoryBuffer() { return &m_BufferPool; } + XnStatus WriteImpl(XnStreamData* /*pStreamData*/) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } //--------------------------------------------------------------------------- // Setters @@ -90,10 +91,9 @@ class XnSensorIRStream : public XnIRStream, public IXnSensorStream static XnStatus XN_CALLBACK_TYPE IsMirroredChangedCallback(const XnProperty* pSender, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); - XnSensorStreamHelper m_Helper; - XnSharedMemoryBufferPool m_BufferPool; + XnActualIntProperty m_InputFormat; - XnActualStringProperty m_SharedBufferName; + XnSensorStreamHelper m_Helper; XnActualIntProperty m_FirmwareCropSizeX; XnActualIntProperty m_FirmwareCropSizeY; XnActualIntProperty m_FirmwareCropOffsetX; diff --git a/Source/XnDeviceSensorV2/XnSensorImageGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorImageGenerator.cpp index 1516020..42a93ba 100644 --- a/Source/XnDeviceSensorV2/XnSensorImageGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorImageGenerator.cpp @@ -1,35 +1,39 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnSensorImageGenerator.h" #include +#include "XnSensorImageStream.h" + +//--------------------------------------------------------------------------- +// Static Data +//--------------------------------------------------------------------------- +static const XnUInt32 INVALID_INPUT_FORMAT = 9999; +static XnUInt32 g_anAllowedRGBFormats[] = { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_IO_IMAGE_FORMAT_YUV422, XN_IO_IMAGE_FORMAT_BAYER, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER }; +static XnUInt32 g_anAllowedYUVFormats[] = { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422, XN_IO_IMAGE_FORMAT_YUV422 }; +static XnUInt32 g_anAllowedJPEGFormats[] = { XN_IO_IMAGE_FORMAT_JPEG }; +static XnUInt32 g_anAllowedGray8Formats[] = { XN_IO_IMAGE_FORMAT_UNCOMPRESSED_GRAY8, XN_IO_IMAGE_FORMAT_BAYER, XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER }; //--------------------------------------------------------------------------- // XnSensorImageGenerator class @@ -38,43 +42,12 @@ XnSensorImageGenerator::XnSensorImageGenerator(xn::Context& context, xn::Device& XnSensorMapGenerator(context, sensor, pSensor, strStreamName) {} -XnStatus XnSensorImageGenerator::Init() -{ - XnStatus nRetVal = XN_STATUS_OK; - - nRetVal = XnSensorMapGenerator::Init(); - XN_IS_STATUS_OK(nRetVal); - - // add supported modes unique for image - XnMapOutputMode mode; - - switch (m_Version.FWVer) - { - case XN_SENSOR_FW_VER_5_1: - case XN_SENSOR_FW_VER_5_2: - // UXGA 30 - mode.nXRes = XN_UXGA_X_RES; - mode.nYRes = XN_UXGA_Y_RES; - mode.nFPS = 30; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); - break; - case XN_SENSOR_FW_VER_5_3: - // SXGA 30 - mode.nXRes = XN_SXGA_X_RES; - mode.nYRes = XN_SXGA_Y_RES; - mode.nFPS = 30; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); - break; - } - - return (XN_STATUS_OK); -} - XnBool XnSensorImageGenerator::IsCapabilitySupported(const XnChar* strCapabilityName) { - return XnSensorMapGenerator::IsCapabilitySupported(strCapabilityName); + return + (GetGeneralIntInterface(strCapabilityName) != NULL || + strcmp(strCapabilityName, XN_CAPABILITY_ANTI_FLICKER) == 0 || + XnSensorMapGenerator::IsCapabilitySupported(strCapabilityName)); } XnUInt8* XnSensorImageGenerator::GetImageMap() @@ -84,15 +57,75 @@ XnUInt8* XnSensorImageGenerator::GetImageMap() XnBool XnSensorImageGenerator::IsPixelFormatSupported(XnPixelFormat Format) { - switch (Format) + for (XnUInt32 i = 0; i < m_nSupportedModesCount; ++i) { - case XN_PIXEL_FORMAT_RGB24: - case XN_PIXEL_FORMAT_YUV422: - case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: - return TRUE; - default: - return FALSE; + switch (Format) + { + case XN_PIXEL_FORMAT_RGB24: + case XN_PIXEL_FORMAT_YUV422: + if (m_aSupportedModes[i].nInputFormat == XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 || + m_aSupportedModes[i].nInputFormat == XN_IO_IMAGE_FORMAT_YUV422) + { + return TRUE; + } + break; + case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: + if (m_aSupportedModes[i].nInputFormat == XN_IO_IMAGE_FORMAT_BAYER || + m_aSupportedModes[i].nInputFormat == XN_IO_IMAGE_FORMAT_UNCOMPRESSED_GRAY8) + { + return TRUE; + } + break; + case XN_PIXEL_FORMAT_MJPEG: + if (m_aSupportedModes[i].nInputFormat == XN_IO_IMAGE_FORMAT_JPEG) + { + return TRUE; + } + break; + default: + return FALSE; + } } + + // not found + return FALSE; +} + +XnUInt32 XnSensorImageGenerator::FindSupportedInputFormat(XnUInt32* anAllowedInputFormats, XnUInt32 nAllowedInputFormats) +{ + // first check if current one is allowed + XnUInt64 nCurrentInputFormat; + GetIntProperty(XN_STREAM_PROPERTY_INPUT_FORMAT, nCurrentInputFormat); + + for (XnUInt32 i = 0; i < nAllowedInputFormats; ++i) + { + if (anAllowedInputFormats[i] == nCurrentInputFormat) + { + return (XnUInt32)nCurrentInputFormat; + } + } + + // current one is not allowed. find a matching mode and take its input format + XnMapOutputMode outputMode; + GetMapOutputMode(outputMode); + + // the order in the allowed input formats is the preferred one + for (XnUInt32 iInput = 0; iInput < nAllowedInputFormats; ++iInput) + { + // see if such a mode exists + for (XnUInt32 iMode = 0; iMode < m_nSupportedModesCount; ++iMode) + { + if (m_aSupportedModes[iMode].nInputFormat == anAllowedInputFormats[iInput] && + m_aSupportedModes[iMode].OutputMode.nXRes == outputMode.nXRes && + m_aSupportedModes[iMode].OutputMode.nYRes == outputMode.nYRes && + m_aSupportedModes[iMode].OutputMode.nFPS == outputMode.nFPS) + { + return anAllowedInputFormats[iInput]; + } + } + } + + return INVALID_INPUT_FORMAT; } XnStatus XnSensorImageGenerator::SetPixelFormat(XnPixelFormat Format) @@ -102,24 +135,50 @@ XnStatus XnSensorImageGenerator::SetPixelFormat(XnPixelFormat Format) return (XN_STATUS_OK); } + XN_PROPERTY_SET_CREATE_ON_STACK(props); + XnStatus nRetVal = XnPropertySetAddModule(&props, m_strModule); + XN_IS_STATUS_OK(nRetVal); + XnOutputFormats OutputFormat; + XnUInt32* anAllowedInputFormats = NULL; + XnUInt32 nAllowedInputFormats = 0; switch (Format) { case XN_PIXEL_FORMAT_RGB24: OutputFormat = XN_OUTPUT_FORMAT_RGB24; + anAllowedInputFormats = g_anAllowedRGBFormats; + nAllowedInputFormats = sizeof(g_anAllowedRGBFormats)/sizeof(XnUInt32); break; case XN_PIXEL_FORMAT_YUV422: OutputFormat = XN_OUTPUT_FORMAT_YUV422; + anAllowedInputFormats = g_anAllowedYUVFormats; + nAllowedInputFormats = sizeof(g_anAllowedYUVFormats)/sizeof(XnUInt32); break; case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: OutputFormat = XN_OUTPUT_FORMAT_GRAYSCALE8; + anAllowedInputFormats = g_anAllowedGray8Formats; + nAllowedInputFormats = sizeof(g_anAllowedGray8Formats)/sizeof(XnUInt32); + break; + case XN_PIXEL_FORMAT_MJPEG: + OutputFormat = XN_OUTPUT_FORMAT_JPEG; + anAllowedInputFormats = g_anAllowedJPEGFormats; + nAllowedInputFormats = sizeof(g_anAllowedJPEGFormats)/sizeof(XnUInt32); break; default: return XN_STATUS_INVALID_OPERATION; } - return m_pSensor->SetProperty(m_strModule, XN_STREAM_PROPERTY_OUTPUT_FORMAT, (XnUInt64)OutputFormat); + XnUInt32 nInputFormat = FindSupportedInputFormat(anAllowedInputFormats, nAllowedInputFormats); + if (nInputFormat == INVALID_INPUT_FORMAT) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Cannot set pixel format to %s - no matching input format.", xnPixelFormatToString(Format)); + } + + XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_INPUT_FORMAT, (XnUInt64)nInputFormat); + XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_OUTPUT_FORMAT, (XnUInt64)OutputFormat); + + return m_pSensor->BatchConfig(&props); } XnPixelFormat XnSensorImageGenerator::GetPixelFormat() @@ -135,6 +194,8 @@ XnPixelFormat XnSensorImageGenerator::GetPixelFormat() return XN_PIXEL_FORMAT_YUV422; case XN_OUTPUT_FORMAT_GRAYSCALE8: return XN_PIXEL_FORMAT_GRAYSCALE_8_BIT; + case XN_OUTPUT_FORMAT_JPEG: + return XN_PIXEL_FORMAT_MJPEG; default: xnLogError(XN_MASK_DEVICE_SENSOR, "Unknown output format: %d", nValue); return (XnPixelFormat)-1; @@ -163,13 +224,255 @@ void XnSensorImageGenerator::FilterProperties(XnActualPropertiesHash* pHash) pHash->Remove(XN_STREAM_PROPERTY_OUTPUT_FORMAT); } +xn::ModuleGeneralIntInterface* XnSensorImageGenerator::GetGeneralIntInterface( const XnChar* strCap ) +{ + if (m_Version.FWVer < XN_SENSOR_FW_VER_5_4) + { + return NULL; + } + + if (strcmp(strCap, XN_CAPABILITY_BRIGHTNESS) == 0 || + strcmp(strCap, XN_CAPABILITY_CONTRAST) == 0 || + strcmp(strCap, XN_CAPABILITY_SATURATION) == 0 || + strcmp(strCap, XN_CAPABILITY_SHARPNESS) == 0 || + strcmp(strCap, XN_CAPABILITY_COLOR_TEMPERATURE) == 0 || + strcmp(strCap, XN_CAPABILITY_BACKLIGHT_COMPENSATION) == 0 || + strcmp(strCap, XN_CAPABILITY_GAIN) == 0 || + strcmp(strCap, XN_CAPABILITY_ZOOM) == 0 || + strcmp(strCap, XN_CAPABILITY_EXPOSURE) == 0 || + strcmp(strCap, XN_CAPABILITY_PAN) == 0 || + strcmp(strCap, XN_CAPABILITY_TILT) == 0 || + strcmp(strCap, XN_CAPABILITY_LOW_LIGHT_COMPENSATION) == 0) + { + return this; + } + else + { + return NULL; + } +} + +XnStatus XnSensorImageGenerator::GetRange( const XnChar* strCap, XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported ) +{ + if (strcmp(strCap, XN_CAPABILITY_BRIGHTNESS) == 0) + { + nMin = 0; + nMax = 255; + nStep = 1; + nDefault = 128; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_CONTRAST) == 0) + { + nMin = 0; + nMax = 255; + nStep = 1; + nDefault = 32; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_SATURATION) == 0) + { + nMin = 0; + nMax = 255; + nStep = 1; + nDefault = 128; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_SHARPNESS) == 0) + { + nMin = 0; + nMax = 255; + nStep = 1; + nDefault = 32; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_COLOR_TEMPERATURE) == 0) + { + nMin = 0; + nMax = 10000; + nStep = 1; + nDefault = 5000; + bIsAutoSupported = TRUE; + } + else if (strcmp(strCap, XN_CAPABILITY_BACKLIGHT_COMPENSATION) == 0) + { + nMin = 0; + nMax = 3; + nStep = 1; + nDefault = 1; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_GAIN) == 0) + { + nMin = 0; + nMax = 255; + nStep = 1; + nDefault = 128; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_ZOOM) == 0) + { + nMin = 100; + nMax = 200; + nStep = 10; + nDefault = 100; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_EXPOSURE) == 0) + { + nMin = 5; + nMax = 2000; + nStep = 1; + nDefault = 100; + bIsAutoSupported = TRUE; + } + else if (strcmp(strCap, XN_CAPABILITY_PAN) == 0) + { + nMin = -180; + nMax = 180; + nStep = 1; + nDefault = 0; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_TILT) == 0) + { + nMin = -180; + nMax = 180; + nStep = 1; + nDefault = 0; + bIsAutoSupported = FALSE; + } + else if (strcmp(strCap, XN_CAPABILITY_LOW_LIGHT_COMPENSATION) == 0) + { + nMin = 0; + nMax = 1; + nStep = 1; + nDefault = 1; + bIsAutoSupported = FALSE; + } + else + { + return XN_STATUS_NO_SUCH_PROPERTY; + } + + return XN_STATUS_OK; +} + +XnStatus XnSensorImageGenerator::Get( const XnChar* strCap, XnInt32& nValue ) +{ + XnUInt64 nValue64; + XnStatus nRetVal = GetIntProperty(strCap, nValue64); + XN_IS_STATUS_OK(nRetVal); + + nValue = (XnInt32)nValue64; + + return XN_STATUS_OK; +} + +XnInt32 XnSensorImageGenerator::Set( const XnChar* strCap, XnInt32 nValue ) +{ + return SetIntProperty(strCap, nValue); +} + +XnStatus XnSensorImageGenerator::RegisterToValueChange( const XnChar* strCap, XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback ) +{ + const XnChar* strProps[] = + { + strCap, + NULL + }; + + return RegisterToProps(handler, pCookie, hCallback, strProps); +} + +void XnSensorImageGenerator::UnregisterFromValueChange( const XnChar* /*strCap*/, XnCallbackHandle hCallback ) +{ + UnregisterFromProps(hCallback); +} + +XnPowerLineFrequency XnSensorImageGenerator::GetPowerLineFrequency() +{ + XnUInt64 nFlicker; + GetIntProperty(XN_STREAM_PROPERTY_FLICKER, nFlicker); + return (XnPowerLineFrequency)nFlicker; +} + +XnStatus XnSensorImageGenerator::SetPowerLineFrequency( XnPowerLineFrequency nFrequency ) +{ + return SetIntProperty(XN_STREAM_PROPERTY_FLICKER, nFrequency); +} + +XnStatus XnSensorImageGenerator::RegisterToPowerLineFrequencyChange( XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback ) +{ + const XnChar* strProps[] = + { + XN_STREAM_PROPERTY_FLICKER, + NULL + }; + + return RegisterToProps(handler, pCookie, hCallback, strProps); +} + +void XnSensorImageGenerator::UnregisterFromPowerLineFrequencyChange( XnCallbackHandle hCallback ) +{ + return UnregisterFromProps(hCallback); +} + //--------------------------------------------------------------------------- // XnExportedSensorImageGenerator class //--------------------------------------------------------------------------- XnExportedSensorImageGenerator::XnExportedSensorImageGenerator() : - XnExportedSensorGenerator(XN_NODE_TYPE_IMAGE, XN_STREAM_TYPE_IMAGE) + XnExportedSensorGenerator(XN_NODE_TYPE_IMAGE, XN_STREAM_TYPE_IMAGE, FALSE) {} +XnStatus XnExportedSensorImageGenerator::IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = XnExportedSensorGenerator::IsSupportedForDevice(context, sensorInfo, pbSupported); + XN_IS_STATUS_OK(nRetVal); + + if (*pbSupported == FALSE) + { + return XN_STATUS_OK; + } + + xn::Device sensor; + nRetVal = sensorInfo.GetInstance(sensor); + XN_IS_STATUS_OK(nRetVal); + + XnUInt64 nImageSupported = FALSE; + + if (sensor.IsValid()) + { + nRetVal = sensor.GetIntProperty(XN_MODULE_PROPERTY_IMAGE_SUPPORTED, nImageSupported); + XN_IS_STATUS_OK(nRetVal); + } + else + { + // Don't create sensor through OpenNI. This will cause it to soft-reset. + // instead, "talk" directly to the sensor class + XnSensor lowLevelSensor(FALSE); + XnDeviceConfig config; + config.DeviceMode = XN_DEVICE_MODE_READ; + config.cpConnectionString = sensorInfo.GetCreationInfo(); + config.SharingMode = XN_DEVICE_EXCLUSIVE; + config.pInitialValues = NULL; + nRetVal = lowLevelSensor.Init(&config); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = lowLevelSensor.GetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_IMAGE_SUPPORTED, &nImageSupported); + XN_IS_STATUS_OK(nRetVal); + } + + if (nImageSupported != TRUE) + { + *pbSupported = FALSE; + } + + return (XN_STATUS_OK); +} + XnSensorGenerator* XnExportedSensorImageGenerator::CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) { return XN_NEW(XnSensorImageGenerator, context, sensor, pSensor, strStreamName); diff --git a/Source/XnDeviceSensorV2/XnSensorImageGenerator.h b/Source/XnDeviceSensorV2/XnSensorImageGenerator.h index 82983cd..15fdb35 100644 --- a/Source/XnDeviceSensorV2/XnSensorImageGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorImageGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_IMAGE_GENERATOR_H__ #define __XN_SENSOR_IMAGE_GENERATOR_H__ @@ -37,17 +31,22 @@ //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorImageGenerator: public XnSensorMapGenerator, - virtual public xn::ModuleImageGenerator + virtual public xn::ModuleImageGenerator, + virtual public xn::ModuleGeneralIntInterface, + virtual public xn::ModuleAntiFlickerInterface { public: XnSensorImageGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); - XnStatus Init(); - XnBool IsCapabilitySupported(const XnChar* strCapabilityName); + const void* GetData() { return XnSensorMapGenerator::GetData(); } XnUInt8* GetImageMap(); XnBool IsPixelFormatSupported(XnPixelFormat Format); XnStatus SetPixelFormat(XnPixelFormat Format); @@ -55,15 +54,36 @@ class XnSensorImageGenerator: XnStatus RegisterToPixelFormatChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback); void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback); + virtual xn::ModuleGeneralIntInterface* GetGeneralIntInterface(const XnChar* strCap); + virtual XnStatus GetRange(const XnChar* strCap, XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported); + virtual XnStatus Get(const XnChar* strCap, XnInt32& nValue); + virtual XnInt32 Set(const XnChar* strCap, XnInt32 nValue); + virtual XnStatus RegisterToValueChange(const XnChar* strCap, XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback); + virtual void UnregisterFromValueChange(const XnChar* strCap, XnCallbackHandle hCallback); + + virtual xn::ModuleAntiFlickerInterface* GetAntiFlickerInterface() { return this; } + virtual XnPowerLineFrequency GetPowerLineFrequency(); + virtual XnStatus SetPowerLineFrequency( XnPowerLineFrequency nFrequency ); + virtual XnStatus RegisterToPowerLineFrequencyChange( XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback ); + virtual void UnregisterFromPowerLineFrequencyChange( XnCallbackHandle hCallback ); + protected: virtual void FilterProperties(XnActualPropertiesHash* pHash); + +private: + XnUInt32 FindSupportedInputFormat(XnUInt32* anAllowedInputFormats, XnUInt32 nAllowedInputFormats); }; class XnExportedSensorImageGenerator : public XnExportedSensorGenerator { public: XnExportedSensorImageGenerator(); + +protected: + virtual XnStatus IsSupportedForDevice(xn::Context& context, xn::NodeInfo& sensorInfo, XnBool* pbSupported); virtual XnSensorGenerator* CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); }; +#pragma warning (pop) + #endif // __XN_SENSOR_IMAGE_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorImageStream.cpp b/Source/XnDeviceSensorV2/XnSensorImageStream.cpp index c9a9909..defb72a 100644 --- a/Source/XnDeviceSensorV2/XnSensorImageStream.cpp +++ b/Source/XnDeviceSensorV2/XnSensorImageStream.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -35,50 +29,61 @@ #include "XnUncompressedBayerProcessor.h" #include "XnPSCompressedImageProcessor.h" #include "XnJpegImageProcessor.h" +#include "XnJpegToRGBImageProcessor.h" #include "XnUncompressedYUVImageProcessor.h" #include "XnUncompressedYUVtoRGBImageProcessor.h" #include "YUV.h" #include "Bayer.h" #include -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -#define XN_IMAGE_STREAM_DEFAULT_FPS 30 -#define XN_IMAGE_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_QVGA -#define XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT XN_IO_IMAGE_FORMAT_YUV422 -#define XN_IMAGE_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_RGB24 -#define XN_IMAGE_STREAM_DEFAULT_FLICKER 0 -#define XN_IMAGE_STREAM_DEFAULT_QUALITY 10 - //--------------------------------------------------------------------------- // XnSensorImageStream class //--------------------------------------------------------------------------- -XnSensorImageStream::XnSensorImageStream(const XnChar* StreamName, XnSensorObjects* pObjects, XnUInt32 nBufferCount) : +XnSensorImageStream::XnSensorImageStream(const XnChar* StreamName, XnSensorObjects* pObjects) : XnImageStream(StreamName, FALSE), m_Helper(pObjects), - m_BufferPool(nBufferCount, StreamName, GetMaxBufferSize(m_Helper.GetFirmwareVersion())), - m_SharedBufferName(XN_STREAM_PROPERTY_SHARED_BUFFER_NAME, m_BufferPool.GetSharedMemoryName()), m_InputFormat(XN_STREAM_PROPERTY_INPUT_FORMAT, XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT), m_AntiFlicker(XN_STREAM_PROPERTY_FLICKER, XN_IMAGE_STREAM_DEFAULT_FLICKER), m_ImageQuality(XN_STREAM_PROPERTY_QUALITY, XN_IMAGE_STREAM_DEFAULT_QUALITY), + m_Brightness(XN_STREAM_PROPERTY_BRIGHTNESS, XN_IMAGE_STREAM_DEFAULT_BRIGHTNESS), + m_Contrast(XN_STREAM_PROPERTY_CONTRAST, XN_IMAGE_STREAM_DEFAULT_CONTRAST), + m_Saturation(XN_STREAM_PROPERTY_SATURATION, XN_IMAGE_STREAM_DEFAULT_SATURATION), + m_Sharpness(XN_STREAM_PROPERTY_SHARPNESS, XN_IMAGE_STREAM_DEFAULT_SHARPNESS), + m_ColorTemperature(XN_STREAM_PROPERTY_COLOR_TEMPERATURE, XN_IMAGE_STREAM_DEFAULT_COLOR_TEMP), + m_BackLightCompensation(XN_STREAM_PROPERTY_BACKLIGHT_COMPENSATION, XN_IMAGE_STREAM_DEFAULT_BACKLIGHT_COMP), + m_Gain(XN_STREAM_PROPERTY_GAIN, XN_IMAGE_STREAM_DEFAULT_GAIN), + m_Zoom(XN_STREAM_PROPERTY_ZOOM, XN_IMAGE_STREAM_DEFAULT_ZOOM), + m_Exposure(XN_STREAM_PROPERTY_EXPOSURE, XN_IMAGE_STREAM_DEFAULT_EXPOSURE_BAR), + m_Pan(XN_STREAM_PROPERTY_PAN, XN_IMAGE_STREAM_DEFAULT_PAN), + m_Tilt(XN_STREAM_PROPERTY_TILT, XN_IMAGE_STREAM_DEFAULT_TILT), + m_LowLightCompensation(XN_STREAM_PROPERTY_LOW_LIGHT_COMPENSATION, XN_IMAGE_STREAM_DEFAULT_LOW_LIGHT_COMP), m_FirmwareMirror("FirmwareMirror", FALSE, StreamName), m_FirmwareCropSizeX("FirmwareCropSizeX", 0, StreamName), m_FirmwareCropSizeY("FirmwareCropSizeY", 0, StreamName), m_FirmwareCropOffsetX("FirmwareCropOffsetX", 0, StreamName), m_FirmwareCropOffsetY("FirmwareCropOffsetY", 0, StreamName), m_FirmwareCropEnabled("FirmwareCropEnabled", FALSE, StreamName), + m_FirmwareColorTemperature("FirmwareWhiteBalance", 0, StreamName), + m_FirmwareAutoWhiteBalance("FirmwareAutoWhiteBalance", 0, StreamName), + m_FirmwareExposure("FirmwareExposure", 0, StreamName), + m_FirmwareAutoExposure("FirmwareAutoExposure", FALSE, StreamName), m_ActualRead(XN_STREAM_PROPERTY_ACTUAL_READ_DATA, FALSE) { m_ActualRead.UpdateSetCallback(SetActualReadCallback, this); } +static XnStatus AddSupportedMode(XnArray& modes, XnUInt16 nInputFormat, XnUInt16 nResolution, XnUInt16 nFPS) +{ + XnCmosPreset preset = { nInputFormat, nResolution, nFPS }; + return modes.AddLast(preset); +} + XnStatus XnSensorImageStream::Init() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = SetBufferPool(&m_BufferPool); - XN_IS_STATUS_OK(nRetVal); +// nRetVal = SetBufferPool(&m_BufferPool); +// XN_IS_STATUS_OK(nRetVal); // init base nRetVal = XnImageStream::Init(); @@ -87,10 +92,24 @@ XnStatus XnSensorImageStream::Init() m_InputFormat.UpdateSetCallback(SetInputFormatCallback, this); m_AntiFlicker.UpdateSetCallback(SetAntiFlickerCallback, this); m_ImageQuality.UpdateSetCallback(SetImageQualityCallback, this); + m_Brightness.UpdateSetCallbackToDefault(); + m_Contrast.UpdateSetCallbackToDefault(); + m_Saturation.UpdateSetCallbackToDefault(); + m_Zoom.UpdateSetCallbackToDefault(); + m_Pan.UpdateSetCallbackToDefault(); + m_Tilt.UpdateSetCallbackToDefault(); + m_Sharpness.UpdateSetCallback(SetSharpnessCallback, this); + m_ColorTemperature.UpdateSetCallback(SetColorTemperatureCallback, this); + m_BackLightCompensation.UpdateSetCallback(SetBacklightCompensationCallback, this); + m_Gain.UpdateSetCallback(SetGainCallback, this); + m_Exposure.UpdateSetCallback(SetExposureCallback, this); + m_LowLightCompensation.UpdateSetCallback(SetLowLightCompensationCallback, this); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_AntiFlicker, &m_ImageQuality, - &m_SharedBufferName, &m_ActualRead); + &m_Brightness, &m_Contrast, &m_Saturation, &m_Sharpness, + &m_ColorTemperature, &m_BackLightCompensation, &m_Gain, &m_Zoom, + &m_Exposure, &m_Pan, &m_Tilt, &m_LowLightCompensation, &m_ActualRead); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_RESOLUTION); @@ -116,6 +135,92 @@ XnStatus XnSensorImageStream::Init() nRetVal = m_Helper.RegisterDataProcessorProperty(ResolutionProperty()); XN_IS_STATUS_OK(nRetVal); + // register supported modes + if (m_Helper.GetFirmware()->GetInfo()->bGetPresetsSupported) + { + // ask the firmware + const XnUInt32 nAllocSize = 100; + XnUInt32 nCount = nAllocSize; + XnCmosPreset aSupportedModes[nAllocSize]; + nRetVal = XnHostProtocolGetCmosPresets(m_Helper.GetPrivateData(), XN_CMOS_TYPE_IMAGE, aSupportedModes, nCount); + XN_IS_STATUS_OK(nRetVal); + + if (nCount == 0) + { + xnLogError(XN_MASK_DEVICE_SENSOR, "Device does not support any image mode!"); + return XN_STATUS_DEVICE_UNSUPPORTED_PARAMETER; + } + + nRetVal = AddSupportedModes(aSupportedModes, nCount); + XN_IS_STATUS_OK(nRetVal); + } + else + { + // Firmware doesn't support getting presets. Instead, we'll need to register presets + // we know according to firmware version + XnCmosPreset* pSupportedModes; + XnUInt8 nSupportedModes; + XnUInt64 nDefaultInputFormat; + + if (m_Helper.GetPrivateData()->pSpecificImageUsb->pUsbConnection->bIsISO) + { + pSupportedModes = m_Helper.GetPrivateData()->FWInfo.imageIsoModes.GetData(); + nSupportedModes = m_Helper.GetPrivateData()->FWInfo.imageIsoModes.GetSize(); + } + else + { + pSupportedModes = m_Helper.GetPrivateData()->FWInfo.imageBulkModes.GetData(); + nSupportedModes = m_Helper.GetPrivateData()->FWInfo.imageBulkModes.GetSize(); + } + + nRetVal = AddSupportedModes(pSupportedModes, nSupportedModes); + XN_IS_STATUS_OK(nRetVal); + } + + // check if our current (default) configuration is valid + XnUInt16 nValidInputFormat = XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT; + XnBool bModeFound = FALSE; + + const XnArray& aSupportedModes = GetSupportedModes(); + + for (XnUInt32 i = 0; i < aSupportedModes.GetSize(); ++i) + { + if (aSupportedModes[i].nResolution == XN_IMAGE_STREAM_DEFAULT_RESOLUTION && + aSupportedModes[i].nFPS == XN_IMAGE_STREAM_DEFAULT_FPS) + { + // found + if (!bModeFound) + { + bModeFound = TRUE; + nValidInputFormat = aSupportedModes[i].nFormat; + } + + if (aSupportedModes[i].nFormat == XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT) + { + nValidInputFormat = XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT; + break; + } + } + } + + if (!bModeFound) + { + xnLogWarning(XN_MASK_DEVICE_SENSOR, "Default mode (res + FPS) is not supported by device. Changing defaults..."); + + nRetVal = ResolutionProperty().UnsafeUpdateValue(aSupportedModes[0].nResolution); + XN_IS_STATUS_OK(nRetVal); + nRetVal = FPSProperty().UnsafeUpdateValue(aSupportedModes[0].nFPS); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_InputFormat.UnsafeUpdateValue(aSupportedModes[0].nFormat); + XN_IS_STATUS_OK(nRetVal); + } + else + { + // just update input format + nRetVal = m_InputFormat.UnsafeUpdateValue(nValidInputFormat); + XN_IS_STATUS_OK(nRetVal); + } + return (XN_STATUS_OK); } @@ -126,35 +231,48 @@ XnStatus XnSensorImageStream::Free() return (XN_STATUS_OK); } -XnUInt32 XnSensorImageStream::GetMaxBufferSize(XnFWVer version) -{ - if (version >= XN_SENSOR_FW_VER_5_3) - { - // max resolution is only SXGA - return (XN_SXGA_X_RES * XN_SXGA_Y_RES * sizeof(XnRGB24Pixel)); - } - else - { - // max resolution is UXGA - return (XN_UXGA_X_RES * XN_UXGA_Y_RES * sizeof(XnRGB24Pixel)); - } -} - XnStatus XnSensorImageStream::MapPropertiesToFirmware() { XnStatus nRetVal = XN_STATUS_OK; - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_ImageFormat, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_ImageResolution, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_ImageFPS, FALSE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_AntiFlicker, GetFirmwareParams()->m_ImageFlickerDetection, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_ImageQuality, GetFirmwareParams()->m_ImageQuality, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_ImageMirror, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_ImageCropSizeX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_ImageCropSizeY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_ImageCropOffsetX, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_ImageCropOffsetY, TRUE)); - XN_IS_STATUS_OK(m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_ImageCropEnabled, TRUE)); + nRetVal = m_Helper.MapFirmwareProperty(m_InputFormat, GetFirmwareParams()->m_ImageFormat, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(ResolutionProperty(), GetFirmwareParams()->m_ImageResolution, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(FPSProperty(), GetFirmwareParams()->m_ImageFPS, FALSE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_AntiFlicker, GetFirmwareParams()->m_ImageFlickerDetection, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_ImageQuality, GetFirmwareParams()->m_ImageQuality, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareMirror, GetFirmwareParams()->m_ImageMirror, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeX, GetFirmwareParams()->m_ImageCropSizeX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropSizeY, GetFirmwareParams()->m_ImageCropSizeY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetX, GetFirmwareParams()->m_ImageCropOffsetX, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropOffsetY, GetFirmwareParams()->m_ImageCropOffsetY, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareCropEnabled, GetFirmwareParams()->m_ImageCropEnabled, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_Sharpness, GetFirmwareParams()->m_ImageSharpness, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareAutoWhiteBalance, GetFirmwareParams()->m_ImageAutoWhiteBalance, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareColorTemperature, GetFirmwareParams()->m_ImageColorTemperature, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_BackLightCompensation, GetFirmwareParams()->m_ImageBacklightCompensation, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_ImageGain, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareExposure, GetFirmwareParams()->m_ImageExposureBar, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FirmwareAutoExposure, GetFirmwareParams()->m_ImageAutoExposure, TRUE); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_LowLightCompensation, GetFirmwareParams()->m_ImageLowLightCompensation, TRUE); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -167,32 +285,51 @@ XnStatus XnSensorImageStream::ValidateMode() XnIOImageFormats nInputFormat = (XnIOImageFormats)m_InputFormat.GetValue(); XnOutputFormats nOutputFormat = GetOutputFormat(); XnResolutions nResolution = GetResolution(); + XnUInt32 nFPS = GetFPS(); - // check resolution - if ((nResolution == XN_RESOLUTION_UXGA || nResolution == XN_RESOLUTION_SXGA) && nInputFormat != XN_IO_IMAGE_FORMAT_BAYER) - { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "UXGA resolution is only supported with BAYER input!"); - } - - // check output format - if (nOutputFormat == XN_OUTPUT_FORMAT_GRAYSCALE8 && nInputFormat != XN_IO_IMAGE_FORMAT_BAYER) - { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Grayscale8 output requires BAYER input!"); - } - else if (nOutputFormat == XN_OUTPUT_FORMAT_YUV422 && nInputFormat != XN_IO_IMAGE_FORMAT_YUV422 && nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422) + // check that input format matches output format + switch (nOutputFormat) { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "YUV output requires YUV input!"); + case XN_OUTPUT_FORMAT_RGB24: + if (nInputFormat != XN_IO_IMAGE_FORMAT_YUV422 && + nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 && + nInputFormat != XN_IO_IMAGE_FORMAT_BAYER && + nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to RGB24!", nInputFormat); + } + break; + case XN_OUTPUT_FORMAT_YUV422: + if (nInputFormat != XN_IO_IMAGE_FORMAT_YUV422 && + nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to YUV422!", nInputFormat); + } + break; + case XN_OUTPUT_FORMAT_JPEG: + if (nInputFormat != XN_IO_IMAGE_FORMAT_JPEG) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to JPEG!", nInputFormat); + } + break; + case XN_OUTPUT_FORMAT_GRAYSCALE8: + if (nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_GRAY8 && + nInputFormat != XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER && + nInputFormat != XN_IO_IMAGE_FORMAT_BAYER) + { + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Input format %d cannot be converted to Gray8!", nInputFormat); + } + break; + default: + // we shouldn't have reached here. Theres a check at SetOutputFormat. + XN_ASSERT(FALSE); + XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported image output format: %d!", nOutputFormat); } - // check input format - if (nInputFormat == XN_IO_IMAGE_FORMAT_BAYER && nResolution != XN_RESOLUTION_UXGA && nResolution != XN_RESOLUTION_SXGA) - { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "BAYER input requires SXGA/UXGA resolution!"); - } - else if (nInputFormat == XN_IO_IMAGE_FORMAT_JPEG && nOutputFormat != XN_OUTPUT_FORMAT_RGB24) - { - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Jpeg input is only supported for RGB24 output!"); - } + // now check that mode exists + XnCmosPreset preset = { (XnUInt16)nInputFormat, (XnUInt16)nResolution, (XnUInt16)nFPS }; + nRetVal = ValidateSupportedMode(preset); + XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } @@ -209,18 +346,24 @@ XnStatus XnSensorImageStream::ConfigureStreamImpl() nRetVal = ValidateMode(); XN_IS_STATUS_OK(nRetVal); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_InputFormat)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(ResolutionProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(FPSProperty())); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_AntiFlicker)); + nRetVal = m_Helper.ConfigureFirmware(m_InputFormat); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(ResolutionProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(FPSProperty()); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_AntiFlicker); + XN_IS_STATUS_OK(nRetVal);; // image quality is only relevant for JPEG if (m_InputFormat.GetValue() == XN_IO_IMAGE_FORMAT_JPEG) { - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_ImageQuality)); + nRetVal = m_Helper.ConfigureFirmware(m_ImageQuality); + XN_IS_STATUS_OK(nRetVal);; } - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareMirror)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareMirror); + XN_IS_STATUS_OK(nRetVal);; if (GetResolution() != XN_RESOLUTION_UXGA && GetResolution() != XN_RESOLUTION_SXGA) { @@ -228,6 +371,26 @@ XnStatus XnSensorImageStream::ConfigureStreamImpl() XN_IS_STATUS_OK(nRetVal); } + if (m_Helper.GetFirmwareVersion() >= XN_SENSOR_FW_VER_5_4) + { + nRetVal = m_Helper.ConfigureFirmware(m_Sharpness); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareColorTemperature); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareAutoWhiteBalance); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareExposure); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareAutoExposure); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_BackLightCompensation); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_Gain); + XN_IS_STATUS_OK(nRetVal); + nRetVal = m_Helper.ConfigureFirmware(m_LowLightCompensation); + XN_IS_STATUS_OK(nRetVal); + } + return (XN_STATUS_OK); } @@ -240,7 +403,8 @@ XnStatus XnSensorImageStream::SetActualRead(XnBool bRead) if (bRead) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB image read thread..."); - nRetVal = xnUSBInitReadThread(GetHelper()->GetPrivateData()->pSpecificImageUsb->pUsbConnection->UsbEp, GetHelper()->GetPrivateData()->pSpecificImageUsb->nChunkReadBytes, XN_SENSOR_USB_IMAGE_BUFFERS, XN_SENSOR_READ_THREAD_TIMEOUT, XnDeviceSensorProtocolUsbEpCb, GetHelper()->GetPrivateData()->pSpecificImageUsb); + XnSpecificUsbDevice* pUSB = GetHelper()->GetPrivateData()->pSpecificImageUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, XN_SENSOR_USB_IMAGE_BUFFERS, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); XN_IS_STATUS_OK(nRetVal); } else @@ -266,12 +430,17 @@ XnStatus XnSensorImageStream::OpenStreamImpl() // Cropping if (m_FirmwareCropEnabled.GetValue() == TRUE) { - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropSizeY)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX)); - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropSizeY); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetX); + XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropOffsetY); + XN_IS_STATUS_OK(nRetVal);; } - XN_IS_STATUS_OK(m_Helper.ConfigureFirmware(m_FirmwareCropEnabled)); + nRetVal = m_Helper.ConfigureFirmware(m_FirmwareCropEnabled); + XN_IS_STATUS_OK(nRetVal);; nRetVal = XnImageStream::Open(); XN_IS_STATUS_OK(nRetVal); @@ -304,6 +473,7 @@ XnStatus XnSensorImageStream::SetOutputFormat(XnOutputFormats nOutputFormat) case XN_OUTPUT_FORMAT_GRAYSCALE8: case XN_OUTPUT_FORMAT_YUV422: case XN_OUTPUT_FORMAT_RGB24: + case XN_OUTPUT_FORMAT_JPEG: break; default: XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported image output format: %d", nOutputFormat); @@ -330,7 +500,7 @@ XnStatus XnSensorImageStream::SetMirror(XnBool bIsMirrored) xnOSEnterCriticalSection(GetLock()); - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareMirror, bFirmwareMirror); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareMirror, (XnUInt16)bFirmwareMirror); if (nRetVal != XN_STATUS_OK) { xnOSLeaveCriticalSection(GetLock()); @@ -349,7 +519,7 @@ XnStatus XnSensorImageStream::SetFPS(XnUInt32 nFPS) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), nFPS); + nRetVal = m_Helper.BeforeSettingFirmwareParam(FPSProperty(), (XnUInt16)nFPS); XN_IS_STATUS_OK(nRetVal); nRetVal = XnImageStream::SetFPS(nFPS); @@ -365,18 +535,7 @@ XnStatus XnSensorImageStream::SetResolution(XnResolutions nResolution) { XnStatus nRetVal = XN_STATUS_OK; - switch (nResolution) - { - case XN_RESOLUTION_QVGA: - case XN_RESOLUTION_VGA: - case XN_RESOLUTION_SXGA: - case XN_RESOLUTION_UXGA: - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unknown resolution: %u", nResolution); - } - - nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), nResolution); + nRetVal = m_Helper.BeforeSettingFirmwareParam(ResolutionProperty(), (XnUInt16)nResolution); XN_IS_STATUS_OK(nRetVal); nRetVal = XnImageStream::SetResolution(nResolution); @@ -405,7 +564,7 @@ XnStatus XnSensorImageStream::SetInputFormat(XnIOImageFormats nInputFormat) XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unknown image input format: %d", nInputFormat); } - nRetVal = m_Helper.SimpleSetFirmwareParam(m_InputFormat, nInputFormat); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_InputFormat, (XnUInt16)nInputFormat); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -415,16 +574,14 @@ XnStatus XnSensorImageStream::SetAntiFlicker(XnUInt32 nFrequency) { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_Helper.SimpleSetFirmwareParam(m_AntiFlicker, nFrequency); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_AntiFlicker, (XnUInt16)nFrequency); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } -XnStatus XnSensorImageStream::SetImageQuality(XnUInt32 nQuality) +XnStatus XnSensorImageStream::SetImageQuality(XnUInt32 /*nQuality*/) { - XnStatus nRetVal = XN_STATUS_OK; - // check relevance if (m_InputFormat.GetValue() != XN_IO_IMAGE_FORMAT_JPEG) { @@ -467,7 +624,9 @@ XnStatus XnSensorImageStream::SetCropping(const XnCropping* pCropping) } if (nRetVal == XN_STATUS_OK) - nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, pCropping->bEnabled); + { + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareCropEnabled, (XnUInt16)pCropping->bEnabled); + } if (nRetVal != XN_STATUS_OK) { @@ -501,15 +660,92 @@ XnStatus XnSensorImageStream::SetCropping(const XnCropping* pCropping) return (XN_STATUS_OK); } -XnStatus XnSensorImageStream::PostProcessFrame(XnStreamData* pFrameData) +XnStatus XnSensorImageStream::SetSharpness( XnInt32 nValue ) { XnStatus nRetVal = XN_STATUS_OK; - m_Helper.GetFPS()->MarkOutputImage(pFrameData->nFrameID, pFrameData->nTimestamp); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_Sharpness, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorImageStream::SetColorTemperature( XnInt32 nValue ) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnBool bIsAuto = (nValue == XN_AUTO_CONTROL); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareAutoWhiteBalance, (XnUInt16)bIsAuto); + XN_IS_STATUS_OK(nRetVal); + + if (!bIsAuto) + { + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareColorTemperature, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + } + + nRetVal = m_ColorTemperature.UnsafeUpdateValue(nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorImageStream::SetBacklightCompensation( XnInt32 nValue ) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_Helper.SimpleSetFirmwareParam(m_BackLightCompensation, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorImageStream::SetGain( XnInt32 nValue ) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_Helper.SimpleSetFirmwareParam(m_Gain, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorImageStream::SetExposure( XnInt32 nValue ) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnBool bIsAuto = (nValue == XN_AUTO_CONTROL); + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareAutoExposure, (XnUInt16)bIsAuto); + XN_IS_STATUS_OK(nRetVal); + + if (!bIsAuto) + { + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FirmwareExposure, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + } + + nRetVal = m_Exposure.UnsafeUpdateValue(nValue); + XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } +XnStatus XnSensorImageStream::SetLowLightCompensation( XnInt32 nValue ) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_Helper.SimpleSetFirmwareParam(m_LowLightCompensation, (XnUInt16)nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnSensorImageStream::PostProcessFrame(XnStreamData* pFrameData) +{ + m_Helper.GetFPS()->MarkOutputImage(pFrameData->nFrameID, pFrameData->nTimestamp); + return (XN_STATUS_OK); +} + XnStatus XnSensorImageStream::ReallocTripleFrameBuffer() { XnStatus nRetVal = XN_STATUS_OK; @@ -602,35 +838,50 @@ XnStatus XnSensorImageStream::CreateDataProcessor(XnDataProcessor** ppProcessor) { XnStatus nRetVal = XN_STATUS_OK; + XnFrameBufferManager* pBufferManager; + nRetVal = GetTripleBuffer(&pBufferManager); + XN_IS_STATUS_OK(nRetVal); + XnStreamProcessor* pNew; switch (m_InputFormat.GetValue()) { case XN_IO_IMAGE_FORMAT_BAYER: - XN_VALIDATE_NEW_AND_INIT(pNew, XnBayerImageProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnBayerImageProcessor, this, &m_Helper, pBufferManager); break; case XN_IO_IMAGE_FORMAT_YUV422: - XN_VALIDATE_NEW_AND_INIT(pNew, XnPSCompressedImageProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnPSCompressedImageProcessor, this, &m_Helper, pBufferManager); break; case XN_IO_IMAGE_FORMAT_JPEG: - XN_VALIDATE_NEW_AND_INIT(pNew, XnJpegImageProcessor, this, &m_Helper); + if (GetOutputFormat() == XN_OUTPUT_FORMAT_JPEG) + { + XN_VALIDATE_NEW_AND_INIT(pNew, XnJpegImageProcessor, this, &m_Helper, pBufferManager); + } + else if (GetOutputFormat() == XN_OUTPUT_FORMAT_RGB24) + { + XN_VALIDATE_NEW_AND_INIT(pNew, XnJpegToRGBImageProcessor, this, &m_Helper, pBufferManager); + } + else + { + XN_LOG_WARNING_RETURN(XN_STATUS_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "invalid output format %d!", GetOutputFormat()); + } break; case XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422: if (GetOutputFormat() == XN_OUTPUT_FORMAT_YUV422) { - XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedYUVImageProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedYUVImageProcessor, this, &m_Helper, pBufferManager); } else if (GetOutputFormat() == XN_OUTPUT_FORMAT_RGB24) { - XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedYUVtoRGBImageProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedYUVtoRGBImageProcessor, this, &m_Helper, pBufferManager); } else { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DEVICE_SENSOR, "invalid ouput format %d!", GetOutputFormat()); + XN_LOG_WARNING_RETURN(XN_STATUS_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "invalid output format %d!", pBufferManager); } break; case XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER: - XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedBayerProcessor, this, &m_Helper); + XN_VALIDATE_NEW_AND_INIT(pNew, XnUncompressedBayerProcessor, this, &m_Helper, pBufferManager); break; default: return XN_STATUS_IO_INVALID_STREAM_IMAGE_FORMAT; @@ -641,27 +892,62 @@ XnStatus XnSensorImageStream::CreateDataProcessor(XnDataProcessor** ppProcessor) return XN_STATUS_OK; } -XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetInputFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetInputFormatCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; return pThis->SetInputFormat((XnIOImageFormats)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetAntiFlickerCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetAntiFlickerCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; return pThis->SetAntiFlicker((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetImageQualityCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetImageQualityCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; return pThis->SetImageQuality((XnUInt32)nValue); } -XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie) +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetActualReadCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; return pThis->SetActualRead(nValue == TRUE); } +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetSharpnessCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetSharpness((XnInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetColorTemperatureCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetColorTemperature((XnInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetBacklightCompensationCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetBacklightCompensation((XnInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetGainCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetGain((XnInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetLowLightCompensationCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetLowLightCompensation((XnInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetExposureCallback( XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie ) +{ + XnSensorImageStream* pThis = (XnSensorImageStream*)pCookie; + return pThis->SetExposure((XnInt32)nValue); +} diff --git a/Source/XnDeviceSensorV2/XnSensorImageStream.h b/Source/XnDeviceSensorV2/XnSensorImageStream.h index 526da72..bd48af9 100644 --- a/Source/XnDeviceSensorV2/XnSensorImageStream.h +++ b/Source/XnDeviceSensorV2/XnSensorImageStream.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_IMAGE_STREAM_H__ #define __XN_SENSOR_IMAGE_STREAM_H__ @@ -32,7 +27,31 @@ //--------------------------------------------------------------------------- #include #include "XnSensorStreamHelper.h" -#include "XnSharedMemoryBufferPool.h" + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_IMAGE_STREAM_DEFAULT_FPS 30 +// --avin mod-- +#define XN_IMAGE_STREAM_DEFAULT_RESOLUTION XN_RESOLUTION_VGA +#define XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER +#define XN_IMAGE_STREAM_DEFAULT_OUTPUT_FORMAT XN_OUTPUT_FORMAT_RGB24 +#define XN_IMAGE_STREAM_DEFAULT_FLICKER 0 +#define XN_IMAGE_STREAM_DEFAULT_QUALITY 3 +#define XN_IMAGE_STREAM_DEFAULT_BRIGHTNESS 128 +#define XN_IMAGE_STREAM_DEFAULT_CONTRAST 32 +#define XN_IMAGE_STREAM_DEFAULT_SATURATION 128 +#define XN_IMAGE_STREAM_DEFAULT_SHARPNESS 32 +#define XN_IMAGE_STREAM_DEFAULT_AWB TRUE +#define XN_IMAGE_STREAM_DEFAULT_COLOR_TEMP 5000 +#define XN_IMAGE_STREAM_DEFAULT_BACKLIGHT_COMP 1 +#define XN_IMAGE_STREAM_DEFAULT_GAIN 128 +#define XN_IMAGE_STREAM_DEFAULT_ZOOM 100 +#define XN_IMAGE_STREAM_DEFAULT_AUTO_EXPOSURE TRUE +#define XN_IMAGE_STREAM_DEFAULT_EXPOSURE_BAR 100 +#define XN_IMAGE_STREAM_DEFAULT_PAN 0 +#define XN_IMAGE_STREAM_DEFAULT_TILT 0 +#define XN_IMAGE_STREAM_DEFAULT_LOW_LIGHT_COMP TRUE //--------------------------------------------------------------------------- // XnSensorImageStream class @@ -40,7 +59,7 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream { public: - XnSensorImageStream(const XnChar* StreamName, XnSensorObjects* pObjects, XnUInt32 nBufferCount); + XnSensorImageStream(const XnChar* StreamName, XnSensorObjects* pObjects); ~XnSensorImageStream() { Free(); } //--------------------------------------------------------------------------- @@ -74,8 +93,7 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream XnStatus CreateDataProcessor(XnDataProcessor** ppProcessor); XnStatus MapPropertiesToFirmware(); void GetFirmwareStreamConfig(XnResolutions* pnRes, XnUInt32* pnFPS) { *pnRes = GetResolution(); *pnFPS = GetFPS(); } - XnStatus WriteImpl(XnStreamData* pStreamData) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } - XnSharedMemoryBufferPool* GetSharedMemoryBuffer() { return &m_BufferPool; } + XnStatus WriteImpl(XnStreamData* /*pStreamData*/) { return XN_STATUS_DEVICE_UNSUPPORTED_MODE; } //--------------------------------------------------------------------------- // Setters @@ -89,27 +107,48 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream virtual XnStatus SetImageQuality(XnUInt32 nQuality); XnStatus SetCropping(const XnCropping* pCropping); XnStatus SetActualRead(XnBool bRead); + XnStatus SetSharpness(XnInt32 nValue); + XnStatus SetColorTemperature(XnInt32 nValue); + XnStatus SetBacklightCompensation(XnInt32 nValue); + XnStatus SetGain(XnInt32 nValue); + XnStatus SetExposure(XnInt32 nValue); + XnStatus SetLowLightCompensation(XnInt32 nValue); private: XnStatus ValidateMode(); - static XnUInt32 GetMaxBufferSize(XnFWVer version); static XnStatus XN_CALLBACK_TYPE SetInputFormatCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetAntiFlickerCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetImageQualityCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetActualReadCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetSharpnessCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetColorTemperatureCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetBacklightCompensationCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetGainCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetExposureCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetLowLightCompensationCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); //--------------------------------------------------------------------------- // Members //--------------------------------------------------------------------------- XnSensorStreamHelper m_Helper; - XnSharedMemoryBufferPool m_BufferPool; - - XnActualStringProperty m_SharedBufferName; XnActualIntProperty m_InputFormat; XnActualIntProperty m_AntiFlicker; XnActualIntProperty m_ImageQuality; + XnActualIntProperty m_Brightness; + XnActualIntProperty m_Contrast; + XnActualIntProperty m_Saturation; + XnActualIntProperty m_Sharpness; + XnActualIntProperty m_ColorTemperature; + XnActualIntProperty m_BackLightCompensation; + XnActualIntProperty m_Gain; + XnActualIntProperty m_Exposure; + XnActualIntProperty m_Zoom; + XnActualIntProperty m_Pan; + XnActualIntProperty m_Tilt; + XnActualIntProperty m_LowLightCompensation; + XnActualIntProperty m_FirmwareMirror; XnActualIntProperty m_FirmwareCropSizeX; @@ -117,6 +156,10 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream XnActualIntProperty m_FirmwareCropOffsetX; XnActualIntProperty m_FirmwareCropOffsetY; XnActualIntProperty m_FirmwareCropEnabled; + XnActualIntProperty m_FirmwareExposure; + XnActualIntProperty m_FirmwareAutoExposure; + XnActualIntProperty m_FirmwareColorTemperature; + XnActualIntProperty m_FirmwareAutoWhiteBalance; XnActualIntProperty m_ActualRead; }; diff --git a/Source/XnDeviceSensorV2/XnSensorMapGenerator.cpp b/Source/XnDeviceSensorV2/XnSensorMapGenerator.cpp index 047dce3..8cdf868 100644 --- a/Source/XnDeviceSensorV2/XnSensorMapGenerator.cpp +++ b/Source/XnDeviceSensorV2/XnSensorMapGenerator.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -34,9 +28,21 @@ // XnSensorMapGenerator class //--------------------------------------------------------------------------- XnSensorMapGenerator::XnSensorMapGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) : - XnSensorGenerator(context, sensor, pSensor, strStreamName) + XnSensorGenerator(context, sensor, pSensor, strStreamName), + m_nSupportedModesCount(0), + m_aSupportedModes(NULL) {} + +XnSensorMapGenerator::~XnSensorMapGenerator() +{ + if (m_aSupportedModes != NULL) + { + xnOSFree(m_aSupportedModes); + m_aSupportedModes = NULL; + } +} + XnStatus XnSensorMapGenerator::Init() { XnStatus nRetVal = XN_STATUS_OK; @@ -44,44 +50,29 @@ XnStatus XnSensorMapGenerator::Init() nRetVal = XnSensorGenerator::Init(); XN_IS_STATUS_OK(nRetVal); - XnMapOutputMode mode; - - // QVGA 30 - mode.nXRes = XN_QVGA_X_RES; - mode.nYRes = XN_QVGA_Y_RES; - mode.nFPS = 30; - nRetVal = m_SupportedModes.AddLast(mode); + // get supported modes + XnUInt64 nCount; + nRetVal = GetIntProperty(XN_STREAM_PROPERTY_SUPPORT_MODES_COUNT, nCount); XN_IS_STATUS_OK(nRetVal); - // QVGA 60 - mode.nXRes = XN_QVGA_X_RES; - mode.nYRes = XN_QVGA_Y_RES; - mode.nFPS = 60; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); + m_aSupportedModes = (SupportedMode*)xnOSMalloc(sizeof(SupportedMode) * (XnSizeT)nCount); + XN_VALIDATE_ALLOC_PTR(m_aSupportedModes); + m_nSupportedModesCount = (XnUInt32)nCount; - // VGA 30 - mode.nXRes = XN_VGA_X_RES; - mode.nYRes = XN_VGA_Y_RES; - mode.nFPS = 30; - nRetVal = m_SupportedModes.AddLast(mode); + const XnUInt32 nAllocCount = 150; + XnCmosPreset aPresets[nAllocCount]; + XN_ASSERT(nAllocCount >= m_nSupportedModesCount); + nRetVal = GetGeneralProperty(XN_STREAM_PROPERTY_SUPPORT_MODES, m_nSupportedModesCount*sizeof(XnCmosPreset), aPresets); XN_IS_STATUS_OK(nRetVal); - if (m_Version.FWVer >= XN_SENSOR_FW_VER_5_2) + // Keep those modes + XnBool bOK = TRUE; + for (XnUInt32 i = 0; i < m_nSupportedModesCount; ++i) { - // QVGA 25 - mode.nXRes = XN_QVGA_X_RES; - mode.nYRes = XN_QVGA_Y_RES; - mode.nFPS = 25; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); - - // VGA 25 - mode.nXRes = XN_VGA_X_RES; - mode.nYRes = XN_VGA_Y_RES; - mode.nFPS = 25; - nRetVal = m_SupportedModes.AddLast(mode); - XN_IS_STATUS_OK(nRetVal); + m_aSupportedModes[i].nInputFormat = aPresets[i].nFormat; + bOK = XnDDKGetXYFromResolution((XnResolutions)aPresets[i].nResolution, &m_aSupportedModes[i].OutputMode.nXRes, &m_aSupportedModes[i].OutputMode.nYRes); + XN_ASSERT(bOK); + m_aSupportedModes[i].OutputMode.nFPS = aPresets[i].nFPS; } return (XN_STATUS_OK); @@ -95,31 +86,36 @@ XnBool XnSensorMapGenerator::IsCapabilitySupported(const XnChar* strCapabilityNa XnUInt32 XnSensorMapGenerator::GetSupportedMapOutputModesCount() { - return m_SupportedModes.Size(); + return m_nSupportedModesCount; } XnStatus XnSensorMapGenerator::GetSupportedMapOutputModes(XnMapOutputMode aModes[], XnUInt32& nCount) { - XnStatus nRetVal = XN_STATUS_OK; - XN_VALIDATE_INPUT_PTR(aModes); - if (nCount < m_SupportedModes.Size()) + if (nCount < m_nSupportedModesCount) { return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; } - XnUInt32 i = 0; - for (XnMapOutputModeList::Iterator it = m_SupportedModes.begin(); it != m_SupportedModes.end(); ++it, ++i) + for (XnUInt32 i = 0; i < m_nSupportedModesCount; ++i) { - aModes[i] = *it; + aModes[i] = m_aSupportedModes[i].OutputMode; } - nCount = m_SupportedModes.Size(); + nCount = m_nSupportedModesCount; return (XN_STATUS_OK); } +XnBool Equals(const XnMapOutputMode& mode1, const XnMapOutputMode& mode2) +{ + return ( + mode1.nXRes == mode2.nXRes && + mode1.nYRes == mode2.nYRes && + mode1.nFPS == mode2.nFPS); +} + XnStatus XnSensorMapGenerator::SetMapOutputMode(const XnMapOutputMode& Mode) { XnStatus nRetVal = XN_STATUS_OK; @@ -127,19 +123,53 @@ XnStatus XnSensorMapGenerator::SetMapOutputMode(const XnMapOutputMode& Mode) XnMapOutputMode current; GetMapOutputMode(current); - if (current.nFPS == Mode.nFPS && - current.nXRes == Mode.nXRes && - current.nYRes == Mode.nYRes) + if (Equals(current, Mode)) { return (XN_STATUS_OK); } + // check if this mode is supported. If it is, make sure current input format is OK + XnUInt64 nCurrInputFormat; + nRetVal = GetIntProperty(XN_STREAM_PROPERTY_INPUT_FORMAT, nCurrInputFormat); + XN_IS_STATUS_OK(nRetVal); + + XnUInt32 nChosenInputFormat = XN_MAX_UINT32; + + for (XnUInt32 i = 0; i < m_nSupportedModesCount; ++i) + { + if (Equals(Mode, m_aSupportedModes[i].OutputMode)) + { + // if current input format is supported, it will always be preferred. + if (m_aSupportedModes[i].nInputFormat == nCurrInputFormat) + { + nChosenInputFormat = (XnUInt32)nCurrInputFormat; + break; + } + else if (nChosenInputFormat == XN_MAX_UINT32) + { + nChosenInputFormat = m_aSupportedModes[i].nInputFormat; + // don't break yet. we might find our input format + } + } + } + + if (nChosenInputFormat == XN_MAX_UINT32) // not found + { + xnLogWarning(XN_MASK_DEVICE_SENSOR, "Mode %ux%u@%u is not supported!", Mode.nXRes, Mode.nYRes, Mode.nFPS); + return XN_STATUS_BAD_PARAM; + } + XN_PROPERTY_SET_CREATE_ON_STACK(props); XnPropertySetAddModule(&props, m_strModule); XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_X_RES, Mode.nXRes); XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_Y_RES, Mode.nYRes); XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_FPS, Mode.nFPS); + if (nChosenInputFormat != nCurrInputFormat) + { + XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_INPUT_FORMAT, nChosenInputFormat); + } + nRetVal = m_pSensor->BatchConfig(&props); XN_IS_STATUS_OK(nRetVal); diff --git a/Source/XnDeviceSensorV2/XnSensorMapGenerator.h b/Source/XnDeviceSensorV2/XnSensorMapGenerator.h index 05af932..733c9c2 100644 --- a/Source/XnDeviceSensorV2/XnSensorMapGenerator.h +++ b/Source/XnDeviceSensorV2/XnSensorMapGenerator.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_MAP_GENERATOR_H__ #define __XN_SENSOR_MAP_GENERATOR_H__ @@ -32,11 +26,14 @@ // Includes //--------------------------------------------------------------------------- #include "XnSensorGenerator.h" -#include //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorMapGenerator : public XnSensorGenerator, virtual public xn::ModuleMapGenerator, @@ -44,6 +41,7 @@ class XnSensorMapGenerator : { public: XnSensorMapGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName); + virtual ~XnSensorMapGenerator(); XnStatus Init(); @@ -66,9 +64,16 @@ class XnSensorMapGenerator : protected: virtual void FilterProperties(XnActualPropertiesHash* pHash); - XN_DECLARE_LIST(XnMapOutputMode, XnMapOutputModeList); + struct SupportedMode + { + XnMapOutputMode OutputMode; + XnUInt32 nInputFormat; + }; - XnMapOutputModeList m_SupportedModes; + SupportedMode* m_aSupportedModes; + XnUInt32 m_nSupportedModesCount; }; +#pragma warning (pop) + #endif // __XN_SENSOR_MAP_GENERATOR_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorOpenNiteImpl.cpp b/Source/XnDeviceSensorV2/XnSensorOpenNiteImpl.cpp index fb6c55b..db16918 100644 --- a/Source/XnDeviceSensorV2/XnSensorOpenNiteImpl.cpp +++ b/Source/XnDeviceSensorV2/XnSensorOpenNiteImpl.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -40,15 +34,7 @@ // Exporting //--------------------------------------------------------------------------- -class SensorModule : public xn::Module -{ - XnStatus Load() - { - return XnSensorClient::TakeServerLocation(); - } -}; - -XN_EXPORT_MODULE(SensorModule) +XN_EXPORT_MODULE(xn::Module) XN_EXPORT_DEVICE(XnExportedSensorDevice) XN_EXPORT_DEPTH(XnExportedSensorDepthGenerator) XN_EXPORT_IMAGE(XnExportedSensorImageGenerator) diff --git a/Source/XnDeviceSensorV2/XnSensorProductionNode.cpp b/Source/XnDeviceSensorV2/XnSensorProductionNode.cpp index 4cbd493..8420ab7 100644 --- a/Source/XnDeviceSensorV2/XnSensorProductionNode.cpp +++ b/Source/XnDeviceSensorV2/XnSensorProductionNode.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,7 +31,8 @@ XnSensorProductionNode::XnSensorProductionNode(xn::Context& context, const XnChar* strInstanceName, XnDeviceBase* pSensor, const XnChar* strModuleName) : m_Context(context), m_pSensor(pSensor), - m_pNotifications(NULL) + m_pNotifications(NULL), + m_pCookie(NULL) { strcpy(m_strInstanceName, strInstanceName); strcpy(m_strModule, strModuleName); @@ -46,9 +41,9 @@ XnSensorProductionNode::XnSensorProductionNode(xn::Context& context, const XnCha XnSensorProductionNode::~XnSensorProductionNode() { // free all memory allocated for registration, even if client did not unregister from it - for (XnMultiPropChangedHandlerHash::Iterator it = m_AllHandlers.begin(); it != m_AllHandlers.end(); ++it) + for (XnMultiPropChangedHandlerHash::Iterator it = m_AllHandlers.Begin(); it != m_AllHandlers.End(); ++it) { - XN_DELETE(it.Key()); + XN_DELETE(it->Key()); } } @@ -88,9 +83,14 @@ XnStatus XnSensorProductionNode::GetRealProperty(const XnChar* strName, XnDouble return m_pSensor->GetProperty(m_strModule, strName, &dValue); } -XnStatus XnSensorProductionNode::GetStringProperty(const XnChar* strName, XnChar* csValue) const +XnStatus XnSensorProductionNode::GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const { - return m_pSensor->GetProperty(m_strModule, strName, csValue); + XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; + XnStatus nRetVal = m_pSensor->GetProperty(m_strModule, strName, strValue); + XN_IS_STATUS_OK(nRetVal); + nRetVal = xnOSStrCopy(csValue, strValue, nBufSize); + XN_IS_STATUS_OK(nRetVal); + return XN_STATUS_OK; } XnStatus XnSensorProductionNode::GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const @@ -106,7 +106,7 @@ XnStatus XnSensorProductionNode::SetLockState(XnBool bLocked) XnBool XnSensorProductionNode::GetLockState() { XnUInt64 nValue = FALSE; - XnStatus nRetVal = m_pSensor->GetProperty(m_strModule, XN_MODULE_PROPERTY_LOCK, &nValue); + m_pSensor->GetProperty(m_strModule, XN_MODULE_PROPERTY_LOCK, &nValue); return (nValue == TRUE); } @@ -140,7 +140,7 @@ XnStatus XnSensorProductionNode::NotifyExState(XnNodeNotifications* pNotificatio nRetVal = m_pSensor->GetAllProperties(&props, FALSE, GetModuleName()); XN_IS_STATUS_OK(nRetVal); - XnActualPropertiesHash* pPropsHash = props.pData->begin().Value(); + XnActualPropertiesHash* pPropsHash = props.pData->Begin()->Value(); // filter properties (remove the ones already exposed as OpenNI interfaces) FilterProperties(pPropsHash); @@ -156,9 +156,9 @@ XnStatus XnSensorProductionNode::NotifyExState(XnNodeNotifications* pNotificatio XnUInt32 nGeneralProps = 0; // enumerate over properties - for (XnActualPropertiesHash::Iterator it = pPropsHash->begin(); it != pPropsHash->end(); ++it) + for (XnActualPropertiesHash::Iterator it = pPropsHash->Begin(); it != pPropsHash->End(); ++it) { - XnProperty* pProp = it.Value(); + XnProperty* pProp = it->Value(); switch (pProp->GetType()) { diff --git a/Source/XnDeviceSensorV2/XnSensorProductionNode.h b/Source/XnDeviceSensorV2/XnSensorProductionNode.h index 19e02ee..2dd50b4 100644 --- a/Source/XnDeviceSensorV2/XnSensorProductionNode.h +++ b/Source/XnDeviceSensorV2/XnSensorProductionNode.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_PRODUCTION_NODE_H__ #define __XN_SENSOR_PRODUCTION_NODE_H__ @@ -33,7 +27,7 @@ //--------------------------------------------------------------------------- #include #include "XnSensor.h" -#include +#include #include "XnSensorClient.h" class XnMultiPropChangedHandler; // forward declaration @@ -41,6 +35,10 @@ class XnMultiPropChangedHandler; // forward declaration //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- +// disable the "inherits via dominance" warning. This is exactly what we want. +#pragma warning (push) +#pragma warning (disable: 4250) + class XnSensorProductionNode : virtual public xn::ModuleProductionNode, virtual public xn::ModuleLockAwareInterface, @@ -58,7 +56,7 @@ class XnSensorProductionNode : XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer); XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const; XnStatus GetRealProperty(const XnChar* strName, XnDouble& dValue) const; - XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue) const; + XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const; XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const; // Lock Aware @@ -96,7 +94,7 @@ class XnSensorProductionNode : static void XN_CALLBACK_TYPE StringPropertyChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); static void XN_CALLBACK_TYPE GeneralPropertyChangedCallback(XnDeviceHandle pDeviceHandle, const XnChar* ModuleName, const XnChar* PropertyName, void* pCookie); - XN_DECLARE_DEFAULT_HASH(XnMultiPropChangedHandler*, XnMultiPropChangedHandler*, XnMultiPropChangedHandlerHash); + typedef XnHashT XnMultiPropChangedHandlerHash; xn::Context m_Context; XnDeviceBase* m_pSensor; @@ -113,4 +111,6 @@ class XnSensorProductionNode : XnCallbackHandle m_hGenProps; }; +#pragma warning (pop) + #endif // __XN_SENSOR_PRODUCTION_NODE_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSensorServer.cpp b/Source/XnDeviceSensorV2/XnSensorServer.cpp index c9e5222..6e36ad1 100644 --- a/Source/XnDeviceSensorV2/XnSensorServer.cpp +++ b/Source/XnDeviceSensorV2/XnSensorServer.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,155 +26,36 @@ #include "XnSensorClientServer.h" #include #include -#include -#include //--------------------------------------------------------------------------- // Defines //--------------------------------------------------------------------------- -#define XN_SENSOR_DEFAULT_SERVER_WAIT_FOR_CLIENT_TIME 10000 #define XN_SENSOR_SERVER_ACCEPT_CONNECTION_TIMEOUT 100 -#define XN_SENSOR_TERMINATE_READER_THREAD_TIMEOUT 5000 -#define XN_MASK_SENSOR_SERVER_COMM_DUMP "SensorServerComm" -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -typedef struct XnDeviceString -{ - XnChar str[XN_DEVICE_MAX_STRING_LENGTH]; -} XnDeviceString; - -typedef struct XnServerStream -{ - XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; - XnUInt32 nRefCount; - XnUInt32 nOpenRefCount; - XnStreamData* pStreamData; - XnBool bNewData; -} XnServerStream; - -XN_DECLARE_STRINGS_HASH(XnDeviceString, XnNamesHash); -XN_DECLARE_STRINGS_HASH(XnServerStream, XnServerStreamsHash); - -struct XnSensorServer::XnClient -{ - XnClient() - { - nID = 0; - hSocket = NULL; - hThread = NULL; - pStream = NULL; - pPrivateIncomingPacker = NULL; - pPrivateOutgoingPacker = NULL; - pServer = NULL; - pStreamDataSet = NULL; - XnDeviceString deviceModule = { XN_MODULE_NAME_DEVICE }; - clientToServerNames.Set(XN_MODULE_NAME_DEVICE, deviceModule); - serverToClientNames.Set(XN_MODULE_NAME_DEVICE, deviceModule); - bShouldRun = TRUE; - } - - ~XnClient() - { - XN_DELETE(pPrivateIncomingPacker); - XN_DELETE(pPrivateOutgoingPacker); - XN_DELETE(pStream); - if (hLock != NULL) - { - xnOSCloseCriticalSection(&hLock); - hLock = NULL; - } - if (pStreamDataSet != NULL) - { - XnStreamDataSetDestroy(&pStreamDataSet); - } - if (hSocket != NULL) - { - xnOSCloseSocket(hSocket); - } - } - - const XnChar* ToServerModule(const XnChar* strClientModule) - { - XnNamesHash::Iterator it = clientToServerNames.end(); - if (XN_STATUS_OK != clientToServerNames.Find(strClientModule, it)) - { - return NULL; - } - - return it.Value().str; - } - - const XnChar* FromServerModule(const XnChar* strServerModule) - { - XnNamesHash::Iterator it = serverToClientNames.end(); - if (XN_STATUS_OK != serverToClientNames.Find(strServerModule, it)) - { - return NULL; - } - - return it.Value().str; - } - - XnBool IsStreamOpen(const XnChar* strServerStream) - { - XnNamesHash::Iterator it = serverToClientNames.end(); - return (XN_STATUS_OK == openStreams.Find(strServerStream, it)); - } - - XnUInt32 nID; - XN_SOCKET_HANDLE hSocket; - XN_THREAD_HANDLE hThread; - XN_CRITICAL_SECTION_HANDLE hLock; - XnIONetworkStream* pStream; - XnDataPacker* pPrivateIncomingPacker; - XnDataPacker* pPrivateOutgoingPacker; - XnSensorServer* pServer; - XnStreamDataSet* pStreamDataSet; - XnNamesHash clientToServerNames; - XnNamesHash serverToClientNames; - volatile XnBool bShouldRun; - XnNamesHash openStreams; -}; - -#define XN_SENSOR_SERVER_LOCK_BLOCK XnAutoCSLocker __locker(m_hSensorLock); -#define XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK XnAutoCSLocker __locker(pClient->hLock); //--------------------------------------------------------------------------- // XnSensorServer class //--------------------------------------------------------------------------- -XnSensorServer::XnSensorServer() : - m_bSensorOpen(FALSE), +XnSensorServer::XnSensorServer(const XnChar* strConfigFile) : m_hListenSocket(NULL), - m_hReaderThread(NULL), - m_hNewDataEvent(NULL), m_hServerRunningEvent(NULL), m_hServerRunningMutex(NULL), - m_hSensorLock(NULL), - m_hBroadcastingLock(NULL), - m_hClientsCriticalSection(NULL), + m_hSessionsLock(NULL), m_nLastClientID(0), - m_pServerStreams(NULL), - m_noClientTimeout(XN_MODULE_PROPERTY_SERVER_NO_CLIENTS_TIMEOUT, XN_SENSOR_DEFAULT_SERVER_WAIT_FOR_CLIENT_TIME), - m_startNewLog(XN_MODULE_PROPERTY_SERVER_START_NEW_LOG_FILE), - m_nErrorState(XN_STATUS_OK) + m_nErrorState(XN_STATUS_OK), + m_sensorsManager(strConfigFile), + m_strConfigFile(strConfigFile) { - m_noClientTimeout.UpdateSetCallbackToDefault(); - m_startNewLog.UpdateSetCallback(StartNewLogCallback, this); - - m_serverDump = XN_DUMP_CLOSED; - xnDumpInit(&m_serverDump, XN_MASK_SENSOR_SERVER_COMM_DUMP, "TS,Type,Size,Client\n", "%s.csv", XN_MASK_SENSOR_SERVER_COMM_DUMP); } XnSensorServer::~XnSensorServer() { - ShutdownServer(); + Free(); } -XnStatus XnSensorServer::Run(const XnChar* strConfigFile) +XnStatus XnSensorServer::Run() { //Initialize server - XnStatus nRetVal = InitServer(strConfigFile); + XnStatus nRetVal = InitServer(); if (nRetVal == XN_STATUS_OK) { @@ -188,8 +63,7 @@ XnStatus XnSensorServer::Run(const XnChar* strConfigFile) nRetVal = ServerMainLoop(); } - //Shutdown the server - ShutdownServer(); + Free(); return nRetVal; } @@ -205,10 +79,19 @@ XnBool XnSensorServer::IsServerRunning() return xnOSIsEventSet(m_hServerRunningEvent); } -XnStatus XnSensorServer::InitServer(const XnChar* strConfigFile) +XnStatus XnSensorServer::InitServer() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = xnOSCreateNamedMutex(&m_hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME); + + XnBool bEnableMultiUsers = FALSE; + + XnUInt32 nValue; + if (XN_STATUS_OK == xnOSReadIntFromINI(m_strConfigFile, XN_SENSOR_SERVER_CONFIG_FILE_SECTION, XN_MODULE_PROPERTY_ENABLE_MULTI_USERS, &nValue)) + { + bEnableMultiUsers = (nValue == TRUE); + } + + nRetVal = xnOSCreateNamedMutexEx(&m_hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME, bEnableMultiUsers); XN_IS_STATUS_OK(nRetVal); XnAutoMutexLocker serverRunningLock(m_hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT); @@ -225,10 +108,10 @@ XnStatus XnSensorServer::InitServer(const XnChar* strConfigFile) /*Create the Server Running event. This is created as a manual-reset event, because only the server resets it when it's shutting down. */ - nRetVal = xnOSOpenNamedEvent(&m_hServerRunningEvent, XN_SENSOR_SERVER_RUNNING_EVENT_NAME); + nRetVal = xnOSOpenNamedEventEx(&m_hServerRunningEvent, XN_SENSOR_SERVER_RUNNING_EVENT_NAME, bEnableMultiUsers); if (nRetVal != XN_STATUS_OK) { - nRetVal = xnOSCreateNamedEvent(&m_hServerRunningEvent, XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE); + nRetVal = xnOSCreateNamedEventEx(&m_hServerRunningEvent, XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE, bEnableMultiUsers); XN_IS_STATUS_OK(nRetVal); } @@ -241,25 +124,15 @@ XnStatus XnSensorServer::InitServer(const XnChar* strConfigFile) return XN_STATUS_DEVICE_SERVER_ALREADY_RUNNING; } - nRetVal = m_sensor.SetGlobalConfigFile(strConfigFile); - XN_IS_STATUS_OK(nRetVal); - - // read default timeout from file - nRetVal = m_noClientTimeout.ReadValueFromFile(strConfigFile, XN_CONFIG_FILE_SERVER_SECTION); + nRetVal = m_sensorsManager.Init(); XN_IS_STATUS_OK(nRetVal); // init network nRetVal = xnOSInitNetwork(); XN_IS_STATUS_OK(nRetVal); - // create locks - nRetVal = xnOSCreateCriticalSection(&m_hSensorLock); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = xnOSCreateCriticalSection(&m_hBroadcastingLock); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = xnOSCreateCriticalSection(&m_hClientsCriticalSection); + // create lock + nRetVal = xnOSCreateCriticalSection(&m_hSessionsLock); XN_IS_STATUS_OK(nRetVal); // create the listen socket @@ -270,18 +143,6 @@ XnStatus XnSensorServer::InitServer(const XnChar* strConfigFile) nRetVal = xnOSBindSocket(m_hListenSocket); XN_IS_STATUS_OK(nRetVal); - // register to events - nRetVal = m_sensor.OnStreamCollectionChangedEvent().Register(StreamCollectionChangedCallback, this); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = m_sensor.OnNewStreamDataEvent().Register(NewStreamDataCallback, this); - XN_IS_STATUS_OK(nRetVal); - - XN_VALIDATE_NEW(m_pServerStreams, XnServerStreamsHash); - - nRetVal = xnOSCreateEvent(&m_hNewDataEvent, FALSE); - XN_IS_STATUS_OK(nRetVal); - // start listening nRetVal = xnOSListenSocket(m_hListenSocket); XN_IS_STATUS_OK(nRetVal); @@ -292,65 +153,55 @@ XnStatus XnSensorServer::InitServer(const XnChar* strConfigFile) nRetVal = xnOSSetEvent(m_hServerRunningEvent); XN_IS_STATUS_OK(nRetVal); - // start reader thread - nRetVal = xnOSCreateThread(ReaderThread, this, &m_hReaderThread); - XN_IS_STATUS_OK(nRetVal); + xnOSGetTimeStamp(&m_nLastSessionActivity); return (XN_STATUS_OK); } -XnStatus XnSensorServer::OpenSensor(const XnChar* strConnectionString) +XnStatus XnSensorServer::ServerMainLoop() { - XnStatus nRetVal = XN_STATUS_OK; - - XnDeviceConfig config; - config.DeviceMode = XN_DEVICE_MODE_READ; - config.cpConnectionString = strConnectionString; - config.pInitialValues = NULL; - config.SharingMode = XN_DEVICE_SHARED; - - nRetVal = m_sensor.Init(&config); - XN_IS_STATUS_OK(nRetVal); - - XN_VALIDATE_ADD_PROPERTIES(m_sensor.DeviceModule(), - &m_startNewLog, &m_noClientTimeout); - - // configure from global file - nRetVal = m_sensor.ConfigureModuleFromGlobalFile(XN_MODULE_NAME_DEVICE, XN_CONFIG_FILE_SERVER_SECTION); - XN_IS_STATUS_OK(nRetVal); + for (;;) + { + CheckForNewClients(XN_SENSOR_SERVER_ACCEPT_CONNECTION_TIMEOUT); - // register to all properties - XN_PROPERTY_SET_CREATE_ON_STACK(props); - nRetVal = m_sensor.DeviceModule()->GetAllProperties(&props); - XN_IS_STATUS_OK(nRetVal); + // do some clean-up + m_sensorsManager.CleanUp(); + CleanUpSessions(); - nRetVal = RegisterToProps(&props); - XN_IS_STATUS_OK(nRetVal); + // now check if we should shutdown + if (ShutdownIfPossible()) + { + break; + } + } - return (XN_STATUS_OK); + return XN_STATUS_OK; } -XnStatus XnSensorServer::ServerMainLoop() +void XnSensorServer::CheckForNewClients(XnUInt32 nTimeout) { XnStatus nRetVal = XN_STATUS_OK; - XnUInt64 nNow = 0; - XnUInt64 nLastClientRemovedTimestamp = 0; - XnUInt64 nTimeSinceNoClients = 0; - XnBool bQuit = FALSE; - XN_SOCKET_HANDLE hClientSocket = NULL; - XnBool bNoClients = FALSE; - - xnOSGetTimeStamp(&nLastClientRemovedTimestamp); - while (!bQuit) + // run in loop until we break due to timeout + XN_SOCKET_HANDLE hClientSocket; + for (;;) { - nRetVal = xnOSAcceptSocket(m_hListenSocket, &hClientSocket, XN_SENSOR_SERVER_ACCEPT_CONNECTION_TIMEOUT); - if (nRetVal == XN_STATUS_OK) + nRetVal = xnOSAcceptSocket(m_hListenSocket, &hClientSocket, nTimeout); + if (nRetVal == XN_STATUS_OS_NETWORK_TIMEOUT) + { + return; + } + else if (nRetVal != XN_STATUS_OK) + { + //Any other error beside timeout is not expected, but we treat it the same. + xnLogWarning(XN_MASK_SENSOR_SERVER, "failed to accept connection: %s", xnGetStatusString(nRetVal)); + } + else { xnLogInfo(XN_MASK_SENSOR_SERVER, "New client trying to connect..."); //TODO: Check if we don't have too many clients - nRetVal = AddClient(hClientSocket); + nRetVal = AddSession(hClientSocket); if (nRetVal != XN_STATUS_OK) { xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to add new client: %s", xnGetStatusString(nRetVal)); @@ -358,66 +209,107 @@ XnStatus XnSensorServer::ServerMainLoop() //Still in loop } } - else // no client trying to connect, do some clean up work + } +} + +void XnSensorServer::CleanUpSessions() +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker locker(m_hSessionsLock); + if (!m_sessions.IsEmpty()) + { + XnSessionsList::Iterator it = m_sessions.Begin(); + while (it != m_sessions.End()) { - if (nRetVal != XN_STATUS_OS_NETWORK_TIMEOUT) + XnSessionsList::Iterator curr = it; + ++it; + + XnServerSession* pSession = *curr; + if (pSession->HasEnded()) { - //Any other error beside timeout is not expected, but we treat it the same. - xnLogWarning(XN_MASK_SENSOR_SERVER, "failed to accept connection: %s", xnGetStatusString(nRetVal)); + nRetVal = RemoveSession(curr); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "failed to remove session: %s", xnGetStatusString(nRetVal)); + } } + } + } +} - // remove all non-active clients - xnOSEnterCriticalSection(&m_hClientsCriticalSection); +XnBool XnSensorServer::ShutdownIfPossible() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // lock sessions list + XnAutoCSLocker locker(m_hSessionsLock); + + // check if no sessions and no sensors + if (CanShutdown()) + { + // lock the running lock + XnAutoMutexLocker serverRunningLock(m_hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT); + nRetVal = serverRunningLock.GetStatus(); + if (nRetVal == XN_STATUS_OK) + { + // make sure no client is waiting to connect + CheckForNewClients(0); - if (!m_clients.IsEmpty()) + // re-check shutdown condition + if (CanShutdown()) { - // create a list of all clients to be removed - XnClientsList toRemove; - for (XnClientsList::Iterator it = m_clients.begin(); it != m_clients.end(); ++it) - { - XnClient* pClient = *it; - if (!pClient->bShouldRun) - { - toRemove.AddLast(pClient); - } - } + xnLogInfo(XN_MASK_SENSOR_SERVER, "No sensors are open and no client is connected. Shutting down..."); - // now actually remove them - for (XnClientsList::Iterator it = toRemove.begin(); it != toRemove.end(); ++it) + // reset the event (to notify server is no longer up) + nRetVal = xnOSResetEvent(m_hServerRunningEvent); + if (nRetVal != XN_STATUS_OK) { - XnClient* pClient = *it; - RemoveClient(pClient); + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to reset sensor server event: %s - proceeding with shutdown.", xnGetStatusString(nRetVal)); + XN_ASSERT(FALSE); } - // check if there are any clients left - if (m_clients.IsEmpty()) - { - xnOSGetTimeStamp(&nLastClientRemovedTimestamp); + // and close the socket (to free the port for another server) + xnOSCloseSocket(m_hListenSocket); + m_hListenSocket = NULL; - // do some clean-up (so that next client will behave as if it started the server) - ReturnToDefaults(); - } + return TRUE; } + } + } + + return FALSE; +} - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); +void XnSensorServer::Free() +{ + if (m_hServerRunningEvent != NULL) + { + xnOSCloseEvent(&m_hServerRunningEvent); + m_hServerRunningEvent = NULL; + } - // if too much time has passed and no client has connected, shut down - xnOSEnterCriticalSection(&m_hClientsCriticalSection); - bNoClients = m_clients.IsEmpty(); - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - - xnOSGetTimeStamp(&nNow); + if (m_hListenSocket != NULL) + { + xnOSCloseSocket(m_hListenSocket); + m_hListenSocket = NULL; + } - nTimeSinceNoClients = (nNow - nLastClientRemovedTimestamp); - if (bNoClients && (nTimeSinceNoClients >= m_noClientTimeout.GetValue())) - { - xnLogInfo(XN_MASK_SENSOR_SERVER, "No client connection for %u ms. Shutting down...", m_noClientTimeout.GetValue()); - bQuit = TRUE; - } - } + if (m_hSessionsLock != NULL) + { + xnOSCloseCriticalSection(&m_hSessionsLock); + m_hSessionsLock = NULL; } +} - return XN_STATUS_OK; +XnBool XnSensorServer::CanShutdown() +{ + XnUInt64 nNow; + xnOSGetTimeStamp(&nNow); + + XnAutoCSLocker locker(m_hSessionsLock); + return (!m_sensorsManager.HasOpenSensors() && m_sessions.IsEmpty() && + (nNow - m_nLastSessionActivity) > m_sensorsManager.GetTimeout()); } void XnSensorServer::ShutdownServer() @@ -446,35 +338,7 @@ void XnSensorServer::ShutdownServer() m_hServerRunningEvent = NULL; } - nRetVal = m_sensor.Destroy(); - if (nRetVal != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to destroy sensor: %s", xnGetStatusString(nRetVal)); - XN_ASSERT(FALSE); - } - - XN_DELETE(m_pServerStreams); - m_pServerStreams = NULL; - - for (XnPropertySetData::Iterator it = m_allStreamsProps.begin(); it != m_allStreamsProps.end(); ++it) - { - XN_DELETE(it.Value()); - } - m_allStreamsProps.Clear(); - - XN_ASSERT(m_clients.IsEmpty()); - - if (m_hNewDataEvent != NULL) - { - xnOSCloseEvent(&m_hNewDataEvent); - m_hNewDataEvent = NULL; - } - - if (m_hReaderThread != NULL) - { - xnOSWaitAndTerminateThread(&m_hReaderThread, XN_SENSOR_TERMINATE_READER_THREAD_TIMEOUT); - m_hReaderThread = NULL; - } + XN_ASSERT(m_sessions.IsEmpty()); if (m_hListenSocket != NULL) { @@ -482,1485 +346,78 @@ void XnSensorServer::ShutdownServer() m_hListenSocket = NULL; } - if (m_hClientsCriticalSection != NULL) - { - xnOSCloseCriticalSection(&m_hClientsCriticalSection); - m_hClientsCriticalSection = NULL; - } - - if (m_hBroadcastingLock != NULL) - { - xnOSCloseCriticalSection(&m_hBroadcastingLock); - m_hBroadcastingLock = NULL; - } - - if (m_hSensorLock != NULL) + if (m_hSessionsLock != NULL) { - xnOSCloseCriticalSection(&m_hSensorLock); - m_hSensorLock = NULL; + xnOSCloseCriticalSection(&m_hSessionsLock); + m_hSessionsLock = NULL; } } -XnStatus XnSensorServer::RegisterToProps(XnPropertySet* pProps) +XnStatus XnSensorServer::AddSession(XN_SOCKET_HANDLE hClientSocket) { XnStatus nRetVal = XN_STATUS_OK; - - for (XnPropertySetData::Iterator itMod = pProps->pData->begin(); itMod != pProps->pData->end(); ++itMod) - { - XnActualPropertiesHash* pHash = itMod.Value(); - XnDeviceModule* pModule; - nRetVal = m_sensor.FindModule(itMod.Key(), &pModule); - XN_IS_STATUS_OK(nRetVal); + XnUInt32 nID = 0; - for (XnActualPropertiesHash::Iterator itProp = pHash->begin(); itProp != pHash->end(); ++itProp) - { - XnProperty* pProp; - nRetVal = pModule->GetProperty(itProp.Key(), &pProp); - XN_IS_STATUS_OK(nRetVal); - - // no need to keep the handle. We only want to unregister when the stream is destroyed, and then - // it happens anyway. - nRetVal = pProp->OnChangeEvent().Register(PropertyChangedCallback, this); - XN_IS_STATUS_OK(nRetVal); - } + { + XnAutoCSLocker locker(m_hSessionsLock); + ++m_nLastClientID; + nID = m_nLastClientID; } - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::OnNewServerEvent(const XnUChar* pData, XnUInt32 nDataSize, XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - nRetVal = pClient->pStream->WriteData(pData, nDataSize); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -void XnSensorServer::DumpMessage(const XnChar* strType, XnUInt32 nSize /* = 0 */, XnUInt32 nClientID /* = 0 */, const XnChar* strComment /* = "" */ ) -{ - XnUInt64 nNow; - xnOSGetHighResTimeStamp(&nNow); - - xnDumpWriteString(m_serverDump, "%llu,%s,%d,%d,%s\n", nNow, strType, nSize, nClientID, strComment); -} - -XnStatus XnSensorServer::OnStreamAdded(const XnChar* StreamName) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // get all props - XN_PROPERTY_SET_CREATE_ON_STACK(props); - nRetVal = m_sensor.GetAllProperties(&props, FALSE, StreamName); - XN_IS_STATUS_OK(nRetVal); - - // register to all props - nRetVal = RegisterToProps(&props); - XN_IS_STATUS_OK(nRetVal); - - XnActualPropertiesHash* pStreamProps = props.pData->begin().Value(); - - // take type - XnProperty* pProp = NULL; - nRetVal = pStreamProps->Get(XN_STREAM_PROPERTY_TYPE, pProp); - XN_IS_STATUS_OK(nRetVal); - XnActualStringProperty* pTypeProp = (XnActualStringProperty*)pProp; + // create new session + XnServerSession* pSession; + XN_VALIDATE_NEW(pSession, XnServerSession, &m_sensorsManager, nID, hClientSocket, &m_logger); - nRetVal = XnPropertySetDataDetachModule(props.pData, StreamName, &pStreamProps); - XN_IS_STATUS_OK(nRetVal); - - // add it to property list - nRetVal = XnPropertySetDataAttachModule(&m_allStreamsProps, StreamName, pStreamProps); - XN_IS_STATUS_OK(nRetVal); - - // create stream data - XnServerStream serverStream; - xnOSMemSet(&serverStream, 0, sizeof(serverStream)); - strcpy(serverStream.strType, StreamName); - nRetVal = m_sensor.CreateStreamData(StreamName, &serverStream.pStreamData); - XN_IS_STATUS_OK(nRetVal); + nRetVal = pSession->Init(); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pSession); + return (nRetVal); + } - nRetVal = m_pServerStreams->Set(StreamName, serverStream); - XN_IS_STATUS_OK(nRetVal); + // add it to list in a lock + { + XnAutoCSLocker locker(m_hSessionsLock); + nRetVal = m_sessions.AddLast(pSession); + } + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(pSession); + return (nRetVal); + } return (XN_STATUS_OK); } -XnStatus XnSensorServer::OnStreamRemoved(const XnChar* StreamName) +XnStatus XnSensorServer::RemoveSession(XnSessionsList::ConstIterator it) { XnStatus nRetVal = XN_STATUS_OK; - - // no need to unregister from its props - they do not exist anymore. - - // remove stream data - XnServerStream* pServerStream; - nRetVal = m_pServerStreams->Get(StreamName, pServerStream); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = m_sensor.DestroyStreamData(&pServerStream->pStreamData); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = m_pServerStreams->Remove(StreamName); - XN_IS_STATUS_OK(nRetVal); - // remove from our list - XnActualPropertiesHash* pStreamProps = NULL; - nRetVal = XnPropertySetDataDetachModule(&m_allStreamsProps, StreamName, &pStreamProps); - XN_IS_STATUS_OK(nRetVal); + XnServerSession* pSession = *it; - XN_DELETE(pStreamProps); - - return (XN_STATUS_OK); -} + XnUInt32 nID = pSession->ID(); + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Removing client %u...", nID); -XnStatus XnSensorServer::OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType) -{ - XnStatus nRetVal = XN_STATUS_OK; - - switch (EventType) { - case XN_DEVICE_STREAM_ADDED: - { - nRetVal = OnStreamAdded(StreamName); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_DEVICE_STREAM_DELETED: - { - nRetVal = OnStreamRemoved(StreamName); - XN_IS_STATUS_OK(nRetVal); - break; - } - default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "unknown event: %d", EventType); - } - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::OnPropertyChanged(const XnProperty* pProp) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XnUInt64 nValue = 0; - XnDouble dValue = 0; - XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; - XnGeneralBuffer gbValue = {NULL, 0}; - XnBool bPassPropToClients = TRUE; + XnAutoCSLocker locker(m_hSessionsLock); + nRetVal = m_sessions.Remove(it); + XN_IS_STATUS_OK(nRetVal); - switch (pProp->GetType()) - { - case XN_PROPERTY_TYPE_INTEGER: - { - XnIntProperty* pIntProp = (XnIntProperty*)pProp; - nRetVal = pIntProp->GetValue(&nValue); - XN_IS_STATUS_OK(nRetVal); - nRetVal = OnIntPropertyChangedInternally(pProp->GetName(), nValue, bPassPropToClients); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PROPERTY_TYPE_REAL: - { - XnRealProperty* pRealProp = (XnRealProperty*)pProp; - nRetVal = pRealProp->GetValue(&dValue); - XN_IS_STATUS_OK(nRetVal); - nRetVal = OnRealPropertyChangedInternally(pProp->GetName(), dValue, bPassPropToClients); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PROPERTY_TYPE_STRING: + if (m_sessions.IsEmpty()) { - XnStringProperty* pStringProp = (XnStringProperty*)pProp; - nRetVal = pStringProp->GetValue(strValue); - XN_IS_STATUS_OK(nRetVal); - nRetVal = OnStringPropertyChangedInternally(pProp->GetName(), strValue, bPassPropToClients); - XN_IS_STATUS_OK(nRetVal); - break; + xnOSGetTimeStamp(&m_nLastSessionActivity); } - case XN_PROPERTY_TYPE_GENERAL: - { - XnGeneralProperty* pGenProp = (XnGeneralProperty*)pProp; - - // find its size from properties map - XnActualPropertiesHash* pModule; - nRetVal = m_allStreamsProps.Get(pProp->GetModule(), pModule); - XN_IS_STATUS_OK(nRetVal); - - XnProperty* pActualProp; - nRetVal = pModule->Get(pProp->GetName(), pActualProp); - XN_IS_STATUS_OK(nRetVal); - - XnActualGeneralProperty* pActualGenProp = (XnActualGeneralProperty*)pActualProp; - - // allocate - nRetVal = XnGeneralBufferAlloc(&gbValue, pActualGenProp->GetValue().nDataSize); - XN_IS_STATUS_OK(nRetVal); - - // take value - nRetVal = pGenProp->GetValue(gbValue); - if (nRetVal != XN_STATUS_OK) - { - XnGeneralBufferFree(&gbValue); - return nRetVal; - } + } - nRetVal = OnGeneralPropertyChangedInternally(pProp->GetName(), gbValue, bPassPropToClients); - if (nRetVal != XN_STATUS_OK) - { - XnGeneralBufferFree(&gbValue); - return nRetVal; - } + pSession->Free(); + XN_DELETE(pSession); - break; - } - default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Unknown property type: %d", pProp->GetType()); - } - - if (bPassPropToClients) - { - xnOSEnterCriticalSection(&m_hClientsCriticalSection); - for (XnClientsList::Iterator it = m_clients.begin(); it != m_clients.end(); ++it) - { - XnClient* pClient = *it; - const XnChar* strModule = pClient->FromServerModule(pProp->GetModule()); - if (strModule == NULL) - { - continue; - } - - // send message - DumpMessage("PropChange", 0, pClient->nID, pProp->GetName()); - switch (pProp->GetType()) - { - case XN_PROPERTY_TYPE_INTEGER: - { - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteProperty(strModule, pProp->GetName(), nValue); - break; - } - case XN_PROPERTY_TYPE_REAL: - { - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteProperty(strModule, pProp->GetName(), dValue); - break; - } - case XN_PROPERTY_TYPE_STRING: - { - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteProperty(strModule, pProp->GetName(), strValue); - break; - } - case XN_PROPERTY_TYPE_GENERAL: - { - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteProperty(strModule, pProp->GetName(), gbValue); - break; - } - } - - if (nRetVal != XN_STATUS_OK) - { - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - XnGeneralBufferFree(&gbValue); - return nRetVal; - } - } // clients loop - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - } - - // free allocated buffer - XnGeneralBufferFree(&gbValue); - return XN_STATUS_OK; -} - -XnStatus XnSensorServer::ReadStreams() -{ - XnStatus nRetVal = XN_STATUS_OK; - - while (IsServerRunning()) - { - nRetVal = xnOSWaitEvent(m_hNewDataEvent, XN_NODE_WAIT_FOR_DATA_TIMEOUT); - if (nRetVal == XN_STATUS_OS_EVENT_TIMEOUT) - { - continue; - } - - if (nRetVal != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Got error waiting for new data event: %s", xnGetStatusString(nRetVal)); - } - - typedef struct - { - XnUInt64 nTimestamp; - XnUInt32 nFrameID; - XnChar strName[XN_MAX_NAME_LENGTH]; - } NewStreamData; - - NewStreamData aNewStreamData[5]; - XnUInt32 nCount = 0; - - // read streams with lock - { - XN_SENSOR_SERVER_LOCK_BLOCK; - for (XnServerStreamsHash::Iterator it = m_pServerStreams->begin(); it != m_pServerStreams->end(); ++it) - { - XnServerStream& stream = it.Value(); - - if (stream.bNewData) - { - // ignore audio (it is read by every client) - if (strcmp(stream.strType, XN_STREAM_NAME_AUDIO) != 0) - { - // read this data - nRetVal = m_sensor.ReadStream(stream.pStreamData); - if (nRetVal != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed reading from stream %s (though event was raised): %s", stream.strType, xnGetStatusString(nRetVal)); - stream.bNewData = FALSE; - continue; - } - } - - stream.bNewData = FALSE; - - aNewStreamData[nCount].nTimestamp = stream.pStreamData->nTimestamp; - aNewStreamData[nCount].nFrameID = stream.pStreamData->nFrameID; - strcpy(aNewStreamData[nCount].strName, stream.strType); - nCount++; - } - } // streams loop - } // lock - - // now send notifications (outside of server lock) - for (XnUInt32 i = 0; i < nCount; ++i) - { - xnOSEnterCriticalSection(&m_hClientsCriticalSection); - for (XnClientsList::Iterator it = m_clients.begin(); it != m_clients.end(); ++it) - { - XnClient* pClient = *it; - - // check if client has stream open - if (!pClient->IsStreamOpen(aNewStreamData[i].strName)) - { - continue; - } - - // notify about the new data - const XnChar* strStreamName = pClient->FromServerModule(aNewStreamData[i].strName); - if (strStreamName != NULL) - { - XnSensorServerNewStreamData message; - xnOSMemSet(&message, 0, sizeof(message)); - message.nTimestamp = aNewStreamData[i].nTimestamp; - message.nFrameID = aNewStreamData[i].nFrameID; - strcpy(message.strStreamName, strStreamName); - DumpMessage("NewData", sizeof(XnSensorServerNewStreamData), 0, strStreamName); - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_NEW_STREAM_DATA, &message, sizeof(XnSensorServerNewStreamData)); - if (nRetVal != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed sending new data event to client %d", pClient->nID); - } //if (nRetVal != XN_STATUS_OK) - } //if (strStreamName != NULL) - } //for (clients) - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - } - - } //while (m_bShouldRun) - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::OnNewStreamData(const XnChar* StreamName) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XnServerStream* pStream; - nRetVal = m_pServerStreams->Get(StreamName, pStream); - XN_IS_STATUS_OK(nRetVal); - - pStream->bNewData = TRUE; - - nRetVal = xnOSSetEvent(m_hNewDataEvent); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::SendInitialState(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XN_PROPERTY_SET_CREATE_ON_STACK(props); - - // get it - nRetVal = m_sensor.GetAllProperties(&props, TRUE); - XN_IS_STATUS_OK(nRetVal); - - // and send it - DumpMessage("InitialState", 0, pClient->nID); - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WritePropertySet(&props); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::AddClient(XN_SOCKET_HANDLE hClientSocket) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // create new client - XnClient* pClient; - XN_VALIDATE_NEW(pClient, XnClient); - pClient->hSocket = hClientSocket; - pClient->pServer = this; - pClient->pStream = XN_NEW(XnIONetworkStream, pClient->hSocket); - pClient->pPrivateIncomingPacker = XN_NEW(XnDataPacker, pClient->pStream, XN_SENSOR_SERVER_CONFIG_PACKER_SIZE); - pClient->pPrivateOutgoingPacker = XN_NEW(XnDataPacker, pClient->pStream, XN_SENSOR_SERVER_CONFIG_PACKER_SIZE); - - if (pClient->pStream == NULL || pClient->pPrivateIncomingPacker == NULL || pClient->pPrivateOutgoingPacker == NULL) - { - XN_DELETE(pClient); - return (XN_STATUS_ALLOC_FAILED); - } - - nRetVal = XnStreamDataSetCreate(&pClient->pStreamDataSet); - if (nRetVal != XN_STATUS_OK) - { - XN_DELETE(pClient); - return (XN_STATUS_ALLOC_FAILED); - } - - nRetVal = xnOSCreateCriticalSection(&pClient->hLock); - if (nRetVal != XN_STATUS_OK) - { - XN_DELETE(pClient); - return (nRetVal); - } - - nRetVal = pClient->pPrivateIncomingPacker->Init(); - if (nRetVal != XN_STATUS_OK) - { - XN_DELETE(pClient); - return (nRetVal); - } - - nRetVal = pClient->pPrivateOutgoingPacker->Init(); - if (nRetVal != XN_STATUS_OK) - { - XN_DELETE(pClient); - return (nRetVal); - } - - // lock the device (so that configuration wouldn't change before we register to it all) - { - XN_SENSOR_SERVER_LOCK_BLOCK; - - m_nLastClientID++; - pClient->nID = m_nLastClientID; - - // create thread - nRetVal = xnOSCreateThread(ClientThread, pClient, &pClient->hThread); - if (nRetVal != XN_STATUS_OK) - { - xnOSLeaveCriticalSection(&m_hSensorLock); - XN_DELETE(pClient); - return (nRetVal); - } - - // add it to clients list - xnOSEnterCriticalSection(&m_hClientsCriticalSection); - m_clients.AddLast(pClient); - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - - } // lock end - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::RemoveClientStream(XnClient* pClient, const XnChar* strName) -{ - XnStatus nRetVal = XN_STATUS_OK; - - const XnChar* strServerName = pClient->ToServerModule(strName); - if (strServerName == NULL) - { - return XN_STATUS_NO_MATCH; - } - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u is releasing stream %s", pClient->nID, strServerName); - - // first of all, if client had a buffer of this stream, release it - XnStreamData* pStreamData = NULL; - nRetVal = XnStreamDataSetGet(pClient->pStreamDataSet, strServerName, &pStreamData); - if (nRetVal == XN_STATUS_OK) - { - XnSharedMemoryBufferPool* pBufferPool = NULL; - nRetVal = m_sensor.GetSharedBufferPool(strServerName, &pBufferPool); - XN_IS_STATUS_OK(nRetVal); - - if (pStreamData->pInternal->pLockedBuffer != NULL) - { - pBufferPool->DecRef(pStreamData->pInternal->pLockedBuffer); - } - - // free data - XnStreamDataSetRemove(pClient->pStreamDataSet, pStreamData); - XnStreamDataDestroy(&pStreamData); - } - - // and dec ref it - XnServerStream* pStream; - nRetVal = m_pServerStreams->Get(strServerName, pStream); - if (nRetVal == XN_STATUS_OK) - { - XN_SENSOR_SERVER_LOCK_BLOCK; - --pStream->nRefCount; - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s now has %u clients", strServerName, pStream->nRefCount); - - if (pStream->nRefCount == 0) - { - m_sensor.CloseStream(strServerName); - m_sensor.DestroyStream(strServerName); - - // the rest will be done in the OnStreamRemoved event handler... - } - } - - // now remove it from client - pClient->serverToClientNames.Remove(strServerName); - pClient->clientToServerNames.Remove(strName); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::RemoveClient(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Removing client %u...", pClient->nID); - - pClient->bShouldRun = FALSE; - - // dec ref of every stream - while (!pClient->clientToServerNames.IsEmpty()) - { - RemoveClientStream(pClient, pClient->clientToServerNames.begin().Key()); - } - - xnOSEnterCriticalSection(&m_hClientsCriticalSection); - XnClientsList::ConstIterator it = m_clients.Find(pClient); - m_clients.Remove(it); - xnOSLeaveCriticalSection(&m_hClientsCriticalSection); - - xnOSWaitAndTerminateThread(&pClient->hThread, 3000); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u removed", pClient->nID); - XN_DELETE(pClient); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::ReturnToDefaults() -{ - XnStatus nRetVal = XN_STATUS_OK; - - // This is a bit ugly, but we need to manually set back to default DEVICE properties - // (we know there aren't any streams and clients, but the Device module always remains) - nRetVal = m_sensor.SetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, (XnUInt64)FALSE); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = m_sensor.ConfigureModuleFromGlobalFile(XN_MODULE_NAME_DEVICE); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::SendReply(XnClient* pClient, XnSensorServerCustomMessages Type, XnStatus nRC, XnUInt32 nDataSize /* = 0 */, void* pAdditionalData /* = NULL */) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XnUChar message[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; - XnSensorClientServerReply* pReply = (XnSensorClientServerReply*)message; - pReply->nRetVal = nRC; - pReply->Type = Type; - pReply->nDataSize = nDataSize; - xnOSMemCopy(pReply->pData, pAdditionalData, nDataSize); - XnUChar* pEnd = pReply->pData + nDataSize; - - DumpMessage("Reply", nDataSize, pClient->nID); - - // lock this so that messages don't mix up - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - - nRetVal = pClient->pPrivateOutgoingPacker->WriteCustomData(Type, message, pEnd - message); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleOpenSensor(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strConnectionString[XN_DEVICE_MAX_STRING_LENGTH]; - XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR, strConnectionString, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to open sensor %s", pClient->nID, strConnectionString); - - // make sure sensor is open - { - XN_SENSOR_SERVER_LOCK_BLOCK; - if (!m_bSensorOpen) - { - nRetVal = OpenSensor(strConnectionString); - m_bSensorOpen = (nRetVal == XN_STATUS_OK); - } - - if (nRetVal == XN_STATUS_OK) - { - // sensor is open. send client its initial state - nRetVal = SendInitialState(pClient); - } - } - - // if an error occurred, send it to the client - if (nRetVal != XN_STATUS_OK) - { - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - } - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleSetIntProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - XnUInt64 nValue; - nRetVal = pClient->pPrivateIncomingPacker->ReadProperty(strModule, strProp, &nValue); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", pClient->nID, strModule, strProp); - - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.SetProperty(pClient->ToServerModule(strModule), strProp, nValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleSetRealProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - XnDouble dValue; - nRetVal = pClient->pPrivateIncomingPacker->ReadProperty(strModule, strProp, &dValue); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", pClient->nID, strModule, strProp); - - // set - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.SetProperty(pClient->ToServerModule(strModule), strProp, dValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleSetStringProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; - nRetVal = pClient->pPrivateIncomingPacker->ReadProperty(strModule, strProp, strValue); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", pClient->nID, strModule, strProp); - - // set - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.SetProperty(pClient->ToServerModule(strModule), strProp, strValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleSetGeneralProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - XnGeneralBuffer gbValue; - nRetVal = pClient->pPrivateIncomingPacker->ReadProperty(strModule, strProp, &gbValue); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", pClient->nID, strModule, strProp); - - // set - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.SetProperty(pClient->ToServerModule(strModule), strProp, gbValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleGetIntProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnSensorServerMessageGetPropertyRequest request; - XnUInt32 nDataSize = sizeof(request); - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY, &request, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - if (nDataSize != sizeof(request)) - { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); - } - - XnUInt64 nValue; - { - XN_SENSOR_SERVER_LOCK_BLOCK; - - nRetVal = m_sensor.GetProperty(pClient->ToServerModule(request.strModuleName), request.strPropertyName, &nValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY, nRetVal, sizeof(nValue), &nValue); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleGetRealProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnSensorServerMessageGetPropertyRequest request; - XnUInt32 nDataSize = sizeof(request); - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY, &request, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - if (nDataSize != sizeof(request)) - { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); - } - - XnDouble dValue; - { - XN_SENSOR_SERVER_LOCK_BLOCK; - - nRetVal = m_sensor.GetProperty(pClient->ToServerModule(request.strModuleName), request.strPropertyName, &dValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY, nRetVal, sizeof(dValue), &dValue); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleGetStringProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnSensorServerMessageGetPropertyRequest request; - XnUInt32 nDataSize = sizeof(request); - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, &request, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - if (nDataSize != sizeof(request)) - { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); - } - - XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; - { - XN_SENSOR_SERVER_LOCK_BLOCK; - - nRetVal = m_sensor.GetProperty(pClient->ToServerModule(request.strModuleName), request.strPropertyName, strValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, nRetVal, sizeof(strValue), strValue); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleGetGeneralProperty(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnUChar bufValue[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; - XnSensorServerMessageGetPropertyRequest* pRequest = (XnSensorServerMessageGetPropertyRequest*)bufValue; - XnUChar* pData = bufValue + sizeof(XnSensorServerMessageGetPropertyRequest); - XnUInt32 nDataSize = XN_SENSOR_SERVER_MAX_REPLY_SIZE; - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, bufValue, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - - if (nDataSize < sizeof(XnSensorServerMessageGetPropertyRequest)) - { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); - } - - XnGeneralBuffer gbValue = XnGeneralBufferPack(pData, pRequest->nSize); - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.GetProperty(pClient->ToServerModule(pRequest->strModuleName), pRequest->strPropertyName, gbValue); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, nRetVal, pRequest->nSize, pData); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleConfigFromINIFile(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnSensorServerMessageIniFile message; - XnUInt32 nDataSize = sizeof(message); - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_INI_FILE, (XnUChar*)&message, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - - if (nDataSize != sizeof(message)) - { - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); - } - - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.LoadConfigFromFile(message.strFileName, message.strSectionName); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleBatchConfig(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XN_PROPERTY_SET_CREATE_ON_STACK(props); - - nRetVal = pClient->pPrivateIncomingPacker->ReadPropertySet(&props); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested a batch config", pClient->nID); - - XN_PROPERTY_SET_CREATE_ON_STACK(serverProps); - for (XnPropertySetData::Iterator it = props.pData->begin(); it != props.pData->end(); ++it) - { - if (nRetVal == XN_STATUS_OK) - { - nRetVal = XnPropertySetCloneModule(&props, &serverProps, it.Key(), pClient->ToServerModule(it.Key())); - } - } - - if (nRetVal == XN_STATUS_OK) - { - XN_SENSOR_SERVER_LOCK_BLOCK; - nRetVal = m_sensor.BatchConfig(&serverProps); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleNewStream(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XN_PROPERTY_SET_CREATE_ON_STACK(props); - - XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; - nRetVal = pClient->pPrivateIncomingPacker->ReadNewStream(strType, strName, &props); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to create stream '%s' (%s)", pClient->nID, strName, strType); - - XnPropertySet* pInitialValues = &props; - if (props.pData->begin() == props.pData->end()) - { - pInitialValues = NULL; - } - - // if a stream of this type already exists, take it instead - XnServerStream* pServerStream; - - XN_SENSOR_SERVER_LOCK_BLOCK; - - if (XN_STATUS_OK == m_pServerStreams->Get(strType, pServerStream)) - { - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s already exists.", strType); - // configure it - if (pInitialValues != NULL) - { - nRetVal = m_sensor.BatchConfig(pInitialValues); - } - } - else - { - // create the stream - nRetVal = m_sensor.CreateStream(strType, strType, pInitialValues); - - if (nRetVal == XN_STATUS_OK) - { - nRetVal = m_pServerStreams->Get(strType, pServerStream); - } - } - - // send client the new stream data - if (nRetVal == XN_STATUS_OK) - { - XN_PROPERTY_SET_CREATE_ON_STACK(streamProps); - XN_PROPERTY_SET_CREATE_ON_STACK(clientStreamProps); - - if (nRetVal == XN_STATUS_OK) - { - // take properties - nRetVal = m_sensor.GetAllProperties(&streamProps, FALSE, strType); - } - - if (nRetVal == XN_STATUS_OK) - { - // copy relevant ones - nRetVal = XnPropertySetCloneModule(&streamProps, &clientStreamProps, strType, strName); - } - - if (nRetVal == XN_STATUS_OK) - { - // now change the state property. It should be OFF, and not the real value (each client has - // its own stream state). - nRetVal = XnPropertySetRemoveProperty(&clientStreamProps, strName, XN_STREAM_PROPERTY_STATE); - } - - if (nRetVal == XN_STATUS_OK) - { - nRetVal = XnPropertySetAddIntProperty(&clientStreamProps, strName, XN_STREAM_PROPERTY_STATE, FALSE); - } - - if (nRetVal == XN_STATUS_OK) - { - DumpMessage("NewStream", 0, pClient->nID, strName); - { - XN_SENSOR_SERVER_CLIENT_LOCK_BLOCK; - nRetVal = pClient->pPrivateOutgoingPacker->WriteNewStream(strType, strName, &clientStreamProps); - } - } - } - - // add ref to it - if (nRetVal == XN_STATUS_OK) - { - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u adding ref to stream '%s'", pClient->nID, strType); - ++pServerStream->nRefCount; - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s now has %u clients.", strType, pServerStream->nRefCount); - } - - // now add it to client data - XnStreamData* pStreamData = NULL; - if (nRetVal == XN_STATUS_OK) - { - // add names mapping - XnDeviceString str; - strcpy(str.str, strType); - pClient->clientToServerNames.Set(strName, str); - strcpy(str.str, strName); - pClient->serverToClientNames.Set(strType, str); - - // create client stream data - nRetVal = m_sensor.CreateStreamData(strType, &pStreamData); - } - - if (nRetVal == XN_STATUS_OK) - { - // and add it to set - nRetVal = XnStreamDataSetAdd(pClient->pStreamDataSet, pStreamData); - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleRemoveStream(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; - nRetVal = pClient->pPrivateIncomingPacker->ReadStreamRemoved(strName); - XN_IS_STATUS_OK(nRetVal); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to close stream %s", pClient->nID, strName); - - nRetVal = RemoveClientStream(pClient, strName); - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleReadStream(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; - XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, strStreamName, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - - const XnChar* strServerName = pClient->ToServerModule(strStreamName); - - // take client stream data and server stream data - XnStreamData* pStreamData; - nRetVal = XnStreamDataSetGet(pClient->pStreamDataSet, strServerName, &pStreamData); - - XnServerStream* pServerStream = NULL; - - if (nRetVal == XN_STATUS_OK) - { - nRetVal = m_pServerStreams->Get(strServerName, pServerStream); - } - - XnSharedMemoryBufferPool* pBufferPool = NULL; - XnBuffer* pDecRef = NULL; - if (nRetVal == XN_STATUS_OK) - { - pDecRef = pStreamData->pInternal->pLockedBuffer; - nRetVal = m_sensor.GetSharedBufferPool(strServerName, &pBufferPool); - } - - if (nRetVal == XN_STATUS_OK) - { - // take server data for this stream, and add ref to it - XN_SENSOR_SERVER_LOCK_BLOCK; - pStreamData->nDataSize = pServerStream->pStreamData->nDataSize; - pStreamData->nFrameID = pServerStream->pStreamData->nFrameID; - pStreamData->nTimestamp = pServerStream->pStreamData->nTimestamp; - pStreamData->pData = pServerStream->pStreamData->pData; - pStreamData->pInternal->pLockedBuffer = pServerStream->pStreamData->pInternal->pLockedBuffer; - - if (pStreamData->pInternal->pLockedBuffer != NULL) - { - pBufferPool->AddRef(pStreamData->pInternal->pLockedBuffer); - } - - if (pDecRef != NULL) - { - pBufferPool->DecRef(pDecRef); - } - - XnSensorServerReadReply reply; - reply.nDataSize = pStreamData->nDataSize; - reply.nFrameID = pStreamData->nFrameID; - reply.nTimestamp = pStreamData->nTimestamp; - reply.nOffset = pBufferPool->GetBufferOffset(pStreamData->pInternal->pLockedBuffer); - - DumpMessage("Data", sizeof(reply), 0, strStreamName); - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_READ_STREAM, XN_STATUS_OK, sizeof(reply), &reply); - XN_IS_STATUS_OK(nRetVal); - } - else - { - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - } - - return (XN_STATUS_OK); -} - -XnStatus XnSensorServer::HandleSetStreamState(XnClient* pClient, XnBool bRequestOpen) -{ - XnStatus nRetVal = XN_STATUS_OK; - - // read it - XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; - XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; - XnUInt32 nType = bRequestOpen ? XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM : XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM; - nRetVal = pClient->pPrivateIncomingPacker->ReadCustomData(nType, strStreamName, &nDataSize); - XN_IS_STATUS_OK(nRetVal); - - const XnChar* strServerName = pClient->ToServerModule(strStreamName); - - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to %s stream %s", pClient->nID, bRequestOpen ? "open" : "close", strServerName); - - { - XN_SENSOR_SERVER_LOCK_BLOCK; - XnServerStream* pServerStream = NULL; - - if (nRetVal == XN_STATUS_OK) - { - nRetVal = m_pServerStreams->Get(strServerName, pServerStream); - } - - if (nRetVal == XN_STATUS_OK) - { - // check if this stream is currently open for this client (meaning, client - // receives its data) - XnBool bIsOpenForClient = FALSE; - XnNamesHash::Iterator it = pClient->openStreams.end(); - bIsOpenForClient = (pClient->openStreams.Find(strServerName, it) == XN_STATUS_OK); - - if (bRequestOpen && !bIsOpenForClient) - { - XnDeviceString dummy; - nRetVal = pClient->openStreams.Set(strServerName, dummy); - - if (nRetVal == XN_STATUS_OK) - { - pServerStream->nOpenRefCount++; - - if (pServerStream->nOpenRefCount == 1) // first one to open - { - // open it - nRetVal = m_sensor.OpenStream(strServerName); - } - - if (nRetVal != XN_STATUS_OK) - { - xnLogError(XN_MASK_SENSOR_SERVER, "Failed to open stream: %s", xnGetStatusString(nRetVal)); - XN_ASSERT(pServerStream->nOpenRefCount > 0); - --pServerStream->nOpenRefCount; - pClient->openStreams.Remove(strServerName); - } - else - { - xnLogInfo(XN_MASK_SENSOR_SERVER, "Stream %s is now open by %u clients.", strServerName, pServerStream->nOpenRefCount); - } - } - } - else if (!bRequestOpen && bIsOpenForClient) - { - pClient->openStreams.Remove(strServerName); - xnLogInfo(XN_MASK_SENSOR_SERVER, "Stream %s is now open by %u clients.", strServerName, pServerStream->nOpenRefCount); - --pServerStream->nOpenRefCount; - - if (pServerStream->nOpenRefCount == 0) - { - m_sensor.CloseStream(strServerName); - } - } - else - { - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client requested to %s stream %s, but this was already the state.", bRequestOpen ? "open" : "close", strServerName); - } - } - } - - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nRetVal); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); -} - - -XnStatus XnSensorServer::HandleSingleRequest(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XnPackedDataType nType; - nRetVal = pClient->pPrivateIncomingPacker->ReadNextObject(&nType); - XN_IS_STATUS_OK(nRetVal); - - XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; - XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; - - switch (nType) - { - case XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR: - { - nRetVal = HandleOpenSensor(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_INT_PROPERTY: - { - nRetVal = HandleSetIntProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_REAL_PROPERTY: - { - nRetVal = HandleSetRealProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_STRING_PROPERTY: - { - nRetVal = HandleSetStringProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_GENERAL_PROPERTY: - { - nRetVal = HandleSetGeneralProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY: - { - nRetVal = HandleGetIntProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY: - { - nRetVal = HandleGetRealProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY: - { - nRetVal = HandleGetStringProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY: - { - nRetVal = HandleGetGeneralProperty(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_INI_FILE: - { - nRetVal = HandleConfigFromINIFile(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_PROPERTY_SET: - { - nRetVal = HandleBatchConfig(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_NEW_STREAM: - { - nRetVal = HandleNewStream(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_PACKED_STREAM_REMOVED: - { - nRetVal = HandleRemoveStream(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_READ_STREAM: - { - nRetVal = HandleReadStream(pClient); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM: - { - nRetVal = HandleSetStreamState(pClient, TRUE); - XN_IS_STATUS_OK(nRetVal); - break; - } - case XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM: - { - nRetVal = HandleSetStreamState(pClient, FALSE); - XN_IS_STATUS_OK(nRetVal); - break; - } - - case XN_SENSOR_SERVER_MESSAGE_BYE: - { - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Received BYE from client %u", pClient->nID); - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_BYE, nRetVal, 0, NULL); - if (nRetVal != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to send BYE reply to client %u: %s", pClient->nID, xnGetStatusString(nRetVal)); - } - pClient->bShouldRun = FALSE; //Signal the client to stop - - break; - } - - default: - xnLogWarning(XN_MASK_SENSOR_SERVER, "Unknown client request: %d", nType); - nRetVal = SendReply(pClient, XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, XN_STATUS_ERROR); - XN_IS_STATUS_OK(nRetVal); - - return XN_STATUS_ERROR; - } + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u removed", nID); return (XN_STATUS_OK); } -XnStatus XnSensorServer::ServeClient(XnClient* pClient) -{ - XnStatus nRetVal = XN_STATUS_OK; - - while (IsServerRunning() && pClient->bShouldRun) - { - if (!pClient->pStream->IsConnected()) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u socket was closed.", pClient->nID); - break; - } - - nRetVal = HandleSingleRequest(pClient); - if ((nRetVal != XN_STATUS_OK) && - (nRetVal != XN_STATUS_OS_NETWORK_CONNECTION_CLOSED) && - (nRetVal != XN_STATUS_OS_NETWORK_TIMEOUT)) - { - xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed processing client request: %s", xnGetStatusString(nRetVal)); - } - } - - // We cannot RemoveClient from this thread (as part of it is to close the thread). Instead, signal that - // client has stopped, and let server main thread wait for exit. - pClient->bShouldRun = FALSE; - - return (XN_STATUS_OK); -} - -XN_THREAD_PROC XnSensorServer::ClientThread(XN_THREAD_PARAM pThreadParam) -{ - XnClient* pClient = (XnClient*)pThreadParam; - XnStatus nRetVal = pClient->pServer->ServeClient(pClient); - XN_THREAD_PROC_RETURN(nRetVal); -} - -XN_THREAD_PROC XnSensorServer::ReaderThread(XN_THREAD_PARAM pThreadParam) -{ - XnSensorServer* pThis = (XnSensorServer*)pThreadParam; - XnStatus nRetVal = pThis->ReadStreams(); - XN_THREAD_PROC_RETURN(nRetVal); -} - -void XnSensorServer::StreamCollectionChangedCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie) -{ - XnSensorServer* pThis = (XnSensorServer*)pCookie; - pThis->OnStreamCollectionChanged(StreamName, EventType); -} - -XnStatus XN_CALLBACK_TYPE XnSensorServer::PropertyChangedCallback(const XnProperty* pProp, void* pCookie) -{ - XnSensorServer* pThis = (XnSensorServer*)pCookie; - return pThis->OnPropertyChanged(pProp); -} - -void XN_CALLBACK_TYPE XnSensorServer::NewServerEventCallback(const XnUChar* pData, XnUInt32 nDataSize, void* pCookie) -{ - XnClient* pClient = (XnClient*)pCookie; - pClient->pServer->OnNewServerEvent(pData, nDataSize, pClient); -} - -void XN_CALLBACK_TYPE XnSensorServer::NewStreamDataCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, void* pCookie) -{ - XnSensorServer* pThis = (XnSensorServer*)pCookie; - pThis->OnNewStreamData(StreamName); -} - -XnStatus XN_CALLBACK_TYPE XnSensorServer::StartNewLogCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie) -{ - xnLogVerbose(XN_MASK_SENSOR_SERVER, "Closing current log file..."); - return xnLogStartNewFile(); -} - -XnStatus XnSensorServer::OnIntPropertyChangedInternally(const XnChar* strPropName, XnUInt64 nValue, XnBool& bPassPropToClients) -{ - XnStatus nRetVal = XN_STATUS_OK; - bPassPropToClients = TRUE; - - if (strcmp(strPropName, XN_STREAM_PROPERTY_STATE) == 0) - { - // ignore STATE property (every client has its own value) - bPassPropToClients = FALSE; - } - else if (strcmp(strPropName, XN_MODULE_PROPERTY_ERROR_STATE) == 0) - { - XnStatus nOldErrorState = m_nErrorState; - m_nErrorState = (XnStatus)nValue; - switch (m_nErrorState) - { - case XN_STATUS_DEVICE_NOT_CONNECTED: - //TODO: Handle disconnection - break; - case XN_STATUS_OK: - if (nOldErrorState == XN_STATUS_DEVICE_NOT_CONNECTED) - { - //TODO: Handle re-connection - break; - } - } - } - - return XN_STATUS_OK; -} - -XnStatus XnSensorServer::OnRealPropertyChangedInternally(const XnChar* strPropName, XnDouble dValue, XnBool& bPassPropToClients) -{ - bPassPropToClients = TRUE; - return XN_STATUS_OK; -} - -XnStatus XnSensorServer::OnStringPropertyChangedInternally(const XnChar* strPropName, const XnChar* strValue, XnBool& bPassPropToClients) -{ - bPassPropToClients = TRUE; - return XN_STATUS_OK; -} - -XnStatus XnSensorServer::OnGeneralPropertyChangedInternally(const XnChar* strPropName, const XnGeneralBuffer &gbValue, XnBool& bPassPropToClients) -{ - bPassPropToClients = TRUE; - return XN_STATUS_OK; -} - XN_DEVICE_API XnStatus XnSensorServerGetGlobalConfigFile(const XnChar* strConfigDir, XnChar* strConfigFile, XnUInt32 nBufSize) { return XnSensor::ResolveGlobalConfigFileName(strConfigFile, nBufSize, strConfigDir); @@ -1968,7 +425,7 @@ XN_DEVICE_API XnStatus XnSensorServerGetGlobalConfigFile(const XnChar* strConfig XN_DEVICE_API XnStatus XnSensorServerRun(const XnChar* strConfigFile) { - XnSensorServer server; - return server.Run(strConfigFile); + XnSensorServer server(strConfigFile); + return server.Run(); } diff --git a/Source/XnDeviceSensorV2/XnSensorServer.h b/Source/XnDeviceSensorV2/XnSensorServer.h index 1792a9f..6b7da06 100644 --- a/Source/XnDeviceSensorV2/XnSensorServer.h +++ b/Source/XnDeviceSensorV2/XnSensorServer.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_SERVER_H__ #define __XN_SENSOR_SERVER_H__ @@ -34,11 +29,10 @@ #include "XnSensor.h" #include #include "XnSensorClientServer.h" - -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -#define XN_CONFIG_FILE_SERVER_SECTION "Server" +#include "XnServerLogger.h" +#include "XnSensorsManager.h" +#include "XnServerSession.h" +#include //--------------------------------------------------------------------------- // XnSensorServer class @@ -48,91 +42,41 @@ class XnServerStreamsHash; class XnSensorServer { public: - XnSensorServer(); + XnSensorServer(const XnChar* strConfigFile); ~XnSensorServer(); - XnStatus Run(const XnChar* strConfigFile); + XnStatus Run(); XnBool IsServerRunning(); private: - struct XnClient; // Forward Declaration + typedef XnListT XnSessionsList; - XnStatus InitServer(const XnChar* strConfigFile); + XnStatus InitServer(); XnStatus ServerMainLoop(); void ShutdownServer(); - XnStatus OpenSensor(const XnChar* strConnectionString); - XnStatus SendInitialState(XnClient* pClient); - XnStatus ServeClient(XnClient* pClient); - XnStatus SendReply(XnClient* pClient, XnSensorServerCustomMessages Type, XnStatus nRC, XnUInt32 nDataSize = 0, void* pAdditionalData = NULL); - XnStatus HandleSingleRequest(XnClient* pClient); - XnStatus HandleOpenSensor(XnClient* pClient); - XnStatus HandleSetIntProperty(XnClient* pClient); - XnStatus HandleSetRealProperty(XnClient* pClient); - XnStatus HandleSetStringProperty(XnClient* pClient); - XnStatus HandleSetGeneralProperty(XnClient* pClient); - XnStatus HandleGetIntProperty(XnClient* pClient); - XnStatus HandleGetRealProperty(XnClient* pClient); - XnStatus HandleGetStringProperty(XnClient* pClient); - XnStatus HandleGetGeneralProperty(XnClient* pClient); - XnStatus HandleConfigFromINIFile(XnClient* pClient); - XnStatus HandleBatchConfig(XnClient* pClient); - XnStatus HandleNewStream(XnClient* pClient); - XnStatus HandleRemoveStream(XnClient* pClient); - XnStatus HandleReadStream(XnClient* pClient); - XnStatus HandleSetStreamState(XnClient* pClient, XnBool bOpen); - - XnStatus AddClient(XN_SOCKET_HANDLE hClientSocket); - XnStatus RemoveClientStream(XnClient* pClient, const XnChar* strName); - XnStatus RemoveClient(XnClient* pClient); - XnStatus ReadStreams(); + void CheckForNewClients(XnUInt32 nTimeout); + void CleanUpSessions(); + XnBool ShutdownIfPossible(); + XnBool CanShutdown(); + void Free(); + XnStatus AddSession(XN_SOCKET_HANDLE hClientSocket); + XnStatus RemoveSession(XnSessionsList::ConstIterator it); XnStatus ReturnToDefaults(); - XnStatus OnStreamAdded(const XnChar* StreamName); - XnStatus OnStreamRemoved(const XnChar* StreamName); - XnStatus OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType); - XnStatus OnPropertyChanged(const XnProperty* pProp); - XnStatus OnNewServerEvent(const XnUChar* pData, XnUInt32 nDataSize, XnClient* pClient); - XnStatus OnNewStreamData(const XnChar* StreamName); - - XnStatus RegisterToProps(XnPropertySet* pProps); - - void DumpMessage(const XnChar* strType, XnUInt32 nSize = 0, XnUInt32 nClientID = 0, const XnChar* strComment = ""); - - static XN_THREAD_PROC ClientThread(XN_THREAD_PARAM pThreadParam); - static XN_THREAD_PROC ReaderThread(XN_THREAD_PARAM pThreadParam); - - static void XN_CALLBACK_TYPE StreamCollectionChangedCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, XnStreamsChangeEventType EventType, void* pCookie); - static XnStatus XN_CALLBACK_TYPE PropertyChangedCallback(const XnProperty* pProp, void* pCookie); - static void XN_CALLBACK_TYPE NewServerEventCallback(const XnUChar* pData, XnUInt32 nDataSize, void* pCookie); - static void XN_CALLBACK_TYPE NewStreamDataCallback(XnDeviceHandle DeviceHandle, const XnChar* StreamName, void* pCookie); - static XnStatus XN_CALLBACK_TYPE StartNewLogCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie); - - XN_DECLARE_LIST(XnClient*, XnClientsList); - XnStatus OnIntPropertyChangedInternally(const XnChar* strPropName, XnUInt64 nValue, XnBool& bPassPropToClients); - XnStatus OnRealPropertyChangedInternally(const XnChar* strPropName, XnDouble dValue, XnBool& bPassPropToClients); - XnStatus OnStringPropertyChangedInternally(const XnChar* strPropName, const XnChar* strValue, XnBool &bPassPropToClients); - XnStatus OnGeneralPropertyChangedInternally(const XnChar* strPropName, const XnGeneralBuffer &gbValue, XnBool& bPassPropToClients); XN_SOCKET_HANDLE m_hListenSocket; - XN_THREAD_HANDLE m_hReaderThread; - XN_EVENT_HANDLE m_hNewDataEvent; XN_EVENT_HANDLE m_hServerRunningEvent; //This event is set as long as the server is running and servicing requests XN_MUTEX_HANDLE m_hServerRunningMutex; //This mutex protects m_hServerRunningEvent - XN_CRITICAL_SECTION_HANDLE m_hSensorLock; - XN_CRITICAL_SECTION_HANDLE m_hBroadcastingLock; - XN_CRITICAL_SECTION_HANDLE m_hClientsCriticalSection; + XN_CRITICAL_SECTION_HANDLE m_hSessionsLock; - XnClientsList m_clients; - XnBool m_bSensorOpen; - XnSensor m_sensor; - XnPropertySetData m_allStreamsProps; - XnServerStreamsHash* m_pServerStreams; + XnSessionsList m_sessions; XnUInt32 m_nLastClientID; - XnDump m_serverDump; XnStatus m_nErrorState; - XnActualIntProperty m_noClientTimeout; - XnIntProperty m_startNewLog; + XnSensorsManager m_sensorsManager; + XnServerLogger m_logger; + XnUInt64 m_nLastSessionActivity; + const XnChar* m_strConfigFile; }; #endif //__XN_SENSOR_SERVER_H__ diff --git a/Source/XnDeviceSensorV2/XnSensorServerRunner.h b/Source/XnDeviceSensorV2/XnSensorServerRunner.h index 97c1cae..84c9011 100644 --- a/Source/XnDeviceSensorV2/XnSensorServerRunner.h +++ b/Source/XnDeviceSensorV2/XnSensorServerRunner.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_SERVER_RUNNER_H__ #define __XN_SENSOR_SERVER_RUNNER_H__ diff --git a/Source/XnDeviceSensorV2/XnSensorStreamHelper.cpp b/Source/XnDeviceSensorV2/XnSensorStreamHelper.cpp index 847929a..09fcef0 100644 --- a/Source/XnDeviceSensorV2/XnSensorStreamHelper.cpp +++ b/Source/XnDeviceSensorV2/XnSensorStreamHelper.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -32,29 +26,6 @@ #include "XnStreamProcessor.h" #include -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class XnSensorStreamHelperCookie -{ -public: - XnSensorStreamHelperCookie(XnActualIntProperty* pStreamProp, XnActualIntProperty* pFirmwareProp, XnBool bAllowWhileOpen, XnSensorStreamHelper::ConvertCallback pStreamToFirmwareFunc) : - pStreamProp(pStreamProp), pFirmwareProp(pFirmwareProp), bAllowWhileOpen(bAllowWhileOpen), pStreamToFirmwareFunc(pStreamToFirmwareFunc), bProcessorProp(FALSE) - {} - - XnActualIntProperty* pStreamProp; - XnActualIntProperty* pFirmwareProp; - XnBool bAllowWhileOpen; - XnSensorStreamHelper::ConvertCallback pStreamToFirmwareFunc; - XnBool bProcessorProp; - - struct - { - XnBool bShouldOpen; - XnBool bChooseProcessor; - } CurrentTransaction; -}; - //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- @@ -91,12 +62,6 @@ XnStatus XnSensorStreamHelper::Free() GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream); } - for (XnHash::Iterator it = m_FirmwareProperties.begin(); it != m_FirmwareProperties.end(); ++it) - { - XnSensorStreamHelperCookie* pCookie = (XnSensorStreamHelperCookie*)it.Value(); - XN_DELETE(pCookie); - } - m_FirmwareProperties.Clear(); return XN_STATUS_OK; @@ -164,6 +129,13 @@ XnStatus XnSensorStreamHelper::Open() nRetVal = Configure(); XN_IS_STATUS_OK(nRetVal); + // Update frequency (it might change on specific stream configuration) + XnFrequencyInformation FrequencyInformation; + nRetVal = XnHostProtocolAlgorithmParams(m_pObjects->pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_FREQUENCY, &FrequencyInformation, sizeof(XnFrequencyInformation), (XnResolutions)0, 0); + XN_IS_STATUS_OK(nRetVal); + + m_pObjects->pDevicePrivateData->fDeviceFrequency = XN_PREPARE_VAR_FLOAT_IN_BUFFER(FrequencyInformation.fDeviceFrequency); + // and now turn it on nRetVal = FinalOpen(); XN_IS_STATUS_OK(nRetVal); @@ -175,10 +147,13 @@ XnStatus XnSensorStreamHelper::Close() { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = m_pSensorStream->CloseStreamImpl(); - XN_IS_STATUS_OK(nRetVal); + if (GetFirmware()->GetStreams()->IsClaimed(m_pStream->GetType(), m_pStream)) + { + nRetVal = m_pSensorStream->CloseStreamImpl(); + XN_IS_STATUS_OK(nRetVal); - GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream); + GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream); + } return (XN_STATUS_OK); } @@ -188,11 +163,10 @@ XnStatus XnSensorStreamHelper::RegisterDataProcessorProperty(XnActualIntProperty XnStatus nRetVal = XN_STATUS_OK; // mark it so - XnValue val; - nRetVal = m_FirmwareProperties.Get(&Property, val); + XnSensorStreamHelperCookie* pCookie; + nRetVal = m_FirmwareProperties.Get(&Property, pCookie); XN_IS_STATUS_OK(nRetVal); - XnSensorStreamHelperCookie* pCookie = (XnSensorStreamHelperCookie*)val; pCookie->bProcessorProp = TRUE; return (XN_STATUS_OK); @@ -203,16 +177,11 @@ XnStatus XnSensorStreamHelper::MapFirmwareProperty(XnActualIntProperty& Property XnStatus nRetVal = XN_STATUS_OK; // init data - XnSensorStreamHelperCookie* pCookie; - XN_VALIDATE_NEW(pCookie, XnSensorStreamHelperCookie, &Property, &FirmwareProperty, bAllowChangeWhileOpen, pStreamToFirmwareFunc); + XnSensorStreamHelperCookie cookie(&Property, &FirmwareProperty, bAllowChangeWhileOpen, pStreamToFirmwareFunc); // add it to the list - nRetVal = m_FirmwareProperties.Set(&Property, pCookie); - if (nRetVal != XN_STATUS_OK) - { - XN_DELETE(pCookie); - return (nRetVal); - } + nRetVal = m_FirmwareProperties.Set(&Property, cookie); + XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } @@ -221,12 +190,10 @@ XnStatus XnSensorStreamHelper::ConfigureFirmware(XnActualIntProperty& Property) { XnStatus nRetVal = XN_STATUS_OK; - XnHash::Iterator it = m_FirmwareProperties.end(); - nRetVal = m_FirmwareProperties.Find(&Property, it); + XnSensorStreamHelperCookie* pPropData = NULL; + nRetVal = m_FirmwareProperties.Get(&Property, pPropData); XN_IS_STATUS_OK(nRetVal); - XnSensorStreamHelperCookie* pPropData = (XnSensorStreamHelperCookie*)it.Value(); - XnUInt64 nFirmwareValue = Property.GetValue(); if (pPropData->pStreamToFirmwareFunc != NULL) @@ -245,12 +212,10 @@ XnStatus XnSensorStreamHelper::BeforeSettingFirmwareParam(XnActualIntProperty& P { XnStatus nRetVal = XN_STATUS_OK; - XnHash::Iterator it = m_FirmwareProperties.end(); - nRetVal = m_FirmwareProperties.Find(&Property, it); + XnSensorStreamHelperCookie* pPropData = NULL; + nRetVal = m_FirmwareProperties.Get(&Property, pPropData); XN_IS_STATUS_OK(nRetVal); - XnSensorStreamHelperCookie* pPropData = (XnSensorStreamHelperCookie*)it.Value(); - pPropData->CurrentTransaction.bShouldOpen = FALSE; pPropData->CurrentTransaction.bChooseProcessor = FALSE; @@ -303,11 +268,9 @@ XnStatus XnSensorStreamHelper::AfterSettingFirmwareParam(XnActualIntProperty& Pr { XnStatus nRetVal = XN_STATUS_OK; - XnHash::Iterator it = m_FirmwareProperties.end(); - nRetVal = m_FirmwareProperties.Find(&Property, it); + XnSensorStreamHelperCookie* pPropData = NULL; + nRetVal = m_FirmwareProperties.Get(&Property, pPropData); XN_IS_STATUS_OK(nRetVal); - - XnSensorStreamHelperCookie* pPropData = (XnSensorStreamHelperCookie*)it.Value(); if (pPropData->CurrentTransaction.bShouldOpen) { @@ -385,11 +348,10 @@ XnStatus XnSensorStreamHelper::UpdateFromFirmware(XnActualIntProperty& Property) { XnStatus nRetVal = XN_STATUS_OK; - XnHash::Iterator it = m_FirmwareProperties.end(); - nRetVal = m_FirmwareProperties.Find(&Property, it); + XnSensorStreamHelperCookie* pPropData = NULL; + nRetVal = m_FirmwareProperties.Get(&Property, pPropData); XN_IS_STATUS_OK(nRetVal); - XnSensorStreamHelperCookie* pPropData = (XnSensorStreamHelperCookie*)it.Value(); nRetVal = pPropData->pStreamProp->UnsafeUpdateValue(pPropData->pFirmwareProp->GetValue()); XN_IS_STATUS_OK(nRetVal); @@ -405,13 +367,12 @@ XnStatus XnSensorStreamHelper::BatchConfig(const XnActualPropertiesHash& props) if (m_pStream->IsOpen()) { // check if one of the properties requires to close the stream - for (XnHash::Iterator it = m_FirmwareProperties.begin(); it != m_FirmwareProperties.end(); ++it) + for (FirmareProperties::Iterator it = m_FirmwareProperties.Begin(); it != m_FirmwareProperties.End(); ++it) { - XnSensorStreamHelperCookie* pPropData = (XnSensorStreamHelperCookie*)it.Value(); - if (!pPropData->bAllowWhileOpen) + if (!it->Value().bAllowWhileOpen) { XnProperty* pProp; - if (XN_STATUS_OK == props.Get(pPropData->pStreamProp->GetName(), pProp)) + if (XN_STATUS_OK == props.Get(it->Value().pStreamProp->GetName(), pProp)) { bShouldClose = TRUE; break; diff --git a/Source/XnDeviceSensorV2/XnSensorStreamHelper.h b/Source/XnDeviceSensorV2/XnSensorStreamHelper.h index 95ddb78..6c80fae 100644 --- a/Source/XnDeviceSensorV2/XnSensorStreamHelper.h +++ b/Source/XnDeviceSensorV2/XnSensorStreamHelper.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_SENSOR_STREAM_HELPER_H__ #define __XN_SENSOR_STREAM_HELPER_H__ @@ -35,7 +30,6 @@ #include "XnSensorFixedParams.h" #include #include -#include "XnSharedMemoryBufferPool.h" //--------------------------------------------------------------------------- // Types @@ -86,7 +80,7 @@ class XnSensorStreamHelper inline XnSensorFirmware* GetFirmware() const { return m_pObjects->pFirmware; } inline XnFWVer GetFirmwareVersion() const { return GetFirmware()->GetInfo()->nFWVer; } - inline XnSensorFixedParams* GetFixedParams() const { return m_pObjects->pFixedParams; } + inline XnSensorFixedParams* GetFixedParams() const { return m_pObjects->pFirmware->GetFixedParams(); } inline XnDevicePrivateData* GetPrivateData() const { return m_pObjects->pDevicePrivateData; } inline XnSensorFPS* GetFPS() const { return m_pObjects->pFPS; } inline XnCmosInfo* GetCmosInfo() const { return m_pObjects->pCmosInfo; } @@ -104,7 +98,29 @@ class XnSensorStreamHelper XnDeviceStream* m_pStream; XnSensorObjects* m_pObjects; - XnHash m_FirmwareProperties; + class XnSensorStreamHelperCookie + { + public: + XnSensorStreamHelperCookie() {} + XnSensorStreamHelperCookie(XnActualIntProperty* pStreamProp, XnActualIntProperty* pFirmwareProp, XnBool bAllowWhileOpen, XnSensorStreamHelper::ConvertCallback pStreamToFirmwareFunc) : + pStreamProp(pStreamProp), pFirmwareProp(pFirmwareProp), bAllowWhileOpen(bAllowWhileOpen), pStreamToFirmwareFunc(pStreamToFirmwareFunc), bProcessorProp(FALSE) + {} + + XnActualIntProperty* pStreamProp; + XnActualIntProperty* pFirmwareProp; + XnBool bAllowWhileOpen; + XnSensorStreamHelper::ConvertCallback pStreamToFirmwareFunc; + XnBool bProcessorProp; + + struct + { + XnBool bShouldOpen; + XnBool bChooseProcessor; + } CurrentTransaction; + }; + + typedef XnHashT FirmareProperties; + FirmareProperties m_FirmwareProperties; }; class XnSensorStreamHolder : public XnDeviceModuleHolder @@ -115,7 +131,6 @@ class XnSensorStreamHolder : public XnDeviceModuleHolder {} inline XnDeviceStream* GetStream() { return (XnDeviceStream*)GetModule(); } - inline XnSharedMemoryBufferPool* GetSharedBufferPool() { return m_pHelper->GetSensorStream()->GetSharedMemoryBuffer(); } XnStatus Configure() { return m_pHelper->Configure(); } XnStatus FinalOpen() { return m_pHelper->FinalOpen(); } diff --git a/Source/XnDeviceSensorV2/XnSensorsManager.cpp b/Source/XnDeviceSensorV2/XnSensorsManager.cpp new file mode 100644 index 0000000..8493d24 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnSensorsManager.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnSensorsManager.h" +#include "XnSensorClientServer.h" + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_SENSOR_DEFAULT_SERVER_WAIT_FOR_CLIENT_TIME 10000 + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnSensorsManager::XnSensorsManager(const XnChar* strGlobalConfigFile) : + m_noClientTimeout(XN_MODULE_PROPERTY_SERVER_NO_CLIENTS_TIMEOUT, XN_SENSOR_DEFAULT_SERVER_WAIT_FOR_CLIENT_TIME), + m_startNewLog(XN_MODULE_PROPERTY_SERVER_START_NEW_LOG_FILE), + m_logFile(XN_MODULE_PROPERTY_SERVER_LOG_FILE, NULL), + m_hLock(NULL) +{ + m_noClientTimeout.UpdateSetCallbackToDefault(); + m_startNewLog.UpdateSetCallback(StartNewLogCallback, this); + m_logFile.UpdateGetCallback(GetLogCallback, this); + strcpy(m_strGlobalConfigFile, strGlobalConfigFile); +} + +XnSensorsManager::~XnSensorsManager() +{ + Free(); +} + +XnStatus XnSensorsManager::Init() +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = xnOSCreateCriticalSection(&m_hLock); + XN_IS_STATUS_OK(nRetVal); + + // read default timeout from file + nRetVal = m_noClientTimeout.ReadValueFromFile(m_strGlobalConfigFile, XN_SENSOR_SERVER_CONFIG_FILE_SECTION); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +void XnSensorsManager::Free() +{ + // close all sensors + while (m_sensors.Begin() != m_sensors.End()) + { + ReferencedSensor& sensor = m_sensors.Begin()->Value(); + XN_DELETE(sensor.pInvoker); + } + + if (m_hLock != NULL) + { + xnOSCloseCriticalSection(&m_hLock); + m_hLock = NULL; + } +} + +XnStatus XnSensorsManager::GetSensor(const XnChar* strDevicePath, XnServerSensorInvoker** ppInvoker) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // check if the sensor is already open + XnAutoCSLocker locker(m_hLock); + ReferencedSensor* pSensor; + nRetVal = m_sensors.Get(strDevicePath, pSensor); + if (nRetVal == XN_STATUS_NO_MATCH) + { + // not open. open it now + xnLogInfo(XN_MASK_SENSOR_SERVER, "Opening sensor '%s'...", strDevicePath); + + ReferencedSensor sensor; + sensor.nRefCount = 0; + XN_VALIDATE_NEW(sensor.pInvoker, XnServerSensorInvoker); + + XnProperty* aAdditionalProps[] = { &m_noClientTimeout, &m_startNewLog, &m_logFile }; + nRetVal = sensor.pInvoker->Init(strDevicePath, m_strGlobalConfigFile, sizeof(aAdditionalProps)/sizeof(XnProperty*), aAdditionalProps); + XN_IS_STATUS_OK(nRetVal); + + // add it to map + nRetVal = m_sensors.Set(sensor.pInvoker->GetDevicePath(), sensor); + XN_IS_STATUS_OK(nRetVal); + + // and take a reference to it + nRetVal = m_sensors.Get(sensor.pInvoker->GetDevicePath(), pSensor); + XN_IS_STATUS_OK(nRetVal); + } + + ++pSensor->nRefCount; + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Sensor '%s' now has %u sessions", pSensor->pInvoker->GetDevicePath(), pSensor->nRefCount); + + *ppInvoker = pSensor->pInvoker; + + return (XN_STATUS_OK); +} + +void XnSensorsManager::ReleaseSensor(XnServerSensorInvoker* pInvoker) +{ + XnAutoCSLocker locker(m_hLock); + ReferencedSensor* pSensor; + XnStatus nRetVal = m_sensors.Get(pInvoker->GetDevicePath(), pSensor); + if (nRetVal != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_SERVER, "Trying to release a sensor that is not in the map!"); + return; + } + + --pSensor->nRefCount; + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Sensor '%s' now has %u sessions", pInvoker->GetDevicePath(), pSensor->nRefCount); + + if (pSensor->nRefCount == 0) + { + // store current time. Then, in CleanUp() if timeout passed, sensor will be closed + xnOSGetTimeStamp(&pSensor->nNoClientsTime); + + // do some clean-up (so that next client will behave as if it started the server) + + // This is a bit ugly, but we need to manually set back to default DEVICE properties + // (we know there aren't any streams and clients, but the Device module always remains) + nRetVal = pSensor->pInvoker->SetIntProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, (XnUInt64)FALSE); + if (nRetVal != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_SERVER, "Failed resetting FrameSync: %s", xnGetStatusString(nRetVal)); + } + + nRetVal = pSensor->pInvoker->ConfigureModuleFromGlobalFile(XN_MODULE_NAME_DEVICE); + if (nRetVal != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_SERVER, "Failed configuring device from global config file: %s", xnGetStatusString(nRetVal)); + } + } +} + +void XnSensorsManager::CleanUp() +{ + // go over sensors list. each sensor that is not open by any session, and timeout has passed should + // be closed and removed + XnAutoCSLocker locker(m_hLock); + + XnUInt64 nNow; + xnOSGetTimeStamp(&nNow); + XnSensorsHash::Iterator it = m_sensors.Begin(); + while (it != m_sensors.End()) + { + XnSensorsHash::Iterator curr = it; + ++it; + + ReferencedSensor& sensor = curr->Value(); + if (sensor.nRefCount == 0 && (nNow - sensor.nNoClientsTime) > m_noClientTimeout.GetValue()) + { + xnLogInfo(XN_MASK_SENSOR_SERVER, "No session holding sensor '%s' for %u ms. Shutting down...", curr->Key(), m_noClientTimeout.GetValue()); + XN_DELETE(sensor.pInvoker); + m_sensors.Remove(curr); + } + } +} + +XnStatus XN_CALLBACK_TYPE XnSensorsManager::StartNewLogCallback(XnIntProperty* /*pSender*/, XnUInt64 /*nValue*/, void* /*pCookie*/) +{ + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Closing current log file..."); + return xnLogStartNewFile(); +} + +XnStatus XN_CALLBACK_TYPE XnSensorsManager::GetLogCallback(const XnStringProperty* /*pSender*/, XnChar* csValue, void* /*pCookie*/) +{ + return xnLogGetFileName(csValue, XN_DEVICE_MAX_STRING_LENGTH); +} + diff --git a/Source/XnDeviceSensorV2/XnSensorsManager.h b/Source/XnDeviceSensorV2/XnSensorsManager.h new file mode 100644 index 0000000..ea249a6 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnSensorsManager.h @@ -0,0 +1,73 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_SENSORS_MANAGER_H__ +#define __XN_SENSORS_MANAGER_H__ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnServerSensorInvoker.h" +#include + +//--------------------------------------------------------------------------- +// Types +//--------------------------------------------------------------------------- +class XnSensorsManager +{ +public: + XnSensorsManager(const XnChar* strGlobalConfigFile); + ~XnSensorsManager(); + + XnStatus Init(); + void Free(); + + XnUInt64 GetTimeout() { return m_noClientTimeout.GetValue(); } + + XnStatus GetSensor(const XnChar* strDevicePath, XnServerSensorInvoker** ppInvoker); + void ReleaseSensor(XnServerSensorInvoker* pInvoker); + + void CleanUp(); + inline XnBool HasOpenSensors() { return m_sensors.Begin() != m_sensors.End(); } + +private: + typedef struct + { + XnUInt64 nNoClientsTime; + XnServerSensorInvoker* pInvoker; + XnUInt32 nRefCount; + } ReferencedSensor; + + typedef XnStringsHashT XnSensorsHash; + + static XnStatus XN_CALLBACK_TYPE StartNewLogCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE GetLogCallback(const XnStringProperty* pSender, XnChar* csValue, void* pCookie); + + XnChar m_strGlobalConfigFile[XN_FILE_MAX_PATH]; + XN_CRITICAL_SECTION_HANDLE m_hLock; + XnSensorsHash m_sensors; + XnActualIntProperty m_noClientTimeout; + XnStringProperty m_logFile; + XnIntProperty m_startNewLog; + XnUInt64 nNoClientsTime; +}; + +#endif // __XN_SENSORS_MANAGER_H__ \ No newline at end of file diff --git a/Source/XnCommon/XnCommon.h b/Source/XnDeviceSensorV2/XnServerLogger.h similarity index 50% rename from Source/XnCommon/XnCommon.h rename to Source/XnDeviceSensorV2/XnServerLogger.h index ef5b9ee..045c7ba 100644 --- a/Source/XnCommon/XnCommon.h +++ b/Source/XnDeviceSensorV2/XnServerLogger.h @@ -1,62 +1,59 @@ -/***************************************************************************** -* * -* PrimeSense Common * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Common is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Common is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Common. If not, see . * -* * -*****************************************************************************/ - - - - - - -#ifndef __XN_COMMON_H__ -#define __XN_COMMON_H__ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_SERVER_LOGGER_H__ +#define __XN_SERVER_LOGGER_H__ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- -#include +#include //--------------------------------------------------------------------------- // Defines //--------------------------------------------------------------------------- -#define XN_VENDOR_PRIMESENSE "PrimeSense" +#define XN_MASK_SENSOR_SERVER_COMM_DUMP "SensorServerComm" //--------------------------------------------------------------------------- // Types //--------------------------------------------------------------------------- -typedef enum XnPrimeSenseErrorModules +class XnServerLogger { - XN_ERROR_GROUP_SECURITY = 0, - XN_ERROR_GROUP_FORMATS = 1000, - XN_ERROR_GROUP_DDK = 2000, - XN_ERROR_GROUP_DEVICE = 3000, - XN_ERROR_GROUP_IO = 4000, - XN_ERROR_GROUP_EE_CORE = 5000, - XN_ERROR_GROUP_EE_FRAMEWORK = 6000, - XN_ERROR_GROUP_EE_NITE = 7000, -} XnPrimeSenseErrorModules; - -#define XN_PS_STATUS_MESSAGE_MAP_START(module) \ - XN_STATUS_MESSAGE_MAP_START_FROM(XN_ERROR_GROUP_PRIMESENSE, module) - -#define XN_PS_STATUS_MESSAGE_MAP_END(module) \ - XN_STATUS_MESSAGE_MAP_END_FROM(XN_ERROR_GROUP_PRIMESENSE, module) +public: + inline XnServerLogger() : m_dump(NULL) + { + m_dump = xnDumpFileOpen(XN_MASK_SENSOR_SERVER_COMM_DUMP, "%s.csv", XN_MASK_SENSOR_SERVER_COMM_DUMP); + xnDumpFileWriteString(m_dump, "TS,Type,Size,Client\n"); + } + + inline void DumpMessage(const XnChar* strType, XnUInt32 nSize = 0, XnUInt32 nClientID = 0, const XnChar* strComment = "") + { + XnUInt64 nNow; + xnOSGetHighResTimeStamp(&nNow); + xnDumpFileWriteString(m_dump, "%llu,%s,%d,%d,%s\n", nNow, strType, nSize, nClientID, strComment); + } + +private: + XnDumpFile* m_dump; +}; + +#endif // __XN_SERVER_LOGGER_H__ -#endif // __XN_COMMON_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnServerSensorInvoker.cpp b/Source/XnDeviceSensorV2/XnServerSensorInvoker.cpp new file mode 100644 index 0000000..8c1c949 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnServerSensorInvoker.cpp @@ -0,0 +1,878 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnServerSensorInvoker.h" +#include "XnSensorClientServer.h" +#include + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define XN_SENSOR_TERMINATE_READER_THREAD_TIMEOUT 5000 +#define XN_SENSOR_DEFAULT_ENABLE_MULTI_USERS FALSE +#define XN_SENSOR_DEFAULT_NUMBER_OF_BUFFERS 6 + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnServerSensorInvoker::XnServerSensorInvoker() : + m_hSensorLock(NULL), + m_hReaderThread(NULL), + m_hNewDataEvent(NULL), + m_bShouldRun(TRUE), + m_errorState(XN_STATUS_OK), + m_numberOfBuffers(XN_MODULE_PROPERTY_NUMBER_OF_BUFFERS, XN_SENSOR_DEFAULT_NUMBER_OF_BUFFERS), + m_allowOtherUsers(XN_MODULE_PROPERTY_ENABLE_MULTI_USERS, XN_SENSOR_DEFAULT_ENABLE_MULTI_USERS) +{ + m_numberOfBuffers.UpdateSetCallback(SetNumberOfBuffersCallback, this); + m_allowOtherUsers.UpdateSetCallback(SetAllowOtherUsersCallback, this); +} + +XnServerSensorInvoker::~XnServerSensorInvoker() +{ + Free(); +} + +XnStatus XnServerSensorInvoker::Init(const XnChar* strDevicePath, const XnChar* strGlobalConfigFile, XnUInt32 nAdditionalProps, XnProperty** aAdditionalProps) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_sensor.SetGlobalConfigFile(strGlobalConfigFile); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateCriticalSection(&m_hSensorLock); + XN_IS_STATUS_OK(nRetVal); + + XnDeviceConfig config; + config.DeviceMode = XN_DEVICE_MODE_READ; + config.cpConnectionString = strDevicePath; + config.pInitialValues = NULL; + config.SharingMode = XN_DEVICE_SHARED; + + nRetVal = m_sensor.Init(&config); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_sensor.DeviceModule()->AddProperties(aAdditionalProps, nAdditionalProps); + XN_IS_STATUS_OK(nRetVal); + + XnProperty* aInvokerAdditionalProps[] = { &m_numberOfBuffers, &m_allowOtherUsers }; + nRetVal = m_sensor.DeviceModule()->AddProperties(aInvokerAdditionalProps, sizeof(aInvokerAdditionalProps) / sizeof(aInvokerAdditionalProps[0])); + XN_IS_STATUS_OK(nRetVal); + + // configure from global file + nRetVal = m_sensor.ConfigureModuleFromGlobalFile(XN_MODULE_NAME_DEVICE, XN_SENSOR_SERVER_CONFIG_FILE_SECTION); + XN_IS_STATUS_OK(nRetVal); + + // register to events + XnCallbackHandle hDummy = NULL; + nRetVal = m_sensor.OnStreamCollectionChangedEvent().Register(StreamCollectionChangedCallback, this, hDummy); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_sensor.OnNewStreamDataEvent().Register(NewStreamDataCallback, this, hDummy); + XN_IS_STATUS_OK(nRetVal); + + // register to all properties + XN_PROPERTY_SET_CREATE_ON_STACK(props); + nRetVal = m_sensor.DeviceModule()->GetAllProperties(&props); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = RegisterToProps(&props); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateEvent(&m_hNewDataEvent, FALSE); + XN_IS_STATUS_OK(nRetVal); + + // start reader thread + nRetVal = xnOSCreateThread(ReaderThread, this, &m_hReaderThread); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +void XnServerSensorInvoker::Free() +{ + m_bShouldRun = FALSE; + + if (m_hReaderThread != NULL) + { + xnOSWaitAndTerminateThread(&m_hReaderThread, XN_SENSOR_TERMINATE_READER_THREAD_TIMEOUT); + m_hReaderThread = NULL; + } + + XnStatus nRetVal = m_sensor.Destroy(); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to destroy sensor: %s", xnGetStatusString(nRetVal)); + XN_ASSERT(FALSE); + } + + if (m_hNewDataEvent != NULL) + { + xnOSCloseEvent(&m_hNewDataEvent); + m_hNewDataEvent = NULL; + } + + if (m_hSensorLock != NULL) + { + xnOSCloseCriticalSection(&m_hSensorLock); + m_hSensorLock = NULL; + } +} + +const XnChar* XnServerSensorInvoker::GetDevicePath() +{ + return m_sensor.GetUSBPath(); +} + +XnStatus XnServerSensorInvoker::RegisterToProps(XnPropertySet* pProps) +{ + XnStatus nRetVal = XN_STATUS_OK; + XnCallbackHandle hDummy = NULL; + + for (XnPropertySetData::Iterator itMod = pProps->pData->Begin(); itMod != pProps->pData->End(); ++itMod) + { + XnActualPropertiesHash* pHash = itMod->Value(); + + XnDeviceModule* pModule; + nRetVal = m_sensor.FindModule(itMod->Key(), &pModule); + XN_IS_STATUS_OK(nRetVal); + + for (XnActualPropertiesHash::Iterator itProp = pHash->Begin(); itProp != pHash->End(); ++itProp) + { + XnProperty* pProp; + nRetVal = pModule->GetProperty(itProp->Key(), &pProp); + XN_IS_STATUS_OK(nRetVal); + + // no need to keep the handle. We only want to unregister when the stream is destroyed, and then + // it happens anyway. + nRetVal = pProp->OnChangeEvent().Register(PropertyChangedCallback, this, hDummy); + XN_IS_STATUS_OK(nRetVal); + } + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::GetIntProperty(const XnChar* strModule, const XnChar* strProperty, XnUInt64* pnValue) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.GetProperty(strModule, strProperty, pnValue); +} + +XnStatus XnServerSensorInvoker::GetRealProperty( const XnChar* strModule, const XnChar* strProperty, XnDouble* pdValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.GetProperty(strModule, strProperty, pdValue); +} + +XnStatus XnServerSensorInvoker::GetStringProperty( const XnChar* strModule, const XnChar* strProperty, XnChar* strValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.GetProperty(strModule, strProperty, strValue); +} + +XnStatus XnServerSensorInvoker::GetGeneralProperty( const XnChar* strModule, const XnChar* strProperty, XnGeneralBuffer& gbValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.GetProperty(strModule, strProperty, gbValue); +} + +XnStatus XnServerSensorInvoker::SetIntProperty( const XnChar* strModule, const XnChar* strProperty, XnUInt64 nValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.SetProperty(strModule, strProperty, nValue); +} + +XnStatus XnServerSensorInvoker::SetRealProperty( const XnChar* strModule, const XnChar* strProperty, XnDouble dValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.SetProperty(strModule, strProperty, dValue); +} + +XnStatus XnServerSensorInvoker::SetStringProperty( const XnChar* strModule, const XnChar* strProperty, const XnChar* strValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.SetProperty(strModule, strProperty, strValue); +} + +XnStatus XnServerSensorInvoker::SetGeneralProperty( const XnChar* strModule, const XnChar* strProperty, const XnGeneralBuffer& gbValue ) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.SetProperty(strModule, strProperty, gbValue); +} + +XnStatus XnServerSensorInvoker::GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams, const XnChar* strModule) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.GetAllProperties(pSet, bNoStreams, strModule); +} + +XnStatus XnServerSensorInvoker::LoadConfigFromFile(const XnChar* strFileName, const XnChar* strSectionName) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.LoadConfigFromFile(strFileName, strSectionName); +} + +XnStatus XnServerSensorInvoker::BatchConfig(const XnPropertySet* pChangeSet) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.BatchConfig(pChangeSet); +} + +XnStatus XnServerSensorInvoker::ConfigureModuleFromGlobalFile(const XnChar* strModule) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.ConfigureModuleFromGlobalFile(strModule); +} + +XnStatus XnServerSensorInvoker::CreateStreamData(const XnChar* strStreamName, XnStreamData** ppStreamData) +{ + XnAutoCSLocker lock(m_hSensorLock); + return m_sensor.CreateStreamData(strStreamName, ppStreamData); +} + +XnStatus XnServerSensorInvoker::GetStream(const XnChar* strType, const XnPropertySet* pInitialValues) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // check if stream already exists + XnAutoCSLocker locker(m_hSensorLock); + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(strType, pStream); + if (nRetVal == XN_STATUS_OK) + { + // stream already exists. add ref to it, and try to configure it according to request + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s already exists.", strType); + + // configure it + if (pInitialValues != NULL) + { + nRetVal = m_sensor.BatchConfig(pInitialValues); + XN_IS_STATUS_OK(nRetVal); + } + } + else if (nRetVal == XN_STATUS_NO_MATCH) + { + // stream doesn't exist. create it (more happens in the OnStreamAdded event handler) + nRetVal = m_sensor.CreateStream(strType, strType, pInitialValues); + XN_IS_STATUS_OK(nRetVal); + + // now take it from the hash + nRetVal = m_streams.Get(strType, pStream); + XN_IS_STATUS_OK(nRetVal); + } + else + { + return (nRetVal); + } + + ++pStream->nRefCount; + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s now has %u clients.", strType, pStream->nRefCount); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::SetStreamSharedMemory(SensorInvokerStream* pStream) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // give shared memory a name (to make the name unique, we'll add process ID) + XN_PROCESS_ID procID; + xnOSGetCurrentProcessID(&procID); + XnChar strSharedMemoryName[XN_FILE_MAX_PATH]; + sprintf(strSharedMemoryName, "%u_%s_%s", (XnUInt32)procID, m_sensor.GetUSBPath(), pStream->strType); + nRetVal = pStream->pSharedMemoryName->UnsafeUpdateValue(strSharedMemoryName); + XN_IS_STATUS_OK(nRetVal); + + XnUInt32 nBufferSize = 0; + XnUInt32 nPixelSize = 0; + + if (strcmp(pStream->strType, XN_STREAM_TYPE_DEPTH) == 0) + { + // have space for depth and shift values + nPixelSize = sizeof(XnDepthPixel) + sizeof(XnUInt16); + } + else if (strcmp(pStream->strType, XN_STREAM_TYPE_IMAGE) == 0) + { + // biggest pixel size is the RGB24 + nPixelSize = sizeof(XnRGB24Pixel); + } + else if (strcmp(pStream->strType, XN_STREAM_TYPE_IR) == 0) + { + // biggest pixel size is the RGB24 + nPixelSize = sizeof(XnIRPixel); + } + else + { + XN_ASSERT(FALSE); + return XN_STATUS_ERROR; + } + + // find out max resolution + XnUInt32 nMaxNumPixels = 0; + nRetVal = GetStreamMaxResolution(pStream, nMaxNumPixels); + XN_IS_STATUS_OK(nRetVal); + + nBufferSize = (XnUInt32)(nMaxNumPixels * nPixelSize * m_numberOfBuffers.GetValue()); + + // allocate shared memory + nRetVal = xnOSCreateSharedMemoryEx(strSharedMemoryName, nBufferSize, XN_OS_FILE_READ | XN_OS_FILE_WRITE, m_allowOtherUsers.GetValue() == TRUE, &pStream->hSharedMemory); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSSharedMemoryGetAddress(pStream->hSharedMemory, (void**)&pStream->pSharedMemoryAddress); + XN_IS_STATUS_OK(nRetVal); + + // Set buffer pool for this stream + XnGeneralBuffer* aBuffers = XN_NEW_ARR(XnGeneralBuffer, m_numberOfBuffers.GetValue()); + XnUInt32 nSingleBufferSize = nBufferSize / m_numberOfBuffers.GetValue(); + for (XnUInt32 i = 0; i < m_numberOfBuffers.GetValue(); ++i) + { + aBuffers[i].pData = pStream->pSharedMemoryAddress + (i * nSingleBufferSize); + aBuffers[i].nDataSize = nSingleBufferSize; + } + + nRetVal = m_sensor.SetProperty(pStream->strType, XN_STREAM_PROPERTY_EXTERNAL_BUFFER_POOL, XnGeneralBufferPack(aBuffers, m_numberOfBuffers.GetValue() * sizeof(XnGeneralBuffer))); + XN_DELETE_ARR(aBuffers); + + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::GetStreamMaxResolution(SensorInvokerStream* pStream, XnUInt32& nMaxNumPixels) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnUInt64 nCount = 0; + nRetVal = m_sensor.GetProperty(pStream->strType, XN_STREAM_PROPERTY_SUPPORT_MODES_COUNT, &nCount); + XN_IS_STATUS_OK(nRetVal); + + XnCmosPreset* aPresets = XN_NEW_ARR(XnCmosPreset, nCount); + nRetVal = m_sensor.GetProperty(pStream->strType, XN_STREAM_PROPERTY_SUPPORT_MODES, XnGeneralBufferPack(aPresets, nCount * sizeof(XnCmosPreset))); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE_ARR(aPresets); + return nRetVal; + } + + XnUInt32 nMaxPixels = 0; + for (XnUInt32 i = 0; i < nCount; ++i) + { + XnUInt32 nXRes; + XnUInt32 nYRes; + if (!XnDDKGetXYFromResolution((XnResolutions)aPresets[i].nResolution, &nXRes, &nYRes)) + { + continue; + } + + if (nXRes * nYRes > nMaxPixels) + { + nMaxPixels = nXRes * nYRes; + } + } + + XN_ASSERT(nMaxPixels > 0); + + XN_DELETE_ARR(aPresets); + + nMaxNumPixels = nMaxPixels; + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::ReleaseStream(const XnChar* strType) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker locker(m_hSensorLock); + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(strType, pStream); + XN_IS_STATUS_OK(nRetVal); + + --pStream->nRefCount; + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Stream %s now has %u clients", strType, pStream->nRefCount); + + if (pStream->nRefCount == 0) + { + m_sensor.CloseStream(strType); + m_sensor.DestroyStream(strType); + + // the rest will be done in the OnStreamRemoved event handler... + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OpenStream(const XnChar* strName, NewStreamDataHandler pNewDataHandler, void* pCookie, XnCallbackHandle& hCallback) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker locker(m_hSensorLock); + + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + // register for new data event + nRetVal = pStream->pNewDataEvent->Register(pNewDataHandler, pCookie, hCallback); + XN_IS_STATUS_OK(nRetVal); + + // increase open ref count + ++pStream->nOpenRefCount; + + if (pStream->nOpenRefCount == 1) // first one to open + { + // open it + nRetVal = m_sensor.OpenStream(strName); + if (nRetVal != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_SERVER, "Failed to open stream: %s", xnGetStatusString(nRetVal)); + --pStream->nOpenRefCount; + pStream->pNewDataEvent->Unregister(hCallback); + return (nRetVal); + } + } + + xnLogInfo(XN_MASK_SENSOR_SERVER, "Stream %s is now open by %u clients.", strName, pStream->nOpenRefCount); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::CloseStream(const XnChar* strName, XnCallbackHandle hCallback) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker locker(m_hSensorLock); + + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + // decrease open ref count + --pStream->nOpenRefCount; + + xnLogInfo(XN_MASK_SENSOR_SERVER, "Stream %s is now open by %u clients.", strName, pStream->nOpenRefCount); + + // check if we actually need to close it + if (pStream->nOpenRefCount == 0) + { + nRetVal = m_sensor.CloseStream(strName); + if (nRetVal != XN_STATUS_OK) + { + xnLogError(XN_MASK_SENSOR_SERVER, "Failed to close stream: %s", xnGetStatusString(nRetVal)); + ++pStream->nOpenRefCount; + return (nRetVal); + } + } + + // unregister from event + pStream->pNewDataEvent->Unregister(hCallback); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::AddRefFrameBuffer(const XnChar* strStreamName, XnBuffer* pBuffer) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnBufferPool* pBufferPool = NULL; + nRetVal = m_sensor.GetBufferPool(strStreamName, &pBufferPool); + XN_IS_STATUS_OK(nRetVal); + + pBufferPool->AddRef(pBuffer); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::ReleaseFrameBuffer(const XnChar* strStreamName, XnBuffer* pBuffer) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnBufferPool* pBufferPool = NULL; + nRetVal = m_sensor.GetBufferPool(strStreamName, &pBufferPool); + XN_IS_STATUS_OK(nRetVal); + + pBufferPool->DecRef(pBuffer); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::ReadStream(XnStreamData* pStreamData, XnUInt32* pnOffset) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker locker(m_hSensorLock); + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(pStreamData->StreamName, pStream); + XN_IS_STATUS_OK(nRetVal); + + XnBufferPool* pBufferPool = NULL; + nRetVal = m_sensor.GetBufferPool(pStreamData->StreamName, &pBufferPool); + XN_IS_STATUS_OK(nRetVal); + + // dec ref old data + if (pStreamData->pInternal->pLockedBuffer != NULL) + { + pBufferPool->DecRef(pStreamData->pInternal->pLockedBuffer); + } + + // "read" + pStreamData->nDataSize = pStream->pStreamData->nDataSize; + pStreamData->nFrameID = pStream->pStreamData->nFrameID; + pStreamData->nTimestamp = pStream->pStreamData->nTimestamp; + pStreamData->pData = pStream->pStreamData->pData; + pStreamData->pInternal->pLockedBuffer = pStream->pStreamData->pInternal->pLockedBuffer; + + // add ref to new data + if (pStreamData->pInternal->pLockedBuffer != NULL) + { + pBufferPool->AddRef(pStreamData->pInternal->pLockedBuffer); + } + + *pnOffset = pStreamData->pInternal->pLockedBuffer->GetData() - pStream->pSharedMemoryAddress; + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::SetNumberOfBuffers(XnUInt32 nCount) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // This is a special property. It can only be changed BEFORE reading starts + if (m_sensor.HasReadingStarted() && nCount != m_numberOfBuffers.GetValue()) + { + return (XN_STATUS_DEVICE_PROPERTY_READ_ONLY); + } + + if (nCount < 3) + { + return XN_STATUS_BAD_PARAM; + } + + nRetVal = m_numberOfBuffers.UnsafeUpdateValue(nCount); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::SetAllowOtherUsers(XnBool bAllowOtherUsers) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // This is a special property. It can only be changed BEFORE reading starts + if (m_sensor.HasReadingStarted() && m_allowOtherUsers.GetValue() != bAllowOtherUsers) + { + return (XN_STATUS_DEVICE_PROPERTY_READ_ONLY); + } + + nRetVal = m_allowOtherUsers.UnsafeUpdateValue(bAllowOtherUsers); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OnPropertyChanged(const XnProperty* pProp) +{ + // some special handling + if (strcmp(pProp->GetName(), XN_STREAM_PROPERTY_STATE) == 0) + { + // ignore STATE property (every client has its own value) + return XN_STATUS_OK; + } + else if (strcmp(pProp->GetName(), XN_MODULE_PROPERTY_ERROR_STATE) == 0) + { + XnActualIntProperty* pActualIntProp = (XnActualIntProperty*)pProp; + XnStatus nOldErrorState = m_errorState; + m_errorState = (XnStatus)pActualIntProp->GetValue(); + switch (m_errorState) + { + case XN_STATUS_DEVICE_NOT_CONNECTED: + //TODO: Handle disconnection + break; + case XN_STATUS_OK: + if (nOldErrorState == XN_STATUS_DEVICE_NOT_CONNECTED) + { + //TODO: Handle re-connection + break; + } + } + } + + // raise event + m_propChangedEvent.Raise(pProp); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OnStreamAdded(const XnChar* StreamName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // get all props + XN_PROPERTY_SET_CREATE_ON_STACK(props); + nRetVal = m_sensor.GetAllProperties(&props, FALSE, StreamName); + XN_IS_STATUS_OK(nRetVal); + + // register to all props + nRetVal = RegisterToProps(&props); + XN_IS_STATUS_OK(nRetVal); + + XnActualPropertiesHash* pStreamProps = props.pData->Begin()->Value(); + + // create stream data + SensorInvokerStream serverStream; + xnOSMemSet(&serverStream, 0, sizeof(serverStream)); + strcpy(serverStream.strType, StreamName); + + XN_VALIDATE_NEW(serverStream.pNewDataEvent, NewStreamDataEvent); + + // check if this is a frame stream + XnProperty* pIsFrameBased; + nRetVal = pStreamProps->Get(XN_STREAM_PROPERTY_IS_FRAME_BASED, pIsFrameBased); + if (nRetVal == XN_STATUS_OK) + { + XnActualIntProperty* pIntProp = (XnActualIntProperty*)pIsFrameBased; + serverStream.bFrameStream = (pIntProp->GetValue() == TRUE); + } + + if (serverStream.bFrameStream) + { + // create the "shared memory name" property + XN_VALIDATE_NEW(serverStream.pSharedMemoryName, XnActualStringProperty, XN_STREAM_PROPERTY_SHARED_BUFFER_NAME); + + // and add it to the stream + XnDeviceStream* pStream; + nRetVal = m_sensor.GetStream(StreamName, &pStream); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(serverStream.pNewDataEvent); + XN_DELETE(serverStream.pSharedMemoryName); + return nRetVal; + } + + nRetVal = pStream->AddProperty(serverStream.pSharedMemoryName); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(serverStream.pNewDataEvent); + XN_DELETE(serverStream.pSharedMemoryName); + return nRetVal; + } + + // create a shared memory buffer pool for it + nRetVal = SetStreamSharedMemory(&serverStream); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(serverStream.pNewDataEvent); + XN_DELETE(serverStream.pSharedMemoryName); + return nRetVal; + } + } + + // create a stream data object for the stream + nRetVal = m_sensor.CreateStreamData(StreamName, &serverStream.pStreamData); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(serverStream.pNewDataEvent); + XN_DELETE(serverStream.pSharedMemoryName); + return (nRetVal); + } + + // and add it to our list of streams + nRetVal = m_streams.Set(StreamName, serverStream); + if (nRetVal != XN_STATUS_OK) + { + XN_DELETE(serverStream.pNewDataEvent); + XN_DELETE(serverStream.pSharedMemoryName); + return (nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OnStreamRemoved(const XnChar* StreamName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // no need to unregister from its props - they do not exist anymore. + + // remove stream data + SensorInvokerStream* pServerStream = NULL; + nRetVal = m_streams.Get(StreamName, pServerStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_sensor.DestroyStreamData(&pServerStream->pStreamData); + XN_IS_STATUS_OK(nRetVal); + + XN_DELETE(pServerStream->pNewDataEvent); + + if (pServerStream->pSharedMemoryName != NULL) + { + XN_DELETE(pServerStream->pSharedMemoryName); + } + + // destroy shared memory + xnOSCloseSharedMemory(pServerStream->hSharedMemory); + + nRetVal = m_streams.Remove(StreamName); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType) +{ + XnStatus nRetVal = XN_STATUS_OK; + + switch (EventType) + { + case XN_DEVICE_STREAM_ADDED: + { + nRetVal = OnStreamAdded(StreamName); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_DEVICE_STREAM_DELETED: + { + nRetVal = OnStreamRemoved(StreamName); + XN_IS_STATUS_OK(nRetVal); + break; + } + default: + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "unknown event: %d", EventType); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::OnNewStreamData(const XnChar* StreamName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // no need to lock the sensor (this might cause a dead lock). + // Instead, only lock the streams collection (so it wouldn't change while we search for the stream) + SensorInvokerStream* pStream = NULL; + nRetVal = m_streams.Get(StreamName, pStream); + XN_IS_STATUS_OK(nRetVal); + + pStream->bNewData = TRUE; + + nRetVal = xnOSSetEvent(m_hNewDataEvent); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSensorInvoker::ReadStreams() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // wait for new data to be available + nRetVal = xnOSWaitEvent(m_hNewDataEvent, XN_NODE_WAIT_FOR_DATA_TIMEOUT); + if (nRetVal == XN_STATUS_OS_EVENT_TIMEOUT) + { + return XN_STATUS_OK; + } + else if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Got error waiting for new data event: %s", xnGetStatusString(nRetVal)); + // but continue anyway + } + + // lock sensor (we iterate over streams list. make sure no stream is added/removed from the list) + { + XnLockedServerStreamsHash lockedHash = m_streams.GetLockedHashForIterating(); + for (XnLockedServerStreamsHash::Iterator it = lockedHash.Begin(); it != lockedHash.End(); ++it) + { + SensorInvokerStream& stream = it->Value(); + + if (stream.bNewData) + { + // ignore audio (it is read by every client) + if (strcmp(stream.strType, XN_STREAM_NAME_AUDIO) != 0) + { + // read this data + nRetVal = m_sensor.ReadStream(stream.pStreamData); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed reading from stream %s (though event was raised): %s", stream.strType, xnGetStatusString(nRetVal)); + stream.bNewData = FALSE; + continue; + } + } + + stream.bNewData = FALSE; + + NewStreamDataEventArgs eventArgs; + eventArgs.strStreamName = stream.strType; + eventArgs.nTimestamp = stream.pStreamData->nTimestamp; + eventArgs.nFrameID = stream.pStreamData->nFrameID; + stream.pNewDataEvent->Raise(eventArgs); + } + } // streams loop + } // lock + + return (XN_STATUS_OK); +} + +XnStatus XN_CALLBACK_TYPE XnServerSensorInvoker::SetNumberOfBuffersCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pCookie; + return pThis->SetNumberOfBuffers((XnUInt32)nValue); +} + +XnStatus XN_CALLBACK_TYPE XnServerSensorInvoker::SetAllowOtherUsersCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pCookie; + return pThis->SetAllowOtherUsers(nValue == TRUE); +} + +XnStatus XN_CALLBACK_TYPE XnServerSensorInvoker::PropertyChangedCallback(const XnProperty* pProp, void* pCookie) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pCookie; + pThis->OnPropertyChanged(pProp); + return XN_STATUS_OK; +} + +void XN_CALLBACK_TYPE XnServerSensorInvoker::StreamCollectionChangedCallback(const XnStreamCollectionChangedEventArgs& args, void* pCookie) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pCookie; + pThis->OnStreamCollectionChanged(args.strStreamName, args.eventType); +} + +void XN_CALLBACK_TYPE XnServerSensorInvoker::NewStreamDataCallback(const XnNewStreamDataEventArgs& args, void* pCookie) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pCookie; + pThis->OnNewStreamData(args.strStreamName); +} + +XN_THREAD_PROC XnServerSensorInvoker::ReaderThread(XN_THREAD_PARAM pThreadParam) +{ + XnServerSensorInvoker* pThis = (XnServerSensorInvoker*)pThreadParam; + while (pThis->m_bShouldRun) + { + pThis->ReadStreams(); + } + XN_THREAD_PROC_RETURN(0); +} + diff --git a/Source/XnDeviceSensorV2/XnServerSensorInvoker.h b/Source/XnDeviceSensorV2/XnServerSensorInvoker.h new file mode 100644 index 0000000..63e2c2e --- /dev/null +++ b/Source/XnDeviceSensorV2/XnServerSensorInvoker.h @@ -0,0 +1,229 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_SERVER_SENSOR_INVOKER_H__ +#define __XN_SERVER_SENSOR_INVOKER_H__ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnSensor.h" +#include +#include + +//--------------------------------------------------------------------------- +// Types +//--------------------------------------------------------------------------- +class XnServerSensorInvoker +{ +public: + typedef struct NewStreamDataEventArgs + { + const XnChar* strStreamName; + XnUInt64 nTimestamp; + XnUInt32 nFrameID; + } NewStreamDataEventArgs; + +private: + typedef XnEventT NewStreamDataEvent; + +public: + XnServerSensorInvoker(); + ~XnServerSensorInvoker(); + + XnStatus Init(const XnChar* strDevicePath, const XnChar* strGlobalConfigFile, XnUInt32 nAdditionalProps, XnProperty** aAdditionalProps); + void Free(); + + const XnChar* GetDevicePath(); + + XnStatus GetIntProperty(const XnChar* strModule, const XnChar* strProperty, XnUInt64* pnValue); + XnStatus GetRealProperty(const XnChar* strModule, const XnChar* strProperty, XnDouble* pdValue); + XnStatus GetStringProperty(const XnChar* strModule, const XnChar* strProperty, XnChar* strValue); + XnStatus GetGeneralProperty(const XnChar* strModule, const XnChar* strProperty, XnGeneralBuffer& gbValue); + + XnStatus SetIntProperty(const XnChar* strModule, const XnChar* strProperty, XnUInt64 nValue); + XnStatus SetRealProperty(const XnChar* strModule, const XnChar* strProperty, XnDouble dValue); + XnStatus SetStringProperty(const XnChar* strModule, const XnChar* strProperty, const XnChar* strValue); + XnStatus SetGeneralProperty(const XnChar* strModule, const XnChar* strProperty, const XnGeneralBuffer& gbValue); + + XnStatus GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams = FALSE, const XnChar* strModule = NULL); + + XnStatus LoadConfigFromFile(const XnChar* strFileName, const XnChar* strSectionName); + XnStatus BatchConfig(const XnPropertySet* pChangeSet); + XnStatus ConfigureModuleFromGlobalFile(const XnChar* strModule); + + XnStatus CreateStreamData(const XnChar* strStreamName, XnStreamData** ppStreamData); + + XnStatus GetStream(const XnChar* strType, const XnPropertySet* pInitialValues); + XnStatus ReleaseStream(const XnChar* strType); + + typedef NewStreamDataEvent::HandlerPtr NewStreamDataHandler; + XnStatus OpenStream(const XnChar* strName, NewStreamDataHandler pNewDataHandler, void* pCookie, XnCallbackHandle& hCallback); + XnStatus CloseStream(const XnChar* strName, XnCallbackHandle hCallback); + + XnStatus AddRefFrameBuffer(const XnChar* strStreamName, XnBuffer* pBuffer); + XnStatus ReleaseFrameBuffer(const XnChar* strStreamName, XnBuffer* pBuffer); + + XnStatus ReadStream(XnStreamData* pStreamData, XnUInt32* pnOffset); + + typedef XnEvent1Arg PropChangeEvent; + PropChangeEvent::TInterface& PropChangedEvent() { return m_propChangedEvent; } + +private: + // Types + typedef struct SensorInvokerStream + { + XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt32 nRefCount; + XnUInt32 nOpenRefCount; + XnStreamData* pStreamData; + XnBool bNewData; + NewStreamDataEvent* pNewDataEvent; + XnBool bFrameStream; + XN_SHARED_MEMORY_HANDLE hSharedMemory; + XnBool bAllowOtherUsers; + XnUChar* pSharedMemoryAddress; + XnActualStringProperty* pSharedMemoryName; + } SensorInvokerStream; + + typedef XnStringsHashT _XnServerStreamsHash; + + class XnServerStreamsHash; + + class XnLockedServerStreamsHash + { + public: + inline XnLockedServerStreamsHash(const XnLockedServerStreamsHash& other) : + m_hash(other.m_hash), + m_locker(other.m_locker) + {} + + inline XnLockedServerStreamsHash& operator=(const XnLockedServerStreamsHash& other) + { + this->m_hash = other.m_hash; + this->m_locker = other.m_locker; + return *this; + } + + inline _XnServerStreamsHash::Iterator Begin() + { + return m_hash.Begin(); + } + + inline _XnServerStreamsHash::Iterator End() + { + return m_hash.End(); + } + + typedef _XnServerStreamsHash::Iterator Iterator; + + private: + inline XnLockedServerStreamsHash(_XnServerStreamsHash& hash, XN_CRITICAL_SECTION_HANDLE hLock) : + m_hash(hash), + m_locker(hLock) + {} + + friend class XnServerSensorInvoker::XnServerStreamsHash; + + _XnServerStreamsHash& m_hash; + XnAutoCSLocker m_locker; + }; + + class XnServerStreamsHash + { + public: + XnServerStreamsHash() + { + XnStatus nRetVal = xnOSCreateCriticalSection(&m_hLock); + XN_ASSERT(nRetVal == XN_STATUS_OK); + } + + ~XnServerStreamsHash() + { + XnStatus nRetVal = xnOSCloseCriticalSection(&m_hLock); + XN_ASSERT(nRetVal == XN_STATUS_OK); + } + + inline XnStatus Set(const XnChar* strName, const SensorInvokerStream& stream) + { + XnAutoCSLocker locker(m_hLock); + return m_hash.Set(strName, stream); + } + + inline XnStatus Get(const XnChar* strName, SensorInvokerStream*& pStream) + { + XnAutoCSLocker locker(m_hLock); + return m_hash.Get(strName, pStream); + } + + inline XnStatus Remove(const XnChar* strName) + { + XnAutoCSLocker locker(m_hLock); + return m_hash.Remove(strName); + } + + inline XnLockedServerStreamsHash GetLockedHashForIterating() + { + return XnLockedServerStreamsHash(m_hash, m_hLock); + } + + private: + XN_CRITICAL_SECTION_HANDLE m_hLock; + _XnServerStreamsHash m_hash; + }; + + // Functions + XnStatus RegisterToProps(XnPropertySet* pProps); + + XnStatus SetNumberOfBuffers(XnUInt32 nCount); + XnStatus SetAllowOtherUsers(XnBool bAllowOtherUsers); + XnStatus OnPropertyChanged(const XnProperty* pProp); + XnStatus OnStreamAdded(const XnChar* StreamName); + XnStatus OnStreamRemoved(const XnChar* StreamName); + XnStatus OnStreamCollectionChanged(const XnChar* StreamName, XnStreamsChangeEventType EventType); + XnStatus OnNewStreamData(const XnChar* StreamName); + XnStatus ReadStreams(); + XnStatus SetStreamSharedMemory(SensorInvokerStream* pStream); + XnStatus GetStreamMaxResolution(SensorInvokerStream* pStream, XnUInt32& nMaxNumPixels); + + static XnStatus XN_CALLBACK_TYPE SetNumberOfBuffersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetAllowOtherUsersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE PropertyChangedCallback(const XnProperty* pProp, void* pCookie); + static void XN_CALLBACK_TYPE StreamCollectionChangedCallback(const XnStreamCollectionChangedEventArgs& args, void* pCookie); + static void XN_CALLBACK_TYPE NewStreamDataCallback(const XnNewStreamDataEventArgs& args, void* pCookie); + static XN_THREAD_PROC ReaderThread(XN_THREAD_PARAM pThreadParam); + + // Members + XnSensor m_sensor; + XN_CRITICAL_SECTION_HANDLE m_hSensorLock; + XN_THREAD_HANDLE m_hReaderThread; + XN_EVENT_HANDLE m_hNewDataEvent; + volatile XnBool m_bShouldRun; + XnStatus m_errorState; + + XnActualIntProperty m_numberOfBuffers; + XnActualIntProperty m_allowOtherUsers; + + PropChangeEvent m_propChangedEvent; + XnServerStreamsHash m_streams; +}; + +#endif // __XN_SERVER_SENSOR_INVOKER_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnServerSession.cpp b/Source/XnDeviceSensorV2/XnServerSession.cpp new file mode 100644 index 0000000..1b858f1 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnServerSession.cpp @@ -0,0 +1,1267 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnServerSession.h" +#include "XnSensorClientServer.h" +#include +#include + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +XnServerSession::XnServerSession(XnSensorsManager* pSensorsManager, XnUInt32 nID, XN_SOCKET_HANDLE hSocket, XnServerLogger* pLogger) : + m_pSensorsManager(pSensorsManager), + m_nID(nID), + m_hSocket(hSocket), + m_hThread(NULL), + m_hCommLock(NULL), + m_hStreamsLock(NULL), + m_ioStream(hSocket), + m_privateIncomingPacker(&m_ioStream, XN_SENSOR_SERVER_CONFIG_PACKER_SIZE), + m_privateOutgoingPacker(&m_ioStream, XN_SENSOR_SERVER_CONFIG_PACKER_SIZE), + m_pStreamDataSet(NULL), + m_bShouldRun(TRUE), + m_bHasEnded(FALSE), + m_pSensor(NULL), + m_pLogger(pLogger), + m_hProprtyChangeCallback(NULL) +{ + SessionStream stream; + strcpy(stream.strStreamName, XN_MODULE_NAME_DEVICE); + strcpy(stream.strClientStreamName, XN_MODULE_NAME_DEVICE); + stream.bIsOpen = FALSE; + m_streamsHash.Set(XN_MODULE_NAME_DEVICE, stream); +} + +XnServerSession::~XnServerSession() +{ + Free(); +} + +XnStatus XnServerSession::Init() +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_privateIncomingPacker.Init(); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_privateOutgoingPacker.Init(); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = XnStreamDataSetCreate(&m_pStreamDataSet); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateCriticalSection(&m_hCommLock); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = xnOSCreateCriticalSection(&m_hStreamsLock); + XN_IS_STATUS_OK(nRetVal); + + // start thread + nRetVal = xnOSCreateThread(ServeThreadCallback, this, &m_hThread); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +void XnServerSession::Free() +{ + if (m_hThread != NULL) + { + xnOSWaitAndTerminateThread(&m_hThread, 2000); + m_hThread = NULL; + } + + if (m_hStreamsLock != NULL) + { + xnOSCloseCriticalSection(&m_hStreamsLock); + m_hStreamsLock = NULL; + } + + if (m_hCommLock != NULL) + { + xnOSCloseCriticalSection(&m_hCommLock); + m_hCommLock = NULL; + } + + if (m_pStreamDataSet != NULL) + { + XnStreamDataSetDestroy(&m_pStreamDataSet); + m_pStreamDataSet = NULL; + } + + if (m_hSocket != NULL) + { + xnOSCloseSocket(m_hSocket); + m_hSocket = NULL; + } + + m_privateIncomingPacker.Free(); + m_privateOutgoingPacker.Free(); +} + +XnStatus XnServerSession::SendReply(XnSensorServerCustomMessages Type, XnStatus nRC, XnUInt32 nDataSize /* = 0 */, void* pAdditionalData /* = NULL */) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnUChar message[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; + XnSensorClientServerReply* pReply = (XnSensorClientServerReply*)message; + pReply->nRetVal = nRC; + pReply->Type = Type; + pReply->nDataSize = nDataSize; + xnOSMemCopy(pReply->pData, pAdditionalData, nDataSize); + XnUChar* pEnd = pReply->pData + nDataSize; + + m_pLogger->DumpMessage("Reply", nDataSize, m_nID); + + // lock this so that messages don't mix up + { + XnAutoCSLocker lock(m_hCommLock); + nRetVal = m_privateOutgoingPacker.WriteCustomData(Type, message, (XnUInt32)(pEnd - message)); + } + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::SendInitialState() +{ + XnStatus nRetVal = XN_STATUS_OK; + + XN_PROPERTY_SET_CREATE_ON_STACK(props); + + // get it + nRetVal = m_pSensor->GetAllProperties(&props, TRUE); + XN_IS_STATUS_OK(nRetVal); + + // and send it + m_pLogger->DumpMessage("InitialState", 0, m_nID); + + { + XnAutoCSLocker lock(m_hCommLock); + nRetVal = m_privateOutgoingPacker.WritePropertySet(&props); + } + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::FindStreamByServerName(const XnChar* strName, SessionStream** ppStream) +{ + for (SessionStreamsHash::Iterator it = m_streamsHash.Begin(); it != m_streamsHash.End(); ++it) + { + SessionStream* pStream = &it->Value(); + if (strcmp(pStream->strStreamName, strName) == 0) + { + *ppStream = pStream; + return XN_STATUS_OK; + } + } + + *ppStream = NULL; + return (XN_STATUS_NO_MATCH); +} + +XnStatus XnServerSession::HandleOpenSensor() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strConnectionString[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR, strConnectionString, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to open sensor %s", m_nID, strConnectionString); + + XnStatus nActionResult = OpenSensorImpl(strConnectionString); + + if (nActionResult == XN_STATUS_OK) + { + // sensor is open. send client its initial state + nActionResult = SendInitialState(); + } + + // if an error occurred, send it to the client + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to open sensor '%s': %s", m_nID, strConnectionString, xnGetStatusString(nActionResult)); + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::OpenSensorImpl(const XnChar* strConnectionString) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_pSensorsManager->GetSensor(strConnectionString, &m_pSensor); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->PropChangedEvent().Register(PropertyChangedCallback, this, m_hProprtyChangeCallback); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::CloseSensorImpl() +{ + if (m_pSensor == NULL) + { + return XN_STATUS_OK; + } + + // unregister from events + m_pSensor->PropChangedEvent().Unregister(m_hProprtyChangeCallback); + m_hProprtyChangeCallback = NULL; + + // release all streams + XnAutoCSLocker locker(m_hStreamsLock); + SessionStreamsHash::Iterator it = m_streamsHash.Begin(); + while (it != m_streamsHash.End()) + { + SessionStreamsHash::Iterator curr = it; + ++it; + const XnChar* strName = curr->Key(); + if (strcmp(strName, XN_MODULE_NAME_DEVICE) != 0) + { + RemoveStreamImpl(strName); + } + else + { + // just remove it from the map + m_streamsHash.Remove(curr); + } + } + + // release sensor + if (m_pSensor != NULL) + { + m_pSensorsManager->ReleaseSensor(m_pSensor); + m_pSensor = NULL; + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleSetIntProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt64 nValue; + nRetVal = m_privateIncomingPacker.ReadProperty(strModule, strProp, &nValue); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = SetIntPropertyImpl(strModule, strProp, nValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to set property '%s.%s': %s", m_nID, strModule, strProp, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::SetIntPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnUInt64 nValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", m_nID, strModule, strProp); + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->SetIntProperty(pStream->strStreamName, strProp, nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleSetRealProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; + XnDouble dValue; + nRetVal = m_privateIncomingPacker.ReadProperty(strModule, strProp, &dValue); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = SetRealPropertyImpl(strModule, strProp, dValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to set property '%s.%s': %s", m_nID, strModule, strProp, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::SetRealPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnDouble dValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", m_nID, strModule, strProp); + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->SetRealProperty(pStream->strStreamName, strProp, dValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleSetStringProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; + nRetVal = m_privateIncomingPacker.ReadProperty(strModule, strProp, strValue); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = SetStringPropertyImpl(strModule, strProp, strValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to set property '%s.%s': %s", m_nID, strModule, strProp, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::SetStringPropertyImpl(const XnChar* strModule, const XnChar* strProp, const XnChar* strValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", m_nID, strModule, strProp); + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->SetStringProperty(pStream->strStreamName, strProp, strValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleSetGeneralProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; + XnGeneralBuffer gbValue; + nRetVal = m_privateIncomingPacker.ReadProperty(strModule, strProp, &gbValue); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = SetGeneralPropertyImpl(strModule, strProp, gbValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to set property '%s.%s': %s", m_nID, strModule, strProp, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::SetGeneralPropertyImpl(const XnChar* strModule, const XnChar* strProp, const XnGeneralBuffer& gbValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to set %s.%s", m_nID, strModule, strProp); + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->SetGeneralProperty(pStream->strStreamName, strProp, gbValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleGetIntProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnSensorServerMessageGetPropertyRequest request; + XnUInt32 nDataSize = sizeof(request); + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY, &request, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + if (nDataSize != sizeof(request)) + { + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); + } + + // get + XnUInt64 nValue; + XnStatus nActionResult = GetIntPropertyImpl(request.strModuleName, request.strPropertyName, &nValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, request.strModuleName, request.strPropertyName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY, nActionResult, sizeof(nValue), &nValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::GetIntPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnUInt64* pnValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->GetIntProperty(pStream->strStreamName, strProp, pnValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleGetRealProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnSensorServerMessageGetPropertyRequest request; + XnUInt32 nDataSize = sizeof(request); + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY, &request, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + if (nDataSize != sizeof(request)) + { + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); + } + + // get + XnDouble dValue; + XnStatus nActionResult = GetRealPropertyImpl(request.strModuleName, request.strPropertyName, &dValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, request.strModuleName, request.strPropertyName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY, nActionResult, sizeof(dValue), &dValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::GetRealPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnDouble* pdValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->GetRealProperty(pStream->strStreamName, strProp, pdValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleGetStringProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnSensorServerMessageGetPropertyRequest request; + XnUInt32 nDataSize = sizeof(request); + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, &request, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + if (nDataSize != sizeof(request)) + { + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); + } + + // get + XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; + XnStatus nActionResult = GetStringPropertyImpl(request.strModuleName, request.strPropertyName, strValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, request.strModuleName, request.strPropertyName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, nActionResult, sizeof(strValue), strValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::GetStringPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnChar* strValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->GetStringProperty(pStream->strStreamName, strProp, strValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleGetGeneralProperty() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnUChar bufValue[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; + XnSensorServerMessageGetPropertyRequest* pRequest = (XnSensorServerMessageGetPropertyRequest*)bufValue; + XnUChar* pData = bufValue + sizeof(XnSensorServerMessageGetPropertyRequest); + XnUInt32 nDataSize = XN_SENSOR_SERVER_MAX_REPLY_SIZE; + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, bufValue, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + if (nDataSize < sizeof(XnSensorServerMessageGetPropertyRequest)) + { + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); + } + + // get + XnGeneralBuffer gbValue = XnGeneralBufferPack(pData, pRequest->nSize); + XnStatus nActionResult = GetGeneralPropertyImpl(pRequest->strModuleName, pRequest->strPropertyName, gbValue); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, pRequest->strModuleName, pRequest->strPropertyName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, nActionResult, pRequest->nSize, pData); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::GetGeneralPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnGeneralBuffer& gbValue) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strModule, pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->GetGeneralProperty(pStream->strStreamName, strProp, gbValue); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleConfigFromINIFile() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnSensorServerMessageIniFile message; + XnUInt32 nDataSize = sizeof(message); + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_INI_FILE, (XnUChar*)&message, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + if (nDataSize != sizeof(message)) + { + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); + } + + // load + XnStatus nActionResult = ConfigFromINIFileImpl(message.strFileName, message.strSectionName); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to config sensor from file '%s': %s", m_nID, message.strFileName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::ConfigFromINIFileImpl(const XnChar* strFileName, const XnChar* strSectionName) +{ + return m_pSensor->LoadConfigFromFile(strFileName, strSectionName); +} + +XnStatus XnServerSession::HandleBatchConfig() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XN_PROPERTY_SET_CREATE_ON_STACK(props); + + nRetVal = m_privateIncomingPacker.ReadPropertySet(&props); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = BatchConfigImpl(&props); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to batch config: %s", m_nID, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::BatchConfigImpl(const XnPropertySet* pProps) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested a batch config", m_nID); + + XN_PROPERTY_SET_CREATE_ON_STACK(serverProps); + for (XnPropertySetData::Iterator it = pProps->pData->Begin(); it != pProps->pData->End(); ++it) + { + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(it->Key(), pStream); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = XnPropertySetCloneModule(pProps, &serverProps, it->Key(), pStream->strStreamName); + XN_IS_STATUS_OK(nRetVal); + } + + nRetVal = m_pSensor->BatchConfig(&serverProps); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleNewStream() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XN_PROPERTY_SET_CREATE_ON_STACK(props); + + XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; + nRetVal = m_privateIncomingPacker.ReadNewStream(strType, strName, &props); + XN_IS_STATUS_OK(nRetVal); + + XnPropertySet* pInitialValues = &props; + if (props.pData->Begin() == props.pData->End()) + { + pInitialValues = NULL; + } + + XnStatus nActionResult = NewStreamImpl(strType, strName, pInitialValues); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to create stream of type '%s': %s", m_nID, strType, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::NewStreamImpl(const XnChar* strType, const XnChar* strName, const XnPropertySet* pInitialValues) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to create stream '%s' (%s)", m_nID, strName, strType); + + nRetVal = m_pSensor->GetStream(strType, pInitialValues); + XN_IS_STATUS_OK(nRetVal); + + // send client the new stream data + XN_PROPERTY_SET_CREATE_ON_STACK(streamProps); + XN_PROPERTY_SET_CREATE_ON_STACK(clientStreamProps); + + // take properties + nRetVal = m_pSensor->GetAllProperties(&streamProps, FALSE, strType); + XN_IS_STATUS_OK(nRetVal); + + // copy relevant ones + nRetVal = XnPropertySetCloneModule(&streamProps, &clientStreamProps, strType, strName); + XN_IS_STATUS_OK(nRetVal); + + // now change the state property. It should be OFF, and not the real value (each client has + // its own stream state). + nRetVal = XnPropertySetRemoveProperty(&clientStreamProps, strName, XN_STREAM_PROPERTY_STATE); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = XnPropertySetAddIntProperty(&clientStreamProps, strName, XN_STREAM_PROPERTY_STATE, FALSE); + XN_IS_STATUS_OK(nRetVal); + + m_pLogger->DumpMessage("NewStream", 0, m_nID, strName); + + { + XnAutoCSLocker lock(m_hCommLock); + nRetVal = m_privateOutgoingPacker.WriteNewStream(strType, strName, &clientStreamProps); + } + XN_IS_STATUS_OK(nRetVal); + + // now add it to client data + nRetVal = AddSessionModule(strName, strType); + XN_IS_STATUS_OK(nRetVal); + + // create client stream data + XnStreamData* pStreamData = NULL; + nRetVal = m_pSensor->CreateStreamData(strType, &pStreamData); + XN_IS_STATUS_OK(nRetVal); + + // and add it to set + nRetVal = XnStreamDataSetAdd(m_pStreamDataSet, pStreamData); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleRemoveStream() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; + nRetVal = m_privateIncomingPacker.ReadStreamRemoved(strName); + XN_IS_STATUS_OK(nRetVal); + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to remove stream %s", m_nID, strName); + XnStatus nActionResult = RemoveStreamImpl(strName); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to remove stream '%s': %s", m_nID, strName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::RemoveStreamImpl(const XnChar* strName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + // first close it (so that ref count will be consistent) + if (pStream->bIsOpen) + { + nRetVal = CloseStreamImpl(strName); + XN_IS_STATUS_OK(nRetVal); + pStream->bIsOpen = FALSE; + } + + // release that stream + nRetVal = m_pSensor->ReleaseStream(pStream->strStreamName); + XN_IS_STATUS_OK(nRetVal); + + // if client had a buffer of this stream, release it + XnStreamData* pStreamData = NULL; + nRetVal = XnStreamDataSetGet(m_pStreamDataSet, pStream->strStreamName, &pStreamData); + if (nRetVal == XN_STATUS_OK) + { + if (pStreamData->pInternal->pLockedBuffer != NULL) + { + m_pSensor->ReleaseFrameBuffer(pStream->strStreamName, pStreamData->pInternal->pLockedBuffer); + } + + // free data + XnStreamDataSetRemove(m_pStreamDataSet, pStreamData); + XnStreamDataDestroy(&pStreamData); + } + + // now remove it from client + nRetVal = RemoveSessionModule(strName); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleOpenStream() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; + XnUInt32 nType = XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM; + nRetVal = m_privateIncomingPacker.ReadCustomData(nType, strStreamName, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = OpenStreamImpl(strStreamName); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to open stream '%s': %s", m_nID, strStreamName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::OpenStreamImpl(const XnChar* strName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to open stream %s", m_nID, strName); + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + if (!pStream->bIsOpen) + { + nRetVal = m_pSensor->OpenStream(pStream->strStreamName, StreamNewDataCallback, pStream, pStream->hNewDataCallback); + XN_IS_STATUS_OK(nRetVal); + pStream->bIsOpen = TRUE; + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleCloseStream() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; + XnUInt32 nType = XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM; + nRetVal = m_privateIncomingPacker.ReadCustomData(nType, strStreamName, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + XnStatus nActionResult = CloseStreamImpl(strStreamName); + if (nActionResult != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to close stream '%s': %s", m_nID, strStreamName, xnGetStatusString(nActionResult)); + } + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::CloseStreamImpl(const XnChar* strName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested to close stream %s", m_nID, strName); + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + if (pStream->bIsOpen) + { + nRetVal = m_pSensor->CloseStream(pStream->strStreamName, pStream->hNewDataCallback); + XN_IS_STATUS_OK(nRetVal); + pStream->bIsOpen = FALSE; + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleReadStream() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // read it + XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; + XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH; + nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, strStreamName, &nDataSize); + XN_IS_STATUS_OK(nRetVal); + + XnSensorServerReadReply reply; + XnStatus nActionResult = ReadStreamImpl(strStreamName, &reply); + if (nActionResult == XN_STATUS_OK) + { + m_pLogger->DumpMessage("Data", sizeof(reply), 0, strStreamName); + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, XN_STATUS_OK, sizeof(reply), &reply); + XN_IS_STATUS_OK(nRetVal); + } + else + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to read stream '%s': %s", m_nID, strStreamName, xnGetStatusString(nActionResult)); + + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult); + XN_IS_STATUS_OK(nRetVal); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::ReadStreamImpl(const XnChar* strName, XnSensorServerReadReply* pReply) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(strName, pStream); + XN_IS_STATUS_OK(nRetVal); + + XnStreamData* pStreamData; + nRetVal = XnStreamDataSetGet(m_pStreamDataSet, pStream->strStreamName, &pStreamData); + XN_IS_STATUS_OK(nRetVal); + + nRetVal = m_pSensor->ReadStream(pStreamData, &pReply->nOffset); + XN_IS_STATUS_OK(nRetVal); + + pReply->nDataSize = pStreamData->nDataSize; + pReply->nFrameID = pStreamData->nFrameID; + pReply->nTimestamp = pStreamData->nTimestamp; + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleCloseSession() +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_SENSOR_SERVER, "Received BYE from client %u", m_nID); + + XnStatus nActionResult = CloseSessionImpl(); + XN_ASSERT(nActionResult == XN_STATUS_OK); + XN_REFERENCE_VARIABLE(nActionResult); + + // client shouldn't care if close succeeded or not. always send OK. + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_BYE, XN_STATUS_OK); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to send BYE reply to client %u: %s", m_nID, xnGetStatusString(nRetVal)); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::CloseSessionImpl() +{ + XnStatus nRetVal = XN_STATUS_OK; + + // stop processing messages + m_bShouldRun = FALSE; + + // close sensor + nRetVal = CloseSensorImpl(); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::HandleSingleRequest() +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnUInt32 nType; + nRetVal = m_privateIncomingPacker.ReadNextObject(&nType); + XN_IS_STATUS_OK(nRetVal); + + switch (nType) + { + case XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR: + { + nRetVal = HandleOpenSensor(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_INT_PROPERTY: + { + nRetVal = HandleSetIntProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_REAL_PROPERTY: + { + nRetVal = HandleSetRealProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_STRING_PROPERTY: + { + nRetVal = HandleSetStringProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_GENERAL_PROPERTY: + { + nRetVal = HandleSetGeneralProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY: + { + nRetVal = HandleGetIntProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY: + { + nRetVal = HandleGetRealProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY: + { + nRetVal = HandleGetStringProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY: + { + nRetVal = HandleGetGeneralProperty(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_INI_FILE: + { + nRetVal = HandleConfigFromINIFile(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_PROPERTY_SET: + { + nRetVal = HandleBatchConfig(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_NEW_STREAM: + { + nRetVal = HandleNewStream(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PACKED_STREAM_REMOVED: + { + nRetVal = HandleRemoveStream(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_READ_STREAM: + { + nRetVal = HandleReadStream(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM: + { + nRetVal = HandleOpenStream(); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM: + { + nRetVal = HandleCloseStream(); + XN_IS_STATUS_OK(nRetVal); + break; + } + + case XN_SENSOR_SERVER_MESSAGE_BYE: + { + nRetVal = HandleCloseSession(); + XN_IS_STATUS_OK(nRetVal); + break; + } + + default: + xnLogWarning(XN_MASK_SENSOR_SERVER, "Unknown client request: %u", nType); + nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, XN_STATUS_ERROR); + XN_IS_STATUS_OK(nRetVal); + + return XN_STATUS_ERROR; + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::ServeThread() +{ + XnStatus nRetVal = XN_STATUS_OK; + + while (m_bShouldRun) + { + if (!m_ioStream.IsConnected()) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u socket was closed. Closing session...", m_nID); + CloseSessionImpl(); + break; + } + + nRetVal = HandleSingleRequest(); + if ((nRetVal != XN_STATUS_OK) && + (nRetVal != XN_STATUS_OS_NETWORK_CONNECTION_CLOSED) && + (nRetVal != XN_STATUS_OS_NETWORK_TIMEOUT)) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed processing client request: %s", xnGetStatusString(nRetVal)); + } + } + + // We cannot RemoveClient from this thread (as part of it is to close the thread). Instead, signal that + // client has stopped, and let server main thread wait for exit. + m_bHasEnded = TRUE; + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::AddSessionModule(const XnChar* clientName, const XnChar* serverName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream stream; + strcpy(stream.strClientStreamName, clientName); + strcpy(stream.strStreamName, serverName); + stream.bIsOpen = FALSE; + stream.pSession = this; + + nRetVal = m_streamsHash.Set(clientName, stream); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::RemoveSessionModule(const XnChar* clientName) +{ + XnStatus nRetVal = XN_STATUS_OK; + + SessionStream* pStream = NULL; + nRetVal = m_streamsHash.Get(clientName, pStream); + if (nRetVal == XN_STATUS_OK) + { + m_streamsHash.Remove(clientName); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::OnPropertyChanged(const XnProperty* pProp) +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnAutoCSLocker streamLocker(m_hStreamsLock); + + SessionStream* pStream = NULL; + nRetVal = FindStreamByServerName(pProp->GetModule(), &pStream); + XN_IS_STATUS_OK(nRetVal); + + // send message + m_pLogger->DumpMessage("PropChange", 0, m_nID, pProp->GetName()); + + XnAutoCSLocker commLocker(m_hCommLock); + switch (pProp->GetType()) + { + case XN_PROPERTY_TYPE_INTEGER: + { + XnActualIntProperty* pActualProp = (XnActualIntProperty*)pProp; + nRetVal = m_privateOutgoingPacker.WriteProperty(pStream->strClientStreamName, pProp->GetName(), pActualProp->GetValue()); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PROPERTY_TYPE_REAL: + { + XnActualRealProperty* pActualProp = (XnActualRealProperty*)pProp; + nRetVal = m_privateOutgoingPacker.WriteProperty(pStream->strClientStreamName, pProp->GetName(), pActualProp->GetValue()); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PROPERTY_TYPE_STRING: + { + XnActualStringProperty* pActualProp = (XnActualStringProperty*)pProp; + nRetVal = m_privateOutgoingPacker.WriteProperty(pStream->strClientStreamName, pProp->GetName(), pActualProp->GetValue()); + XN_IS_STATUS_OK(nRetVal); + break; + } + case XN_PROPERTY_TYPE_GENERAL: + { + XnActualGeneralProperty* pActualProp = (XnActualGeneralProperty*)pProp; + nRetVal = m_privateOutgoingPacker.WriteProperty(pStream->strClientStreamName, pProp->GetName(), pActualProp->GetValue()); + XN_IS_STATUS_OK(nRetVal); + break; + } + default: + XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Unknown property type: %d", pProp->GetType()); + } + + return (XN_STATUS_OK); +} + +XnStatus XnServerSession::OnNewData(SessionStream* pStream, XnUInt64 nTimestamp, XnUInt32 nFrameID) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // send to client + XnSensorServerNewStreamData message; + xnOSMemSet(&message, 0, sizeof(message)); + message.nTimestamp = nTimestamp; + message.nFrameID = nFrameID; + strcpy(message.strStreamName, pStream->strClientStreamName); + m_pLogger->DumpMessage("NewData", sizeof(XnSensorServerNewStreamData), 0, pStream->strClientStreamName); + + XnAutoCSLocker locker(m_hCommLock); + nRetVal = m_privateOutgoingPacker.WriteCustomData(XN_SENSOR_SERVER_MESSAGE_NEW_STREAM_DATA, &message, sizeof(XnSensorServerNewStreamData)); + if (nRetVal != XN_STATUS_OK) + { + xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed sending new data event to client %d", m_nID); + } + + return (XN_STATUS_OK); +} + +void XN_CALLBACK_TYPE XnServerSession::PropertyChangedCallback(const XnProperty* pProp, void* pCookie) +{ + XnServerSession* pThis = (XnServerSession*)pCookie; + pThis->OnPropertyChanged(pProp); +} + +void XN_CALLBACK_TYPE XnServerSession::StreamNewDataCallback(const XnServerSensorInvoker::NewStreamDataEventArgs& args, void* pCookie) +{ + SessionStream* pStream = (SessionStream*)pCookie; + pStream->pSession->OnNewData(pStream, args.nTimestamp, args.nFrameID); +} + +XN_THREAD_PROC XnServerSession::ServeThreadCallback(XN_THREAD_PARAM pThreadParam) +{ + XnServerSession* pThis = (XnServerSession*)pThreadParam; + XnStatus nRetVal = pThis->ServeThread(); + XN_THREAD_PROC_RETURN(nRetVal); +} + diff --git a/Source/XnDeviceSensorV2/XnServerSession.h b/Source/XnDeviceSensorV2/XnServerSession.h new file mode 100644 index 0000000..3068936 --- /dev/null +++ b/Source/XnDeviceSensorV2/XnServerSession.h @@ -0,0 +1,138 @@ +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ +#ifndef __XN_SERVER_SESSION_H__ +#define __XN_SERVER_SESSION_H__ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnSensorsManager.h" +#include +#include +#include "XnSensorClientServer.h" +#include "XnServerLogger.h" +#include + +//--------------------------------------------------------------------------- +// Types +//--------------------------------------------------------------------------- + +class XnServerSession +{ +public: + XnServerSession(XnSensorsManager* pSensorsManager, XnUInt32 nID, XN_SOCKET_HANDLE hSocket, XnServerLogger* pLogger); + ~XnServerSession() ; + + XnStatus Init(); + void Free(); + + inline XnUInt32 ID() const { return m_nID; } + inline XnBool HasEnded() const { return m_bHasEnded; } + +private: + // Types + typedef struct + { + XnServerSession* pSession; + XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH]; + XnChar strClientStreamName[XN_DEVICE_MAX_STRING_LENGTH]; + XnBool bIsOpen; + XnCallbackHandle hNewDataCallback; + } SessionStream; + + typedef XnStringsHashT SessionStreamsHash; + + // Functions + XnStatus SendReply(XnSensorServerCustomMessages Type, XnStatus nRC, XnUInt32 nDataSize = 0, void* pAdditionalData = NULL); + XnStatus SendInitialState(); + XnStatus FindStreamByServerName(const XnChar* strName, SessionStream** ppStream); + + XnStatus HandleOpenSensor(); + XnStatus OpenSensorImpl(const XnChar* strConnectionString); + XnStatus CloseSensorImpl(); + XnStatus HandleSetIntProperty(); + XnStatus SetIntPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnUInt64 nValue); + XnStatus HandleSetRealProperty(); + XnStatus SetRealPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnDouble dValue); + XnStatus HandleSetStringProperty(); + XnStatus SetStringPropertyImpl(const XnChar* strModule, const XnChar* strProp, const XnChar* strValue); + XnStatus HandleSetGeneralProperty(); + XnStatus SetGeneralPropertyImpl(const XnChar* strModule, const XnChar* strProp, const XnGeneralBuffer& gbValue); + XnStatus HandleGetIntProperty(); + XnStatus GetIntPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnUInt64* pnValue); + XnStatus HandleGetRealProperty(); + XnStatus GetRealPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnDouble* pdValue); + XnStatus HandleGetStringProperty(); + XnStatus GetStringPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnChar* strValue); + XnStatus HandleGetGeneralProperty(); + XnStatus GetGeneralPropertyImpl(const XnChar* strModule, const XnChar* strProp, XnGeneralBuffer& gbValue); + XnStatus HandleConfigFromINIFile(); + XnStatus ConfigFromINIFileImpl(const XnChar* strFileName, const XnChar* strSectionName); + XnStatus HandleBatchConfig(); + XnStatus BatchConfigImpl(const XnPropertySet* pProps); + XnStatus HandleNewStream(); + XnStatus NewStreamImpl(const XnChar* strType, const XnChar* strName, const XnPropertySet* pInitialValues); + XnStatus HandleRemoveStream(); + XnStatus RemoveStreamImpl(const XnChar* strName); + XnStatus HandleOpenStream(); + XnStatus OpenStreamImpl(const XnChar* strName); + XnStatus HandleCloseStream(); + XnStatus CloseStreamImpl(const XnChar* strName); + XnStatus HandleReadStream(); + XnStatus ReadStreamImpl(const XnChar* strName, XnSensorServerReadReply* pReply); + XnStatus HandleCloseSession(); + XnStatus CloseSessionImpl(); + + XnStatus HandleSingleRequest(); + + XnStatus AddSessionModule(const XnChar* clientName, const XnChar* serverName); + XnStatus RemoveSessionModule(const XnChar* clientName); + + XnStatus OnPropertyChanged(const XnProperty* pProp); + XnStatus OnNewData(SessionStream* pStream, XnUInt64 nTimestamp, XnUInt32 nFrameID); + + XnStatus ServeThread(); + + static void XN_CALLBACK_TYPE PropertyChangedCallback(const XnProperty* pProp, void* pCookie); + static void XN_CALLBACK_TYPE StreamNewDataCallback(const XnServerSensorInvoker::NewStreamDataEventArgs& args, void* pCookie); + static XN_THREAD_PROC ServeThreadCallback(XN_THREAD_PARAM pThreadParam); + + // Members + XnSensorsManager* m_pSensorsManager; + XnUInt32 m_nID; + XN_SOCKET_HANDLE m_hSocket; + XN_THREAD_HANDLE m_hThread; + XN_CRITICAL_SECTION_HANDLE m_hCommLock; + XN_CRITICAL_SECTION_HANDLE m_hStreamsLock; + XnIONetworkStream m_ioStream; + XnDataPacker m_privateIncomingPacker; + XnDataPacker m_privateOutgoingPacker; + XnStreamDataSet* m_pStreamDataSet; + XnBool m_bShouldRun; + XnBool m_bHasEnded; + XnServerSensorInvoker* m_pSensor; + SessionStreamsHash m_streamsHash; + XnServerLogger* m_pLogger; + XnCallbackHandle m_hProprtyChangeCallback; +}; + +#endif // __XN_SERVER_SESSION_H__ \ No newline at end of file diff --git a/Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.cpp b/Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.cpp deleted file mode 100644 index 4e6d432..0000000 --- a/Source/XnDeviceSensorV2/XnSharedMemoryBufferPool.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnSharedMemoryBufferPool.h" - -//--------------------------------------------------------------------------- -// Code -//--------------------------------------------------------------------------- - -XnSharedMemoryBufferPool::XnSharedMemoryBufferPool(XnUInt32 nBufferCount, const XnChar* strName, XnUInt32 nMaxBufferSize) : - XnBufferPool(nBufferCount), - m_nMaxBufferSize(nMaxBufferSize), - m_hSharedMemory(NULL), - m_pSharedMemoryAddress(NULL) -{ - // to make the name unique, we'll add process ID - XN_PROCESS_ID procID; - xnOSGetCurrentProcessID(&procID); - sprintf(m_strName, "%u_%s", procID, strName); -} - -XnSharedMemoryBufferPool::~XnSharedMemoryBufferPool() -{ - XnSharedMemoryBufferPool::Free(); -} - -XnStatus XnSharedMemoryBufferPool::AllocateBuffers() -{ - XnStatus nRetVal = XN_STATUS_OK; - - if (m_nBufferSize > m_nMaxBufferSize) - { - return XN_STATUS_ALLOC_FAILED; - } - - if (m_pSharedMemoryAddress != NULL) - { - // already allocated. nothing to do here - return (XN_STATUS_OK); - } - - // first time. allocate shared memory - XnUInt32 nTotalSize = m_nMaxBufferSize * m_nBufferCount; - nRetVal = xnOSCreateSharedMemory(m_strName, nTotalSize, XN_OS_FILE_READ | XN_OS_FILE_WRITE, &m_hSharedMemory); - XN_IS_STATUS_OK(nRetVal); - - void* pAddress; - nRetVal = xnOSSharedMemoryGetAddress(m_hSharedMemory, &pAddress); - if (nRetVal != XN_STATUS_OK) - { - xnOSCloseSharedMemory(m_hSharedMemory); - m_hSharedMemory = NULL; - return (nRetVal); - } - - m_pSharedMemoryAddress = (XnUChar*)pAddress; - - // now allocate buffers - for (XnUInt32 i = 0; i < m_nBufferCount; ++i) - { - XnBufferInPool* pBuffer = XN_NEW(XnBufferInPool); - if (pBuffer == NULL) - { - Free(); - return (XN_STATUS_ALLOC_FAILED); - } - - pBuffer->m_nID = i; - - pBuffer->SetExternalBuffer(m_pSharedMemoryAddress + i*m_nMaxBufferSize, m_nMaxBufferSize); - - xnDumpWriteString(Dump(), "Allocated buffer %u with size %u\n", i, m_nMaxBufferSize); - - // add it to free list - m_AllBuffers.AddLast(pBuffer); - m_FreeBuffers.AddLast(pBuffer); - } - - return (XN_STATUS_OK); -} - -void XnSharedMemoryBufferPool::DestroyBuffer(XnBufferInPool* pBuffer) -{ - // simply add it back to free list - m_FreeBuffers.AddLast(pBuffer); -} - -void XnSharedMemoryBufferPool::Free() -{ - if (m_hSharedMemory != NULL) - { - xnOSCloseSharedMemory(m_hSharedMemory); - m_hSharedMemory = NULL; - } - - for (XnBuffersList::Iterator it = m_AllBuffers.begin(); it != m_AllBuffers.end(); ++it) - { - XnBufferInPool* pBuffer = *it; - XN_DELETE(pBuffer); - } - - m_AllBuffers.Clear(); - m_FreeBuffers.Clear(); - XnBufferPool::Free(); -} diff --git a/Source/XnDeviceSensorV2/XnStreamProcessor.cpp b/Source/XnDeviceSensorV2/XnStreamProcessor.cpp index 91e68fc..1839c82 100644 --- a/Source/XnDeviceSensorV2/XnStreamProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnStreamProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnStreamProcessor.h b/Source/XnDeviceSensorV2/XnStreamProcessor.h index 7423299..d0a2551 100644 --- a/Source/XnDeviceSensorV2/XnStreamProcessor.h +++ b/Source/XnDeviceSensorV2/XnStreamProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_STREAM_PROCESSOR_H__ #define __XN_STREAM_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.cpp b/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.cpp index 326daee..9052314 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -37,8 +31,8 @@ // Code //--------------------------------------------------------------------------- -XnUncompressedBayerProcessor::XnUncompressedBayerProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnUncompressedBayerProcessor::XnUncompressedBayerProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) { } @@ -67,7 +61,7 @@ XnStatus XnUncompressedBayerProcessor::Init() return (XN_STATUS_OK); } -void XnUncompressedBayerProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnUncompressedBayerProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnUncompressedBayerProcessor::ProcessFramePacketChunk") diff --git a/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.h b/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.h index 4227186..f0e7047 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.h +++ b/Source/XnDeviceSensorV2/XnUncompressedBayerProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_UNCOMPRESSED_BAYER_PROCESSOR_H__ #define __XN_UNCOMPRESSED_BAYER_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnUncompressedBayerProcessor : public XnImageProcessor { public: - XnUncompressedBayerProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnUncompressedBayerProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnUncompressedBayerProcessor(); XnStatus Init(); diff --git a/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.cpp b/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.cpp index faf8bfd..17680f8 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -35,8 +29,8 @@ // Code //--------------------------------------------------------------------------- -XnUncompressedDepthProcessor::XnUncompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper) : - XnDepthProcessor(pStream, pHelper) +XnUncompressedDepthProcessor::XnUncompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnDepthProcessor(pStream, pHelper, pBufferManager) { } @@ -44,15 +38,15 @@ XnUncompressedDepthProcessor::~XnUncompressedDepthProcessor() { } -void XnUncompressedDepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnUncompressedDepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnUncompressedDepthProcessor::ProcessFramePacketChunk") // when depth is uncompressed, we can just copy it directly to write buffer XnBuffer* pWriteBuffer = GetWriteBuffer(); - // make sure we have enough room - if (CheckWriteBufferForOverflow(nDataSize)) + // Check there is enough room for the depth pixels + if (CheckDepthBufferForOverflow(nDataSize)) { // sometimes, when packets are lost, we get uneven number of bytes, so we need to complete // one byte, in order to keep UINT16 alignment @@ -65,13 +59,20 @@ void XnUncompressedDepthProcessor::ProcessFramePacketChunk(const XnSensorProtoco // copy values. Make sure we do not get corrupted shifts XnUInt16* pRaw = (XnUInt16*)(pData); XnUInt16* pRawEnd = (XnUInt16*)(pData + nDataSize); - XnDepthPixel* pWriteBuf = (XnDepthPixel*)pWriteBuffer->GetUnsafeWritePointer(); + XnDepthPixel* pDepthBuf = GetDepthOutputBuffer(); + XnDepthPixel* pShiftBuf = GetShiftsOutputBuffer(); + XnUInt16 shift; while (pRaw < pRawEnd) { - *pWriteBuf = GetOutput(XN_MIN(*pRaw, XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)); + shift = (((*pRaw) < (XN_DEVICE_SENSOR_MAX_SHIFT_VALUE-1)) ? (*pRaw) : 0); + *pShiftBuf = shift; + *pDepthBuf = GetOutput(shift); + ++pRaw; - ++pWriteBuf; + ++pDepthBuf; + ++pShiftBuf; + } pWriteBuffer->UnsafeUpdateSize(nDataSize); @@ -79,3 +80,4 @@ void XnUncompressedDepthProcessor::ProcessFramePacketChunk(const XnSensorProtoco XN_PROFILING_END_SECTION } + diff --git a/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.h b/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.h index d5f52eb..90b57a0 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.h +++ b/Source/XnDeviceSensorV2/XnUncompressedDepthProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_UNCOMPRESSED_DEPTH_PROCESSOR_H__ #define __XN_UNCOMPRESSED_DEPTH_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnUncompressedDepthProcessor : public XnDepthProcessor { public: - XnUncompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper); + XnUncompressedDepthProcessor(XnSensorDepthStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); virtual ~XnUncompressedDepthProcessor(); protected: diff --git a/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.cpp b/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.cpp index aa61ef4..6727f30 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -35,8 +29,8 @@ // Code //--------------------------------------------------------------------------- -XnUncompressedYUVImageProcessor::XnUncompressedYUVImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnUncompressedYUVImageProcessor::XnUncompressedYUVImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) { } @@ -44,7 +38,7 @@ XnUncompressedYUVImageProcessor::~XnUncompressedYUVImageProcessor() { } -void XnUncompressedYUVImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnUncompressedYUVImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnUncompressedYUVImageProcessor::ProcessFramePacketChunk") diff --git a/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.h b/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.h index 7b95d48..fcba971 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnUncompressedYUVImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_UNCOMPRESSED_YUV_IMAGE_PROCESSOR_H__ #define __XN_UNCOMPRESSED_YUV_IMAGE_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnUncompressedYUVImageProcessor : public XnImageProcessor { public: - XnUncompressedYUVImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnUncompressedYUVImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnUncompressedYUVImageProcessor(); //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.cpp b/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.cpp index aa485e7..cb4b2f8 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -36,8 +30,8 @@ // Code //--------------------------------------------------------------------------- -XnUncompressedYUVtoRGBImageProcessor::XnUncompressedYUVtoRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper) : - XnImageProcessor(pStream, pHelper) +XnUncompressedYUVtoRGBImageProcessor::XnUncompressedYUVtoRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : + XnImageProcessor(pStream, pHelper, pBufferManager) { } @@ -57,7 +51,7 @@ XnStatus XnUncompressedYUVtoRGBImageProcessor::Init() return (XN_STATUS_OK); } -void XnUncompressedYUVtoRGBImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize) +void XnUncompressedYUVtoRGBImageProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnUncompressedYUVtoRGBImageProcessor::ProcessFramePacketChunk") diff --git a/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.h b/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.h index 5412b91..850377b 100644 --- a/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.h +++ b/Source/XnDeviceSensorV2/XnUncompressedYUVtoRGBImageProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_UNCOMPRESSED_YUV_TO_RGB_IMAGE_PROCESSOR_H__ #define __XN_UNCOMPRESSED_YUV_TO_RGB_IMAGE_PROCESSOR_H__ @@ -39,7 +34,7 @@ class XnUncompressedYUVtoRGBImageProcessor : public XnImageProcessor { public: - XnUncompressedYUVtoRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper); + XnUncompressedYUVtoRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager); ~XnUncompressedYUVtoRGBImageProcessor(); XnStatus Init(); diff --git a/Source/XnDeviceSensorV2/XnWholePacketProcessor.cpp b/Source/XnDeviceSensorV2/XnWholePacketProcessor.cpp index f44b8dc..c5d3b14 100644 --- a/Source/XnDeviceSensorV2/XnWholePacketProcessor.cpp +++ b/Source/XnDeviceSensorV2/XnWholePacketProcessor.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnDeviceSensorV2/XnWholePacketProcessor.h b/Source/XnDeviceSensorV2/XnWholePacketProcessor.h index 24dbfbf..5a4b099 100644 --- a/Source/XnDeviceSensorV2/XnWholePacketProcessor.h +++ b/Source/XnDeviceSensorV2/XnWholePacketProcessor.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_WHOLE_PACKET_PROCESSOR_H__ #define __XN_WHOLE_PACKET_PROCESSOR_H__ diff --git a/Source/XnDeviceSensorV2/YUV.cpp b/Source/XnDeviceSensorV2/YUV.cpp index 6eeb605..c236527 100644 --- a/Source/XnDeviceSensorV2/YUV.cpp +++ b/Source/XnDeviceSensorV2/YUV.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -55,9 +49,9 @@ void YUV444ToRGB888(XnUInt8 cY, XnUInt8 cU, XnUInt8 cV, nC = nC * 298 + 128; - cR = XN_MIN(XN_MAX((nC + 409 * nE) >> 8, 0), 255); - cG = XN_MIN(XN_MAX((nC - 100 * nD - 208 * nE) >> 8, 0), 255); - cB = XN_MIN(XN_MAX((nC + 516 * nD ) >> 8, 0), 255); + cR = (XnUInt8)XN_MIN(XN_MAX((nC + 409 * nE) >> 8, 0), 255); + cG = (XnUInt8)XN_MIN(XN_MAX((nC - 100 * nD - 208 * nE) >> 8, 0), 255); + cB = (XnUInt8)XN_MIN(XN_MAX((nC + 516 * nD ) >> 8, 0), 255); } #if (XN_PLATFORM == XN_PLATFORM_WIN32) @@ -69,7 +63,6 @@ void YUV422ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVS const XnUInt8* pRGBOrig = pRGBImage; const XnUInt8* pRGBLast = pRGBImage + *pnRGBSize - 12; - const __m128 minus16 = _mm_set_ps1(-16); const __m128 minus128 = _mm_set_ps1(-128); const __m128 plus113983 = _mm_set_ps1(1.13983F); const __m128 minus039466 = _mm_set_ps1(-0.39466F); @@ -149,29 +142,29 @@ void YUV422ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVS // extract the 4 pixels RGB values. // because we made sure values are between 0 and 255, we can just take the lower byte // of each INT16 - pRGBImage[0] = piR[0]; - pRGBImage[1] = piG[0]; - pRGBImage[2] = piB[0]; + pRGBImage[0] = (XnUInt8)piR[0]; + pRGBImage[1] = (XnUInt8)piG[0]; + pRGBImage[2] = (XnUInt8)piB[0]; - pRGBImage[3] = piR[1]; - pRGBImage[4] = piG[1]; - pRGBImage[5] = piB[1]; + pRGBImage[3] = (XnUInt8)piR[1]; + pRGBImage[4] = (XnUInt8)piG[1]; + pRGBImage[5] = (XnUInt8)piB[1]; - pRGBImage[6] = piR[2]; - pRGBImage[7] = piG[2]; - pRGBImage[8] = piB[2]; + pRGBImage[6] = (XnUInt8)piR[2]; + pRGBImage[7] = (XnUInt8)piG[2]; + pRGBImage[8] = (XnUInt8)piB[2]; - pRGBImage[9] = piR[3]; - pRGBImage[10] = piG[3]; - pRGBImage[11] = piB[3]; + pRGBImage[9] = (XnUInt8)piR[3]; + pRGBImage[10] = (XnUInt8)piG[3]; + pRGBImage[11] = (XnUInt8)piB[3]; // advance the streams pYUVImage += 8; pRGBImage += 12; } - *pnActualRead = pYUVImage - pYUVOrig; - *pnRGBSize = pRGBImage - pRGBOrig; + *pnActualRead = (XnUInt32)(pYUVImage - pYUVOrig); + *pnRGBSize = (XnUInt32)(pRGBImage - pRGBOrig); } #else // not Win32 @@ -202,10 +195,9 @@ void YUV422ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVS #endif -void YUV420ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVSize, XnUInt32 nRGBSize) +void YUV420ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVSize, XnUInt32 /*nRGBSize*/) { const XnUInt8* pLastYUV = pYUVImage + nYUVSize - YUV420_BPP; - XnUInt8* pLastRGB = pRGBImage + nRGBSize - 12; while (pYUVImage < pLastYUV && pRGBImage < pYUVImage) { diff --git a/Source/XnDeviceSensorV2/YUV.h b/Source/XnDeviceSensorV2/YUV.h index 2634d72..47ef8e9 100644 --- a/Source/XnDeviceSensorV2/YUV.h +++ b/Source/XnDeviceSensorV2/YUV.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_YUV_H_ #define _XN_YUV_H_ diff --git a/Source/XnFormats/Xn16zCodec.h b/Source/XnFormats/Xn16zCodec.h index 27bc664..a45e50b 100644 --- a/Source/XnFormats/Xn16zCodec.h +++ b/Source/XnFormats/Xn16zCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_16Z_CODEC_H__ #define __XN_16Z_CODEC_H__ diff --git a/Source/XnFormats/Xn16zEmbTablesCodec.h b/Source/XnFormats/Xn16zEmbTablesCodec.h index 44a35dc..4655d9f 100644 --- a/Source/XnFormats/Xn16zEmbTablesCodec.h +++ b/Source/XnFormats/Xn16zEmbTablesCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_16Z_EMB_TABLES_CODEC_H__ #define __XN_16Z_EMB_TABLES_CODEC_H__ diff --git a/Source/XnFormats/Xn8zCodec.h b/Source/XnFormats/Xn8zCodec.h index 1b9f24c..beaae21 100644 --- a/Source/XnFormats/Xn8zCodec.h +++ b/Source/XnFormats/Xn8zCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_8Z_CODEC_H__ #define __XN_8Z_CODEC_H__ diff --git a/Source/XnFormats/XnCodec.h b/Source/XnFormats/XnCodec.h index 8718997..a6e8900 100644 --- a/Source/XnFormats/XnCodec.h +++ b/Source/XnFormats/XnCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_CODEC_H__ #define __XN_CODEC_H__ diff --git a/Source/XnFormats/XnCodecBase.h b/Source/XnFormats/XnCodecBase.h index bef220f..4a4744a 100644 --- a/Source/XnFormats/XnCodecBase.h +++ b/Source/XnFormats/XnCodecBase.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_CODEC_BASE_H__ #define __XN_CODEC_BASE_H__ diff --git a/Source/XnFormats/XnCodecs.cpp b/Source/XnFormats/XnCodecs.cpp index 12b2ebd..73cb5dd 100644 --- a/Source/XnFormats/XnCodecs.cpp +++ b/Source/XnFormats/XnCodecs.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnFormats/XnFormats.cpp b/Source/XnFormats/XnFormats.cpp index 37cb216..90151cf 100644 --- a/Source/XnFormats/XnFormats.cpp +++ b/Source/XnFormats/XnFormats.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnFormats/XnFormats.h b/Source/XnFormats/XnFormats.h index 80779cc..55484bf 100644 --- a/Source/XnFormats/XnFormats.h +++ b/Source/XnFormats/XnFormats.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_FORMATS_H_ #define _XN_FORMATS_H_ diff --git a/Source/XnFormats/XnFormatsMirror.cpp b/Source/XnFormats/XnFormatsMirror.cpp index 3bb3834..aab2219 100644 --- a/Source/XnFormats/XnFormatsMirror.cpp +++ b/Source/XnFormats/XnFormatsMirror.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -84,7 +78,7 @@ XnStatus XnMirrorTwoBytePixels(XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt32 XnUInt16* pDest = NULL; XnUInt16* pDestVal = &pLineBuffer[0] + nLineSize - 1; XnUInt16* pDestEnd = &pLineBuffer[0] - 1; - XnUInt16 nMemCpyLineSize = nLineSize * sizeof(XnUInt16); + XnUInt16 nMemCpyLineSize = (XnUInt16)(nLineSize * sizeof(XnUInt16)); XnUInt16 nValue; if (nLineSize > XN_MIRROR_MAX_LINE_SIZE) @@ -120,7 +114,7 @@ XnStatus XnMirrorThreeBytePixels(XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt3 XnUInt8* pDest = NULL; XnUInt8* pDestVal = &pLineBuffer[0] + nLineSize * 3 - 1; XnUInt8* pDestEnd = &pLineBuffer[0] - 1; - XnUInt16 nMemCpyLineSize = nLineSize * 3; + XnUInt16 nMemCpyLineSize = (XnUInt16)(nLineSize * 3); if (nMemCpyLineSize > XN_MIRROR_MAX_LINE_SIZE) { diff --git a/Source/XnFormats/XnFormatsStatus.cpp b/Source/XnFormats/XnFormatsStatus.cpp index cd5d309..41a7773 100644 --- a/Source/XnFormats/XnFormatsStatus.cpp +++ b/Source/XnFormats/XnFormatsStatus.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- diff --git a/Source/XnFormats/XnJpegCodec.h b/Source/XnFormats/XnJpegCodec.h index 40728e0..8cf5599 100644 --- a/Source/XnFormats/XnJpegCodec.h +++ b/Source/XnFormats/XnJpegCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_JPEG_CODEC_H__ #define __XN_JPEG_CODEC_H__ @@ -71,7 +66,9 @@ class XN_FORMATS_CPP_API XnJpegCodec : public XnCodecBase virtual XnUInt32 GetOverheadSize() const { return 0; } protected: - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) + XN_DISABLE_COPY_AND_ASSIGN(XnJpegCodec); + + virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 /*nDataSize*/, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) { if (m_bRGB) { diff --git a/Source/XnFormats/XnNiCodec.h b/Source/XnFormats/XnNiCodec.h index 51b413c..215d127 100644 --- a/Source/XnFormats/XnNiCodec.h +++ b/Source/XnFormats/XnNiCodec.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_XN_CODEC_H__ #define __XN_XN_CODEC_H__ diff --git a/Source/XnFormats/XnStreamCompression.cpp b/Source/XnFormats/XnStreamCompression.cpp index aea0a55..836188d 100644 --- a/Source/XnFormats/XnStreamCompression.cpp +++ b/Source/XnFormats/XnStreamCompression.cpp @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -73,7 +67,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const X nCurrValue = *pInput; nDiffValue = (nLastValue - nCurrValue); - nAbsDiffValue = abs(nDiffValue); + nAbsDiffValue = (XnUInt16)abs(nDiffValue); if (nAbsDiffValue <= 6) { @@ -81,13 +75,13 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const X if (cOutStage == 0) { - cOutChar = nDiffValue << 4; + cOutChar = (XnUInt8)(nDiffValue << 4); cOutStage = 1; } else { - cOutChar += nDiffValue; + cOutChar += (XnUInt8)nDiffValue; if (cOutChar == 0x66) { @@ -145,7 +139,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const X { nDiffValue += 192; - *pOutput = nDiffValue; + *pOutput = (XnUInt8)nDiffValue; pOutput++; } else @@ -171,7 +165,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const X pOutput++; } - *pnOutputSize = pOutput - pOrigOutput; + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); @@ -239,7 +233,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pIn nCurrValue = nEmbTable[*pInput]; nDiffValue = (nLastValue - nCurrValue); - nAbsDiffValue = abs(nDiffValue); + nAbsDiffValue = (XnUInt16)abs(nDiffValue); if (nAbsDiffValue <= 6) { @@ -247,13 +241,13 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pIn if (cOutStage == 0) { - cOutChar = nDiffValue << 4; + cOutChar = (XnUInt8)(nDiffValue << 4); cOutStage = 1; } else { - cOutChar += nDiffValue; + cOutChar += (XnUInt8)nDiffValue; if (cOutChar == 0x66) { @@ -311,7 +305,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pIn { nDiffValue += 192; - *pOutput = nDiffValue; + *pOutput = (XnUInt8)nDiffValue; pOutput++; } else @@ -337,7 +331,7 @@ XN_FORMATS_API XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pIn pOutput++; } - *pnOutputSize = pOutput - pOrigOutput; + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); @@ -478,7 +472,7 @@ XN_FORMATS_API XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const } } - *pnOutputSize = (pOutput - pOrigOutput) * sizeof(XnUInt16); + *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); // All is good... return (XN_STATUS_OK); @@ -628,7 +622,7 @@ XN_FORMATS_API XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pI } } - *pnOutputSize = (pOutput - pOrigOutput) * sizeof(XnUInt16); + *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); // All is good... return (XN_STATUS_OK); @@ -666,7 +660,7 @@ XN_FORMATS_API XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnU nCurrValue = *pInput; nDiffValue = (nLastValue - nCurrValue); - nAbsDiffValue = abs(nDiffValue); + nAbsDiffValue = (XnUInt8)abs(nDiffValue); if (nAbsDiffValue <= 6) { @@ -765,7 +759,7 @@ XN_FORMATS_API XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnU pOutput++; } - *pnOutputSize = pOutput - pOrigOutput; + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); @@ -884,7 +878,7 @@ XN_FORMATS_API XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const X } } - *pnOutputSize = (pOutput - pOrigOutput); + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); @@ -915,7 +909,7 @@ XN_FORMATS_API XnStatus XnStreamCompressConf4(const XnUInt8* pInput, const XnUIn pOutput++; } - *pnOutputSize = pOutput - pOrigOutput; + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); @@ -963,18 +957,18 @@ XN_FORMATS_API XnStatus XnStreamUncompressConf4(const XnUInt8* pInput, const XnU pInput+=2; } - *pnOutputSize = (pOutput - pOrigOutput); + *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); // All is good... return (XN_STATUS_OK); } -void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* pjCompStruct) +void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* /*pjCompStruct*/) { // Dummy libjpeg function to wrap internal buffers usage... } -boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* pjCompStruct) +boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* /*pjCompStruct*/) { // If we ever got to the point we need to allocate more memory, something is wrong! return (FALSE); @@ -1049,7 +1043,7 @@ XN_FORMATS_API XnStatus XnStreamCompressImage8J(XnStreamCompJPEGContext* pStream jpeg_finish_compress(pjCompStruct); - *pnOutputSize -= pjCompStruct->dest->free_in_buffer; + *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; // All is good... return (XN_STATUS_OK); @@ -1097,18 +1091,18 @@ XN_FORMATS_API XnStatus XnStreamCompressImage24J(XnStreamCompJPEGContext* pStrea jpeg_finish_compress(pjCompStruct); - *pnOutputSize -= pjCompStruct->dest->free_in_buffer; + *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; // All is good... return (XN_STATUS_OK); } -void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* pjDecompStruct) +void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) { // Dummy libjpeg function to wrap internal buffers usage... } -boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* pjDecompStruct) +boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) { // If we ever got to the point we need to allocate more memory, something is wrong! return (FALSE); @@ -1192,6 +1186,10 @@ XN_FORMATS_API XnStatus XnStreamFreeUncompressImageJ(XnStreamUncompJPEGContext* return (XN_STATUS_OK); } +// to allow the use of setjmp +#pragma warning(push) +#pragma warning(disable: 4611) + XN_FORMATS_API XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext, const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) { // Local function variables @@ -1273,3 +1271,5 @@ XN_FORMATS_API XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStr // All is good... return (XN_STATUS_OK); } + +#pragma warning(pop) diff --git a/Source/XnFormats/XnStreamCompression.h b/Source/XnFormats/XnStreamCompression.h index 35f31d1..d49723c 100644 --- a/Source/XnFormats/XnStreamCompression.h +++ b/Source/XnFormats/XnStreamCompression.h @@ -1,30 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef _XN_STREAMCOMPRESSION_H_ #define _XN_STREAMCOMPRESSION_H_ diff --git a/Source/XnFormats/XnUncompressedCodec.h b/Source/XnFormats/XnUncompressedCodec.h index cd6e2e5..4853965 100644 --- a/Source/XnFormats/XnUncompressedCodec.h +++ b/Source/XnFormats/XnUncompressedCodec.h @@ -1,29 +1,24 @@ -/***************************************************************************** -* * -* PrimeSense Sensor 5.0 Alpha * -* Copyright (C) 2010 PrimeSense Ltd. * -* * -* This file is part of PrimeSense Common. * -* * -* PrimeSense Sensor is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* PrimeSense Sensor is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with PrimeSense Sensor. If not, see . * -* * -*****************************************************************************/ - - - - - +/**************************************************************************** +* * +* PrimeSense Sensor 5.x Alpha * +* Copyright (C) 2011 PrimeSense Ltd. * +* * +* This file is part of PrimeSense Sensor. * +* * +* PrimeSense Sensor is free software: you can redistribute it and/or modify* +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* PrimeSense Sensor is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with PrimeSense Sensor. If not, see .* +* * +****************************************************************************/ #ifndef __XN_UNCOMPRESSED_CODEC_H__ #define __XN_UNCOMPRESSED_CODEC_H__