├── INSTALL.txt ├── LICENSE ├── README.md ├── examples ├── CALIBRATION │ ├── CALIBRATION.pde │ ├── Calibrate.pde │ ├── GUI.pde │ └── Util.pde ├── RENDER │ ├── GUI.pde │ ├── RENDER.pde │ ├── Ribbon.pde │ └── data │ │ ├── blobby.glsl │ │ ├── calibration.txt │ │ ├── drip.glsl │ │ ├── waterNoise.glsl │ │ └── waves.glsl ├── TestBackgroundFX │ ├── TestBackgroundFX.pde │ └── data │ │ ├── calibration.txt │ │ └── waves.glsl ├── TestBodyGraphics │ ├── TestBodyGraphics.pde │ └── data │ │ └── calibration.txt ├── TestBodyImage │ ├── TestBodyImage.pde │ └── data │ │ ├── calibration.txt │ │ └── texture.jpg ├── TestBodyMovie │ ├── TestBodyMovie.pde │ └── data │ │ └── calibration.txt ├── TestBodyShader │ ├── TestBodyShader.pde │ └── data │ │ ├── calibration.txt │ │ └── waves.glsl ├── TestConnectHands │ ├── TestConnectHands.pde │ └── data │ │ └── calibration.txt ├── TestFallingPolygons │ ├── TestFallingPolygons.pde │ └── data │ │ ├── calibration.txt │ │ └── texture.jpg ├── TestFireball │ ├── Fireball.pde │ ├── TestFireball.pde │ └── data │ │ └── calibration.txt ├── TestKrang │ ├── TestKrang.pde │ └── data │ │ ├── calibration.txt │ │ └── krang.mp4 ├── TestPhysics │ ├── TestPhysics.pde │ └── data │ │ ├── calibration.txt │ │ └── texture.jpg ├── TestRibbons │ ├── Ribbon.pde │ ├── TestRibbons.pde │ └── data │ │ └── calibration.txt └── TestSkeleton │ ├── TestSkeleton.pde │ └── data │ └── calibration.txt ├── index.html ├── library.properties ├── library ├── Jama-1.0.3.jar └── KinectProjectorToolkit.jar ├── reference ├── KinectProjectorToolkit │ ├── KinectProjectorToolkit.html │ ├── ProjectedContour.html │ ├── package-frame.html │ ├── package-summary.html │ └── package-tree.html ├── allclasses-frame.html ├── allclasses-noframe.html ├── constant-values.html ├── deprecated-list.html ├── help-doc.html ├── index-all.html ├── index.html ├── overview-tree.html ├── package-list ├── resources │ └── inherit.gif └── stylesheet.css ├── src └── KinectProjectorToolkit │ ├── KinectProjectorToolkit.java │ └── ProjectedContour.java └── stylesheet.css /INSTALL.txt: -------------------------------------------------------------------------------- 1 | How to install library Kinect Projector Toolkit 2 | 3 | 4 | Install with the "Add Library..." tool 5 | 6 | New for Processing 2.0: Add contributed libraries by selecting "Add Library..." 7 | from the "Import Library..." submenu within the Sketch menu. Not all available 8 | libraries have been converted to show up in this menu. If a library isn't there, 9 | it will need to be installed manually by following the instructions below. 10 | 11 | 12 | Manual Install 13 | 14 | Contributed libraries may be downloaded separately and manually placed within 15 | the "libraries" folder of your Processing sketchbook. To find (and change) the 16 | Processing sketchbook location on your computer, open the Preferences window 17 | from the Processing application (PDE) and look for the "Sketchbook location" 18 | item at the top. 19 | 20 | Copy the contributed library's folder into the "libraries" folder at this 21 | location. You will need to create the "libraries" folder if this is your first 22 | contributed library. 23 | 24 | By default the following locations are used for your sketchbook folder: 25 | For Mac users, the sketchbook folder is located inside ~/Documents/Processing. 26 | For Windows users, the sketchbook folder is located inside 27 | 'My Documents'/Processing. 28 | 29 | The folder structure for library Kinect Projector Toolkit should be as follows: 30 | 31 | Processing 32 | libraries 33 | Kinect Projector Toolkit 34 | examples 35 | library 36 | Kinect Projector Toolkit.jar 37 | reference 38 | src 39 | 40 | Some folders like "examples" or "src" might be missing. After library 41 | Kinect Projector Toolkit has been successfully installed, restart the Processing 42 | application. 43 | 44 | 45 | If you're having trouble, have a look at the Processing Wiki for more 46 | information: http://wiki.processing.org/w/How_to_Install_a_Contributed_Library 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Kinect Projector Toolkit 2 | 3 | Processing library for calibrating a kinect and a projector together, such that projected image is automatically aligned to the physical space it is projecting onto, facilitating the projection of images onto moving bodies and surfaces. 4 | 5 | To see some applications of the software, see this [highlight video](http://vimeo.com/81914893) of a workshop applying the software to live dance. 6 | 7 | The calibration methodology comes from this writeup by [Jan Hrdlička at 3dsense blog](http://blog.3dsense.org/programming/kinect-projector-calibration-human-mapping-2/). For other work on Projector/Kinect calibration, see works and code by [Elliot Woods, Kyle McDonald](https://github.com/elliotwoods/artandcode.Camera-and-projector-calibration), and [Daito Manabe](http://thecreatorsproject.vice.com/blog/projection-mapped-dance-performance-daito-manabe), as well as the OpenFrameworks addon [ofxCamaraLucida](http://chparsons.com.ar/#camara_lucida). 8 | 9 | ##V2 version 10 | 11 | A very nice-looking fork of this for Kinect V2 is available [here](https://github.com/bradenneufeld/K2P3Toolkit). 12 | 13 | ##Installation 14 | 15 | The library requires [Processing 2.0+](http://www.processing.org), [SimpleOpenNI](https://code.google.com/p/simple-openni/), [ControlP5](http://www.sojamo.de/libraries/controlP5/), and [OpenCV](https://github.com/atduskgreg/opencv-processing). 16 | 17 | To install the library, copy the entire contents of this repository into a folder called "KinectProjectorToolkit" inside your Processing libraries folder, as any other library. 18 | 19 | The library comes with a number of demos in the "examples" folder, as well as a program called **CALIBRATION.pde** which is the application used for determining the fit between the projector and Kinect. Instructions for calibration follow below. 20 | 21 | 22 | ##Instructions for calibration 23 | 24 | ###*[Video tutorial for calibration](http://vimeo.com/84658886)* 25 | 26 | ###1) Room setup 27 | 28 | After setting the projector, fix the Kinect to face the space onto which you are projecting. Ideally, the Kinect is tracking roughly the full space of the projection; if it is too close it may not see everything the projector sees, and if it is too far, it will be less precise. Unless you have a short-throw projector, the Kinect will probably be closer to the stage than the projector. 29 | 30 | The Kinect and projector must be *totally immobilized* during calibration and after, because a calibration only works for that positioning of the two devices together. 31 | 32 | 33 | ###2) Software setup 34 | 35 | Set your computer's display to extended/dual screen and project the secondary screen. Open up **CALIBRATION.pde** and make sure to set the `pWidth` and `pHeight` variables at the top to exactly match the resolution of the secondary display, e.g. 1024x768. 36 | 37 | Finally, set the `calibFilename` variable to the exact path to which you want to save the calibration file to. 38 | 39 | ![Setting up display](http://www.genekogan.com/images/kinect-projector-toolkit/kpt_screen_1.jpg) 40 | 41 | 42 | ###3) Getting point pairs 43 | 44 | The interface allows you to position a 5x4 chessboard which is being projected onto your stage/room. You can move its position using the XY grid on the right side of the interface, and resize it using the "size" slider. The "searching" button toggles whether the app is actively searching for a chessboard pattern. 45 | 46 | ![Setting up display](http://www.genekogan.com/images/kinect-projector-toolkit/kpt_screen_2.jpg) 47 | 48 | You need some sort of a flat, mobile panel (best if white) to project onto. Place the panel somewhere in front of the Kinect, and position the projected chessboard onto it. When the chessboard is visible in the Kinect RGB view on the left of the interface, toggle the "searching" button to have the program search for the chessboard. If it finds it, you should see 12 green circles pop up over the corners of the chessboard in the interface, and the "add pair" button becomes visible. If the green circles are not coming up, the chessboard can not be found in the image, which means the chessboard is too small or the lighting is not adequate. See the tutorial video for a good example. If the circles do appear, but some or all of them are red, it means the chessboard is either too close or too far from the Kinect and it can't read the depth; move it into an appropriate range. Only when 12 green circles are visible is the "add pair" button accessible. 49 | 50 | ![Setting up display](http://www.genekogan.com/images/kinect-projector-toolkit/kpt_screen_3.jpg) 51 | 52 | Repeat this process for a series of panel positions throughout your stage space. To get the best possible fit, you should sample the space as widely as possible. Move the board to at least two or three different depths (distance from the Kinect), and position the board at high and low positions as well. The more dispersed your board points are across all three spatial dimensions, the better your fit will be. If the points are mostly coplanar, the model may not generalize well to undersampled regions. 53 | 54 | 55 | ###4) Calibration 56 | 57 | Depending on the demands of your application, you may need only a few board positions, or several dozen. Generally, 10-15 board positions gives a good fit, with each position contributing 12 point pairs. When you have a good amount of point pairs, click the "calibrate" button. This will generate a calibration. 58 | 59 | Once you have generated a calibration, you can toggle into "Testing mode" which allows you to test the fit. In testing mode, you can click anywhere on the Kinect image to place a red dot over a desired point in the camera image. A corresponding green point should then be projected onto that same location in your physical space. If the calibration is good, the red dot in the Kinect's image and the green one in the physical space should match. Try a few points at different locations to test the accuracy of the calibration. 60 | 61 | If the calibration is satisfactory, click "Save." It will generate a text file containing the calibration parameters, which will be located in the path you specified in the `calibFilename` variable. 62 | 63 | 64 | ##Using the calibration 65 | 66 | The core function of the library is the ability to map any 3d point in physical space to the corresponding pixel which falls on that point. The process goes as follows. 67 | 68 | First, set up the Kinect and OpenCV. Make sure to run the Kinect's `alternativeViewPointDepthToImage()` so that the RGB and depth maps are aligned. 69 | 70 | kinect = new SimpleOpenNI(this); 71 | kinect.enableDepth(); 72 | kinect.alternativeViewPointDepthToImage(); 73 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 74 | 75 | Next, load your calibration file (replace `CALIBRATION_PATH` with the path to the calibration file saved from the process described above). 76 | 77 | kpt = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 78 | kpt.loadCalibration(CALIBRATION_PATH); 79 | 80 | In a frame, update the Kinect and then send its real world depth map to the KinectProjectorToolkit object. 81 | 82 | kinect.update(); 83 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 84 | 85 | Then, given a point from the real world depth map, you can obtain its pixel coordinate by running the `convertKinectToProjector()` method. The point can be, for example, the real world point of a tracked skeleton's hand. Make sure you are sampling from `depthMapRealWorld()` not `depthMap()`. So given real world PVector realWorldPoint, the projected coordinate is accessible via: 86 | 87 | PVector projectedPoint = kpt.convertKinectToProjector(realWorldPoint); 88 | 89 | The toolkit has some higher level functions which automate some of this, depending on the specific task. For example, if you are tracking a skeleton and have an ArrayList of PVectors which correspond to a tracked object's contour points, you can convert all of them using the function `getProjectedContour(ArrayList contourPoints)`. 90 | 91 | An optional second parameter "dilates" the projected contour, i.e. stretches or compresses it. For example, `getProjectedContour(ArrayList contourPoints, 2.0)` will return a projected contour which has been stretched out to double its original dimensions; this can be useful, for example, in tracing a user's contour on the screen behind them. The default dilation is 1.0 (original size, no stretching). 92 | 93 | The test applications in the library demonstrate some of these tasks. 94 | 95 | 96 | ##Test applications 97 | 98 | The library contains a number of examples, prefixed "Test" which demonstrate various uses of the toolkit for creative projection. Demos include projecting an image onto a human body, projecting images onto specific tracked parts of a body, graphics projected onto background surfaces interacting with tracked bodies, etc. 99 | 100 | You must first make sure to go through the calibration process and generate the calibration file. Before running any of the demos, you must change the location of the loaded calibration file to the calibration you generated in the first step, and modify the line in the example accordingly. 101 | 102 | kpt.loadCalibration(YOUR_PATH_HERE); 103 | 104 | Descriptions for test applications follow below: 105 | 106 | ###TestSkeleton, TestKrang, TestFireball 107 | These demos are the simplest applications of the calibration. The Kinect tracks users and returns real world coordinates for their joints and limbs, and we project objects onto them. Skeleton projects the entire skeleton onto each person, Krang projects an image of [Krang](http://en.wikipedia.org/wiki/Krang) onto users' torsos. 108 | 109 | ###TestBodyGraphics, TestBodyImage, TestBodyMovie, TestBodyShader 110 | Show the process of projecting graphics onto a tracked human body, via the Kinect's userImage. They are identical, except for the content of the graphics, showing how to project a PGraphics object, a PImage, a Movie, and a shader, respectively. 111 | 112 | ###TestRibbons 113 | Similar to the body projection examples, but instead projects ribbon-like lines around the contour of a body, tracing them onto the background behind the user. 114 | 115 | ###TestBackgroundFX 116 | This example shows how a tracked user can manipulate background graphics projected behind them onto a screen or floor. 117 | 118 | ###TestFallingPolygons 119 | Similar to TestBackgroundFX as it involves a user manipulating a background screen. A game in which polygons fall from the sky and a user can physically interact with them on a wall. 120 | 121 | ###RENDER 122 | This is a high-level application combining the previous examples with a user interface for applying the effects. It is currently still under development. 123 | -------------------------------------------------------------------------------- /examples/CALIBRATION/CALIBRATION.pde: -------------------------------------------------------------------------------- 1 | //========================================================== 2 | // set resolution of your projector image/second monitor 3 | // and name of your calibration file-to-be 4 | int pWidth = 1024; 5 | int pHeight = 768; 6 | String calibFilename = "calibration.txt"; 7 | 8 | 9 | //========================================================== 10 | //========================================================== 11 | 12 | import javax.swing.JFrame; 13 | import SimpleOpenNI.*; 14 | import gab.opencv.*; 15 | import controlP5.*; 16 | import Jama.*; 17 | 18 | SimpleOpenNI kinect; 19 | OpenCV opencv; 20 | ChessboardFrame frameBoard; 21 | ChessboardApplet ca; 22 | PVector[] depthMap; 23 | ArrayList foundPoints = new ArrayList(); 24 | ArrayList projPoints = new ArrayList(); 25 | ArrayList ptsK, ptsP; 26 | PVector testPoint, testPointP; 27 | boolean isSearchingBoard = false; 28 | boolean calibrated = false; 29 | boolean testingMode = false; 30 | int cx, cy, cwidth; 31 | 32 | void setup() 33 | { 34 | size(1200, 768); 35 | textFont(createFont("Courier", 24)); 36 | frameBoard = new ChessboardFrame(); 37 | 38 | // set up kinect 39 | kinect = new SimpleOpenNI(this); 40 | kinect.setMirror(false); 41 | kinect.enableDepth(); 42 | //kinect.kinect.enableIR(); 43 | kinect.enableRGB(); 44 | kinect.alternativeViewPointDepthToImage(); 45 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 46 | 47 | // matching pairs 48 | ptsK = new ArrayList(); 49 | ptsP = new ArrayList(); 50 | testPoint = new PVector(); 51 | testPointP = new PVector(); 52 | setupGui(); 53 | } 54 | 55 | void draw() 56 | { 57 | // draw chessboard onto scene 58 | projPoints = drawChessboard(cx, cy, cwidth); 59 | 60 | // update kinect and look for chessboard 61 | kinect.update(); 62 | depthMap = kinect.depthMapRealWorld(); 63 | opencv.loadImage(kinect.rgbImage()); 64 | //opencv.loadImage(kinect.irImage()); 65 | opencv.gray(); 66 | 67 | if (isSearchingBoard) 68 | foundPoints = opencv.findChessboardCorners(4, 3); 69 | 70 | drawGui(); 71 | } 72 | 73 | void drawGui() 74 | { 75 | background(0, 100, 0); 76 | 77 | // draw the RGB image 78 | pushMatrix(); 79 | translate(30, 120); 80 | textSize(22); 81 | fill(255); 82 | //image(kinect.irImage(), 0, 0); 83 | image(kinect.rgbImage(), 0, 0); 84 | 85 | // draw chessboard corners, if found 86 | if (isSearchingBoard) { 87 | int numFoundPoints = 0; 88 | for (PVector p : foundPoints) { 89 | if (getDepthMapAt((int)p.x, (int)p.y).z > 0) { 90 | fill(0, 255, 0); 91 | numFoundPoints += 1; 92 | } 93 | else fill(255, 0, 0); 94 | ellipse(p.x, p.y, 5, 5); 95 | } 96 | if (numFoundPoints == 12) guiAdd.show(); 97 | else guiAdd.hide(); 98 | } 99 | else guiAdd.hide(); 100 | if (calibrated && testingMode) { 101 | fill(255, 0, 0); 102 | ellipse(testPoint.x, testPoint.y, 10, 10); 103 | } 104 | popMatrix(); 105 | 106 | // draw GUI 107 | pushMatrix(); 108 | pushStyle(); 109 | translate(kinect.depthWidth()+70, 40); 110 | fill(0); 111 | rect(0, 0, 450, 680); 112 | fill(255); 113 | text(ptsP.size()+" pairs", 26, guiPos.y+525); 114 | popStyle(); 115 | popMatrix(); 116 | } 117 | 118 | ArrayList drawChessboard(int x0, int y0, int cwidth) { 119 | ArrayList projPoints = new ArrayList(); 120 | int cheight = (int)(cwidth * 0.8); 121 | ca.background(255); 122 | ca.fill(0); 123 | for (int j=0; j<4; j++) { 124 | for (int i=0; i<5; i++) { 125 | int x = int(x0 + map(i, 0, 5, 0, cwidth)); 126 | int y = int(y0 + map(j, 0, 4, 0, cheight)); 127 | if (i>0 && j>0) projPoints.add(new PVector((float)x/pWidth, (float)y/pHeight)); 128 | if ((i+j)%2==0) ca.rect(x, y, cwidth/5, cheight/4); 129 | } 130 | } 131 | ca.fill(0, 255, 0); 132 | if (calibrated) 133 | ca.ellipse(testPointP.x, testPointP.y, 20, 20); 134 | ca.redraw(); 135 | return projPoints; 136 | } 137 | 138 | 139 | void addPointPair() { 140 | if (projPoints.size() == foundPoints.size()) { 141 | for (int i=0; i> allProjectedContours; 11 | ArrayList ribbons; 12 | boolean renderBody, renderRibbons, ribbonIsCurved, ribbonIsWhite, guiVisible=true; 13 | PGraphics pg, bg; 14 | PShader shade, bgshade; 15 | float blobDilate, ribbonNoiseFactor, ribbonThickness; 16 | int ribbonSpawnRate, ribbonMaxAge, ribbonLength, ribbonSpeed, ribbonSkip, ribbonMargin, ribbonAlpha; 17 | int samplingMode, idxShader, numframes, idxBg; 18 | 19 | void setup() 20 | { 21 | size(displayWidth, displayHeight, P2D); 22 | 23 | // setup Kinect 24 | kinect = new SimpleOpenNI(this); 25 | kinect.enableDepth(); 26 | kinect.enableUser(); 27 | kinect.alternativeViewPointDepthToImage(); 28 | 29 | // setup OpenCV 30 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 31 | //opencv = new OpenCV(this, 640, 480); 32 | 33 | // setup Kinect Projector Toolkit 34 | //kpc = new KinectProjectorToolkit(this, 640, 480); 35 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight());// kinect.depthWidth(), kinect.depthHeight()); 36 | kpc.loadCalibration("calibration.txt"); 37 | kpc.setContourSmoothness(3); 38 | 39 | // initialize ribbons 40 | ribbons = new ArrayList(); 41 | 42 | // shaders and body graphics 43 | pg = createGraphics(600, 800, P2D); 44 | bg = createGraphics(width, height, P2D); 45 | setupShader(idxShader); 46 | setupBackground(idxBg); 47 | 48 | // archive of projected contours 49 | allProjectedContours = new ArrayList>(); 50 | 51 | setupGUI(); 52 | } 53 | 54 | void setupShader(int idxShader) { 55 | if (idxShader == 0) 56 | shade = loadShader("blobby.glsl"); 57 | else if (idxShader == 1) { 58 | shade = loadShader("drip.glsl"); 59 | shade.set("intense", 0.5); 60 | shade.set("speed", 3.0); 61 | shade.set("c", 0.5, 1.0); 62 | } 63 | else if (idxShader == 2) 64 | shade = loadShader("waterNoise.glsl"); 65 | else if (idxShader == 3) 66 | shade = loadShader("waves.glsl"); 67 | shade.set("resolution", float(pg.width), float(pg.height)); 68 | pg.shader(shade); 69 | } 70 | 71 | void setupBackground(int idxBg) { 72 | if (idxBg == 0) { 73 | bg.beginDraw(); 74 | bg.background(0); 75 | bg.endDraw(); 76 | bg.resetShader(); 77 | } 78 | else if (idxBg == 1) { 79 | bg.beginDraw(); 80 | bg.background(255); 81 | bg.endDraw(); 82 | bg.resetShader(); 83 | } 84 | else if (idxBg == 2) { 85 | bgshade = loadShader("blobby.glsl"); 86 | bgshade.set("resolution", float(bg.width), float(bg.height)); 87 | bg.shader(bgshade); 88 | } 89 | else if (idxBg == 3) { 90 | bgshade = loadShader("drip.glsl"); 91 | bgshade.set("intense", 0.5); 92 | bgshade.set("speed", 3.0); 93 | bgshade.set("c", 0.5, 1.0); 94 | bgshade.set("resolution", float(bg.width), float(bg.height)); 95 | bg.shader(bgshade); 96 | } 97 | else if (idxBg == 4) { 98 | bgshade = loadShader("waterNoise.glsl"); 99 | bgshade.set("resolution", float(bg.width), float(bg.height)); 100 | bg.shader(bgshade); 101 | } 102 | else if (idxBg == 5) { 103 | bgshade = loadShader("waves.glsl"); 104 | bgshade.set("resolution", float(bg.width), float(bg.height)); 105 | bg.shader(bgshade); 106 | } 107 | } 108 | 109 | void draw() 110 | { 111 | kinect.update(); 112 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 113 | kpc.setKinectUserImage(kinect.userImage()); 114 | opencv.loadImage(kpc.getImage()); 115 | 116 | // get projected contours 117 | ArrayList projectedContours = new ArrayList(); 118 | 119 | ArrayList contours = opencv.findContours(); 120 | for (Contour contour : contours) { 121 | if (contour.area() > 2000) { 122 | ArrayList cvContour = contour.getPoints(); 123 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, blobDilate); 124 | projectedContours.add(projectedContour); 125 | } 126 | } 127 | 128 | // add to running list of projected contours 129 | allProjectedContours.add(projectedContours); 130 | while (allProjectedContours.size() > numframes) allProjectedContours.remove(0); 131 | 132 | // get current projected contours depending on strategy 133 | int t = allProjectedContours.size()-1; 134 | if (samplingMode == 1) 135 | t = (int) map(sin(0.01*frameCount), -1, 1, 0, allProjectedContours.size() - 1); 136 | else if (samplingMode == 2) 137 | t = (int) map(mouseX, 0, width, 0, allProjectedContours.size() - 1); 138 | projectedContours = allProjectedContours.get(t); 139 | 140 | // draw background 141 | if (idxBg > 1) { 142 | bgshade.set("time", millis()/1000.0); 143 | bg.beginDraw(); 144 | bg.rect(0, 0, bg.width, bg.height); 145 | bg.endDraw(); 146 | } 147 | image(bg, 0, 0); 148 | 149 | 150 | // render bodies 151 | if (renderBody) { 152 | for (int i=0; i 0) addNewRibbons(t, ribbonSpawnRate); 174 | ArrayList nextRibbons = new ArrayList(); 175 | for (Ribbon r : ribbons) { 176 | r.update(); 177 | r.draw(); 178 | if (r.age < r.maxAge) nextRibbons.add(r); 179 | } 180 | ribbons = nextRibbons; 181 | } 182 | 183 | // for gui 184 | if (guiVisible) { 185 | fill(0, 100); 186 | rect(36, 24, 500, 640); 187 | } 188 | } 189 | 190 | void addNewRibbons(int t, int n) { 191 | ArrayList projectedContours = allProjectedContours.get(t); 192 | for (int i=0; i contourPoints = projectedContours.get(p).getProjectedContours(); 195 | Ribbon newRibbon = new Ribbon(contourPoints); 196 | ribbons.add(newRibbon); 197 | } 198 | } 199 | 200 | void keyPressed() { 201 | if (key=='g') { 202 | if (cp5.isVisible()) { 203 | cp5.hide(); 204 | guiVisible = false; 205 | } 206 | else { 207 | cp5.show(); 208 | guiVisible = true; 209 | } 210 | } 211 | } -------------------------------------------------------------------------------- /examples/RENDER/Ribbon.pde: -------------------------------------------------------------------------------- 1 | class Ribbon 2 | { 3 | ArrayList contour; 4 | int age, maxAge, pos, len, speed, skip, margin, alph; 5 | color col; 6 | float noiseFactor, thickness; 7 | boolean isCurved; 8 | 9 | Ribbon(ArrayList contour) { 10 | this.contour = contour; 11 | pos = (int) random(contour.size()); 12 | age = 0; 13 | maxAge = (int) random(cp5.getController("ribbonMaxAge").getArrayValue(0), cp5.getController("ribbonMaxAge").getArrayValue(1)); 14 | len = (int) random(cp5.getController("ribbonLength").getArrayValue(0), cp5.getController("ribbonLength").getArrayValue(1)); 15 | skip = (int) random(cp5.getController("ribbonSkip").getArrayValue(0), cp5.getController("ribbonSkip").getArrayValue(1)); 16 | speed = (int) random(cp5.getController("ribbonSpeed").getArrayValue(0), cp5.getController("ribbonSpeed").getArrayValue(1)); 17 | margin = (int) random(cp5.getController("ribbonMargin").getArrayValue(0), cp5.getController("ribbonMargin").getArrayValue(1)); 18 | noiseFactor = random(cp5.getController("ribbonNoiseFactor").getArrayValue(0), cp5.getController("ribbonNoiseFactor").getArrayValue(1)); 19 | thickness = random(cp5.getController("ribbonThickness").getArrayValue(0), cp5.getController("ribbonThickness").getArrayValue(1)); 20 | alph = (int) random(cp5.getController("ribbonAlpha").getArrayValue(0), cp5.getController("ribbonAlpha").getArrayValue(1)); 21 | isCurved = ribbonIsCurved; 22 | if (ribbonIsWhite) col = color(255); else col = color(0); 23 | } 24 | 25 | void update() { 26 | age++; 27 | pos = (pos + speed) % contour.size(); 28 | } 29 | 30 | void draw() { 31 | pushStyle(); 32 | noFill(); 33 | stroke(col, map(abs(age - 0.5*maxAge), 0.5*maxAge, 0, 0, alph)); 34 | strokeWeight(thickness); 35 | beginShape(); 36 | for (int i=0; i projectedContours; 9 | PVector[] pts; 10 | 11 | int NUM_PTS = 256; 12 | float LERP_RATE = 0.1; 13 | 14 | void setup() 15 | { 16 | size(displayWidth, displayHeight, P2D); 17 | 18 | // setup Kinect 19 | kinect = new SimpleOpenNI(this); 20 | kinect.enableDepth(); 21 | kinect.enableUser(); 22 | kinect.alternativeViewPointDepthToImage(); 23 | 24 | // setup OpenCV 25 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 26 | 27 | // setup Kinect Projector Toolkit 28 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 29 | kpc.loadCalibration("calibration.txt"); 30 | kpc.setContourSmoothness(3); 31 | 32 | pts = new PVector[NUM_PTS]; 33 | for (int i=0; i(); 46 | ArrayList contours = opencv.findContours(); 47 | for (Contour contour : contours) { 48 | if (contour.area() > 2000) { 49 | ArrayList cvContour = contour.getPoints(); 50 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 51 | projectedContours.add(projectedContour); 52 | } 53 | } 54 | 55 | // make for arbitrary number of people 56 | 57 | // draw projected contours 58 | background(0); 59 | for (int i=0; i contour = projectedContour.getProjectedContours(); 62 | for (int j=0; j projectedContours; 9 | ArrayList projectedGraphics; 10 | 11 | void setup() 12 | { 13 | size(displayWidth, displayHeight, P2D); 14 | 15 | // setup Kinect 16 | kinect = new SimpleOpenNI(this); 17 | kinect.enableDepth(); 18 | kinect.enableUser(); 19 | kinect.alternativeViewPointDepthToImage(); 20 | 21 | // setup OpenCV 22 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 23 | 24 | // setup Kinect Projector Toolkit 25 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 26 | kpc.loadCalibration("calibration.txt"); 27 | kpc.setContourSmoothness(4); 28 | 29 | projectedGraphics = initializeProjectedGraphics(); 30 | } 31 | 32 | void draw() 33 | { 34 | kinect.update(); 35 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 36 | kpc.setKinectUserImage(kinect.userImage()); 37 | opencv.loadImage(kpc.getImage()); 38 | 39 | // get projected contours 40 | projectedContours = new ArrayList(); 41 | ArrayList contours = opencv.findContours(); 42 | for (Contour contour : contours) { 43 | if (contour.area() > 2000) { 44 | ArrayList cvContour = contour.getPoints(); 45 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 46 | projectedContours.add(projectedContour); 47 | } 48 | } 49 | 50 | // draw projected contours 51 | background(0); 52 | for (int i=0; i initializeProjectedGraphics() { 66 | ArrayList projectedGraphics = new ArrayList(); 67 | for (int p=0; p<3; p++) { 68 | color col = color(random(255), random(255), random(255)); 69 | PGraphics pg = createGraphics(800, 400, P2D); 70 | pg.beginDraw(); 71 | pg.background(random(255)); 72 | pg.noStroke(); 73 | for (int i=0; i<100; i++) { 74 | pg.fill(red(col)+(int)random(-30,30), green(col)+(int)random(-30,30), blue(col)+(int)random(-30,30)); 75 | if (p==0) pg.ellipse(random(pg.width), random(pg.height), random(200), random(200)); 76 | else if (p==1) pg.rect(random(pg.width), random(pg.height), random(200), random(200)); 77 | else if (p==2) pg.triangle(random(pg.width), random(pg.height), random(pg.width), random(pg.height), random(pg.width), random(pg.height)); 78 | } 79 | pg.endDraw(); 80 | projectedGraphics.add(pg); 81 | } 82 | return projectedGraphics; 83 | } -------------------------------------------------------------------------------- /examples/TestBodyGraphics/data/calibration.txt: -------------------------------------------------------------------------------- 1 | 0.002608315897860353 2 | 1.0505449155879362E-4 3 | 8.982701873834213E-4 4 | 0.23785498857906104 5 | -5.639679676254882E-5 6 | -0.004125835503480505 7 | 0.0016941417243858412 8 | -1.6183115185985817 9 | -1.489422746804211E-5 10 | 2.3627671020597305E-4 11 | 0.0016099040009057567 -------------------------------------------------------------------------------- /examples/TestBodyImage/TestBodyImage.pde: -------------------------------------------------------------------------------- 1 | import gab.opencv.*; 2 | import SimpleOpenNI.*; 3 | import KinectProjectorToolkit.*; 4 | 5 | SimpleOpenNI kinect; 6 | OpenCV opencv; 7 | KinectProjectorToolkit kpc; 8 | ArrayList projectedContours; 9 | PImage img; 10 | 11 | void setup() 12 | { 13 | size(displayWidth, displayHeight, P2D); 14 | 15 | // setup Kinect 16 | kinect = new SimpleOpenNI(this); 17 | kinect.enableDepth(); 18 | kinect.enableUser(); 19 | kinect.alternativeViewPointDepthToImage(); 20 | 21 | // setup OpenCV 22 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 23 | 24 | // setup Kinect Projector Toolkit 25 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 26 | kpc.loadCalibration("calibration.txt"); 27 | kpc.setContourSmoothness(4); 28 | 29 | // load image 30 | img = loadImage("texture.jpg"); 31 | } 32 | 33 | void draw() 34 | { 35 | kinect.update(); 36 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 37 | kpc.setKinectUserImage(kinect.userImage()); 38 | opencv.loadImage(kpc.getImage()); 39 | 40 | // get projected contours 41 | projectedContours = new ArrayList(); 42 | ArrayList contours = opencv.findContours(); 43 | for (Contour contour : contours) { 44 | if (contour.area() > 2000) { 45 | ArrayList cvContour = contour.getPoints(); 46 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 47 | projectedContours.add(projectedContour); 48 | } 49 | } 50 | 51 | // draw projected contours 52 | background(0); 53 | for (int i=0; i projectedContours; 10 | Movie mov; 11 | 12 | void setup() 13 | { 14 | size(displayWidth, displayHeight, P2D); 15 | 16 | // setup Kinect 17 | kinect = new SimpleOpenNI(this); 18 | kinect.enableDepth(); 19 | kinect.enableUser(); 20 | kinect.alternativeViewPointDepthToImage(); 21 | 22 | // setup OpenCV 23 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 24 | 25 | // setup Kinect Projector Toolkit 26 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 27 | kpc.loadCalibration("calibration.txt"); 28 | kpc.setContourSmoothness(4); 29 | 30 | // load image 31 | mov = new Movie(this, "/Users/Gene/Movies/german_train_grid.mov"); 32 | mov.loop(); 33 | } 34 | 35 | void movieEvent(Movie m) { 36 | m.read(); 37 | } 38 | 39 | void draw() 40 | { 41 | kinect.update(); 42 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 43 | kpc.setKinectUserImage(kinect.userImage()); 44 | opencv.loadImage(kpc.getImage()); 45 | 46 | // get projected contours 47 | projectedContours = new ArrayList(); 48 | ArrayList contours = opencv.findContours(); 49 | for (Contour contour : contours) { 50 | if (contour.area() > 2000) { 51 | ArrayList cvContour = contour.getPoints(); 52 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 53 | projectedContours.add(projectedContour); 54 | } 55 | } 56 | 57 | // draw projected contours 58 | background(0); 59 | for (int i=0; i projectedContours; 9 | PGraphics pg; 10 | PShader shade; 11 | 12 | void setup() 13 | { 14 | size(displayWidth, displayHeight, P2D); 15 | 16 | // setup Kinect 17 | kinect = new SimpleOpenNI(this); 18 | kinect.enableDepth(); 19 | kinect.enableUser(); 20 | kinect.alternativeViewPointDepthToImage(); 21 | 22 | // setup OpenCV 23 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 24 | 25 | // setup Kinect Projector Toolkit 26 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 27 | kpc.loadCalibration("calibration.txt"); 28 | kpc.setContourSmoothness(4); 29 | 30 | // load shader and PGraphics 31 | pg = createGraphics(600, 800, P2D); 32 | shade = loadShader("waves.glsl"); 33 | shade.set("resolution", float(pg.width), float(pg.height)); 34 | pg.shader(shade); 35 | } 36 | 37 | void draw() 38 | { 39 | kinect.update(); 40 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 41 | kpc.setKinectUserImage(kinect.userImage()); 42 | opencv.loadImage(kpc.getImage()); 43 | 44 | // get projected contours 45 | projectedContours = new ArrayList(); 46 | ArrayList contours = opencv.findContours(); 47 | for (Contour contour : contours) { 48 | if (contour.area() > 2000) { 49 | ArrayList cvContour = contour.getPoints(); 50 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 51 | projectedContours.add(projectedContour); 52 | } 53 | } 54 | 55 | // draw PGraphics object with shader 56 | shade.set("time", millis()/1000.0); 57 | pg.beginDraw(); 58 | pg.rect(0, 0, pg.width, pg.height); 59 | pg.endDraw(); 60 | 61 | // draw projected contours 62 | background(0); 63 | for (int i=0; i projectedContours; 10 | FWorld world; 11 | ArrayList users; 12 | 13 | void setup() 14 | { 15 | size(displayWidth, displayHeight, P2D); 16 | 17 | // setup Kinect 18 | kinect = new SimpleOpenNI(this); 19 | kinect.enableDepth(); 20 | kinect.enableUser(); 21 | kinect.alternativeViewPointDepthToImage(); 22 | 23 | // setup OpenCV 24 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 25 | 26 | // setup Kinect Projector Toolkit 27 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 28 | kpc.loadCalibration("calibration.txt"); 29 | kpc.setContourSmoothness(4); 30 | 31 | // setup physics 32 | Fisica.init(this); 33 | world = new FWorld(); 34 | world.setGravity(0, 800); 35 | world.setEdges(this, color(0)); 36 | world.setEdgesRestitution(1.0); 37 | users = new ArrayList(); 38 | } 39 | 40 | void draw() 41 | { 42 | kinect.update(); 43 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 44 | kpc.setKinectUserImage(kinect.userImage()); 45 | opencv.loadImage(kpc.getImage()); 46 | 47 | // reset physics obstacles 48 | for (FPoly user : users) world.remove(user); 49 | users = new ArrayList(); 50 | 51 | // for each projected contour, create new user obstacle 52 | projectedContours = new ArrayList(); 53 | ArrayList contours = opencv.findContours(); 54 | for (Contour contour : contours) { 55 | if (contour.area() > 2000) { 56 | ArrayList cvContour = contour.getPoints(); 57 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 58 | projectedContours.add(projectedContour); 59 | 60 | FPoly newUser = new FPoly(); 61 | newUser.setStrokeWeight(0); 62 | newUser.setFill(255, 255, 255); 63 | newUser.setDensity(10); 64 | newUser.setRestitution(0.5); 65 | ArrayList p = projectedContour.getProjectedContours(); 66 | for (int i=0; i next = new ArrayList(); 12 | for (Fireball fireball : fireballs) { 13 | fireball.update(); 14 | fireball.draw(); 15 | if (fireball.active) next.add(fireball); 16 | } 17 | fireballs = next; 18 | } 19 | 20 | void renderFireball() { 21 | pgFireball.beginDraw(); 22 | pgFireball.clear(); 23 | pgFireball.colorMode(HSB); 24 | pgFireball.noStroke(); 25 | pgFireball.translate(pgFireball.width/2, pgFireball.height/2); 26 | for (int k=0; k<24; k++) { 27 | pgFireball.fill(map(k, 0, 24, 5, 40), 28 | map(noise(0.01*k+10, 0.01*frameCount+15), 0, 1, 180, 250), 29 | map(noise(0.01*k+20, 0.01*frameCount+25), 0, 1, 180, 250), 100); 30 | pgFireball.rotate(noise(k)); 31 | pgFireball.beginShape(); 32 | for (int i=0; i<120; i++) { 33 | float ang = map(i, 0, 120, 0, TWO_PI); 34 | float rad = map(noise(0.04*i+k, 0.03*frameCount+5), 0, 1, 35 | map(k, 0, 24, pgFireball.width/6, 0), 36 | map(k, 0, 24, pgFireball.width/2, 10)); 37 | float x = rad * cos(ang); 38 | float y = rad * sin(ang); 39 | pgFireball.curveVertex(x, y); 40 | } 41 | pgFireball.endShape(CLOSE); 42 | } 43 | pgFireball.endDraw(); 44 | } 45 | 46 | class Fireball 47 | { 48 | float t; 49 | PVector ctr, vel; 50 | boolean active; 51 | float maxSize; 52 | 53 | Fireball(PVector ctr, PVector vel) { 54 | this.ctr = ctr; 55 | this.vel = vel; 56 | vel.setMag(5.0); 57 | t = 0; 58 | maxSize = 300; 59 | active = true; 60 | } 61 | 62 | void update() { 63 | ctr.add(vel); 64 | t += 3.0; 65 | if (ctr.x < -180 || ctr.x > width + 180 || ctr.y < -180 || ctr.y > height + 180) 66 | active = false; 67 | } 68 | 69 | void draw() { 70 | pushMatrix(); 71 | pushStyle(); 72 | translate(ctr.x, ctr.y); 73 | image(pgFireball, 0, 0, constrain(t, 0, maxSize), constrain(t, 0, maxSize)); 74 | popStyle(); 75 | popMatrix(); 76 | } 77 | } -------------------------------------------------------------------------------- /examples/TestFireball/TestFireball.pde: -------------------------------------------------------------------------------- 1 | import SimpleOpenNI.*; 2 | import KinectProjectorToolkit.*; 3 | 4 | SimpleOpenNI kinect; 5 | KinectProjectorToolkit kpc; 6 | ArrayList fireballs; 7 | PGraphics pgFireball; 8 | 9 | void setup() 10 | { 11 | size(displayWidth, displayHeight, P2D); 12 | 13 | // setup Kinect 14 | kinect = new SimpleOpenNI(this); 15 | kinect.enableDepth(); 16 | kinect.enableUser(); 17 | kinect.alternativeViewPointDepthToImage(); 18 | 19 | // setup Kinect Projector Toolkit 20 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 21 | kpc.loadCalibration("calibration.txt"); 22 | 23 | // load fireballs data 24 | pgFireball = createGraphics(400, 400); 25 | fireballs = new ArrayList(); 26 | } 27 | 28 | void draw() 29 | { 30 | kinect.update(); 31 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 32 | 33 | background(255); 34 | renderFireball(); 35 | drawProjectedSkeletons(); 36 | drawFireballs(); 37 | } 38 | 39 | // hit the spacebar to shoot a fireball! (needs a detected skeleton) 40 | void keyPressed() { 41 | if (key==' ') { 42 | int[] userList = kinect.getUsers(); 43 | if (userList.length > 0) 44 | addFireBall(userList[(int)random(userList.length)]); 45 | } 46 | } 47 | 48 | void drawProjectedSkeletons() { 49 | int[] userList = kinect.getUsers(); 50 | for(int i=0; i projectedContours; 10 | FWorld world; 11 | ArrayList users; 12 | 13 | void setup() 14 | { 15 | size(displayWidth, displayHeight, P2D); 16 | 17 | // setup Kinect 18 | kinect = new SimpleOpenNI(this); 19 | kinect.enableDepth(); 20 | kinect.enableUser(); 21 | kinect.alternativeViewPointDepthToImage(); 22 | 23 | // setup OpenCV 24 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 25 | 26 | // setup Kinect Projector Toolkit 27 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 28 | kpc.loadCalibration("calibration.txt"); 29 | kpc.setContourSmoothness(8); 30 | 31 | // setup physics 32 | Fisica.init(this); 33 | world = new FWorld(); 34 | world.setGravity(0, 0); 35 | world.setEdges(this, color(0)); 36 | for (int i=0; i<16; i++){ 37 | FCircle ball = new FCircle(24); 38 | ball.setNoStroke(); 39 | ball.setFill(random(255), random(255), random(255)); 40 | ball.setPosition(random(width), random(height)); 41 | ball.setVelocity(random(-300, 300), random(-300, 300)); 42 | ball.setRestitution(1); 43 | ball.setDamping(0); 44 | world.add(ball); 45 | } 46 | users = new ArrayList(); 47 | } 48 | 49 | void draw() 50 | { 51 | kinect.update(); 52 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 53 | kpc.setKinectUserImage(kinect.userImage()); 54 | opencv.loadImage(kpc.getImage()); 55 | 56 | // reset physics obstacles 57 | for (FPoly user : users) world.remove(user); 58 | users = new ArrayList(); 59 | 60 | // for each projected contour, create new user obstacle 61 | projectedContours = new ArrayList(); 62 | ArrayList contours = opencv.findContours(); 63 | for (Contour contour : contours) { 64 | if (contour.area() > 2000) { 65 | ArrayList cvContour = contour.getPoints(); 66 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0); 67 | projectedContours.add(projectedContour); 68 | FPoly newUser = new FPoly(); 69 | for (PVector p : projectedContour.getProjectedContours()) 70 | newUser.vertex(p.x, p.y); 71 | //ArrayList points = projectedContour.getProjectedContours(); 72 | //for (int i=0; i contour; 4 | int age, maxAge, pos, len, speed, skip, margin; 5 | 6 | Ribbon(ArrayList contour) { 7 | this.contour = contour; 8 | maxAge = 24; 9 | age = 0; 10 | pos = (int) random(contour.size()); 11 | len = 36; 12 | skip = 1; 13 | speed = 3; 14 | margin = 40; 15 | } 16 | 17 | void update() { 18 | age++; 19 | pos = (pos + speed) % contour.size(); 20 | } 21 | 22 | void draw() { 23 | pushStyle(); 24 | noFill(); 25 | stroke(255, 150); 26 | strokeWeight(4); 27 | beginShape(); 28 | for (int i=0; i projectedContours; 9 | ArrayList ribbons; 10 | 11 | void setup() 12 | { 13 | size(displayWidth, displayHeight, P2D); 14 | 15 | // setup Kinect 16 | kinect = new SimpleOpenNI(this); 17 | kinect.enableDepth(); 18 | kinect.enableUser(); 19 | kinect.alternativeViewPointDepthToImage(); 20 | 21 | // setup OpenCV 22 | opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight()); 23 | 24 | // setup Kinect Projector Toolkit 25 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 26 | kpc.loadCalibration("calibration.txt"); 27 | kpc.setContourSmoothness(4); 28 | 29 | // initialize ribbons 30 | ribbons = new ArrayList(); 31 | } 32 | 33 | void draw() 34 | { 35 | kinect.update(); 36 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 37 | kpc.setKinectUserImage(kinect.userImage()); 38 | opencv.loadImage(kpc.getImage()); 39 | 40 | // get projected contours 41 | projectedContours = new ArrayList(); 42 | ArrayList contours = opencv.findContours(); 43 | for (Contour contour : contours) { 44 | if (contour.area() > 2000) { 45 | ArrayList cvContour = contour.getPoints(); 46 | ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.2); 47 | projectedContours.add(projectedContour); 48 | } 49 | } 50 | 51 | // add a ribbon 52 | if (projectedContours.size() > 0) addNewRibbons(3); 53 | 54 | background(0); 55 | 56 | // draw ribbons 57 | ArrayList nextRibbons = new ArrayList(); 58 | for (Ribbon r : ribbons) { 59 | r.update(); 60 | r.draw(); 61 | if (r.age < r.maxAge) nextRibbons.add(r); 62 | } 63 | ribbons = nextRibbons; 64 | } 65 | 66 | void addNewRibbons(int n) { 67 | for (int i=0; i contourPoints = projectedContours.get(p).getProjectedContours(); 70 | Ribbon newRibbon = new Ribbon(contourPoints); 71 | ribbons.add(newRibbon); 72 | } 73 | } -------------------------------------------------------------------------------- /examples/TestRibbons/data/calibration.txt: -------------------------------------------------------------------------------- 1 | 0.002608315897860353 2 | 1.0505449155879362E-4 3 | 8.982701873834213E-4 4 | 0.23785498857906104 5 | -5.639679676254882E-5 6 | -0.004125835503480505 7 | 0.0016941417243858412 8 | -1.6183115185985817 9 | -1.489422746804211E-5 10 | 2.3627671020597305E-4 11 | 0.0016099040009057567 -------------------------------------------------------------------------------- /examples/TestSkeleton/TestSkeleton.pde: -------------------------------------------------------------------------------- 1 | import SimpleOpenNI.*; 2 | import KinectProjectorToolkit.*; 3 | 4 | SimpleOpenNI kinect; 5 | KinectProjectorToolkit kpc; 6 | 7 | int SIZE_JOINTS = 20; 8 | 9 | void setup() 10 | { 11 | size(displayWidth, displayHeight, P2D); 12 | 13 | // setup Kinect 14 | kinect = new SimpleOpenNI(this); 15 | kinect.enableDepth(); 16 | kinect.enableUser(); 17 | kinect.alternativeViewPointDepthToImage(); 18 | 19 | // setup Kinect Projector Toolkit 20 | kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight()); 21 | kpc.loadCalibration("calibration.txt"); 22 | } 23 | 24 | void draw() 25 | { 26 | kinect.update(); 27 | kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 28 | 29 | background(255); 30 | drawProjectedSkeletons(); 31 | } 32 | 33 | void drawProjectedSkeletons() { 34 | int[] userList = kinect.getUsers(); 35 | for(int i=0; i 3 | 4 | 5 | Kinect Projector Toolkit 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 25 | 26 | 38 | 39 |
40 | 41 |
42 |

Kinect Projector Toolkit

43 |

44 | A library by Gene Kogan for the Processing programming environment.
45 | Last update, 01/21/2014. 46 |

47 |

48 | A utility for calibrating a depth camera to a projector, enabling automated projection mapping
49 |
50 | Feel free to replace this paragraph with a description of the library.
51 | Contributed libraries are developed, documented, and maintained by members of the Processing community. Further directions are included with each library. For feedback and support, please post to the Discourse. We strongly encourage all libraries to be open source, but not all of them are. 52 |

53 |
54 | 55 | 56 | 57 |
58 |

Download

59 |

60 | Download Kinect Projector Toolkit version 1.0.0 (1) in 61 | .zip format. 62 |

63 |

Installation

64 |

65 | Unzip and put the extracted KinectProjectorToolkit folder into the libraries folder of your Processing sketches. Reference and examples are included in the KinectProjectorToolkit folder. 66 |

67 |
68 | 69 | 70 |
71 |

Keywords. ?

72 |

Reference. Have a look at the javadoc reference here. A copy of the reference is included in the .zip as well.

73 |

Source. The source code of Kinect Projector Toolkit is available at GitHub, and its repository can be browsed here.

74 |
75 | 76 | 77 |
78 |

Examples

79 |

Find a list of examples in the current distribution of Kinect Projector Toolkit, or have a look at them by following the links below.

80 | 83 |
84 | 85 | 86 |
87 |

Tested

88 |

89 | 90 | Platform osx 91 | 92 | 93 |
Processing 2.0 94 | 95 | 96 |
Dependencies ? 97 |

98 |
99 | 100 | 101 | 102 | 114 | 115 | 116 | 121 | 122 | 123 | 127 | 128 | 129 |
130 |
131 | 132 | 135 |
136 | 137 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | # More on this file here: https://github.com/processing/processing/wiki/Library-Basics 2 | # UTF-8 supported. 3 | 4 | # The name of your library as you want it formatted. 5 | name = Kinect Projector Toolkit 6 | 7 | # List of authors. Links can be provided using the syntax [author name](url). 8 | authorList = [Gene Kogan](http://www.genekogan.com) 9 | 10 | # A web page for your library, NOT a direct link to where to download it. 11 | url = http://www.genekogan.com 12 | 13 | # The category of your library, must be one (or many) of the following: 14 | # "3D" "Animation" "Compilations" "Data" 15 | # "Fabrication" "Geometry" "GUI" "Hardware" 16 | # "I/O" "Language" "Math" "Simulation" 17 | # "Sound" "Utilities" "Typography" "Video & Vision" 18 | # 19 | # If a value other than those listed is used, your library will listed as 20 | # "Other". 21 | category = Video & Vision 22 | 23 | # A short sentence (or fragment) to summarize the library's function. This will 24 | # be shown from inside the PDE when the library is being installed. Avoid 25 | # repeating the name of your library here. Also, avoid saying anything redundant 26 | # like mentioning that it's a library. This should start with a capitalized 27 | # letter, and end with a period. 28 | sentence = A utility for calibrating a depth camera to a projector, enabling automated projection mapping 29 | 30 | # Additional information suitable for the Processing website. The value of 31 | # 'sentence' always will be prepended, so you should start by writing the 32 | # second sentence here. If your library only works on certain operating systems, 33 | # mention it here. 34 | paragraph = 35 | 36 | # Links in the 'sentence' and 'paragraph' attributes can be inserted using the 37 | # same syntax as for authors. 38 | # That is, [here is a link to Processing](http://processing.org/) 39 | 40 | 41 | # A version number that increments once with each release. This is used to 42 | # compare different versions of the same library, and check if an update is 43 | # available. You should think of it as a counter, counting the total number of 44 | # releases you've had. 45 | version = 1 # This must be parsable as an int 46 | 47 | # The version as the user will see it. If blank, the version attribute will be 48 | # used here. 49 | prettyVersion = 1.0.0 # This is treated as a String 50 | -------------------------------------------------------------------------------- /library/Jama-1.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/genekogan/KinectProjectorToolkit/4fa57ead3d3a6f3bb21eaea6b736a855de3f728c/library/Jama-1.0.3.jar -------------------------------------------------------------------------------- /library/KinectProjectorToolkit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/genekogan/KinectProjectorToolkit/4fa57ead3d3a6f3bb21eaea6b736a855de3f728c/library/KinectProjectorToolkit.jar -------------------------------------------------------------------------------- /reference/KinectProjectorToolkit/KinectProjectorToolkit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KinectProjectorToolkit (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 | 76 | 78 | 80 | 81 |
50 | 51 |
82 | 83 | 84 | 85 |
86 | 87 |

88 | 89 | KinectProjectorToolkit 90 |
91 | Class KinectProjectorToolkit

92 |
 93 | java.lang.Object
 94 |   extended by KinectProjectorToolkit.KinectProjectorToolkit
 95 | 
96 |
97 |
98 |
public class KinectProjectorToolkit
extends Object
99 | 100 | 101 |

102 |


103 | 104 |

105 | 106 | 107 | 108 | 109 | 110 | 111 | 113 | 114 | 115 | 121 | 122 |
112 | Constructor Summary
KinectProjectorToolkit(PApplet theParent, 116 | int theWidth, 117 | int theHeight) 118 | 119 |
120 |           create a new instance of KinectProjectorToolkit
123 |   124 | 125 | 126 | 127 | 128 | 129 | 131 | 132 | 133 | 135 | 139 | 140 | 141 | 143 | 148 | 149 | 150 | 152 | 156 | 157 | 158 | 160 | 165 | 166 | 167 | 169 | 173 | 174 | 175 | 177 | 181 | 182 | 183 | 185 | 189 | 190 | 191 | 193 | 197 | 198 |
130 | Method Summary
134 |  PVectorconvertKinectToProjector(PVector kinectPoint) 136 | 137 |
138 |           get 2d projector point of a 3d real world kinect point
142 |  PVectorgetDepthMapAt(int x, 144 | int y) 145 | 146 |
147 |           get 3d real world kinect point from 640x480 Kinect depth map
151 |  PGraphicsgetImage() 153 | 154 |
155 |           get kinect depth image
159 |  ProjectedContourgetProjectedContour(ArrayList<PVector> contourPoints, 161 | float blobDilate) 162 | 163 |
164 |           takes OpenCV body contours, returns projected contours
168 |  voidloadCalibration(String filename) 170 | 171 |
172 |           load a previous calibration
176 |  voidsetContourSmoothness(int smoothness) 178 | 179 |
180 |           sets smoothness of found contours
184 |  voidsetDepthMapRealWorld(PVector[] theDepthMapRealWorld) 186 | 187 |
188 |           update real world depth map
192 |  voidsetKinectUserImage(PImage theKinectUserImage) 194 | 195 |
196 |           update kinect depth image
199 |   200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
208 |   209 |

210 | 211 | 212 | 213 | 214 | 215 | 216 | 218 | 219 |
217 | Constructor Detail
220 | 221 |

222 | KinectProjectorToolkit

223 |
224 | public KinectProjectorToolkit(PApplet theParent,
225 |                               int theWidth,
226 |                               int theHeight)
227 |
228 |
create a new instance of KinectProjectorToolkit 229 |

230 |

231 |
Parameters:
theParent -
theWidth -
theHeight - 236 |
+Example
import gab.opencv.*;
237 | import SimpleOpenNI.*;
238 | import KinectProjectorToolkit.*;
239 | 
240 | SimpleOpenNI kinect;
241 | OpenCV opencv;
242 | KinectProjectorToolkit kpc;
243 | ArrayList projectedContours;
244 | ArrayList projectedGraphics;
245 | 
246 | void setup()
247 | {
248 |   size(displayWidth, displayHeight, P2D); 
249 | 
250 |   // setup Kinect
251 |   kinect = new SimpleOpenNI(this); 
252 |   kinect.enableDepth();
253 |   kinect.enableUser();
254 |   kinect.alternativeViewPointDepthToImage();
255 |   
256 |   // setup OpenCV
257 |   opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight());
258 | 
259 |   // setup Kinect Projector Toolkit
260 |   kpc = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight());
261 |   kpc.loadCalibration("calibration.txt");
262 |   kpc.setContourSmoothness(4);
263 |   
264 |   projectedGraphics = initializeProjectedGraphics();
265 | }
266 | 
267 | void draw()
268 | {  
269 |   kinect.update();  
270 |   kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 
271 |   kpc.setKinectUserImage(kinect.userImage());
272 |   opencv.loadImage(kpc.getImage());
273 |   
274 |   // get projected contours
275 |   projectedContours = new ArrayList();
276 |   ArrayList contours = opencv.findContours();
277 |   for (Contour contour : contours) {
278 |     if (contour.area() > 2000) {
279 |       ArrayList cvContour = contour.getPoints();
280 |       ProjectedContour projectedContour = kpc.getProjectedContour(cvContour, 1.0);
281 |       projectedContours.add(projectedContour);
282 |     }
283 |   }
284 |   
285 |   // draw projected contours
286 |   background(0);
287 |   for (int i=0; i initializeProjectedGraphics() {
301 |   ArrayList projectedGraphics = new ArrayList();
302 |   for (int p=0; p<3; p++) {
303 |     color col = color(random(255), random(255), random(255));
304 |     PGraphics pg = createGraphics(800, 400, P2D);
305 |     pg.beginDraw();
306 |     pg.background(random(255));
307 |     pg.noStroke();
308 |     for (int i=0; i<100; i++) {
309 |       pg.fill(red(col)+(int)random(-30,30), green(col)+(int)random(-30,30), blue(col)+(int)random(-30,30)); 
310 |       if      (p==0)  pg.ellipse(random(pg.width), random(pg.height), random(200), random(200));
311 |       else if (p==1)  pg.rect(random(pg.width), random(pg.height), random(200), random(200));
312 |       else if (p==2)  pg.triangle(random(pg.width), random(pg.height), random(pg.width), random(pg.height), random(pg.width), random(pg.height));
313 |     }
314 |     pg.endDraw();
315 |     projectedGraphics.add(pg);
316 |   }  
317 |   return projectedGraphics;
318 | }
319 | 
320 |
321 | 322 | 323 | 324 | 325 | 326 | 327 | 329 | 330 |
328 | Method Detail
331 | 332 |

333 | loadCalibration

334 |
335 | public void loadCalibration(String filename)
336 |
337 |
load a previous calibration 338 |

339 |

340 |
Parameters:
filepath - path to calibration file
341 |
342 |
343 |
344 | 345 |

346 | convertKinectToProjector

347 |
348 | public PVector convertKinectToProjector(PVector kinectPoint)
349 |
350 |
get 2d projector point of a 3d real world kinect point 351 |

352 |

353 |
Parameters:
kinectPoint - 3d point in Kinect real world space 354 |
Returns:
PVector
355 |
356 |
357 |
358 | 359 |

360 | getDepthMapAt

361 |
362 | public PVector getDepthMapAt(int x,
363 |                              int y)
364 |
365 |
get 3d real world kinect point from 640x480 Kinect depth map 366 |

367 |

368 |
Parameters:
x -
y - 369 |
Returns:
PVector
370 |
371 |
372 |
373 | 374 |

375 | setDepthMapRealWorld

376 |
377 | public void setDepthMapRealWorld(PVector[] theDepthMapRealWorld)
378 |
379 |
update real world depth map 380 |

381 |

382 |
Parameters:
theDepthMapRealWorld -
383 |
384 |
385 |
386 | 387 |

388 | setKinectUserImage

389 |
390 | public void setKinectUserImage(PImage theKinectUserImage)
391 |
392 |
update kinect depth image 393 |

394 |

395 |
Parameters:
theKinectUserImage -
396 |
397 |
398 |
399 | 400 |

401 | getImage

402 |
403 | public PGraphics getImage()
404 |
405 |
get kinect depth image 406 |

407 |

408 |
Parameters:
theKinectUserImage -
409 |
410 |
411 |
412 | 413 |

414 | setContourSmoothness

415 |
416 | public void setContourSmoothness(int smoothness)
417 |
418 |
sets smoothness of found contours 419 |

420 |

421 |
Parameters:
smoothness - number of contour points to average over
422 |
423 |
424 |
425 | 426 |

427 | getProjectedContour

428 |
429 | public ProjectedContour getProjectedContour(ArrayList<PVector> contourPoints,
430 |                                             float blobDilate)
431 |
432 |
takes OpenCV body contours, returns projected contours 433 |

434 |

435 |
Parameters:
contourPoints - blob contour points found by OpenCV
blobDilate - stretches bounding box of the contour (default 1.0 is no stretching) 436 |
Returns:
ProjectedContour
437 |
438 |
439 | 440 |
441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 461 | 464 | 465 | 466 | 467 | 470 | 486 | 487 | 488 | 490 | 492 | 493 |
462 | 463 |
494 | 495 | 496 | 497 |
498 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 499 | 500 | 501 | -------------------------------------------------------------------------------- /reference/KinectProjectorToolkit/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KinectProjectorToolkit (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | KinectProjectorToolkit 20 | 21 | 22 | 29 | 30 |
23 | Classes  24 | 25 |
26 | KinectProjectorToolkit 27 |
28 | ProjectedContour
31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /reference/KinectProjectorToolkit/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KinectProjectorToolkit (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |

81 | Package KinectProjectorToolkit 82 |

83 | 84 | 85 | 86 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
87 | Class Summary
KinectProjectorToolkit 
ProjectedContour 
98 |   99 | 100 |

101 |

102 |
103 |
104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 124 | 127 | 128 | 129 | 130 | 133 | 149 | 150 |
125 | 126 |
151 | 152 | 153 | 154 |
155 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 156 | 157 | 158 | -------------------------------------------------------------------------------- /reference/KinectProjectorToolkit/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KinectProjectorToolkit Class Hierarchy (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |
81 |

82 | Hierarchy For Package KinectProjectorToolkit 83 |

84 |
85 |

86 | Class Hierarchy 87 |

88 | 92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 113 | 116 | 117 | 118 | 119 | 122 | 138 | 139 |
114 | 115 |
140 | 141 | 142 | 143 |
144 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 145 | 146 | 147 | -------------------------------------------------------------------------------- /reference/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 29 | 30 |
KinectProjectorToolkit 25 |
26 | ProjectedContour 27 |
28 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /reference/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 29 | 30 |
KinectProjectorToolkit 25 |
26 | ProjectedContour 27 |
28 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /reference/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |
81 |

82 | Constant Field Values

83 |
84 |
85 | Contents
    86 |
87 | 88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 141 | 142 | 143 | -------------------------------------------------------------------------------- /reference/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |
81 |

82 | Deprecated API

83 |
84 |
85 | Contents
    86 |
87 | 88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 141 | 142 | 143 | -------------------------------------------------------------------------------- /reference/help-doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | API Help (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |
81 |

82 | How This API Document Is Organized

83 |
84 | This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

85 | Package

86 |
87 | 88 |

89 | Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    90 |
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
91 |
92 |

93 | Class/Interface

94 |
95 | 96 |

97 | Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    98 |
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description 99 |

    100 |

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary 101 |

    102 |

  • Field Detail
  • Constructor Detail
  • Method Detail
103 | Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
104 | 105 |

106 | Annotation Type

107 |
108 | 109 |

110 | Each annotation type has its own separate page with the following sections:

    111 |
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
112 |
113 | 114 |

115 | Enum

116 |
117 | 118 |

119 | Each enum has its own separate page with the following sections:

    120 |
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
121 |
122 |

123 | Tree (Class Hierarchy)

124 |
125 | There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    126 |
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
127 |
128 |

129 | Deprecated API

130 |
131 | The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
132 |

133 | Index

134 |
135 | The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
136 |

137 | Prev/Next

138 | These links take you to the next or previous class, interface, package, or related page.

139 | Frames/No Frames

140 | These links show and hide the HTML frames. All pages are available with or without frames. 141 |

142 |

143 | Serialized Form

144 | Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. 145 |

146 |

147 | Constant Field Values

148 | The Constant Field Values page lists the static final fields and their values. 149 |

150 | 151 | 152 | This help file applies to API documentation generated using the standard doclet. 153 | 154 |
155 |


156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 176 | 179 | 180 | 181 | 182 | 185 | 201 | 202 |
177 | 178 |
203 | 204 | 205 | 206 |
207 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 208 | 209 | 210 | -------------------------------------------------------------------------------- /reference/index-all.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Index (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 | C G K L P S
80 |

81 | C

82 |
83 |
calculateProjectedContour(float) - 84 | Method in class KinectProjectorToolkit.ProjectedContour 85 |
calculates the projected, dilated, and smoothed contour points 86 |
calculateProjectedContour() - 87 | Method in class KinectProjectorToolkit.ProjectedContour 88 |
calculates the projected, dilated, and smoothed contour points with no stretching 89 |
convertKinectToProjector(PVector) - 90 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 91 |
get 2d projector point of a 3d real world kinect point 92 |
93 |
94 |

95 | G

96 |
97 |
getBoundingBox() - 98 | Method in class KinectProjectorToolkit.ProjectedContour 99 |
get projected contour's bounding box (requires java.awt.*) 100 |
getDepthMapAt(int, int) - 101 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 102 |
get 3d real world kinect point from 640x480 Kinect depth map 103 |
getImage() - 104 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 105 |
get kinect depth image 106 |
getProjectedContour(ArrayList<PVector>, float) - 107 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 108 |
takes OpenCV body contours, returns projected contours 109 |
getProjectedContours() - 110 | Method in class KinectProjectorToolkit.ProjectedContour 111 |
get projected contour points 112 |
getTextureCoordinate(PVector) - 113 | Method in class KinectProjectorToolkit.ProjectedContour 114 |
get a single contour point's coordinates for texture mapping 115 |
116 |
117 |

118 | K

119 |
120 |
KinectProjectorToolkit - package KinectProjectorToolkit
 
KinectProjectorToolkit - Class in KinectProjectorToolkit
 
KinectProjectorToolkit(PApplet, int, int) - 121 | Constructor for class KinectProjectorToolkit.KinectProjectorToolkit 122 |
create a new instance of KinectProjectorToolkit 123 |
124 |
125 |

126 | L

127 |
128 |
loadCalibration(String) - 129 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 130 |
load a previous calibration 131 |
132 |
133 |

134 | P

135 |
136 |
ProjectedContour - Class in KinectProjectorToolkit
 
ProjectedContour(ArrayList<PVector>, KinectProjectorToolkit) - 137 | Constructor for class KinectProjectorToolkit.ProjectedContour 138 |
create projected contours from a set of OpenCV contour points and an instance of KinectProjectorToolkit 139 |
140 |
141 |

142 | S

143 |
144 |
setContourSmoothness(int) - 145 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 146 |
sets smoothness of found contours 147 |
setDepthMapRealWorld(PVector[]) - 148 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 149 |
update real world depth map 150 |
setKinectUserImage(PImage) - 151 | Method in class KinectProjectorToolkit.KinectProjectorToolkit 152 |
update kinect depth image 153 |
154 |
155 | C G K L P S 156 | 157 | 158 | 159 | 160 | 161 | 162 | 175 | 178 | 179 | 180 | 181 | 184 | 200 | 201 |
176 | 177 |
202 | 203 | 204 | 205 |
206 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 207 | 208 | 209 | -------------------------------------------------------------------------------- /reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Javadocs: KinectProjectorToolkit 8 | 9 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | <H2> 62 | Frame Alert</H2> 63 | 64 | <P> 65 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 66 | <BR> 67 | Link to<A HREF="KinectProjectorToolkit/package-summary.html">Non-frame version.</A> 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /reference/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Class Hierarchy (Javadocs: KinectProjectorToolkit) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 49 | 52 | 53 | 54 | 55 | 58 | 74 | 75 |
50 | 51 |
76 | 77 | 78 | 79 |
80 |
81 |

82 | Hierarchy For All Packages

83 |
84 |
85 |
Package Hierarchies:
KinectProjectorToolkit
86 |
87 |

88 | Class Hierarchy 89 |

90 | 94 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 115 | 118 | 119 | 120 | 121 | 124 | 140 | 141 |
116 | 117 |
142 | 143 | 144 | 145 |
146 | Processing library KinectProjectorToolkit by Gene Kogan. (c) 2013 147 | 148 | 149 | -------------------------------------------------------------------------------- /reference/package-list: -------------------------------------------------------------------------------- 1 | KinectProjectorToolkit 2 | -------------------------------------------------------------------------------- /reference/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/genekogan/KinectProjectorToolkit/4fa57ead3d3a6f3bb21eaea6b736a855de3f728c/reference/resources/inherit.gif -------------------------------------------------------------------------------- /reference/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | /* Define colors, fonts and other style attributes here to override the defaults */ 3 | /* processingLibs style by andreas schlegel, sojamo */ 4 | 5 | 6 | body { 7 | margin : 0; 8 | padding : 0; 9 | padding-left : 10px; 10 | padding-right : 8px; 11 | background-color : #FFFFFF; 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.7em; 15 | font-weight : normal; 16 | line-height : normal; 17 | margin-bottom:30px; 18 | } 19 | 20 | 21 | 22 | 23 | /* Headings */ 24 | h1, h2, h3, h4, h5, th { 25 | font-family :Arial, Helvetica, sans-serif; 26 | font-size:1.2em; 27 | } 28 | 29 | 30 | p { 31 | font-size : 1em; 32 | width:80%; 33 | } 34 | 35 | pre, code { 36 | font-family : "Courier New", Courier, monospace; 37 | font-size : 12px; 38 | line-height : normal; 39 | } 40 | 41 | 42 | 43 | table { 44 | border:0; 45 | margin-bottom:10px; 46 | margin-top:10px; 47 | } 48 | 49 | 50 | tr, td { 51 | border-top: 0px solid; 52 | border-left: 0px solid; 53 | padding-top:8px; 54 | padding-bottom:8px; 55 | } 56 | 57 | 58 | 59 | hr { 60 | border:0; 61 | height:1px; 62 | padding:0; 63 | margin:0; 64 | margin-bottom:4px; 65 | 66 | } 67 | 68 | 69 | 70 | dd, th, td, font { 71 | font-size:1.0em; 72 | line-height:1.0em; 73 | } 74 | 75 | 76 | 77 | dt { 78 | margin-bottom:0px; 79 | } 80 | 81 | 82 | 83 | dd { 84 | margin-top:2px; 85 | margin-bottom:4px; 86 | } 87 | 88 | 89 | 90 | a { 91 | text-decoration: underline; 92 | font-weight: normal; 93 | } 94 | 95 | a:hover, 96 | a:active { 97 | text-decoration: underline; 98 | font-weight: normal; 99 | } 100 | 101 | a:visited, 102 | a:link:visited { 103 | text-decoration: underline; 104 | font-weight: normal; 105 | } 106 | 107 | 108 | img { 109 | border: 0px solid #000000; 110 | } 111 | 112 | 113 | 114 | /* Navigation bar fonts */ 115 | .NavBarCell1 { 116 | border:0; 117 | } 118 | 119 | .NavBarCell1Rev { 120 | border:0; 121 | } 122 | 123 | .NavBarFont1 { 124 | font-family: Arial, Helvetica, sans-serif; 125 | font-size:1.1em; 126 | } 127 | 128 | 129 | .NavBarFont1 b { 130 | font-weight:normal; 131 | } 132 | 133 | 134 | 135 | .NavBarFont1:after, .NavBarFont1Rev:after { 136 | font-weight:normal; 137 | content: " \\"; 138 | } 139 | 140 | 141 | .NavBarFont1Rev { 142 | font-family: Arial, Helvetica, sans-serif; 143 | font-size:1.1em; 144 | } 145 | 146 | .NavBarFont1Rev b { 147 | font-family: Arial, Helvetica, sans-serif; 148 | font-size:1.1em; 149 | font-weight:normal; 150 | } 151 | 152 | .NavBarCell2 { 153 | font-family: Arial, Helvetica, sans-serif; 154 | } 155 | 156 | .NavBarCell3 { 157 | font-family: Arial, Helvetica, sans-serif; 158 | } 159 | 160 | 161 | 162 | font.FrameItemFont { 163 | font-family: Helvetica, Arial, sans-serif; 164 | font-size:1.1em; 165 | line-height:1.1em; 166 | } 167 | 168 | font.FrameHeadingFont { 169 | font-family: Helvetica, Arial, sans-serif; 170 | line-height:32px; 171 | } 172 | 173 | /* Font used in left-hand frame lists */ 174 | .FrameTitleFont { 175 | font-family: Helvetica, Arial, sans-serif 176 | } 177 | 178 | 179 | .toggleList { 180 | padding:0; 181 | margin:0; 182 | margin-top:12px; 183 | } 184 | 185 | .toggleList dt { 186 | font-weight:bold; 187 | font-size:12px; 188 | font-family:arial,sans-serif; 189 | padding:0px; 190 | margin:10px 0px 10px 0px; 191 | } 192 | 193 | .toggleList dt span { 194 | font-family: monospace; 195 | padding:0; 196 | margin:0; 197 | } 198 | 199 | 200 | .toggleList dd { 201 | margin:0; 202 | padding:0; 203 | } 204 | 205 | html.isjs .toggleList dd { 206 | display: none; 207 | } 208 | 209 | .toggleList pre { 210 | padding: 4px 4px 4px 4px; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | /* COLORS */ 218 | 219 | pre, code { 220 | color: #000000; 221 | } 222 | 223 | 224 | body { 225 | color : #333333; 226 | background-color :#FFFFFF; 227 | } 228 | 229 | 230 | h1, h2, h3, h4, h5, h6 { 231 | color:#555; 232 | } 233 | 234 | a, 235 | .toggleList dt { 236 | color: #1a7eb0; 237 | } 238 | 239 | a:hover, 240 | a:active { 241 | color: #1a7eb0; 242 | } 243 | 244 | a:visited, 245 | a:link:visited { 246 | color: #1a7eb0; 247 | } 248 | 249 | td,tr { 250 | border-color: #999999; 251 | } 252 | 253 | hr { 254 | color:#999999; 255 | background:#999999; 256 | } 257 | 258 | 259 | .TableHeadingColor { 260 | background: #dcdcdc; 261 | color: #555; 262 | } 263 | 264 | 265 | .TableSubHeadingColor { 266 | background: #EEEEFF 267 | } 268 | 269 | .TableRowColor { 270 | background: #FFFFFF 271 | } 272 | 273 | 274 | .NavBarCell1 { 275 | background-color:#dcdcdc; 276 | color:#000; 277 | } 278 | 279 | .NavBarCell1 a { 280 | color:#333; 281 | } 282 | 283 | 284 | .NavBarCell1Rev { 285 | background-color:transparent; 286 | } 287 | 288 | .NavBarFont1 { 289 | color:#333; 290 | } 291 | 292 | 293 | .NavBarFont1Rev { 294 | color:#fff; 295 | } 296 | 297 | .NavBarCell2 { 298 | background-color:#999; 299 | } 300 | 301 | .NavBarCell2 a { 302 | color:#fff; 303 | } 304 | 305 | 306 | 307 | .NavBarCell3 { 308 | background-color:#dcdcdc; 309 | } 310 | 311 | -------------------------------------------------------------------------------- /src/KinectProjectorToolkit/KinectProjectorToolkit.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Kinect Projector Toolkit 3 | * A utility for calibrating a depth camera to a projector, enabling automated projection mapping 4 | * http://www.genekogan.com 5 | * 6 | * Copyright (c) 2013 Gene Kogan http://www.genekogan.com 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General 19 | * Public License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | * Boston, MA 02111-1307 USA 22 | * 23 | * @author Gene Kogan http://www.genekogan.com 24 | * @modified 01/13/2014 25 | * @version 1.0.0 (1) 26 | */ 27 | 28 | package KinectProjectorToolkit; 29 | 30 | /** 31 | * KinectProjectorToolkit is a Processing library which facilitates 32 | * the calibrated alignment of a Kinect depth camera with a video 33 | * projector. 34 | * 35 | * 2013 by Gene Kogan 36 | * 37 | * This library is free software; you can redistribute it and/or 38 | * modify it under the terms of the GNU Lesser General Public License 39 | * as published by the Free Software Foundation; either version 2.1 40 | * of the License, or (at your option) any later version. 41 | * This library is distributed in the hope that it will be useful, 42 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 43 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 44 | * Lesser General Public License for more details. 45 | * 46 | * You should have received a copy of the GNU Lesser General 47 | * Public License along with this library; if not, write to the 48 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 49 | * Boston, MA 02111-1307 USA 50 | * 51 | * @author Gene Kogan (http://www.genekogan.com) 52 | * @modified Jan 2014 53 | * @version 1.0 54 | * @example TestBodyGraphics 55 | * 56 | */ 57 | 58 | 59 | import processing.core.*; 60 | import processing.opengl.*; 61 | import java.util.ArrayList; 62 | 63 | 64 | public class KinectProjectorToolkit 65 | { 66 | PApplet myParent; 67 | int width, height; 68 | float[] projectorMatrix; 69 | PVector[] depthMapRealWorld; 70 | PGraphics pgKinect; 71 | PShader userShader; 72 | float[] window; 73 | float totalWindow; 74 | int blobWindow, blobSkip; 75 | 76 | 77 | /** 78 | * create a new instance of KinectProjectorToolkit 79 | * 80 | * @example TestBodyGraphics 81 | * @param theParent 82 | * @param theWidth 83 | * @param theHeight 84 | */ 85 | public KinectProjectorToolkit(PApplet theParent, int theWidth, int theHeight) { 86 | myParent = theParent; 87 | width = theWidth; 88 | height = theHeight; 89 | pgKinect = myParent.createGraphics(width, height, PApplet.P2D); 90 | userShader = myParent.loadShader("kinectUser.glsl"); 91 | userShader.set("resolution", (float)pgKinect.width, (float)pgKinect.height); 92 | pgKinect.shader(userShader); 93 | setContourSmoothness(1); 94 | System.out.println("Kinect Projector Toolkit 1.0.0 by Gene Kogan http://www.genekogan.com"); 95 | } 96 | 97 | /** 98 | * load a previous calibration 99 | * 100 | * @param filepath 101 | * path to calibration file 102 | */ 103 | public void loadCalibration(String filename) { 104 | String[] s = myParent.loadStrings(myParent.dataPath(filename)); 105 | projectorMatrix = new float[s.length]; 106 | for (int i=0; i contourPoints, float blobDilate) { 183 | ProjectedContour projectedContour = new ProjectedContour(contourPoints, this); 184 | projectedContour.calculateProjectedContour(blobDilate); 185 | return projectedContour; 186 | } 187 | 188 | private void setupBlobWindow() { 189 | totalWindow = 1.0f; 190 | window = new float[blobWindow+1]; 191 | window[0] = 1.0f; 192 | for (int i=1; i<=blobWindow; i++) { 193 | window[i] = 1.0f - (i/(blobWindow+1)); 194 | totalWindow += 2*window[i]; 195 | } 196 | } 197 | } 198 | 199 | -------------------------------------------------------------------------------- /src/KinectProjectorToolkit/ProjectedContour.java: -------------------------------------------------------------------------------- 1 | package KinectProjectorToolkit; 2 | 3 | /** 4 | * KinectProjectorToolkit is a Processing library which facilitates 5 | * the calibrated alignment of a Kinect depth camera with a video 6 | * projector. 7 | * 8 | * 2013 by Gene Kogan 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public License 12 | * as published by the Free Software Foundation; either version 2.1 13 | * of the License, or (at your option) any later version. 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General 20 | * Public License along with this library; if not, write to the 21 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 22 | * Boston, MA 02111-1307 USA 23 | * 24 | * @author Gene Kogan (http://www.genekogan.com) 25 | * @modified Jan 2014 26 | * @version 1.0 27 | * @example TestBodyGraphics 28 | * 29 | */ 30 | 31 | import processing.core.PApplet; 32 | import processing.core.PVector; 33 | import java.awt.Rectangle; 34 | import java.util.ArrayList; 35 | 36 | public class ProjectedContour 37 | { 38 | KinectProjectorToolkit kpc; 39 | ArrayList contourPoints; 40 | ArrayList blobPoints; 41 | Rectangle boundingBox; 42 | 43 | /** 44 | * create projected contours from a set of OpenCV contour points and an instance of KinectProjectorToolkit 45 | * 46 | * @example TestBodyGraphics 47 | * @param theContourPoints 48 | * @param theKpc 49 | */ 50 | public ProjectedContour(ArrayList theContourPoints, KinectProjectorToolkit theKpc) { 51 | contourPoints = theContourPoints; 52 | kpc = theKpc; 53 | } 54 | 55 | /** 56 | * calculates the projected, dilated, and smoothed contour points 57 | * 58 | * @example TestBodyGraphics 59 | * @param blobDilate stretching factor of contour's bounding box (1.0 = no stretching) 60 | */ 61 | public void calculateProjectedContour(float blobDilate) 62 | { 63 | ArrayList projectedPoints = new ArrayList(); 64 | blobPoints = new ArrayList(); 65 | 66 | if (contourPoints.size() < 100) { 67 | blobPoints = new ArrayList(); 68 | return; 69 | } 70 | 71 | PVector bbTL = new PVector(kpc.width, kpc.height); 72 | PVector bbBR = new PVector(0, 0); 73 | for (PVector cp : contourPoints) { 74 | cp.x = PApplet.constrain(cp.x, 0, kpc.width-1); 75 | cp.y = PApplet.constrain(cp.y, 0, kpc.height-1); 76 | 77 | PVector kp = kpc.getDepthMapAt((int)cp.x, (int)cp.y); 78 | PVector pp = kpc.convertKinectToProjector(kp); 79 | projectedPoints.add(pp); 80 | if (pp.x < bbTL.x) bbTL.x = pp.x; 81 | else if (pp.x > bbBR.x) bbBR.x = pp.x; 82 | if (pp.y < bbTL.y) bbTL.y = pp.y; 83 | else if (pp.y > bbBR.y) bbBR.y = pp.y; 84 | } 85 | 86 | Rectangle bbOriginal = new Rectangle( 87 | (int)bbTL.x, (int)bbTL.y, 88 | (int)(bbBR.x - bbTL.x), (int)(bbBR.y - bbTL.y)); 89 | Rectangle bbDilated = new Rectangle( 90 | (int) (bbTL.x - 0.5 * bbOriginal.width * (blobDilate - 1.0)), (int)(bbTL.y - 0.5 * bbOriginal.height * (blobDilate - 1.0)), 91 | (int) (bbOriginal.width * blobDilate), (int) (bbOriginal.height * blobDilate)); 92 | 93 | // dilate bounding box 94 | for (PVector pp : projectedPoints) { 95 | pp.set(PApplet.map(pp.x, bbOriginal.x, bbOriginal.x + bbOriginal.width, bbDilated.x, bbDilated.x + bbDilated.width), 96 | PApplet.map(pp.y, bbOriginal.y, bbOriginal.y + bbOriginal.height, bbDilated.y, bbDilated.y + bbDilated.height)); 97 | } 98 | 99 | // smooth points and add to blobPoints 100 | for (int i=0; i getProjectedContours() { 131 | return blobPoints; 132 | } 133 | 134 | /** 135 | * get projected contour's bounding box (requires java.awt.*) 136 | * 137 | * @example TestBodyGraphics 138 | * @return boundingBox 139 | */ 140 | public Rectangle getBoundingBox() { 141 | return boundingBox; 142 | } 143 | 144 | /** 145 | * get a single contour point's coordinates for texture mapping 146 | * 147 | * @example TestBodyGraphics 148 | * @return PVector 149 | */ 150 | public PVector getTextureCoordinate(PVector p) { 151 | return new PVector((p.x - boundingBox.x) / boundingBox.width, 152 | (p.y - boundingBox.y) / boundingBox.height); 153 | } 154 | } -------------------------------------------------------------------------------- /stylesheet.css: -------------------------------------------------------------------------------- 1 | /* processingLibs style by andreas schlegel, sojamo. */ 2 | 3 | 4 | * { 5 | margin:0; 6 | padding:0; 7 | border:0; 8 | } 9 | 10 | 11 | body { 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.70em; 15 | font-weight : normal; 16 | line-height : normal; 17 | } 18 | 19 | 20 | 21 | #container { 22 | margin-left:64px; 23 | background-color:#fff; 24 | } 25 | 26 | #header { 27 | float:left; 28 | padding-top:24px; 29 | padding-bottom:48px; 30 | } 31 | 32 | #menu { 33 | margin-top:16px; 34 | float:left; 35 | margin-bottom:64px; 36 | } 37 | 38 | 39 | #about, 40 | #download, 41 | #examples, 42 | #demos, 43 | #misc { 44 | width:480px; 45 | float:left; 46 | margin-right:24px; 47 | } 48 | 49 | 50 | #resources, #info { 51 | width:320px; 52 | float:left; 53 | } 54 | 55 | 56 | .clear { 57 | clear:both; 58 | } 59 | 60 | #footer { 61 | margin-top:300px; 62 | height:20px; 63 | margin-bottom:32px; 64 | } 65 | 66 | 67 | ul { 68 | list-style:none; 69 | padding:0; 70 | margin:0; 71 | } 72 | 73 | 74 | #menu ul li, #subMenu ul li { 75 | float:left; 76 | padding-right:6px; 77 | } 78 | 79 | 80 | 81 | 82 | 83 | 84 | /* Headings */ 85 | 86 | h1 { 87 | font-size:2em; 88 | font-weight:normal; 89 | } 90 | 91 | 92 | h2, h3, h4, h5, th { 93 | font-size:1.3em; 94 | font-weight:normal; 95 | margin-bottom:4px; 96 | } 97 | 98 | 99 | 100 | p { 101 | font-size:1em; 102 | width:90%; 103 | margin-bottom:32px; 104 | } 105 | 106 | 107 | pre, code { 108 | font-family:"Courier New", Courier, monospace; 109 | font-size:1em; 110 | line-height:normal; 111 | } 112 | 113 | 114 | 115 | 116 | hr { 117 | border:0; 118 | height:1px; 119 | margin-bottom:24px; 120 | } 121 | 122 | 123 | a { 124 | text-decoration: underline; 125 | font-weight: normal; 126 | } 127 | 128 | 129 | a:hover, 130 | a:active { 131 | text-decoration: underline; 132 | font-weight: normal; 133 | } 134 | 135 | 136 | a:visited, 137 | a:link:visited { 138 | text-decoration: underline; 139 | font-weight: normal; 140 | } 141 | 142 | 143 | 144 | img { 145 | border: 0px solid #000000; 146 | } 147 | 148 | 149 | 150 | 151 | 152 | /* COLORS */ 153 | 154 | 155 | body { 156 | color : #333; 157 | background-color :#fff; 158 | } 159 | 160 | 161 | #header { 162 | background-color:#fff; 163 | color:#333; 164 | } 165 | 166 | 167 | 168 | h1, h2, h3, h4, h5, h6 { 169 | color:#666; 170 | } 171 | 172 | 173 | pre, code { 174 | color: #000000; 175 | } 176 | 177 | 178 | a,strong { 179 | color: #333; 180 | } 181 | 182 | 183 | a:hover, 184 | a:active { 185 | color: #333; 186 | } 187 | 188 | 189 | a:visited, 190 | a:link:visited { 191 | color: #333; 192 | } 193 | 194 | 195 | #footer, #menu { 196 | background-color:#fff; 197 | color:#333; 198 | } 199 | 200 | 201 | #footer a, #menu a { 202 | color:#333; 203 | } 204 | --------------------------------------------------------------------------------