├── .gitignore ├── README.md ├── fin.py ├── fin_2.png ├── fin_2.xml ├── fist.png ├── fist.py ├── fist.xml ├── hand.png ├── hand.py ├── hand.xml ├── main_file.py ├── ok.xml ├── okay.png ├── okay.py ├── point.png ├── point.py ├── point1.xml ├── thumbdown.png ├── thumbdown.py └── thumbdown.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hand-Gesture-Recognition-for-Presentation-Process-in-Python 2 | Controls the presentation process using hand gestures. 3 | 4 | Version: 5 | python 3 or above is recommended 6 | 7 | 8 | Save all files in one single location and update the path in all scripts. 9 | 10 | Commands: 11 | Install packages using following commands: 12 | 13 | 1.pip install opencv-python 14 | 2.pip install keyboard 15 | 3.pip install pyautogui 16 | 4.pip install numpy 17 | 18 | Run the main file and start the slide show of your presentation. 19 | 20 | XML file functions: 21 | fin_2 is used for next slide, 22 | point is used for previous slide, 23 | ok is used to zoom in, 24 | hand is used to zoom out, 25 | 26 | You can any additional functions using fist and thumbdowm gesture. 27 | 28 | 29 | Hand gestures are shown in images. 30 | -------------------------------------------------------------------------------- /fin.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def f_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | # applying gaussian blur 13 | value = (35, 35) 14 | blurred = cv2.GaussianBlur(grey, value, 0) 15 | 16 | # thresholdin: Otsu's Binarization method 17 | _, thresh1 = cv2.threshold(blurred, 127, 255, 18 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 19 | 20 | # show thresholded image 21 | cv2.imshow('Thresholded', thresh1) 22 | 23 | # check OpenCV version to avoid unpacking error 24 | (version, _, _) = cv2.__version__.split('.') 25 | 26 | if version == '3': 27 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 28 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 29 | elif version == '2': 30 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 31 | cv2.CHAIN_APPROX_NONE) 32 | 33 | # find contour with max area 34 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 35 | 36 | # create bounding rectangle around the contour (can skip below two lines) 37 | x, y, w, h = cv2.boundingRect(cnt) 38 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 39 | 40 | # finding convex hull 41 | hull = cv2.convexHull(cnt) 42 | 43 | # drawing contours 44 | drawing = np.zeros(crop_img.shape,np.uint8) 45 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 46 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 47 | 48 | # finding convex hull 49 | hull = cv2.convexHull(cnt, returnPoints=False) 50 | 51 | # finding convexity defects 52 | defects = cv2.convexityDefects(cnt, hull) 53 | count_defects = 0 54 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 55 | 56 | # applying Cosine Rule to find angle for all defects (between fingers) 57 | # with angle > 90 degrees and ignore defects 58 | for i in range(defects.shape[0]): 59 | s,e,f,d = defects[i,0] 60 | 61 | start = tuple(cnt[s][0]) 62 | end = tuple(cnt[e][0]) 63 | far = tuple(cnt[f][0]) 64 | if d>10000: 65 | count_defects+=1 66 | 67 | # find length of all sides of triangle 68 | 69 | 70 | # define actions required 71 | 72 | count_defects+=1 73 | if count_defects == 1: 74 | keyboard.press_and_release('right') 75 | 76 | 77 | else: 78 | cv2.putText(img,"0", (50, 50),\ 79 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 80 | ha=0 81 | 82 | #time.sleep(1) 83 | # show appropriate images in windows 84 | #cv2.imshow('Gesture', img) 85 | all_img = np.hstack((drawing, crop_img)) 86 | cv2.imshow('Contours', all_img) 87 | -------------------------------------------------------------------------------- /fin_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/fin_2.png -------------------------------------------------------------------------------- /fist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/fist.png -------------------------------------------------------------------------------- /fist.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def fs_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | # applying gaussian blur 13 | value = (35, 35) 14 | blurred = cv2.GaussianBlur(grey, value, 0) 15 | 16 | # thresholdin: Otsu's Binarization method 17 | _, thresh1 = cv2.threshold(blurred, 127, 255, 18 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 19 | 20 | # show thresholded image 21 | cv2.imshow('Thresholded', thresh1) 22 | 23 | # check OpenCV version to avoid unpacking error 24 | (version, _, _) = cv2.__version__.split('.') 25 | 26 | if version == '3': 27 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 28 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 29 | elif version == '2': 30 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 31 | cv2.CHAIN_APPROX_NONE) 32 | 33 | # find contour with max area 34 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 35 | 36 | # create bounding rectangle around the contour (can skip below two lines) 37 | x, y, w, h = cv2.boundingRect(cnt) 38 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 39 | 40 | # finding convex hull 41 | hull = cv2.convexHull(cnt) 42 | 43 | # drawing contours 44 | drawing = np.zeros(crop_img.shape,np.uint8) 45 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 46 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 47 | 48 | # finding convex hull 49 | hull = cv2.convexHull(cnt, returnPoints=False) 50 | 51 | # finding convexity defects 52 | defects = cv2.convexityDefects(cnt, hull) 53 | count_defects = 0 54 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 55 | 56 | # applying Cosine Rule to find angle for all defects (between fingers) 57 | # with angle > 90 degrees and ignore defects 58 | for i in range(defects.shape[0]): 59 | s,e,f,d = defects[i,0] 60 | 61 | start = tuple(cnt[s][0]) 62 | end = tuple(cnt[e][0]) 63 | far = tuple(cnt[f][0]) 64 | if d>10000: 65 | count_defects+=1 66 | 67 | # define actions required 68 | 69 | count_defects+=1 70 | # define actions required 71 | if count_defects == 1: 72 | cv2.putText(img,"ha", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 73 | keyboard.press_and_release('enter') 74 | 75 | else: 76 | cv2.putText(img,"0", (50, 50),\ 77 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 78 | ha=0 79 | 80 | #time.sleep(1) 81 | # show appropriate images in windows 82 | #cv2.imshow('Gesture', img) 83 | all_img = np.hstack((drawing, crop_img)) 84 | cv2.imshow('Contours', all_img) 85 | -------------------------------------------------------------------------------- /fist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 24 24 6 | 7 | <_> 8 | 9 | 10 | <_> 11 | 12 | <_> 13 | 14 | 15 | 16 | <_> 17 | 3 3 9 16 -1. 18 | <_> 19 | 3 7 9 8 2. 20 | 0 21 | -0.0223442204296589 22 | 0.7737345099449158 23 | -0.9436557292938232 24 | <_> 25 | 26 | <_> 27 | 28 | 29 | 30 | <_> 31 | 0 9 12 5 -1. 32 | <_> 33 | 6 9 6 5 2. 34 | 0 35 | -9.3714958056807518e-003 36 | 0.5525149106979370 37 | -0.9004204869270325 38 | -0.3911409080028534 39 | -1 40 | -1 41 | <_> 42 | 43 | 44 | <_> 45 | 46 | <_> 47 | 48 | 49 | 50 | <_> 51 | 12 14 12 10 -1. 52 | <_> 53 | 12 14 6 5 2. 54 | <_> 55 | 18 19 6 5 2. 56 | 0 57 | 0.0127444602549076 58 | -0.7241874933242798 59 | 0.5557708144187927 60 | <_> 61 | 62 | <_> 63 | 64 | 65 | 66 | <_> 67 | 2 4 16 8 -1. 68 | <_> 69 | 2 8 16 4 2. 70 | 0 71 | -0.0203973893076181 72 | 0.3255875110626221 73 | -0.9134256243705750 74 | <_> 75 | 76 | <_> 77 | 78 | 79 | 80 | <_> 81 | 9 6 15 14 -1. 82 | <_> 83 | 9 13 15 7 2. 84 | 0 85 | 1.5015050303190947e-003 86 | -0.8422530293464661 87 | 0.2950277030467987 88 | <_> 89 | 90 | <_> 91 | 92 | 93 | 94 | <_> 95 | 0 10 10 5 -1. 96 | <_> 97 | 5 10 5 5 2. 98 | 0 99 | -9.5540005713701248e-003 100 | 0.2949278056621552 101 | -0.8186870813369751 102 | <_> 103 | 104 | <_> 105 | 106 | 107 | 108 | <_> 109 | 8 0 16 6 -1. 110 | <_> 111 | 8 0 16 3 2. 112 | 1 113 | -9.0454015880823135e-003 114 | -0.9253956079483032 115 | 0.2449316978454590 116 | -0.8027257919311523 117 | 0 118 | -1 119 | <_> 120 | 121 | 122 | <_> 123 | 124 | <_> 125 | 126 | 127 | 128 | <_> 129 | 11 9 9 6 -1. 130 | <_> 131 | 14 12 3 6 3. 132 | 1 133 | 0.0339135192334652 134 | -0.6010565757751465 135 | 0.5952491760253906 136 | <_> 137 | 138 | <_> 139 | 140 | 141 | 142 | <_> 143 | 15 1 8 10 -1. 144 | <_> 145 | 15 6 8 5 2. 146 | 0 147 | -6.3976310193538666e-003 148 | 0.2902083992958069 149 | -0.9008722901344299 150 | <_> 151 | 152 | <_> 153 | 154 | 155 | 156 | <_> 157 | 12 23 12 1 -1. 158 | <_> 159 | 18 23 6 1 2. 160 | 0 161 | 3.5964029375463724e-003 162 | -0.6108912825584412 163 | 0.3585815131664276 164 | <_> 165 | 166 | <_> 167 | 168 | 169 | 170 | <_> 171 | 0 8 16 11 -1. 172 | <_> 173 | 8 8 8 11 2. 174 | 0 175 | 3.1002631294541061e-004 176 | 0.2521544992923737 177 | -0.9231098890304565 178 | -0.6695849895477295 179 | 1 180 | -1 181 | <_> 182 | 183 | 184 | <_> 185 | 186 | <_> 187 | 188 | 189 | 190 | <_> 191 | 12 22 12 2 -1. 192 | <_> 193 | 18 22 6 2 2. 194 | 0 195 | 8.9982077479362488e-003 196 | -0.6216139197349548 197 | 0.5311666131019592 198 | <_> 199 | 200 | <_> 201 | 202 | 203 | 204 | <_> 205 | 6 7 10 5 -1. 206 | <_> 207 | 6 7 5 5 2. 208 | 1 209 | 5.8961678296327591e-003 210 | 0.3589088022708893 211 | -0.8741096854209900 212 | <_> 213 | 214 | <_> 215 | 216 | 217 | 218 | <_> 219 | 10 8 3 2 -1. 220 | <_> 221 | 10 9 3 1 2. 222 | 0 223 | -7.3489747592248023e-005 224 | 0.2021690011024475 225 | -0.8340616226196289 226 | <_> 227 | 228 | <_> 229 | 230 | 231 | 232 | <_> 233 | 15 15 3 4 -1. 234 | <_> 235 | 15 15 3 2 2. 236 | 1 237 | -1.3183970004320145e-003 238 | -0.8218436241149902 239 | 0.2309758067131043 240 | -0.9460288882255554 241 | 2 242 | -1 243 | <_> 244 | 245 | 246 | <_> 247 | 248 | <_> 249 | 250 | 251 | 252 | <_> 253 | 4 18 20 6 -1. 254 | <_> 255 | 4 18 10 3 2. 256 | <_> 257 | 14 21 10 3 2. 258 | 0 259 | 5.8955969288945198e-003 260 | -0.7554979920387268 261 | 0.3239434063434601 262 | <_> 263 | 264 | <_> 265 | 266 | 267 | 268 | <_> 269 | 3 1 20 14 -1. 270 | <_> 271 | 3 1 10 7 2. 272 | <_> 273 | 13 8 10 7 2. 274 | 0 275 | 8.6170788854360580e-003 276 | -0.7028874754905701 277 | 0.2782224118709564 278 | <_> 279 | 280 | <_> 281 | 282 | 283 | 284 | <_> 285 | 2 11 3 9 -1. 286 | <_> 287 | 3 14 1 3 9. 288 | 0 289 | -1.5837070532143116e-003 290 | -0.7751926779747009 291 | 0.2773326933383942 292 | <_> 293 | 294 | <_> 295 | 296 | 297 | 298 | <_> 299 | 0 4 12 20 -1. 300 | <_> 301 | 0 4 6 10 2. 302 | <_> 303 | 6 14 6 10 2. 304 | 0 305 | 7.9292394220829010e-003 306 | -0.7723438143730164 307 | 0.2167312055826187 308 | <_> 309 | 310 | <_> 311 | 312 | 313 | 314 | <_> 315 | 16 15 6 2 -1. 316 | <_> 317 | 16 15 6 1 2. 318 | 1 319 | -1.4443190302699804e-003 320 | -0.8843228220939636 321 | 0.2078661024570465 322 | <_> 323 | 324 | <_> 325 | 326 | 327 | 328 | <_> 329 | 11 8 7 2 -1. 330 | <_> 331 | 11 9 7 1 2. 332 | 0 333 | -4.8251380212605000e-004 334 | 0.2337501049041748 335 | -0.6776664853096008 336 | <_> 337 | 338 | <_> 339 | 340 | 341 | 342 | <_> 343 | 20 15 4 6 -1. 344 | <_> 345 | 22 15 2 6 2. 346 | 0 347 | 8.0077340826392174e-003 348 | -0.3731102049350739 349 | 0.5163818001747131 350 | -1.0588489770889282 351 | 3 352 | -1 353 | <_> 354 | 355 | 356 | <_> 357 | 358 | <_> 359 | 360 | 361 | 362 | <_> 363 | 14 19 1 2 -1. 364 | <_> 365 | 14 20 1 1 2. 366 | 0 367 | -5.8145709772361442e-005 368 | 0.3404448032379150 369 | -0.6792302131652832 370 | <_> 371 | 372 | <_> 373 | 374 | 375 | 376 | <_> 377 | 0 6 2 7 -1. 378 | <_> 379 | 1 6 1 7 2. 380 | 0 381 | -1.1419489746913314e-003 382 | 0.3598371148109436 383 | -0.5890597105026245 384 | <_> 385 | 386 | <_> 387 | 388 | 389 | 390 | <_> 391 | 8 0 10 2 -1. 392 | <_> 393 | 8 0 5 2 2. 394 | 1 395 | 5.8654937893152237e-003 396 | -0.9622359871864319 397 | 0.1721540987491608 398 | <_> 399 | 400 | <_> 401 | 402 | 403 | 404 | <_> 405 | 5 8 16 7 -1. 406 | <_> 407 | 13 8 8 7 2. 408 | 0 409 | 1.1028599692508578e-004 410 | -0.7706093192100525 411 | 0.2389315962791443 412 | <_> 413 | 414 | <_> 415 | 416 | 417 | 418 | <_> 419 | 2 9 14 12 -1. 420 | <_> 421 | 9 9 7 12 2. 422 | 0 423 | 0.0145609602332115 424 | 0.1552716046571732 425 | -0.8984915018081665 426 | -0.7966647148132324 427 | 4 428 | -1 429 | <_> 430 | 431 | 432 | <_> 433 | 434 | <_> 435 | 436 | 437 | 438 | <_> 439 | 2 11 6 10 -1. 440 | <_> 441 | 2 11 3 5 2. 442 | <_> 443 | 5 16 3 5 2. 444 | 0 445 | 3.9159432053565979e-003 446 | -0.7370954751968384 447 | 0.2886646091938019 448 | <_> 449 | 450 | <_> 451 | 452 | 453 | 454 | <_> 455 | 0 3 4 9 -1. 456 | <_> 457 | 2 3 2 9 2. 458 | 0 459 | -4.6402178704738617e-003 460 | 0.3129867017269135 461 | -0.5601897239685059 462 | <_> 463 | 464 | <_> 465 | 466 | 467 | 468 | <_> 469 | 7 10 10 8 -1. 470 | <_> 471 | 12 10 5 8 2. 472 | 0 473 | -4.2656981386244297e-003 474 | -0.8286197781562805 475 | 0.2132489979267120 476 | <_> 477 | 478 | <_> 479 | 480 | 481 | 482 | <_> 483 | 8 16 16 8 -1. 484 | <_> 485 | 8 16 8 4 2. 486 | <_> 487 | 16 20 8 4 2. 488 | 0 489 | 7.9925684258341789e-003 490 | -0.6752548217773438 491 | 0.2340082973241806 492 | <_> 493 | 494 | <_> 495 | 496 | 497 | 498 | <_> 499 | 4 13 6 3 -1. 500 | <_> 501 | 6 15 2 3 3. 502 | 1 503 | -6.2725958414375782e-003 504 | -0.7839264273643494 505 | 0.2019792944192886 506 | <_> 507 | 508 | <_> 509 | 510 | 511 | 512 | <_> 513 | 13 3 11 18 -1. 514 | <_> 515 | 13 12 11 9 2. 516 | 0 517 | -0.0288890209048986 518 | -0.7889788150787354 519 | 0.1651563942432404 520 | <_> 521 | 522 | <_> 523 | 524 | 525 | 526 | <_> 527 | 10 7 5 4 -1. 528 | <_> 529 | 10 9 5 2 2. 530 | 0 531 | -1.5122259501367807e-003 532 | 0.1971655040979385 533 | -0.7596625089645386 534 | <_> 535 | 536 | <_> 537 | 538 | 539 | 540 | <_> 541 | 11 17 6 3 -1. 542 | <_> 543 | 13 18 2 1 9. 544 | 0 545 | 4.3620187789201736e-003 546 | 0.1344974040985107 547 | -0.9309347271919251 548 | <_> 549 | 550 | <_> 551 | 552 | 553 | 554 | <_> 555 | 12 7 12 17 -1. 556 | <_> 557 | 15 7 6 17 2. 558 | 0 559 | -3.2192119397222996e-003 560 | 0.2437663972377777 561 | -0.6044244170188904 562 | -1.0856239795684814 563 | 5 564 | -1 565 | <_> 566 | 567 | 568 | <_> 569 | 570 | <_> 571 | 572 | 573 | 574 | <_> 575 | 14 18 1 2 -1. 576 | <_> 577 | 14 19 1 1 2. 578 | 0 579 | -4.3883759644813836e-005 580 | 0.3130159080028534 581 | -0.6793813705444336 582 | <_> 583 | 584 | <_> 585 | 586 | 587 | 588 | <_> 589 | 3 11 6 12 -1. 590 | <_> 591 | 3 11 3 6 2. 592 | <_> 593 | 6 17 3 6 2. 594 | 0 595 | 6.2022951897233725e-004 596 | -0.8423554897308350 597 | 0.1801322996616364 598 | <_> 599 | 600 | <_> 601 | 602 | 603 | 604 | <_> 605 | 22 13 2 7 -1. 606 | <_> 607 | 23 13 1 7 2. 608 | 0 609 | 1.0972339659929276e-003 610 | -0.4771775007247925 611 | 0.3450973927974701 612 | <_> 613 | 614 | <_> 615 | 616 | 617 | 618 | <_> 619 | 16 15 1 2 -1. 620 | <_> 621 | 16 15 1 1 2. 622 | 1 623 | -2.6349889230914414e-004 624 | -0.7629253864288330 625 | 0.2153723984956741 626 | <_> 627 | 628 | <_> 629 | 630 | 631 | 632 | <_> 633 | 0 5 22 18 -1. 634 | <_> 635 | 0 14 22 9 2. 636 | 0 637 | -0.0542980991303921 638 | -0.8849576711654663 639 | 0.1730009019374847 640 | <_> 641 | 642 | <_> 643 | 644 | 645 | 646 | <_> 647 | 13 19 3 3 -1. 648 | <_> 649 | 14 20 1 1 9. 650 | 0 651 | -2.1721520461142063e-003 652 | -0.8367894887924194 653 | 0.1638997048139572 654 | <_> 655 | 656 | <_> 657 | 658 | 659 | 660 | <_> 661 | 15 0 5 2 -1. 662 | <_> 663 | 15 1 5 1 2. 664 | 0 665 | -1.6347350319847465e-003 666 | 0.3731253147125244 667 | -0.4079189002513886 668 | <_> 669 | 670 | <_> 671 | 672 | 673 | 674 | <_> 675 | 5 15 4 5 -1. 676 | <_> 677 | 5 15 2 5 2. 678 | 1 679 | -2.9642079025506973e-003 680 | -0.7973154187202454 681 | 0.1886135041713715 682 | -0.8849025964736939 683 | 6 684 | -1 685 | <_> 686 | 687 | 688 | <_> 689 | 690 | <_> 691 | 692 | 693 | 694 | <_> 695 | 12 16 2 8 -1. 696 | <_> 697 | 12 20 2 4 2. 698 | 0 699 | -2.6686030905693769e-003 700 | 0.2950133979320526 701 | -0.6534382104873657 702 | <_> 703 | 704 | <_> 705 | 706 | 707 | 708 | <_> 709 | 0 18 2 4 -1. 710 | <_> 711 | 1 18 1 4 2. 712 | 0 713 | -7.9764809925109148e-004 714 | 0.3938421010971069 715 | -0.4435322880744934 716 | <_> 717 | 718 | <_> 719 | 720 | 721 | 722 | <_> 723 | 8 3 12 4 -1. 724 | <_> 725 | 8 3 12 2 2. 726 | 1 727 | -5.1704752258956432e-003 728 | -0.7686781883239746 729 | 0.2110860049724579 730 | <_> 731 | 732 | <_> 733 | 734 | 735 | 736 | <_> 737 | 6 17 3 2 -1. 738 | <_> 739 | 7 18 1 2 3. 740 | 1 741 | -1.5294969780370593e-003 742 | -0.8944628238677979 743 | 0.1583137959241867 744 | <_> 745 | 746 | <_> 747 | 748 | 749 | 750 | <_> 751 | 1 0 10 6 -1. 752 | <_> 753 | 6 0 5 6 2. 754 | 0 755 | -6.3780639320611954e-003 756 | 0.3393965959548950 757 | -0.4529472887516022 758 | <_> 759 | 760 | <_> 761 | 762 | 763 | 764 | <_> 765 | 12 9 3 2 -1. 766 | <_> 767 | 12 10 3 1 2. 768 | 0 769 | -2.6243639877066016e-004 770 | 0.2850841879844666 771 | -0.4983885884284973 772 | <_> 773 | 774 | <_> 775 | 776 | 777 | 778 | <_> 779 | 11 1 12 11 -1. 780 | <_> 781 | 11 1 6 11 2. 782 | 1 783 | 0.0361888185143471 784 | 0.2132015973329544 785 | -0.7394319772720337 786 | <_> 787 | 788 | <_> 789 | 790 | 791 | 792 | <_> 793 | 21 13 2 10 -1. 794 | <_> 795 | 21 18 2 5 2. 796 | 0 797 | 7.7682351693511009e-003 798 | -0.4052247107028961 799 | 0.4112299978733063 800 | <_> 801 | 802 | <_> 803 | 804 | 805 | 806 | <_> 807 | 15 16 1 2 -1. 808 | <_> 809 | 15 16 1 1 2. 810 | 1 811 | -2.3738530580885708e-004 812 | -0.7753518819808960 813 | 0.1911296993494034 814 | <_> 815 | 816 | <_> 817 | 818 | 819 | 820 | <_> 821 | 0 11 8 8 -1. 822 | <_> 823 | 0 11 4 4 2. 824 | <_> 825 | 4 15 4 4 2. 826 | 0 827 | 4.2231627739965916e-003 828 | -0.7229338884353638 829 | 0.1739158928394318 830 | -1.0250910520553589 831 | 7 832 | -1 833 | <_> 834 | 835 | 836 | <_> 837 | 838 | <_> 839 | 840 | 841 | 842 | <_> 843 | 11 11 7 6 -1. 844 | <_> 845 | 11 13 7 2 3. 846 | 0 847 | 2.9137390665709972e-003 848 | -0.5349493026733398 849 | 0.3337337076663971 850 | <_> 851 | 852 | <_> 853 | 854 | 855 | 856 | <_> 857 | 12 17 3 3 -1. 858 | <_> 859 | 13 18 1 1 9. 860 | 0 861 | -1.6270120395347476e-003 862 | -0.8804692029953003 863 | 0.1722342073917389 864 | <_> 865 | 866 | <_> 867 | 868 | 869 | 870 | <_> 871 | 0 9 2 2 -1. 872 | <_> 873 | 1 9 1 2 2. 874 | 0 875 | -2.9037619242444634e-004 876 | 0.2734786868095398 877 | -0.5733091235160828 878 | <_> 879 | 880 | <_> 881 | 882 | 883 | 884 | <_> 885 | 13 17 1 2 -1. 886 | <_> 887 | 13 18 1 1 2. 888 | 0 889 | -1.4552129869116470e-005 890 | 0.2491019070148468 891 | -0.5995762944221497 892 | <_> 893 | 894 | <_> 895 | 896 | 897 | 898 | <_> 899 | 7 0 17 18 -1. 900 | <_> 901 | 7 9 17 9 2. 902 | 0 903 | 0.0141834802925587 904 | 0.1507173925638199 905 | -0.8961830139160156 906 | <_> 907 | 908 | <_> 909 | 910 | 911 | 912 | <_> 913 | 8 11 8 2 -1. 914 | <_> 915 | 8 11 8 1 2. 916 | 1 917 | -5.8600129705155268e-005 918 | 0.1771630048751831 919 | -0.7106314897537231 920 | <_> 921 | 922 | <_> 923 | 924 | 925 | 926 | <_> 927 | 18 17 6 7 -1. 928 | <_> 929 | 21 17 3 7 2. 930 | 0 931 | 7.3492531664669514e-003 932 | -0.5106546878814697 933 | 0.2574213147163391 934 | <_> 935 | 936 | <_> 937 | 938 | 939 | 940 | <_> 941 | 2 19 8 1 -1. 942 | <_> 943 | 6 19 4 1 2. 944 | 0 945 | -1.7738100141286850e-003 946 | -0.8705360293388367 947 | 0.1460683941841126 948 | -0.9740471243858337 949 | 8 950 | -1 951 | <_> 952 | 953 | 954 | <_> 955 | 956 | <_> 957 | 958 | 959 | 960 | <_> 961 | 12 10 10 6 -1. 962 | <_> 963 | 12 10 5 3 2. 964 | <_> 965 | 17 13 5 3 2. 966 | 0 967 | -8.5521116852760315e-003 968 | 0.3413020968437195 969 | -0.4556924998760223 970 | <_> 971 | 972 | <_> 973 | 974 | 975 | 976 | <_> 977 | 5 20 18 4 -1. 978 | <_> 979 | 5 20 9 2 2. 980 | <_> 981 | 14 22 9 2 2. 982 | 0 983 | 2.9570560436695814e-003 984 | -0.5616099834442139 985 | 0.2246744036674500 986 | <_> 987 | 988 | <_> 989 | 990 | 991 | 992 | <_> 993 | 1 10 22 5 -1. 994 | <_> 995 | 12 10 11 5 2. 996 | 0 997 | -0.0195402801036835 998 | -0.8423789739608765 999 | 0.1363316029310226 1000 | <_> 1001 | 1002 | <_> 1003 | 1004 | 1005 | 1006 | <_> 1007 | 1 11 12 1 -1. 1008 | <_> 1009 | 1 11 6 1 2. 1010 | 1 1011 | -3.2073149923235178e-003 1012 | -0.7569847702980042 1013 | 0.1883326023817062 1014 | <_> 1015 | 1016 | <_> 1017 | 1018 | 1019 | 1020 | <_> 1021 | 12 0 12 24 -1. 1022 | <_> 1023 | 12 6 12 12 2. 1024 | 0 1025 | -8.4488727152347565e-003 1026 | 0.1382011026144028 1027 | -0.8026102185249329 1028 | <_> 1029 | 1030 | <_> 1031 | 1032 | 1033 | 1034 | <_> 1035 | 4 15 5 6 -1. 1036 | <_> 1037 | 4 17 5 2 3. 1038 | 0 1039 | 1.1350389831932262e-004 1040 | -0.7027189135551453 1041 | 0.1435786038637161 1042 | <_> 1043 | 1044 | <_> 1045 | 1046 | 1047 | 1048 | <_> 1049 | 12 2 6 4 -1. 1050 | <_> 1051 | 14 4 2 4 3. 1052 | 1 1053 | -5.8187649119645357e-004 1054 | -0.4507982134819031 1055 | 0.2510882019996643 1056 | <_> 1057 | 1058 | <_> 1059 | 1060 | 1061 | 1062 | <_> 1063 | 0 7 2 17 -1. 1064 | <_> 1065 | 1 7 1 17 2. 1066 | 0 1067 | -0.0161978900432587 1068 | 0.6447368860244751 1069 | -0.2079977989196777 1070 | <_> 1071 | 1072 | <_> 1073 | 1074 | 1075 | 1076 | <_> 1077 | 13 15 3 9 -1. 1078 | <_> 1079 | 14 15 1 9 3. 1080 | 0 1081 | 6.6894508199766278e-004 1082 | 0.1998561024665833 1083 | -0.7483944892883301 1084 | <_> 1085 | 1086 | <_> 1087 | 1088 | 1089 | 1090 | <_> 1091 | 13 18 3 3 -1. 1092 | <_> 1093 | 14 19 1 1 9. 1094 | 0 1095 | -1.8372290069237351e-003 1096 | -0.8788912892341614 1097 | 0.1146014034748077 1098 | <_> 1099 | 1100 | <_> 1101 | 1102 | 1103 | 1104 | <_> 1105 | 17 17 1 2 -1. 1106 | <_> 1107 | 17 18 1 1 2. 1108 | 0 1109 | -4.3397278204793110e-005 1110 | 0.2129840999841690 1111 | -0.5028128027915955 1112 | -1.4024209976196289 1113 | 9 1114 | -1 1115 | <_> 1116 | 1117 | 1118 | <_> 1119 | 1120 | <_> 1121 | 1122 | 1123 | 1124 | <_> 1125 | 10 11 4 12 -1. 1126 | <_> 1127 | 10 11 2 6 2. 1128 | <_> 1129 | 12 17 2 6 2. 1130 | 0 1131 | -2.0713880658149719e-003 1132 | 0.2486661970615387 1133 | -0.5756726861000061 1134 | <_> 1135 | 1136 | <_> 1137 | 1138 | 1139 | 1140 | <_> 1141 | 12 23 12 1 -1. 1142 | <_> 1143 | 18 23 6 1 2. 1144 | 0 1145 | 3.6768750287592411e-003 1146 | -0.5755078196525574 1147 | 0.2280506044626236 1148 | <_> 1149 | 1150 | <_> 1151 | 1152 | 1153 | 1154 | <_> 1155 | 13 10 3 4 -1. 1156 | <_> 1157 | 13 10 3 2 2. 1158 | 1 1159 | -3.0887479078955948e-004 1160 | 0.2362288981676102 1161 | -0.6454687118530273 1162 | <_> 1163 | 1164 | <_> 1165 | 1166 | 1167 | 1168 | <_> 1169 | 0 0 24 24 -1. 1170 | <_> 1171 | 0 0 12 12 2. 1172 | <_> 1173 | 12 12 12 12 2. 1174 | 0 1175 | -0.0257820300757885 1176 | -0.7496209144592285 1177 | 0.1617882996797562 1178 | <_> 1179 | 1180 | <_> 1181 | 1182 | 1183 | 1184 | <_> 1185 | 2 10 2 6 -1. 1186 | <_> 1187 | 2 13 2 3 2. 1188 | 0 1189 | -1.2850989587605000e-003 1190 | -0.7813286781311035 1191 | 0.1440877020359039 1192 | <_> 1193 | 1194 | <_> 1195 | 1196 | 1197 | 1198 | <_> 1199 | 0 11 2 6 -1. 1200 | <_> 1201 | 0 14 2 3 2. 1202 | 0 1203 | 3.3493789378553629e-003 1204 | 0.1375873982906342 1205 | -0.7505543231964111 1206 | <_> 1207 | 1208 | <_> 1209 | 1210 | 1211 | 1212 | <_> 1213 | 0 1 24 1 -1. 1214 | <_> 1215 | 8 1 8 1 3. 1216 | 0 1217 | -2.6788329705595970e-003 1218 | 0.2596372067928314 1219 | -0.4255296885967255 1220 | <_> 1221 | 1222 | <_> 1223 | 1224 | 1225 | 1226 | <_> 1227 | 13 7 4 2 -1. 1228 | <_> 1229 | 13 8 4 1 2. 1230 | 0 1231 | -2.8834199838456698e-005 1232 | 0.1635348945856094 1233 | -0.7050843238830566 1234 | <_> 1235 | 1236 | <_> 1237 | 1238 | 1239 | 1240 | <_> 1241 | 0 13 3 10 -1. 1242 | <_> 1243 | 1 13 1 10 3. 1244 | 0 1245 | -1.6196980141103268e-003 1246 | 0.3419960141181946 1247 | -0.3415850102901459 1248 | <_> 1249 | 1250 | <_> 1251 | 1252 | 1253 | 1254 | <_> 1255 | 1 10 10 10 -1. 1256 | <_> 1257 | 6 10 5 10 2. 1258 | 0 1259 | 1.0517919436097145e-003 1260 | 0.1479195058345795 1261 | -0.7929052114486694 1262 | <_> 1263 | 1264 | <_> 1265 | 1266 | 1267 | 1268 | <_> 1269 | 9 0 4 6 -1. 1270 | <_> 1271 | 9 0 4 3 2. 1272 | 1 1273 | -2.4886541068553925e-003 1274 | -0.8937227129936218 1275 | 0.1043419018387795 1276 | -1.1141099929809570 1277 | 10 1278 | -1 1279 | <_> 1280 | 1281 | 1282 | <_> 1283 | 1284 | <_> 1285 | 1286 | 1287 | 1288 | <_> 1289 | 16 18 1 2 -1. 1290 | <_> 1291 | 16 19 1 1 2. 1292 | 0 1293 | -5.7590808864915743e-005 1294 | 0.2734906971454620 1295 | -0.6426038742065430 1296 | <_> 1297 | 1298 | <_> 1299 | 1300 | 1301 | 1302 | <_> 1303 | 21 14 2 8 -1. 1304 | <_> 1305 | 22 14 1 8 2. 1306 | 0 1307 | 7.1206100983545184e-004 1308 | -0.5435984134674072 1309 | 0.2552855014801025 1310 | <_> 1311 | 1312 | <_> 1313 | 1314 | 1315 | 1316 | <_> 1317 | 0 7 21 9 -1. 1318 | <_> 1319 | 7 10 7 3 9. 1320 | 0 1321 | -0.3888005912303925 1322 | 0.6930956840515137 1323 | -0.1862079948186874 1324 | <_> 1325 | 1326 | <_> 1327 | 1328 | 1329 | 1330 | <_> 1331 | 16 16 1 4 -1. 1332 | <_> 1333 | 16 17 1 2 2. 1334 | 0 1335 | 2.5288251345045865e-004 1336 | 0.2914173901081085 1337 | -0.5620415806770325 1338 | <_> 1339 | 1340 | <_> 1341 | 1342 | 1343 | 1344 | <_> 1345 | 19 15 2 6 -1. 1346 | <_> 1347 | 17 17 2 2 3. 1348 | 1 1349 | -2.1006830502301455e-003 1350 | -0.6822040081024170 1351 | 0.1185996010899544 1352 | <_> 1353 | 1354 | <_> 1355 | 1356 | 1357 | 1358 | <_> 1359 | 6 0 15 4 -1. 1360 | <_> 1361 | 6 1 15 2 2. 1362 | 0 1363 | -3.2310429960489273e-003 1364 | 0.3972072899341583 1365 | -0.2774995863437653 1366 | <_> 1367 | 1368 | <_> 1369 | 1370 | 1371 | 1372 | <_> 1373 | 9 16 1 4 -1. 1374 | <_> 1375 | 9 17 1 2 2. 1376 | 0 1377 | 1.4478569937637076e-005 1378 | -0.5476933717727661 1379 | 0.2119608968496323 1380 | <_> 1381 | 1382 | <_> 1383 | 1384 | 1385 | 1386 | <_> 1387 | 8 20 8 2 -1. 1388 | <_> 1389 | 8 20 4 1 2. 1390 | <_> 1391 | 12 21 4 1 2. 1392 | 0 1393 | -9.0244162129238248e-004 1394 | -0.8646997213363648 1395 | 0.1194489970803261 1396 | <_> 1397 | 1398 | <_> 1399 | 1400 | 1401 | 1402 | <_> 1403 | 0 9 3 14 -1. 1404 | <_> 1405 | 1 9 1 14 3. 1406 | 0 1407 | -1.5906910412013531e-003 1408 | 0.2919914126396179 1409 | -0.3928124904632568 1410 | <_> 1411 | 1412 | <_> 1413 | 1414 | 1415 | 1416 | <_> 1417 | 11 1 11 4 -1. 1418 | <_> 1419 | 11 1 11 2 2. 1420 | 1 1421 | 7.4913240969181061e-003 1422 | 0.2679530084133148 1423 | -0.4020768105983734 1424 | -1.0776710510253906 1425 | 11 1426 | -1 1427 | <_> 1428 | 1429 | 1430 | <_> 1431 | 1432 | <_> 1433 | 1434 | 1435 | 1436 | <_> 1437 | 15 20 1 2 -1. 1438 | <_> 1439 | 15 21 1 1 2. 1440 | 0 1441 | -7.1240079705603421e-005 1442 | 0.2823083102703095 1443 | -0.4779424071311951 1444 | <_> 1445 | 1446 | <_> 1447 | 1448 | 1449 | 1450 | <_> 1451 | 2 18 1 2 -1. 1452 | <_> 1453 | 2 18 1 1 2. 1454 | 1 1455 | -2.6417701155878603e-004 1456 | 0.3084900975227356 1457 | -0.4036655128002167 1458 | <_> 1459 | 1460 | <_> 1461 | 1462 | 1463 | 1464 | <_> 1465 | 0 14 12 6 -1. 1466 | <_> 1467 | 0 16 12 2 3. 1468 | 0 1469 | 5.2890321239829063e-004 1470 | -0.7423822879791260 1471 | 0.1605536937713623 1472 | <_> 1473 | 1474 | <_> 1475 | 1476 | 1477 | 1478 | <_> 1479 | 4 10 2 14 -1. 1480 | <_> 1481 | 4 10 1 7 2. 1482 | <_> 1483 | 5 17 1 7 2. 1484 | 0 1485 | 3.8283021422103047e-004 1486 | -0.6108828783035278 1487 | 0.1794416010379791 1488 | <_> 1489 | 1490 | <_> 1491 | 1492 | 1493 | 1494 | <_> 1495 | 22 3 2 15 -1. 1496 | <_> 1497 | 23 3 1 15 2. 1498 | 0 1499 | 5.4077422246336937e-003 1500 | -0.2767061889171600 1501 | 0.4017147123813629 1502 | <_> 1503 | 1504 | <_> 1505 | 1506 | 1507 | 1508 | <_> 1509 | 4 17 3 1 -1. 1510 | <_> 1511 | 5 18 1 1 3. 1512 | 1 1513 | -8.2620367174968123e-004 1514 | -0.8456827998161316 1515 | 0.1641048043966293 1516 | <_> 1517 | 1518 | <_> 1519 | 1520 | 1521 | 1522 | <_> 1523 | 21 6 3 9 -1. 1524 | <_> 1525 | 21 9 3 3 3. 1526 | 0 1527 | -8.9606801047921181e-003 1528 | -0.6698572039604187 1529 | 0.1270485967397690 1530 | <_> 1531 | 1532 | <_> 1533 | 1534 | 1535 | 1536 | <_> 1537 | 1 7 23 4 -1. 1538 | <_> 1539 | 1 9 23 2 2. 1540 | 0 1541 | -3.0286349356174469e-003 1542 | 0.1227105036377907 1543 | -0.7880274057388306 1544 | <_> 1545 | 1546 | <_> 1547 | 1548 | 1549 | 1550 | <_> 1551 | 4 3 20 20 -1. 1552 | <_> 1553 | 4 13 20 10 2. 1554 | 0 1555 | -0.0262723900377750 1556 | -0.7226560711860657 1557 | 0.1347829997539520 1558 | <_> 1559 | 1560 | <_> 1561 | 1562 | 1563 | 1564 | <_> 1565 | 14 13 7 4 -1. 1566 | <_> 1567 | 14 15 7 2 2. 1568 | 0 1569 | -5.0153239862993360e-004 1570 | 0.2890014052391052 1571 | -0.3537223935127258 1572 | <_> 1573 | 1574 | <_> 1575 | 1576 | 1577 | 1578 | <_> 1579 | 2 6 2 2 -1. 1580 | <_> 1581 | 2 6 2 1 2. 1582 | 1 1583 | -1.9847620569635183e-004 1584 | 0.2491115033626556 1585 | -0.4667024016380310 1586 | -1.1201709508895874 1587 | 12 1588 | -1 1589 | <_> 1590 | 1591 | 1592 | <_> 1593 | 1594 | <_> 1595 | 1596 | 1597 | 1598 | <_> 1599 | 13 15 6 4 -1. 1600 | <_> 1601 | 13 17 6 2 2. 1602 | 0 1603 | -1.6098109772428870e-003 1604 | 0.2436411976814270 1605 | -0.5425583124160767 1606 | <_> 1607 | 1608 | <_> 1609 | 1610 | 1611 | 1612 | <_> 1613 | 17 0 7 24 -1. 1614 | <_> 1615 | 17 8 7 8 3. 1616 | 0 1617 | 3.0391800682991743e-003 1618 | 0.1427879035472870 1619 | -0.7677937150001526 1620 | <_> 1621 | 1622 | <_> 1623 | 1624 | 1625 | 1626 | <_> 1627 | 3 7 20 8 -1. 1628 | <_> 1629 | 13 7 10 8 2. 1630 | 0 1631 | -0.0111625995486975 1632 | -0.7964649796485901 1633 | 0.1309580951929092 1634 | <_> 1635 | 1636 | <_> 1637 | 1638 | 1639 | 1640 | <_> 1641 | 0 7 22 1 -1. 1642 | <_> 1643 | 11 7 11 1 2. 1644 | 0 1645 | -1.6689340118318796e-003 1646 | 0.2306797951459885 1647 | -0.4947401881217957 1648 | <_> 1649 | 1650 | <_> 1651 | 1652 | 1653 | 1654 | <_> 1655 | 7 9 8 2 -1. 1656 | <_> 1657 | 7 10 8 1 2. 1658 | 0 1659 | -8.8481552666053176e-004 1660 | 0.2005017995834351 1661 | -0.5158239006996155 1662 | <_> 1663 | 1664 | <_> 1665 | 1666 | 1667 | 1668 | <_> 1669 | 2 0 3 18 -1. 1670 | <_> 1671 | 2 6 3 6 3. 1672 | 0 1673 | -2.6040559168905020e-003 1674 | 0.1298092007637024 1675 | -0.7818121910095215 1676 | <_> 1677 | 1678 | <_> 1679 | 1680 | 1681 | 1682 | <_> 1683 | 2 13 3 5 -1. 1684 | <_> 1685 | 3 13 1 5 3. 1686 | 0 1687 | -2.3444599355570972e-004 1688 | -0.5695487260818481 1689 | 0.1478334069252014 1690 | <_> 1691 | 1692 | <_> 1693 | 1694 | 1695 | 1696 | <_> 1697 | 14 16 3 4 -1. 1698 | <_> 1699 | 15 16 1 4 3. 1700 | 0 1701 | 8.4604357834905386e-004 1702 | 0.1037243008613586 1703 | -0.8308842182159424 1704 | <_> 1705 | 1706 | <_> 1707 | 1708 | 1709 | 1710 | <_> 1711 | 10 0 12 3 -1. 1712 | <_> 1713 | 10 1 12 1 3. 1714 | 0 1715 | -2.4807569570839405e-003 1716 | 0.3425926864147186 1717 | -0.2719523906707764 1718 | <_> 1719 | 1720 | <_> 1721 | 1722 | 1723 | 1724 | <_> 1725 | 15 16 3 1 -1. 1726 | <_> 1727 | 16 17 1 1 3. 1728 | 1 1729 | -1.1127090547233820e-003 1730 | -0.8275328278541565 1731 | 0.1176175028085709 1732 | <_> 1733 | 1734 | <_> 1735 | 1736 | 1737 | 1738 | <_> 1739 | 22 13 2 5 -1. 1740 | <_> 1741 | 23 13 1 5 2. 1742 | 0 1743 | 1.4298419700935483e-003 1744 | -0.3477616012096405 1745 | 0.2652699053287506 1746 | <_> 1747 | 1748 | <_> 1749 | 1750 | 1751 | 1752 | <_> 1753 | 11 14 4 6 -1. 1754 | <_> 1755 | 11 16 4 2 3. 1756 | 0 1757 | -1.4572150539606810e-003 1758 | -0.8802363276481628 1759 | 0.1092033982276917 1760 | -1.0063530206680298 1761 | 13 1762 | -1 1763 | <_> 1764 | 1765 | 1766 | <_> 1767 | 1768 | <_> 1769 | 1770 | 1771 | 1772 | <_> 1773 | 14 15 1 2 -1. 1774 | <_> 1775 | 14 16 1 1 2. 1776 | 0 1777 | -1.4507149899145588e-005 1778 | 0.2605004012584686 1779 | -0.4580149054527283 1780 | <_> 1781 | 1782 | <_> 1783 | 1784 | 1785 | 1786 | <_> 1787 | 6 3 6 5 -1. 1788 | <_> 1789 | 6 3 3 5 2. 1790 | 1 1791 | 0.0136784398928285 1792 | -0.7149971723556519 1793 | 0.1477705985307694 1794 | <_> 1795 | 1796 | <_> 1797 | 1798 | 1799 | 1800 | <_> 1801 | 2 8 1 2 -1. 1802 | <_> 1803 | 2 8 1 1 2. 1804 | 1 1805 | -7.3151881224475801e-005 1806 | 0.2058611065149307 1807 | -0.4995836019515991 1808 | <_> 1809 | 1810 | <_> 1811 | 1812 | 1813 | 1814 | <_> 1815 | 9 17 4 4 -1. 1816 | <_> 1817 | 9 18 4 2 2. 1818 | 0 1819 | -6.7043182207271457e-004 1820 | -0.7319483757019043 1821 | 0.1358278989791870 1822 | <_> 1823 | 1824 | <_> 1825 | 1826 | 1827 | 1828 | <_> 1829 | 10 6 4 5 -1. 1830 | <_> 1831 | 11 6 2 5 2. 1832 | 0 1833 | -1.1992789804935455e-003 1834 | 0.4456472992897034 1835 | -0.2521241009235382 1836 | <_> 1837 | 1838 | <_> 1839 | 1840 | 1841 | 1842 | <_> 1843 | 2 21 12 2 -1. 1844 | <_> 1845 | 8 21 6 2 2. 1846 | 0 1847 | -0.0117351496592164 1848 | -0.7972438931465149 1849 | 0.1424607038497925 1850 | <_> 1851 | 1852 | <_> 1853 | 1854 | 1855 | 1856 | <_> 1857 | 12 8 12 15 -1. 1858 | <_> 1859 | 16 8 4 15 3. 1860 | 0 1861 | -4.7361929900944233e-003 1862 | 0.1624221056699753 1863 | -0.5223402976989746 1864 | <_> 1865 | 1866 | <_> 1867 | 1868 | 1869 | 1870 | <_> 1871 | 0 3 20 20 -1. 1872 | <_> 1873 | 0 13 20 10 2. 1874 | 0 1875 | -0.1084595024585724 1876 | -0.7962973713874817 1877 | 0.1265926957130432 1878 | <_> 1879 | 1880 | <_> 1881 | 1882 | 1883 | 1884 | <_> 1885 | 16 17 4 2 -1. 1886 | <_> 1887 | 16 17 4 1 2. 1888 | 1 1889 | -3.2293208641931415e-004 1890 | -0.7129234075546265 1891 | 0.0899520069360733 1892 | <_> 1893 | 1894 | <_> 1895 | 1896 | 1897 | 1898 | <_> 1899 | 21 14 2 5 -1. 1900 | <_> 1901 | 21 14 1 5 2. 1902 | 1 1903 | 2.5980910286307335e-003 1904 | -0.2800100147724152 1905 | 0.3197942078113556 1906 | <_> 1907 | 1908 | <_> 1909 | 1910 | 1911 | 1912 | <_> 1913 | 12 0 12 8 -1. 1914 | <_> 1915 | 12 0 12 4 2. 1916 | 1 1917 | -7.5798099860548973e-003 1918 | -0.7153301239013672 1919 | 0.1406804025173187 1920 | <_> 1921 | 1922 | <_> 1923 | 1924 | 1925 | 1926 | <_> 1927 | 17 0 7 24 -1. 1928 | <_> 1929 | 17 6 7 12 2. 1930 | 0 1931 | -8.4003582596778870e-003 1932 | 0.1168404966592789 1933 | -0.6506950259208679 1934 | <_> 1935 | 1936 | <_> 1937 | 1938 | 1939 | 1940 | <_> 1941 | 13 10 3 6 -1. 1942 | <_> 1943 | 13 12 3 2 3. 1944 | 0 1945 | 3.6820198874920607e-003 1946 | -0.2631436884403229 1947 | 0.3865979909896851 1948 | -1.0373339653015137 1949 | 14 1950 | -1 1951 | <_> 1952 | 1953 | 1954 | <_> 1955 | 1956 | <_> 1957 | 1958 | 1959 | 1960 | <_> 1961 | 8 11 9 9 -1. 1962 | <_> 1963 | 11 14 3 3 9. 1964 | 0 1965 | 0.0240733902901411 1966 | -0.4794333875179291 1967 | 0.2617827057838440 1968 | <_> 1969 | 1970 | <_> 1971 | 1972 | 1973 | 1974 | <_> 1975 | 17 18 7 6 -1. 1976 | <_> 1977 | 17 21 7 3 2. 1978 | 0 1979 | 1.9582170061767101e-003 1980 | -0.4434475898742676 1981 | 0.2301298975944519 1982 | <_> 1983 | 1984 | <_> 1985 | 1986 | 1987 | 1988 | <_> 1989 | 9 8 4 2 -1. 1990 | <_> 1991 | 9 9 4 1 2. 1992 | 0 1993 | -2.0559200493153185e-004 1994 | 0.1224080994725227 1995 | -0.7277694940567017 1996 | <_> 1997 | 1998 | <_> 1999 | 2000 | 2001 | 2002 | <_> 2003 | 7 7 7 6 -1. 2004 | <_> 2005 | 7 9 7 2 3. 2006 | 0 2007 | 1.0637210216373205e-003 2008 | -0.1582341045141220 2009 | 0.6447200775146484 2010 | <_> 2011 | 2012 | <_> 2013 | 2014 | 2015 | 2016 | <_> 2017 | 2 9 1 9 -1. 2018 | <_> 2019 | 2 12 1 3 3. 2020 | 0 2021 | -3.5040560760535300e-004 2022 | -0.5160586237907410 2023 | 0.2033808976411820 2024 | <_> 2025 | 2026 | <_> 2027 | 2028 | 2029 | 2030 | <_> 2031 | 1 0 1 20 -1. 2032 | <_> 2033 | 1 10 1 10 2. 2034 | 0 2035 | -1.5382179990410805e-003 2036 | 0.2029495984315872 2037 | -0.5412080287933350 2038 | <_> 2039 | 2040 | <_> 2041 | 2042 | 2043 | 2044 | <_> 2045 | 5 11 4 3 -1. 2046 | <_> 2047 | 5 11 2 3 2. 2048 | 1 2049 | 4.2215911671519279e-003 2050 | 0.1420246958732605 2051 | -0.6884710788726807 2052 | <_> 2053 | 2054 | <_> 2055 | 2056 | 2057 | 2058 | <_> 2059 | 1 6 14 13 -1. 2060 | <_> 2061 | 8 6 7 13 2. 2062 | 0 2063 | 4.0536639280617237e-003 2064 | 0.0946411192417145 2065 | -0.8890265226364136 2066 | <_> 2067 | 2068 | <_> 2069 | 2070 | 2071 | 2072 | <_> 2073 | 11 6 6 4 -1. 2074 | <_> 2075 | 13 6 2 4 3. 2076 | 0 2077 | 3.9104130119085312e-003 2078 | -0.2211245000362396 2079 | 0.4553441107273102 2080 | <_> 2081 | 2082 | <_> 2083 | 2084 | 2085 | 2086 | <_> 2087 | 15 20 2 2 -1. 2088 | <_> 2089 | 15 20 2 1 2. 2090 | 1 2091 | -5.8839347911998630e-004 2092 | -0.7423400878906250 2093 | 0.1466006040573120 2094 | <_> 2095 | 2096 | <_> 2097 | 2098 | 2099 | 2100 | <_> 2101 | 11 7 11 2 -1. 2102 | <_> 2103 | 11 8 11 1 2. 2104 | 0 2105 | 4.7331111272796988e-004 2106 | 0.0803736001253128 2107 | -0.8416292071342468 2108 | <_> 2109 | 2110 | <_> 2111 | 2112 | 2113 | 2114 | <_> 2115 | 14 0 7 4 -1. 2116 | <_> 2117 | 14 1 7 2 2. 2118 | 0 2119 | -1.4589539496228099e-003 2120 | 0.2730404138565064 2121 | -0.2989330887794495 2122 | -0.9257612824440002 2123 | 15 2124 | -1 2125 | -------------------------------------------------------------------------------- /hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/hand.png -------------------------------------------------------------------------------- /hand.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def h_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | # applying gaussian blur 13 | value = (35, 35) 14 | blurred = cv2.GaussianBlur(grey, value, 0) 15 | 16 | # thresholdin: Otsu's Binarization method 17 | _, thresh1 = cv2.threshold(blurred, 127, 255, 18 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 19 | 20 | # show thresholded image 21 | cv2.imshow('Thresholded', thresh1) 22 | 23 | # check OpenCV version to avoid unpacking error 24 | (version, _, _) = cv2.__version__.split('.') 25 | 26 | if version == '3': 27 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 28 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 29 | elif version == '2': 30 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 31 | cv2.CHAIN_APPROX_NONE) 32 | 33 | # find contour with max area 34 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 35 | 36 | # create bounding rectangle around the contour (can skip below two lines) 37 | x, y, w, h = cv2.boundingRect(cnt) 38 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 39 | 40 | # finding convex hull 41 | hull = cv2.convexHull(cnt) 42 | 43 | # drawing contours 44 | drawing = np.zeros(crop_img.shape,np.uint8) 45 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 46 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 47 | 48 | # finding convex hull 49 | hull = cv2.convexHull(cnt, returnPoints=False) 50 | 51 | # finding convexity defects 52 | defects = cv2.convexityDefects(cnt, hull) 53 | count_defects = 0 54 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 55 | 56 | # applying Cosine Rule to find angle for all defects (between fingers) 57 | # with angle > 90 degrees and ignore defects 58 | for i in range(defects.shape[0]): 59 | s,e,f,d = defects[i,0] 60 | 61 | start = tuple(cnt[s][0]) 62 | end = tuple(cnt[e][0]) 63 | far = tuple(cnt[f][0]) 64 | 65 | # find length of all sides of triangle 66 | a = math.sqrt((end[0] - start[0])**2 + (end[1] - start[1])**2) 67 | b = math.sqrt((far[0] - start[0])**2 + (far[1] - start[1])**2) 68 | c = math.sqrt((end[0] - far[0])**2 + (end[1] - far[1])**2) 69 | 70 | # apply cosine rule here 71 | angle = math.acos((b**2 + c**2 - a**2)/(2*b*c)) * 57 72 | 73 | # ignore angles > 90 and highlight rest with red dots 74 | if angle <= 90: 75 | count_defects += 1 76 | cv2.circle(crop_img, far, 1, [0,0,255], -1) 77 | #dist = cv2.pointPolygonTest(cnt,far,True) 78 | 79 | # draw a line from start to end i.e. the convex points (finger tips) 80 | # (can skip this part) 81 | cv2.line(crop_img,start, end, [0,255,0], 2) 82 | cv2.circle(crop_img,far,5,[0,0,255],-1) 83 | 84 | # define actions required 85 | 86 | if count_defects == 4: 87 | #pyautogui.press('right') 88 | #os.startfile('cal') 89 | keyboard.press_and_release('-') 90 | else: 91 | cv2.putText(img,"0", (50, 50),\ 92 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 93 | 94 | 95 | #time.sleep(1) 96 | # show appropriate images in windows 97 | #cv2.imshow('Gesture', img) 98 | all_img = np.hstack((drawing, crop_img)) 99 | cv2.imshow('Contours', all_img) 100 | -------------------------------------------------------------------------------- /main_file.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | from point import p_crop 9 | from hand import h_crop 10 | from fin import f_crop 11 | from fist import fs_crop 12 | from thumbdown import t_crop 13 | from okay import ok_crop 14 | 15 | os.chdir("location of scripts,xml files") 16 | h1_cascade=cv2.CascadeClassifier('hand.xml') 17 | okay_cascade = cv2.CascadeClassifier('ok.xml') 18 | point_cascade = cv2.CascadeClassifier('point1.xml') 19 | fin_cascade=cv2.CascadeClassifier('fin_2.xml') 20 | fist_cascade=cv2.CascadeClassifier('fist.xml') 21 | thumbdown_cascade = cv2.CascadeClassifier('thumbdown.xml') 22 | cap = cv2.VideoCapture(0) 23 | ca=0 24 | 25 | while(1): 26 | _,img=cap.read() 27 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 28 | point=point_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3,flags=0, minSize=(100,80)) 29 | fin=fin_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3,flags=0, minSize=(100,80)) 30 | hand=h1_cascade.detectMultiScale(gray,1.1, 5) 31 | fist=fist_cascade.detectMultiScale(gray,1.3, 5) 32 | okay=okay_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3,flags=0, minSize=(100,150)) 33 | thumbdown=thumbdown_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3,flags=0, minSize=(100,80)) 34 | for (x,y,w,h) in okay: 35 | cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2) 36 | roi_gray=gray[y:y+h,x:x+w] 37 | roi_color=img[y:y+h,x:x+w] 38 | crop_img=img[y:y+h,x:x+w] 39 | ok_crop(crop_img,img) 40 | #time.sleep(0.5) 41 | 42 | 43 | for (x,y,w,h) in point: 44 | cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,255),2) 45 | roi_gray=gray[y:y+h,x:x+w] 46 | roi_color=img[y:y+h,x:x+w] 47 | crop_img=img[y:y+h,x:x+w] 48 | ha=2 49 | p_crop(crop_img,img) 50 | #time.sleep(0.5) 51 | 52 | for (x,y,w,h) in fin: 53 | cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2) 54 | roi_gray=gray[y:y+h,x:x+w] 55 | roi_color=img[y:y+h,x:x+w] 56 | crop_img=img[y:y+h,x:x+w] 57 | f_crop(crop_img,img) 58 | #time.sleep(0.5) 59 | 60 | 61 | for (x,y,w,h) in thumbdown: 62 | cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) 63 | roi_gray=gray[y:y+h,x:x+w] 64 | roi_color=img[y:y+h,x:x+w] 65 | crop_img=img[y:y+h,x:x+w] 66 | ha=5 67 | t_crop(crop_img,img) 68 | #time.sleep(0.5) 69 | 70 | for (x,y,w,h) in hand: 71 | cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) 72 | roi_gray=gray[y:y+h,x:x+w] 73 | roi_color=img[y:y+h,x:x+w] 74 | crop_img=img[y:y+h,x:x+w] 75 | h_crop(crop_img,img) 76 | 77 | 78 | 79 | cv2.imshow('Feed',img) 80 | 81 | k=cv2.waitKey(10) 82 | if k==27: 83 | break 84 | cv2.destroyAllWindows() 85 | 86 | 87 | -------------------------------------------------------------------------------- /okay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/okay.png -------------------------------------------------------------------------------- /okay.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def ok_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | value = (35, 35) 13 | blurred = cv2.GaussianBlur(grey, value, 0) 14 | 15 | 16 | _, thresh1 = cv2.threshold(blurred, 127, 255, 17 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 18 | 19 | 20 | cv2.imshow('Thresholded', thresh1) 21 | 22 | 23 | (version, _, _) = cv2.__version__.split('.') 24 | 25 | if version == '3': 26 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 27 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 28 | elif version == '2': 29 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 30 | cv2.CHAIN_APPROX_NONE) 31 | 32 | 33 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 34 | 35 | 36 | x, y, w, h = cv2.boundingRect(cnt) 37 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 38 | 39 | 40 | hull = cv2.convexHull(cnt) 41 | 42 | 43 | drawing = np.zeros(crop_img.shape,np.uint8) 44 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 45 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 46 | 47 | 48 | hull = cv2.convexHull(cnt, returnPoints=False) 49 | 50 | 51 | defects = cv2.convexityDefects(cnt, hull) 52 | count_defects = 0 53 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 54 | 55 | 56 | for i in range(defects.shape[0]): 57 | s,e,f,d = defects[i,0] 58 | 59 | start = tuple(cnt[s][0]) 60 | end = tuple(cnt[e][0]) 61 | far = tuple(cnt[f][0]) 62 | 63 | 64 | a = math.sqrt((end[0] - start[0])**2 + (end[1] - start[1])**2) 65 | b = math.sqrt((far[0] - start[0])**2 + (far[1] - start[1])**2) 66 | c = math.sqrt((end[0] - far[0])**2 + (end[1] - far[1])**2) 67 | 68 | 69 | angle = math.acos((b**2 + c**2 - a**2)/(2*b*c)) * 57 70 | 71 | 72 | if angle <= 90: 73 | count_defects += 1 74 | cv2.circle(crop_img, far, 1, [0,0,255], -1) 75 | 76 | 77 | cv2.line(crop_img,start, end, [0,255,0], 2) 78 | cv2.circle(crop_img,far,5,[0,0,255],-1) 79 | 80 | 81 | 82 | if count_defects == 3 or count_defects==2: 83 | keyboard.press_and_release('+') 84 | else: 85 | cv2.putText(img,"0", (50, 50),\ 86 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 87 | ha=0 88 | 89 | 90 | all_img = np.hstack((drawing, crop_img)) 91 | cv2.imshow('Contours', all_img) 92 | -------------------------------------------------------------------------------- /point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/point.png -------------------------------------------------------------------------------- /point.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def p_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | # applying gaussian blur 13 | value = (35, 35) 14 | blurred = cv2.GaussianBlur(grey, value, 0) 15 | 16 | # thresholdin: Otsu's Binarization method 17 | _, thresh1 = cv2.threshold(blurred, 127, 255, 18 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 19 | 20 | # show thresholded image 21 | cv2.imshow('Thresholded', thresh1) 22 | 23 | # check OpenCV version to avoid unpacking error 24 | (version, _, _) = cv2.__version__.split('.') 25 | 26 | if version == '3': 27 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 28 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 29 | elif version == '2': 30 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 31 | cv2.CHAIN_APPROX_NONE) 32 | 33 | # find contour with max area 34 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 35 | 36 | # create bounding rectangle around the contour (can skip below two lines) 37 | x, y, w, h = cv2.boundingRect(cnt) 38 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 39 | 40 | # finding convex hull 41 | hull = cv2.convexHull(cnt) 42 | 43 | # drawing contours 44 | drawing = np.zeros(crop_img.shape,np.uint8) 45 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 46 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 47 | 48 | # finding convex hull 49 | hull = cv2.convexHull(cnt, returnPoints=False) 50 | 51 | # finding convexity defects 52 | defects = cv2.convexityDefects(cnt, hull) 53 | count_defects = 0 54 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 55 | 56 | # applying Cosine Rule to find angle for all defects (between fingers) 57 | # with angle > 90 degrees and ignore defects 58 | for i in range(defects.shape[0]): 59 | s,e,f,d = defects[i,0] 60 | 61 | start = tuple(cnt[s][0]) 62 | end = tuple(cnt[e][0]) 63 | far = tuple(cnt[f][0]) 64 | if d>10000: 65 | count_defects+=1 66 | 67 | # define actions required 68 | count_defects+=1 69 | if count_defects == 2: 70 | keyboard.press_and_release('left') 71 | 72 | else: 73 | cv2.putText(img,"0", (50, 50),\ 74 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 75 | ha=0 76 | 77 | #time.sleep(1) 78 | # show appropriate images in windows 79 | #cv2.imshow('Gesture', img) 80 | all_img = np.hstack((drawing, crop_img)) 81 | cv2.imshow('Contours', all_img) 82 | -------------------------------------------------------------------------------- /thumbdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepalichakre/Hand-Gesture-Recognition-for-Presentation-Process-in-Python/3ef5025e9ba6b83890b82705a9b574cd197c0d4d/thumbdown.png -------------------------------------------------------------------------------- /thumbdown.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import cv2 3 | import numpy as np 4 | import math 5 | import os 6 | import time 7 | import pyautogui 8 | os.chdir("location of scripts,xml files") 9 | def t_crop(crop_img,img): 10 | grey = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY) 11 | 12 | # applying gaussian blur 13 | value = (35, 35) 14 | blurred = cv2.GaussianBlur(grey, value, 0) 15 | 16 | # thresholdin: Otsu's Binarization method 17 | _, thresh1 = cv2.threshold(blurred, 127, 255, 18 | cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 19 | 20 | # show thresholded image 21 | cv2.imshow('Thresholded', thresh1) 22 | 23 | # check OpenCV version to avoid unpacking error 24 | (version, _, _) = cv2.__version__.split('.') 25 | 26 | if version == '3': 27 | image, contours, hierarchy = cv2.findContours(thresh1.copy(), \ 28 | cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) 29 | elif version == '2': 30 | contours, hierarchy = cv2.findContours(thresh1.copy(),cv2.RETR_TREE, \ 31 | cv2.CHAIN_APPROX_NONE) 32 | 33 | # find contour with max area 34 | cnt = max(contours, key = lambda x: cv2.contourArea(x)) 35 | 36 | # create bounding rectangle around the contour (can skip below two lines) 37 | x, y, w, h = cv2.boundingRect(cnt) 38 | cv2.rectangle(crop_img, (x, y), (x+w, y+h), (0, 0, 255), 0) 39 | 40 | # finding convex hull 41 | hull = cv2.convexHull(cnt) 42 | 43 | # drawing contours 44 | drawing = np.zeros(crop_img.shape,np.uint8) 45 | cv2.drawContours(drawing, [cnt], 0, (0, 255, 0), 0) 46 | cv2.drawContours(drawing, [hull], 0,(0, 0, 255), 0) 47 | 48 | # finding convex hull 49 | hull = cv2.convexHull(cnt, returnPoints=False) 50 | 51 | # finding convexity defects 52 | defects = cv2.convexityDefects(cnt, hull) 53 | count_defects = 0 54 | cv2.drawContours(thresh1, contours, -1, (0, 255, 0), 3) 55 | 56 | # applying Cosine Rule to find angle for all defects (between fingers) 57 | # with angle > 90 degrees and ignore defects 58 | for i in range(defects.shape[0]): 59 | s,e,f,d = defects[i,0] 60 | 61 | start = tuple(cnt[s][0]) 62 | end = tuple(cnt[e][0]) 63 | far = tuple(cnt[f][0]) 64 | if d>9000: 65 | count_defects+=1 66 | # find length of all sides of triangle 67 | '''a = math.sqrt((end[0] - start[0])**2 + (end[1] - start[1])**2) 68 | b = math.sqrt((far[0] - start[0])**2 + (far[1] - start[1])**2) 69 | c = math.sqrt((end[0] - far[0])**2 + (end[1] - far[1])**2) 70 | 71 | # apply cosine rule here 72 | angle = math.acos((b**2 + c**2 - a**2)/(2*b*c)) * 57 73 | 74 | # ignore angles > 90 and highlight rest with red dots 75 | if angle <= 90: 76 | count_defects += 1 77 | cv2.circle(crop_img, far, 1, [0,0,255], -1) 78 | #dist = cv2.pointPolygonTest(cnt,far,True) 79 | 80 | # draw a line from start to end i.e. the convex points (finger tips) 81 | # (can skip this part) 82 | cv2.line(crop_img,start, end, [0,255,0], 2) 83 | cv2.circle(crop_img,far,5,[0,0,255],-1)''' 84 | 85 | # define actions required 86 | count_defects+=1 87 | if count_defects==2 or count_defects==1: 88 | keyboard.press_and_release('enter') 89 | 90 | 91 | else: 92 | cv2.putText(img,"0", (50, 50),\ 93 | cv2.FONT_HERSHEY_SIMPLEX, 2, 2) 94 | ha=0 95 | 96 | #time.sleep(1) 97 | # show appropriate images in windows 98 | #cv2.imshow('Gesture', img) 99 | all_img = np.hstack((drawing, crop_img)) 100 | cv2.imshow('Contours', all_img) 101 | --------------------------------------------------------------------------------