├── .gitignore ├── LICENSE ├── README.md ├── demo_eval_flic.m ├── demo_eval_flic_pc.m ├── demo_eval_lsp.m ├── demo_eval_mpiicooking.m ├── demo_eval_parse.m ├── gt ├── flic-joints-oc.mat ├── flic-joints-test-oc.mat ├── lsp-joints-OC.mat ├── lsp-joints-PC.mat ├── mpii-cooking.mat ├── parse-joints.mat └── parse-labels.mat ├── results ├── FLIC │ ├── pred_keypoints_flic_oc.mat │ └── pred_sticks_flic_oc.mat ├── LSP │ ├── pred_keypoints_lsp_oc.mat │ ├── pred_keypoints_lsp_pc.mat │ ├── pred_sticks_lsp_oc.mat │ └── pred_sticks_lsp_pc.mat ├── PARSE │ ├── pred_keypoints_parse_pc.mat │ └── pred_sticks_parse_pc.mat └── mpii-cooking │ └── Rohrbach_cvpr12.mat ├── startup.m └── utils ├── eval_pck.m ├── eval_pcp.m ├── eval_pdj.m ├── keypoints2sticks.m ├── keypoints2sticks_mpii_cooking.m ├── scale01.m └── scaleAB.m /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /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 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # End-to-End Learning of Deformable Mixture of Parts and Deep Convolutional Neural Networks for Human Pose Estimation 2 | 3 | Pose estimation results on the [LSP](http://www.comp.leeds.ac.uk/mat4saj/lsp.html) [1] dataset, the [FLIC](http://vision.grasp.upenn.edu/cgi-bin/index.php?n=VideoLearning.FLIC) [2] dataset, and the [Image Parse](http://www.cs.cmu.edu/~deva/papers/parse/index.html) [3] dataset for the following paper. 4 | > Wei Yang, Wanli Ouyang, Hongsheng Li, Xiaogang Wang. "End-to-End Learning of Deformable Mixture of Parts and Deep Convolutional Neural Networks for Human Pose Estimation". In CVPR, 2016. 5 | 6 | ## Instruction 7 | Please run `demo_eval_DATASETNAME.m` to evaluate a specific dataset. `DATASETNAME` can be `lsp`, `flic` or `parse`. 8 | 9 | ## Acknowledgement 10 | The evaluation code for the PCP and the PCK measurements are from a widely used version from the [MPII Human Pose Dataset](http://human-pose.mpi-inf.mpg.de/#related_benchmarks). The code for the PDJ measurement is from [Chen and Yuille, NIPS'14](http://www.stat.ucla.edu/~xianjie.chen/projects/pose_estimation/pose_estimation.html) 11 | 12 | ## Citation 13 | 14 | @InProceedings{yang2016end, 15 | Title = {End-to-End Learning of Deformable Mixture of Parts and Deep Convolutional Neural Networks for Human Pose Estimation}, 16 | Author = {Yang, Wei and Ouyang, Wanli and Li, Hongsheng and Wang, Xiaogang}, 17 | Booktitle = {CVPR}, 18 | Year = {2016} 19 | } 20 | 21 | 22 | ## References 23 | 1. S. Johnson and M. Everingham. *Clustered pose and nonlinear appearance models for human pose estimation*. In BMVC, 2010. 24 | 2. B. Sapp and B. Taskar. *Modec: Multimodal decomposable models for human pose estimation*. In CVPR, 2013. 25 | 3. D. Ramanan. *Learning to parse images of articulated objects.* In NIPS, 2006. 26 | 27 | -------------------------------------------------------------------------------- /demo_eval_flic.m: -------------------------------------------------------------------------------- 1 | % FLIC joint 2 | % 1 nose 3 | % 2 neck (interpolated) 4 | % 3 right shoulder 5 | % 4 right elbow 6 | % 5 right wrist 7 | % 6 right hip 8 | % 7 left shoulder 9 | % 8 left elbow 10 | % 9 left wrist 11 | % 10 left hip 12 | startup; 13 | 14 | reference_joints_pair = [6, 7]; % right shoulder and left hip (from observer's perspective) 15 | % symmetry_joint_id(i) = j, if joint j is the symmetry joint of i (e.g., the left 16 | % shoulder is the symmetry joint of the right shoulder). 17 | symmetry_joint_id = [2,1,7,8,9,10,3,4,5,6]; 18 | joint_name = {'Head', 'Shou', 'Elbo', 'Wris', 'Hip'}; 19 | 20 | symmetry_part_id = [1,2,5,6,3,4]; 21 | part_name = {'Head', 'Torso', 'U.arms', 'L.arms'}; 22 | 23 | %% Evaluate FLIC (Observer Centric) 24 | load('gt/flic-joints-test-oc.mat', 'joints'); % load original FLIC labels 25 | eval_name = 'FLIC-OC'; 26 | 27 | % eval PCP 28 | load('results/FLIC/pred_sticks_flic_oc.mat', 'pred'); 29 | gt_sticks = keypoints2sticks(joints); 30 | eval_pcp(pred, gt_sticks, symmetry_part_id, part_name, eval_name); 31 | 32 | % eval PCK 33 | load('results/FLIC/pred_keypoints_flic_oc.mat', 'pred'); 34 | eval_pck(pred, joints, symmetry_joint_id, joint_name, eval_name); 35 | 36 | % eval PDJ 37 | eval_pdj(pred, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name); -------------------------------------------------------------------------------- /demo_eval_flic_pc.m: -------------------------------------------------------------------------------- 1 | % FLIC joint 2 | % 1 nose 3 | % 2 neck (interpolated) 4 | % 3 right shoulder 5 | % 4 right elbow 6 | % 5 right wrist 7 | % 6 right hip 8 | % 7 left shoulder 9 | % 8 left elbow 10 | % 9 left wrist 11 | % 10 left hip 12 | startup; 13 | 14 | % prepare groundtruth annotation 15 | 16 | joint_order = [13, 14, 17, 4, 5, 6, 10, 1, 2, 3, 7]; 17 | np = length(joint_order); 18 | 19 | flic_anno = load('~/Data/dataset/FLIC/examples.mat', 'examples'); 20 | flic_anno = flic_anno.examples; 21 | test_frs_pos = find([flic_anno.istest] == 1); % testing frames for positive 22 | % ------------------ original images ------------------- 23 | joints = zeros(2, np, length(test_frs_pos)); 24 | cnt = 1; 25 | for ii = test_frs_pos 26 | clc; fprintf('%4d | %4d\n', ii, length(test_frs_pos)); 27 | fr = flic_anno(ii); 28 | joints(:, :, cnt) = fr.coords(1:2,joint_order); 29 | cnt = cnt + 1; 30 | end 31 | 32 | 33 | reference_joints_pair = [4, 11]; % right shoulder and left hip (from observer's perspective) 34 | % symmetry_joint_id(i) = j, if joint j is the symmetry joint of i (e.g., the left 35 | % shoulder is the symmetry joint of the right shoulder). 36 | symmetry_joint_id = [2,1,3,8,9,10,11,4,5,6,7]; 37 | joint_name = {'Eyes', 'Nose', 'Shou', 'Elbo', 'Wris', 'Hip'}; 38 | 39 | symmetry_part_id = [1,2,5,6,3,4]; 40 | part_name = {'Head', 'Torso', 'U.arms', 'L.arms'}; 41 | 42 | %% Evaluate FLIC (Person Centric) 43 | eval_name = 'FLIC-OC'; 44 | 45 | predfile = '/home/wyang/code/pose/fb.resnet.torch.pose/checkpoints/flic_s8_mean/pred_best.h5'; 46 | preds = hdf5read(predfile,'preds'); 47 | 48 | % eval PCK 49 | load('results/FLIC/pred_keypoints_flic_oc.mat', 'pred'); 50 | eval_pck(preds, joints, symmetry_joint_id, joint_name, eval_name); 51 | 52 | % % eval PDJ 53 | % eval_pdj(preds, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name); -------------------------------------------------------------------------------- /demo_eval_lsp.m: -------------------------------------------------------------------------------- 1 | % LSP joint 2 | % 1 Right ankle 3 | % 2 Right knee 4 | % 3 Right hip 5 | % 4 Left hip 6 | % 5 Left knee 7 | % 6 Left ankle 8 | % 7 Right wrist 9 | % 8 Right elbow 10 | % 9 Right shoulder 11 | % 10 Left shoulder 12 | % 11 Left elbow 13 | % 12 Left wrist 14 | % 13 Neck 15 | % 14 Head top 16 | startup; 17 | 18 | reference_joints_pair = [3, 10]; % right shoulder and left hip (from observer's perspective) 19 | % symmetry_joint_id(i) = j, if joint j is the symmetry joint of i (e.g., the left 20 | % shoulder is the symmetry joint of the right shoulder). 21 | symmetry_joint_id = [6,5,4,3,2,1,12,11,10,9,8,7,14,13]; 22 | joint_name = {'Ankle', 'Knee', 'Hip', 'Wris', 'Elbo', 'Shou', 'Head'}; 23 | 24 | % symmetry_part_id(i) = j, if part j is the symmetry part of i (e.g., the left 25 | % upper arm is the symmetry part of the right upper arm). 26 | symmetry_part_id = [4,3,2,1,8,7,6,5,9,10]; 27 | part_name = {'L.legs', 'U.legs', 'L.arms', 'U.arms', 'Head', 'Torso'}; 28 | %% Evaluate LSP (Observer Centric) 29 | load('gt/lsp-joints-OC.mat', 'joints'); 30 | joints = joints(1:2,:,1001:end); 31 | eval_name = 'LSP-OC'; 32 | 33 | % eval PCP 34 | load('results/LSP/pred_sticks_lsp_oc.mat', 'pred'); 35 | gt_sticks = keypoints2sticks(joints); 36 | eval_pcp(pred, gt_sticks, symmetry_part_id, part_name, eval_name); 37 | 38 | % eval PCK 39 | load('results/LSP/pred_keypoints_lsp_oc.mat', 'pred'); 40 | eval_pck(pred, joints, symmetry_joint_id, joint_name, eval_name); 41 | 42 | % eval PDJ 43 | eval_pdj(pred, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name); 44 | 45 | %% Evaluate LSP (Person Centric) 46 | load('gt/lsp-joints-PC.mat', 'joints'); 47 | joints = joints(1:2,:,1001:end); 48 | eval_name = 'LSP-PC'; 49 | 50 | % eval PCP 51 | load('results/LSP/pred_sticks_lsp_pc.mat', 'pred'); 52 | gt_sticks = keypoints2sticks(joints); 53 | eval_pcp(pred, gt_sticks, symmetry_part_id, part_name, eval_name); 54 | 55 | % eval PCK 56 | load('results/LSP/pred_keypoints_lsp_pc.mat', 'pred'); 57 | eval_pck(pred, joints, symmetry_joint_id, joint_name, eval_name); 58 | 59 | % eval PDJ 60 | eval_pdj(pred, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name); 61 | -------------------------------------------------------------------------------- /demo_eval_mpiicooking.m: -------------------------------------------------------------------------------- 1 | % MPII Cooking joint 2 | % 1 neck 3 | % 2 bottom torso 4 | % 3 right shoulder 5 | % 4 left shoulder 6 | % 5 right elbow 7 | % 6 left elbow 8 | % 7 right wrist 9 | % 8 left wrist 10 | % 9 right hand 11 | % 10 left hand 12 | % 11 bottom head 13 | % 12 top head 14 | % 15 | % MPII cooking has no `hip` annotations and cannot use the PDJ and PCK 16 | % evaluation measure 17 | % It also has no head bounding box, hence can not use the PCKh protocal 18 | % Match the released results available at 19 | % http://datasets.d2.mpi-inf.mpg.de/MPIICookingActivities/poseChallenge-1.1.zip 20 | % 21 | % Wei YANG 22 | % Sep 10, 2016 23 | clc; 24 | startup; 25 | 26 | reference_joints_pair = [3, 10]; % right shoulder and left hip (from observer's perspective) 27 | % symmetry_joint_id(i) = j, if joint j is the symmetry joint of i (e.g., the left 28 | % shoulder is the symmetry joint of the right shoulder). 29 | symmetry_joint_id = [6,5,4,3,2,1,12,11,10,9,8,7,14,13]; 30 | joint_name = {'Ankle', 'Knee', 'Hip', 'Wris', 'Elbo', 'Shou', 'Head'}; 31 | 32 | % symmetry_part_id(i) = j, if part j is the symmetry part of i (e.g., the left 33 | % upper arm is the symmetry part of the right upper arm). 34 | symmetry_part_id = [1,3,2,5,4,6]; 35 | part_name = {'Torso', 'U.arms', 'L.arms', 'Head' }; 36 | %% Evaluate MPII cooking 37 | load('gt/mpii-cooking.mat', 'joints'); 38 | eval_name = 'MPII-cooking'; 39 | 40 | % eval PCP 41 | load('results/mpii-cooking/Rohrbach_cvpr12.mat', 'pred'); 42 | gt_sticks = keypoints2sticks_mpii_cooking(joints); 43 | pred_sticks = keypoints2sticks_mpii_cooking(pred); 44 | eval_pcp(pred_sticks, gt_sticks, symmetry_part_id, part_name, eval_name); 45 | 46 | -------------------------------------------------------------------------------- /demo_eval_parse.m: -------------------------------------------------------------------------------- 1 | % PARSE joint 2 | % 1 Left ankle 3 | % 2 Left knee 4 | % 3 Left hip 5 | % 4 Right hip 6 | % 5 Right knee 7 | % 6 Right ankle 8 | % 7 Left wrist 9 | % 8 Left elbow 10 | % 9 Left shoulder 11 | % 10 Right shoulder 12 | % 11 Right elbow 13 | % 12 Right wrist 14 | % 13 Neck 15 | % 14 Head top 16 | startup; 17 | 18 | reference_joints_pair = [3, 10]; % right shoulder and left hip (from observer's perspective) 19 | % symmetry_joint_id(i) = j, if joint j is the symmetry joint of i (e.g., the left 20 | % shoulder is the symmetry joint of the right shoulder). 21 | symmetry_joint_id = [6,5,4,3,2,1,12,11,10,9,8,7,14,13]; 22 | joint_name = {'Ankle', 'Knee', 'Hip', 'Wris', 'Elbo', 'Shou', 'Head'}; 23 | 24 | % symmetry_part_id(i) = j, if part j is the symmetry part of i (e.g., the left 25 | % upper arm is the symmetry part of the right upper arm). 26 | symmetry_part_id = [4,3,2,1,8,7,6,5,9,10]; 27 | part_name = {'L.legs', 'U.legs', 'L.arms', 'U.arms', 'Head', 'Torso'}; 28 | %% Evaluate PARSE (Person Centric) 29 | load('gt/parse-labels.mat', 'ptsAll'); % load original parse labels 30 | joints = permute(ptsAll, [2 1 3]); 31 | joints = joints(:,:,101:305); 32 | eval_name = 'PARSE-PC'; 33 | 34 | % eval PCP 35 | load('results/PARSE/pred_sticks_parse_pc.mat', 'pred'); 36 | gt_sticks = keypoints2sticks(joints); 37 | eval_pcp(pred, gt_sticks, symmetry_part_id, part_name, eval_name); 38 | 39 | % eval PCK 40 | load('results/PARSE/pred_keypoints_parse_pc.mat', 'pred'); 41 | eval_pck(pred, joints, symmetry_joint_id, joint_name, eval_name); 42 | 43 | % eval PDJ 44 | eval_pdj(pred, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name); -------------------------------------------------------------------------------- /gt/flic-joints-oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/flic-joints-oc.mat -------------------------------------------------------------------------------- /gt/flic-joints-test-oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/flic-joints-test-oc.mat -------------------------------------------------------------------------------- /gt/lsp-joints-OC.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/lsp-joints-OC.mat -------------------------------------------------------------------------------- /gt/lsp-joints-PC.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/lsp-joints-PC.mat -------------------------------------------------------------------------------- /gt/mpii-cooking.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/mpii-cooking.mat -------------------------------------------------------------------------------- /gt/parse-joints.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/parse-joints.mat -------------------------------------------------------------------------------- /gt/parse-labels.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/gt/parse-labels.mat -------------------------------------------------------------------------------- /results/FLIC/pred_keypoints_flic_oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/FLIC/pred_keypoints_flic_oc.mat -------------------------------------------------------------------------------- /results/FLIC/pred_sticks_flic_oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/FLIC/pred_sticks_flic_oc.mat -------------------------------------------------------------------------------- /results/LSP/pred_keypoints_lsp_oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/LSP/pred_keypoints_lsp_oc.mat -------------------------------------------------------------------------------- /results/LSP/pred_keypoints_lsp_pc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/LSP/pred_keypoints_lsp_pc.mat -------------------------------------------------------------------------------- /results/LSP/pred_sticks_lsp_oc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/LSP/pred_sticks_lsp_oc.mat -------------------------------------------------------------------------------- /results/LSP/pred_sticks_lsp_pc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/LSP/pred_sticks_lsp_pc.mat -------------------------------------------------------------------------------- /results/PARSE/pred_keypoints_parse_pc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/PARSE/pred_keypoints_parse_pc.mat -------------------------------------------------------------------------------- /results/PARSE/pred_sticks_parse_pc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/PARSE/pred_sticks_parse_pc.mat -------------------------------------------------------------------------------- /results/mpii-cooking/Rohrbach_cvpr12.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearpaw/eval_pose/f6c71b64c8183aa71f18577494fa32d3b0536396/results/mpii-cooking/Rohrbach_cvpr12.mat -------------------------------------------------------------------------------- /startup.m: -------------------------------------------------------------------------------- 1 | addpath('./utils'); -------------------------------------------------------------------------------- /utils/eval_pck.m: -------------------------------------------------------------------------------- 1 | function eval_pck(pred, joints, symmetry_joint_id, joint_name, name) 2 | % implementation of PCK measure, 3 | % as defined in [Sapp&Taskar, CVPR'13]. 4 | % torso height: ||left_shoulder - right hip|| 5 | range = 0:0.01:0.2; 6 | show_joint_ids = (symmetry_joint_id >= 1:numel(symmetry_joint_id)); 7 | 8 | % compute distance to ground truth joints 9 | dist = get_dist_pck(pred,joints(1:2,:,:)); 10 | 11 | % compute PCK 12 | pck_all = compute_pck(dist,range); 13 | pck = pck_all(end, :); 14 | pck(1:end-1) = (pck(1:end-1) + pck(symmetry_joint_id))/2; 15 | % plot results 16 | pck = [pck(show_joint_ids) pck(end)]; 17 | fprintf('------------ PCK Evaluation: %s -------------\n', name); 18 | fprintf('Parts '); fprintf('& %s ', joint_name{:}); fprintf('& Mean\n'); 19 | fprintf('PCK '); fprintf('& %.1f ', pck); fprintf('\n'); 20 | 21 | auc = area_under_curve(scale01(range),pck_all(:,end)); 22 | % plot(range,pck(:,end),'color',p.colorName,'LineStyle','-','LineWidth',3); 23 | fprintf('%s, AUC: %1.1f\n', name, auc); 24 | 25 | % ------------------------------------------------------------------------- 26 | function dist = get_dist_pck(pred,gt) 27 | 28 | assert(size(pred,1) == size(gt,1) && size(pred,2) == size(gt,2) && size(pred,3) == size(gt,3)); 29 | 30 | dist = nan(1,size(pred,2),size(pred,3)); 31 | 32 | for imgidx = 1:size(pred,3) 33 | 34 | % torso diameter 35 | if size(gt, 2) == 14 36 | refDist = norm(gt(:,10,imgidx) - gt(:,3,imgidx)); 37 | elseif size(gt, 2) == 10 % 10 joints FLIC 38 | refDist = norm(gt(:,7,imgidx) - gt(:,6,imgidx)); 39 | elseif size(gt, 2) == 11 % 11 joints FLIC 40 | refDist = norm(gt(:,4,imgidx) - gt(:,11,imgidx)); 41 | else 42 | error('Number of joints should be 14 or 10 or 11'); 43 | end 44 | 45 | % distance to gt joints 46 | dist(1,:,imgidx) = sqrt(sum((pred(:,:,imgidx) - gt(:,:,imgidx)).^2,1))./refDist; 47 | 48 | end 49 | 50 | 51 | % ------------------------------------------------------------------------- 52 | function pck = compute_pck(dist,range) 53 | 54 | pck = zeros(numel(range),size(dist,2)+1); 55 | 56 | for jidx = 1:size(dist,2) 57 | % compute PCK for each threshold 58 | for k = 1:numel(range) 59 | pck(k,jidx) = 100*mean(squeeze(dist(1,jidx,:))<=range(k)); 60 | end 61 | end 62 | 63 | % compute average PCK 64 | for k = 1:numel(range) 65 | pck(k,end) = 100*mean(reshape(squeeze(dist(1,:,:)),size(dist,2)*size(dist,3),1)<=range(k)); 66 | end 67 | 68 | % ------------------------------------------------------------------------- 69 | function auc = area_under_curve(xpts,ypts) 70 | 71 | if nargin == 1 72 | ypts = xpts; 73 | xpts = (1:size(ypts,2))/size(ypts,2); 74 | end 75 | 76 | a = min(xpts); 77 | b = max(xpts); 78 | %remove duplicate points 79 | [ignore,I,J] = unique(xpts); 80 | xpts = xpts(I); 81 | ypts = ypts(I); 82 | if length(xpts) < 2; auc = NaN; return; end 83 | myfun = @(x)(interp1(xpts,ypts,x)); 84 | auc = quadgk(myfun,a,b); -------------------------------------------------------------------------------- /utils/eval_pcp.m: -------------------------------------------------------------------------------- 1 | function eval_pcp(pred, gt_sticks, symmetry_part_id, part_name, name) 2 | show_part_ids = find(symmetry_part_id >= 1:numel(symmetry_part_id)); 3 | % evaluate strict PCP 4 | range = 0.5; 5 | % compute distance to ground truth joints 6 | dist = getDistPCP(pred,gt_sticks); 7 | 8 | % compute PCP 9 | pcp = computePCP(dist,range); 10 | 11 | % plot results 12 | pcp(1:end-1) = (pcp(1:end-1) + pcp(symmetry_part_id))/2; 13 | print_pcp(pcp, show_part_ids, part_name, name); 14 | 15 | 16 | % ------------------------------------------------------------------------- 17 | function dist = getDistPCP(pred,gt_sticks) 18 | % assert(size(gt_sticks,2) == 20); 19 | assert(size(pred,1) == size(gt_sticks,1) && size(pred,2) == size(gt_sticks,2) && size(pred,3) == size(gt_sticks,3)); 20 | 21 | dist = nan(1,size(pred,2),size(pred,3)); 22 | 23 | for imgidx = 1:size(pred,3) 24 | for jidx = 1:size(gt_sticks,2)/2 25 | jidx1 = 2*(jidx-1)+1; 26 | jidx2 = 2*(jidx-1)+2; 27 | % distance to gt endpoints 28 | dist(1,jidx1,imgidx) = norm(gt_sticks(:,jidx1,imgidx) - pred(:,jidx1,imgidx))/norm(gt_sticks(:,jidx1,imgidx) - gt_sticks(:,jidx2,imgidx)); 29 | dist(1,jidx2,imgidx) = norm(gt_sticks(:,jidx2,imgidx) - pred(:,jidx2,imgidx))/norm(gt_sticks(:,jidx1,imgidx) - gt_sticks(:,jidx2,imgidx)); 30 | end 31 | end 32 | 33 | % ------------------------------------------------------------------------- 34 | function [pcp, match] = computePCP(dist,range) 35 | pcp = zeros(numel(range),size(dist,2)/2+1); 36 | matchAll = zeros(numel(range),size(dist,2)/2*size(dist,3)); 37 | match = cell(1, size(dist,2)/2); 38 | for jidx = 1:size(dist,2)/2 39 | % compute PCP for each threshold 40 | jidx1 = 2*(jidx-1)+1; 41 | jidx2 = 2*(jidx-1)+2; 42 | for k = 1:numel(range) 43 | match{jidx} = squeeze(dist(1,jidx1,:))<=range(k) & squeeze(dist(1,jidx2,:)<=range(k)); 44 | pcp(k,jidx) = 100*mean(match{jidx}); 45 | matchAll(k,size(dist,3)*(jidx-1)+1:size(dist,3)*(jidx)) = match{jidx}; 46 | end 47 | end 48 | % compute average PCP 49 | for k = 1:numel(range) 50 | pcp(k,end) = 100*mean(matchAll(k,:)); 51 | end 52 | 53 | % ------------------------------------------------------------------------- 54 | function print_pcp(pcp, show_part_ids, part_name, name) 55 | pcp = [pcp(show_part_ids) pcp(end)]; 56 | fprintf('------------ strict PCP Evaluation: %s -------------\n', name); 57 | fprintf('Parts '); fprintf('& %s ', part_name{:}); fprintf('& Mean\n'); 58 | fprintf('strict PCP '); fprintf('& %.1f ', pcp); fprintf('\n'); -------------------------------------------------------------------------------- /utils/eval_pdj.m: -------------------------------------------------------------------------------- 1 | function [accs, range] = eval_pdj(pred, joints, reference_joints_pair, symmetry_joint_id, joint_name, eval_name) 2 | % Evaluate Percentage of Detected Joints (PDJ) 3 | assert(numel(reference_joints_pair) == 2); 4 | show_joint_ids = find(symmetry_joint_id >= 1:numel(symmetry_joint_id)); 5 | range = 0:0.01:0.5; 6 | 7 | % im = zeros(500, 500, 3); 8 | % imshow(im); hold on; 9 | % for i = 1:14 10 | % plot(joints(1, i, 2), joints(2, i, 2), 'Marker','o','MarkerFaceColor','red'); hold on; pause; 11 | % end 12 | % close; 13 | 14 | num = size(pred, 3); 15 | assert(num >= 1); 16 | % the number of joints 17 | joint_n = size(joints, 2); 18 | 19 | scale = zeros(1, num); 20 | for ii = 1:num 21 | scale(ii) = norm( joints(:,reference_joints_pair(1), ii) ... 22 | - joints(:,reference_joints_pair(2), ii) ); 23 | end 24 | 25 | dists = zeros(num, joint_n); 26 | for ii = 1:num 27 | dists(ii,:) = sqrt(sum( (pred(:, :, ii) - joints(:,:,ii)).^2, 1 )); 28 | dists(ii,:) = dists(ii,:) / scale(ii); 29 | end 30 | 31 | accs = zeros(numel(range), joint_n); 32 | for ii = 1:numel(range) 33 | accs(ii,:) = mean(dists <= range(ii),1); 34 | end 35 | 36 | accs = (accs + accs(:,symmetry_joint_id)) / 2; 37 | accs = accs(:, show_joint_ids); 38 | % print 39 | fprintf('-------------- PDJ Evaluation ---------------\n') 40 | fprintf('Joints '); fprintf('& %s ', joint_name{:}); fprintf('\n'); 41 | sample_pdj_thresholds = [0.1, 0.2, 0.3, 0.4]; 42 | for ii = 1:length(sample_pdj_thresholds) 43 | t = sample_pdj_thresholds(ii); 44 | idx = (range == t); 45 | fprintf('PDJ@%.2f ', t); fprintf('& %.1f ', accs(idx,:)*100); fprintf('\n'); 46 | end 47 | % plot 48 | line_width = 2; 49 | p_color = {'g','y','b','r','c','k','m'}; 50 | % visualize 51 | figure; hold on; grid on; 52 | for ii = 1:numel(show_joint_ids) 53 | plot(range, accs(:, ii), p_color{mod(ii, numel(p_color))+1}, 'linewidth', line_width); 54 | end 55 | leg_str = cell(numel(show_joint_ids), 1); 56 | for ii = 1:numel(show_joint_ids) 57 | leg_str{ii} = sprintf('%s', joint_name{ii}); 58 | end 59 | h_leg = legend(leg_str, 'FontSize', 12); 60 | set(h_leg, 'location', 'southeast', 'linewidth', 1); 61 | 62 | axis([range(1),range(end), 0, 1]); 63 | set(gca,'ytick', 0:0.1:1); 64 | set(gca, 'linewidth', 1); 65 | % --- titles 66 | xlabel('Normalized Precision Threshold') % x-axis label 67 | ylabel('Detection Rate') % y-axis label 68 | 69 | title([eval_name ' PDJ']); 70 | hold off; 71 | -------------------------------------------------------------------------------- /utils/keypoints2sticks.m: -------------------------------------------------------------------------------- 1 | function sticks = keypoints2sticks(keypoints) 2 | joint_n = size(keypoints, 2); 3 | 4 | if joint_n == 14 % LSP and PARSE 5 | % The canonical part stick order: 6 | % 1 Right Lower Leg 7 | % 2 Right Upper Leg 8 | % 3 Left Upper Leg 9 | % 4 Left Lower Leg 10 | % 5 Right Lower Arm 11 | % 6 Right Upper Arm 12 | % 7 Left Upper Arm 13 | % 8 Left Lower Arm 14 | % 9 Torso 15 | % 10 Head 16 | sticks = zeros(2,20,size(keypoints,3)); 17 | sticks(:,1:2,:) = keypoints(:,1:2,:); 18 | sticks(:,3:4,:) = keypoints(:,2:3,:); 19 | sticks(:,5:6,:) = keypoints(:,4:5,:); 20 | sticks(:,7:8,:) = keypoints(:,5:6,:); 21 | sticks(:,9:10,:) = keypoints(:,7:8,:); 22 | sticks(:,11:12,:) = keypoints(:,8:9,:); 23 | sticks(:,13:14,:) = keypoints(:,10:11,:); 24 | sticks(:,15:16,:) = keypoints(:,11:12,:); 25 | sticks(:,17:18,:) = keypoints(:,13:14,:); 26 | sticks(:,19,:) = mean(keypoints(:,3:4,:),2); 27 | sticks(:,20,:) = mean(keypoints(:,9:10,:),2); 28 | else % FLIC 29 | % The canonical joint order: 30 | % 1 Nose 31 | % 2 Neck 32 | % 3 Left shoulder (from observer's perspective) 33 | % 4 Left elbow 34 | % 5 Left wrist 35 | % 6 Left hip 36 | % 7 Right shoulder 37 | % 8 Right elbow 38 | % 9 Right wrist 39 | % 10 Right hip 40 | % 41 | % The canonical part stick order: 42 | % 1 Torso 43 | % 2 Head 44 | % 3 Left Upper Arm 45 | % 4 Left Lower Arm 46 | % 5 Right Upper Arm 47 | % 6 Right Lower Arm 48 | stick_no = 6; 49 | sticks = zeros(2,stick_no*2,size(keypoints,3)); 50 | 51 | sticks(:,1:2,:) = [keypoints(:, 2, :), (keypoints(:, 6, :) + keypoints(:, 10, :))/2]; % Torso 52 | sticks(:,3:4,:) = [keypoints(:, 1, :), keypoints(:, 2, :)]; % Head 53 | sticks(:,5:6,:) = [keypoints(:, 3, :), keypoints(:, 4, :)]; % Left Upper Arm 54 | sticks(:,7:8,:) = [keypoints(:, 4, :), keypoints(:, 5, :)]; % Left Lower Arm 55 | sticks(:,9:10,:) = [keypoints(:, 7, :), keypoints(:, 8, :)]; % Right Upper Arm 56 | sticks(:,11:12,:) = [keypoints(:, 8, :), keypoints(:, 9, :)]; % Right Lower Arm 57 | end 58 | end -------------------------------------------------------------------------------- /utils/keypoints2sticks_mpii_cooking.m: -------------------------------------------------------------------------------- 1 | function sticks = keypoints2sticks_mpii_cooking(keypoints) 2 | 3 | 4 | % MPII Cooking joint 5 | % 1 neck 6 | % 2 bottom torso 7 | % 3 right shoulder 8 | % 4 left shoulder 9 | % 5 right elbow 10 | % 6 left elbow 11 | % 7 right wrist 12 | % 8 left wrist 13 | % 9 right hand 14 | % 10 left hand 15 | % 11 bottom head 16 | % 12 top head 17 | % 18 | % The canonical part stick order: 19 | % 1 Right Lower Arm 20 | % 2 Right Upper Arm 21 | % 3 Left Upper Arm 22 | % 4 Left Lower Arm 23 | % 5 Torso 24 | % 6 Head 25 | 26 | sticks = zeros(2,12,size(keypoints,3)); 27 | sticks(:,1:2,:) = [keypoints(:,1,:) keypoints(:,2,:)]; % torso 28 | sticks(:,3:4,:) = [keypoints(:,3,:) keypoints(:,5,:)]; % right-upper-arm 29 | sticks(:,5:6,:) = [keypoints(:,4,:) keypoints(:,6,:)]; % left-upper-arm 30 | sticks(:,7:8,:) = [keypoints(:,5,:) keypoints(:,7,:)]; % right-fore-arm 31 | sticks(:,9:10,:) = [keypoints(:,6,:) keypoints(:,8,:)]; % left-fore-arm 32 | sticks(:,11:12,:) = [keypoints(:,11,:) keypoints(:,12,:)]; % head 33 | end -------------------------------------------------------------------------------- /utils/scale01.m: -------------------------------------------------------------------------------- 1 | function X = scale01(X,d) 2 | X = double(X); 3 | if nargin == 1 4 | X = scaleAB(X,0,1); 5 | else 6 | X = scaleAB(X,0,1,d); 7 | end 8 | 9 | return 10 | 11 | % if isempty(X), return; end 12 | % if nargin == 1 13 | % minval = min(X(:)); 14 | % maxval = max(X(:)); 15 | % diffval = maxval-minval; 16 | % diffval(diffval==0) = 1; 17 | % X = (X - minval)/diffval; 18 | % else 19 | % minvals = min(X,[],d); 20 | % maxvals = max(X,[],d); 21 | % diffvals = maxvals - minvals; 22 | % diffvals(diffvals==0) = 1; 23 | % X = bsxfun(@times,bsxfun(@minus,X,minvals),1./(diffvals)); 24 | % end 25 | 0; -------------------------------------------------------------------------------- /utils/scaleAB.m: -------------------------------------------------------------------------------- 1 | function X = scaleAB(X,A,B,d) 2 | % X = scaleAB(X,A,B) 3 | % X = scaleAB(X,A,B,d) 4 | 5 | if isempty(X), return; end 6 | if nargin == 3 7 | m = min(X(:)); 8 | M = max(X(:)); 9 | diffval = m-M; 10 | diffval(diffval==0) = 1; 11 | X = (X - M)/diffval*(A-B)+B; 12 | else 13 | m = min(X,[],d); 14 | M = max(X,[],d); 15 | diffvals = m - M; 16 | diffvals(diffvals==0) = 1; 17 | X = bsxfun(@times,bsxfun(@minus,X,M),1./(diffvals)*(A-B))+ B; 18 | end 19 | 0; --------------------------------------------------------------------------------