mirror of
https://github.com/opencv/opencv.git
synced 2026-07-24 21:03:03 +04:00
Compare commits
1966 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb9a143429 | |||
| 52ac61d87c | |||
| 942ff5be57 | |||
| 95a4943762 | |||
| ed8a7fa541 | |||
| 0e46b4cd03 | |||
| 75487d43f5 | |||
| 9a5aa4b23c | |||
| cf4a536440 | |||
| 00b2124876 | |||
| 4530c7ad08 | |||
| f7243be79c | |||
| 5240a03217 | |||
| 257463719b | |||
| aab6f6c56f | |||
| 75ede6e17c | |||
| 8760a344ec | |||
| 6f86c9f118 | |||
| 5d8098a2c3 | |||
| c5632d412e | |||
| a602185fb6 | |||
| 5f590ebed0 | |||
| 71ff228ad3 | |||
| a37876ab95 | |||
| 9786e0a760 | |||
| 1fe403f461 | |||
| 3ed89a8879 | |||
| 8392296eda | |||
| f5d9359da8 | |||
| 0825120f6a | |||
| 12c69ad490 | |||
| 9ac06a9333 | |||
| d97f9fc477 | |||
| 8a4a1bb018 | |||
| 30111a786a | |||
| 3cd7941098 | |||
| 01bd4961e3 | |||
| c3100eeb19 | |||
| dfd0b297ce | |||
| 28f3a44e33 | |||
| 713ddb89bd | |||
| c97c0be4f2 | |||
| 5505aa28ce | |||
| 91676de638 | |||
| b4d3b34acf | |||
| 1c7ee88b84 | |||
| 3deea1c3ce | |||
| 5119564579 | |||
| 1629d50999 | |||
| 5898dcae4a | |||
| da806cc3e7 | |||
| 8124d10526 | |||
| 6fb282aa39 | |||
| 10b3d00fd1 | |||
| bca4eb5e00 | |||
| f3dfdfef8a | |||
| 563200fbf6 | |||
| d119afafdb | |||
| fe7b48aa8f | |||
| 27d2d3cbac | |||
| 31df47b6ea | |||
| f937f4d951 | |||
| 6df1198e8b | |||
| 8fd61c9aa6 | |||
| 73115233bb | |||
| 8202ab37d8 | |||
| b7d1a70919 | |||
| 911e1bd1e4 | |||
| b73b28ab9c | |||
| dfe5fff2f5 | |||
| 498da24b8b | |||
| 835b5e2179 | |||
| 6b0e63b652 | |||
| 2b94bcffb9 | |||
| c54b8f9b00 | |||
| 07744af790 | |||
| 0f66e2757b | |||
| 8368d54d36 | |||
| 9ef373f6a5 | |||
| d0137b6d2d | |||
| 4de4ff5682 | |||
| 92f326a1b1 | |||
| e2f24f43c9 | |||
| e49536e88b | |||
| 05e7c29de5 | |||
| 9a233999a9 | |||
| 09907eeb62 | |||
| 68305703bd | |||
| 0224a20ff6 | |||
| 99eed2d885 | |||
| 72cac5e19f | |||
| 62f90219fc | |||
| 74457cd3b5 | |||
| ce0297ed61 | |||
| 88672f414b | |||
| 951014803b | |||
| 1da3f9d85f | |||
| 7cba3ac4f8 | |||
| b3a54d588b | |||
| 7849c35de1 | |||
| f908c2b0e3 | |||
| 032c363ea0 | |||
| 0be18aca81 | |||
| 4c54b287e4 | |||
| b7899c3d5c | |||
| 03435c0d74 | |||
| b5f251c815 | |||
| 6ad4521b78 | |||
| d0f789dc90 | |||
| 8dab2ffce7 | |||
| 6b05ca589d | |||
| 98d5731ad8 | |||
| c5ad6de596 | |||
| 7dd7dd97cd | |||
| c9b5d8cf4c | |||
| 00221e96fd | |||
| 44fbfb2cf6 | |||
| 2a0b39d30a | |||
| eb9fdb0164 | |||
| fec21239c8 | |||
| d30729a816 | |||
| 44f24efad4 | |||
| 3d0a270a66 | |||
| e9ccadebed | |||
| 7d41ce23a7 | |||
| d921cde4d2 | |||
| 0428ce4703 | |||
| f3aa4bdf59 | |||
| ca183707f2 | |||
| bab5700a09 | |||
| d611684d9e | |||
| 9d9411555f | |||
| 976c727eec | |||
| 218b12c557 | |||
| fc0f254f00 | |||
| 55188fe991 | |||
| d2f1c00719 | |||
| 06547120aa | |||
| 74d2a6eed1 | |||
| 774d277c1f | |||
| 2637b18b67 | |||
| 7999fbf765 | |||
| f32b52ea8d | |||
| 8c2c3b54d9 | |||
| b2acd1f75a | |||
| a05ce00a65 | |||
| a58767eff8 | |||
| 432b7cb235 | |||
| 61423a2d47 | |||
| 3fe4980ce1 | |||
| 2d587ad691 | |||
| cb9b88e65b | |||
| dbedc63c55 | |||
| a3da3a01e1 | |||
| cdb7b83741 | |||
| add9ce46c3 | |||
| 222f8a3d5e | |||
| 24b01a8e4f | |||
| 98a1181240 | |||
| 79b593d8d8 | |||
| eeb786fcfd | |||
| 9cb79b9abb | |||
| 8e9d1d9fe6 | |||
| 2520e335d1 | |||
| 28ca6ac05e | |||
| d3cdfefa03 | |||
| c6593d02a6 | |||
| c20ff6ce19 | |||
| 2026094691 | |||
| c595457ea0 | |||
| 11dd36f3aa | |||
| b33a093844 | |||
| 74e58ddbb1 | |||
| 0f9b79ef64 | |||
| aad4104297 | |||
| 184c5917bf | |||
| 936536a284 | |||
| d01ca30f55 | |||
| b724208510 | |||
| 983e75e5de | |||
| 345b69d5f7 | |||
| 05164bf713 | |||
| b3e31fb8d6 | |||
| 625fd61313 | |||
| 18de8dee62 | |||
| f8aecb2a32 | |||
| b48e487d53 | |||
| 11a0e3ff78 | |||
| 17a6b8cdc0 | |||
| 7030a1f9a2 | |||
| 9db8592aa8 | |||
| 2f2a9ad536 | |||
| b0cd822924 | |||
| 10b60f8d16 | |||
| 52df3b232d | |||
| fd10557e78 | |||
| 8def44047a | |||
| c9876c3cd8 | |||
| 4fe04775d1 | |||
| 3b608fa489 | |||
| 3c5eb7de84 | |||
| 223cdcd0ee | |||
| 1a1097ab23 | |||
| ef8647fe30 | |||
| 2ab7fb6051 | |||
| 5267ed46c7 | |||
| 7f82960897 | |||
| a782ee93de | |||
| e368f17caf | |||
| 90ac88cb8e | |||
| bd8894002e | |||
| d3d0434f07 | |||
| 878dec65c8 | |||
| eaec132091 | |||
| ba3783d205 | |||
| dce1824a91 | |||
| cf2a307832 | |||
| 4c8a9c5d70 | |||
| 101769d26c | |||
| a1791c6be3 | |||
| b8bc99676d | |||
| 6e4562bb56 | |||
| dbb5993d13 | |||
| dc3c691c8c | |||
| e7216a5987 | |||
| 277802483f | |||
| e9bed17d98 | |||
| 4cdc155eac | |||
| 0972a2d758 | |||
| 88d05a89d4 | |||
| 14d0b763ec | |||
| 1a14d8506d | |||
| 14631be59f | |||
| 41df63aacd | |||
| a587759d76 | |||
| 962b519708 | |||
| 0c749fd7e5 | |||
| af83884dc7 | |||
| 1925fab427 | |||
| 11e9e375a3 | |||
| 2fd01dcced | |||
| 97f6dd1820 | |||
| 1ad9827fc4 | |||
| 00263dd664 | |||
| f42bb0bd65 | |||
| 4255746c00 | |||
| 1310dc4ca2 | |||
| 50a1def80b | |||
| cb492cc24d | |||
| ef0f010437 | |||
| 4dfb613c3e | |||
| fecfaf4092 | |||
| 27d97aa231 | |||
| ba706177cb | |||
| 586ace1873 | |||
| 6cac76bfe4 | |||
| fc8f0e341b | |||
| 5f47f70183 | |||
| a2ae1db31c | |||
| 9ab3b89c53 | |||
| 42ecfc5538 | |||
| 964657a155 | |||
| 1d1bfd3d7d | |||
| d25770ee76 | |||
| 7da0e37ba8 | |||
| ee90b88dd7 | |||
| 8e80f9b7a8 | |||
| 603030b005 | |||
| fe29af2e58 | |||
| e49d148d47 | |||
| 37d01e2d27 | |||
| a98ce86ca3 | |||
| 1f0ca00d75 | |||
| e51c0810b6 | |||
| 66ac46214d | |||
| 16a82b1747 | |||
| facb2f9a81 | |||
| f8442da945 | |||
| 551ab83cf2 | |||
| d7038423dd | |||
| 6a769c92b3 | |||
| da1ac35930 | |||
| 7bd7c85b1d | |||
| 58cf2a8f19 | |||
| 4fdd6de8e8 | |||
| 1d2cf0e20e | |||
| 52f76a3283 | |||
| 7791264525 | |||
| 2b9e556055 | |||
| b17bf031f6 | |||
| 6c8b6bd0c7 | |||
| ed07241f89 | |||
| e5a3ab3cb9 | |||
| 0318d27720 | |||
| 5dd9263848 | |||
| 63a8cb594a | |||
| 716218cac4 | |||
| d1c7983fe5 | |||
| 9d107fb2d5 | |||
| bd144cfa64 | |||
| fd51c133df | |||
| 9e3124a1c9 | |||
| 315c80f793 | |||
| d2493393db | |||
| cc703b01df | |||
| 1242a66119 | |||
| 4dcd37f699 | |||
| 9a58b1a3a0 | |||
| a7006ac21c | |||
| 17d69be902 | |||
| e82241cba5 | |||
| 4644689d5a | |||
| 85601e03dd | |||
| 52516085d9 | |||
| 1ff270e41c | |||
| 9b8002cd43 | |||
| b792419cde | |||
| 6d86d63ac5 | |||
| 9bc71f4cb6 | |||
| eed5cbc5db | |||
| 3ab117df04 | |||
| 021b0cb4d5 | |||
| 0e2ea45c93 | |||
| 2832cfdfe5 | |||
| d8d946a458 | |||
| 2982e77495 | |||
| fe29ed461c | |||
| e532bd50d5 | |||
| 1533d0448f | |||
| d848704b35 | |||
| 8f8450793a | |||
| 8b32235854 | |||
| 7a77cf584a | |||
| dbefbbc522 | |||
| 40370345c5 | |||
| b1793e2fb9 | |||
| 7171431e7c | |||
| ca307669d4 | |||
| b63a7e66db | |||
| d58f736935 | |||
| f773cd9a3e | |||
| 381986d044 | |||
| 3490a5aded | |||
| e169083fed | |||
| df74a266cf | |||
| 0876ec7a67 | |||
| 67e23ed972 | |||
| cbf63b0709 | |||
| 910d8f8e0b | |||
| f2a2467de3 | |||
| 6dd3244019 | |||
| fee3d6931b | |||
| c949845a6b | |||
| a0816c6d15 | |||
| 347eaa8685 | |||
| 2e49ca4903 | |||
| 0d49f97128 | |||
| f8b23cff18 | |||
| 0f1a0a9818 | |||
| e8f5c2fcf6 | |||
| a3bde36c84 | |||
| 7fe7facfee | |||
| eb8366bb0a | |||
| e79ceb4b45 | |||
| d05d235c01 | |||
| 4286f60387 | |||
| e1553d5da3 | |||
| b2ab1b758a | |||
| 41dcd0ac03 | |||
| 7d9f79b130 | |||
| 90dce84314 | |||
| e2b86974ae | |||
| e04c39b089 | |||
| b449bd5150 | |||
| e25dca21d1 | |||
| d44e3c369d | |||
| 68827072c9 | |||
| b71744082b | |||
| 7674f3ddbf | |||
| 964b260937 | |||
| 55d84cf815 | |||
| 690c932d7f | |||
| 2fe07abf83 | |||
| 8fdbdb131d | |||
| d183554600 | |||
| e6c305cb75 | |||
| c5d3c08256 | |||
| 93f8581b69 | |||
| e5b63d43f2 | |||
| effff27c4e | |||
| 46e2216165 | |||
| 10c772fa7f | |||
| 133d861d65 | |||
| 8539d424b2 | |||
| c3329ff79d | |||
| dcf96b2da7 | |||
| 0e534b5a25 | |||
| d6233b13ba | |||
| d65abcaedb | |||
| b1ac35e14a | |||
| 43e4946cca | |||
| a3b9884674 | |||
| 561703ca27 | |||
| 14548227ca | |||
| d40cb39616 | |||
| 92ead5fab3 | |||
| 1b18ebf28a | |||
| 15197eb09b | |||
| fe4bdcd71b | |||
| f6cf68094f | |||
| 6bb8c46d9a | |||
| d826bcdbbb | |||
| 070be56e14 | |||
| 157257b072 | |||
| 95550c2582 | |||
| 972119bff3 | |||
| 54e4ef657c | |||
| 9c8b9fc733 | |||
| cbd0511a56 | |||
| 978f7eb44a | |||
| ebb0255e19 | |||
| 5c8cd76893 | |||
| 3a8af7d691 | |||
| acbabedac9 | |||
| e0584bb818 | |||
| 1493160f26 | |||
| b304868d91 | |||
| 667a9328fb | |||
| cac1218eef | |||
| 654bdde8ed | |||
| d5c99a07b6 | |||
| 36db85a94d | |||
| 2d81595ed4 | |||
| e8850bf84a | |||
| 1576e24c93 | |||
| e89e3066e8 | |||
| 1138fbb940 | |||
| e9bb750d4e | |||
| b0a70787e1 | |||
| 1a73aa1f6a | |||
| 16ab6ec534 | |||
| a3592cd068 | |||
| ad9272e836 | |||
| 6f2fea7ea5 | |||
| 730ead44fe | |||
| d4f938ed56 | |||
| c4fdf71bb3 | |||
| 436342d5f4 | |||
| b21b8ff9d7 | |||
| 8f2aaff6d7 | |||
| 47e345bcb6 | |||
| a73809e6fc | |||
| 66f2e527b6 | |||
| 07c0d50edf | |||
| ea2228774d | |||
| ea1b14ee95 | |||
| 3858f2291d | |||
| 09bcc061dd | |||
| fb8fa3fdac | |||
| b6769c9db1 | |||
| f45da9866a | |||
| 3ece65ad62 | |||
| 98421e5970 | |||
| 6d4c4dcd94 | |||
| 4f1d06d14a | |||
| 84bb77e914 | |||
| 87f4b47a4f | |||
| e89cee35e5 | |||
| 0528d2e2b3 | |||
| c23da52564 | |||
| 44ffa42064 | |||
| 007593cab7 | |||
| 863784efc6 | |||
| 6952b90ed0 | |||
| eeddda4701 | |||
| 01a98fae93 | |||
| 6e0d77469a | |||
| 07446ec954 | |||
| 7688a18264 | |||
| 05e0b3b7e6 | |||
| 655465d9f8 | |||
| eb54c83985 | |||
| d9daa0cbaa | |||
| 6d6ad1b1d9 | |||
| b32fbe72f6 | |||
| 6a94862fef | |||
| cb69a5c29a | |||
| 75742fcd01 | |||
| acebfcd24f | |||
| c99ce0f427 | |||
| 65953fe39a | |||
| ea6da6ee95 | |||
| 9391ccfe35 | |||
| 4c7ed03b5f | |||
| c41a134394 | |||
| ce5bae1c67 | |||
| 06fb5da7c8 | |||
| dcaa8735ba | |||
| 13db948023 | |||
| 82da445a15 | |||
| a7036d9668 | |||
| 1db9cc3f0d | |||
| 04628d770c | |||
| 93712e913a | |||
| 606df0469a | |||
| 9bf296eeb0 | |||
| c424d36041 | |||
| 660d7cd3ae | |||
| 7391df386f | |||
| 6550c4f682 | |||
| b6e25a9fc7 | |||
| 6dd658a0af | |||
| f269a89792 | |||
| 758a1eb63d | |||
| 504bc7634a | |||
| d5244eb645 | |||
| 724f5e7f19 | |||
| 54292a8376 | |||
| e1e243588e | |||
| 45f21e4f12 | |||
| 2c134318f7 | |||
| 41ceadf9ed | |||
| afe6b66d33 | |||
| 052c8516a8 | |||
| ad7440c014 | |||
| 2b2ce3f6e9 | |||
| 3391caf434 | |||
| 7ccbe10970 | |||
| 316c044e06 | |||
| f1e24381d1 | |||
| b2c2aabd04 | |||
| 14671e0cd6 | |||
| 3500c940d4 | |||
| 055adc2302 | |||
| feeb386bf3 | |||
| b3655233f1 | |||
| 88ceee05c6 | |||
| 33239fca70 | |||
| 96ce9810a9 | |||
| c9528b3952 | |||
| eeaa4b3665 | |||
| c072c28e28 | |||
| 071daa1d8f | |||
| bf39f694ea | |||
| 03f665e870 | |||
| 91201b225a | |||
| 4d0848b3e8 | |||
| 9edd24fe51 | |||
| 556206de2d | |||
| 1f4ddbe5b6 | |||
| e0f40a7f4a | |||
| 8681b52dba | |||
| 634da9f3bf | |||
| 659d21332e | |||
| 0b2cafb08b | |||
| cf72d2695c | |||
| 278616bada | |||
| ff6f5d4d24 | |||
| ed1c56e063 | |||
| 4ef311949b | |||
| 150dd39b08 | |||
| 3a35ca5190 | |||
| 64344f4545 | |||
| 02b32d86d3 | |||
| 7f2662b310 | |||
| 5403bdd228 | |||
| 2040995801 | |||
| fc610979bb | |||
| f08d88fa78 | |||
| 1a7a262f74 | |||
| e430ab1a58 | |||
| ea417ac04a | |||
| fd5a8b3e97 | |||
| f30301d171 | |||
| 15b6fd2ec4 | |||
| 59c8edfd98 | |||
| 5d924b7a75 | |||
| 0c0ebca855 | |||
| 8a5f2781fc | |||
| 3f485d58bb | |||
| a42259421c | |||
| b327312bd3 | |||
| 47f1026ce0 | |||
| 405f12fe80 | |||
| 6d3413bc6a | |||
| c2ca059baf | |||
| ab9dff12d5 | |||
| ee8adc10a1 | |||
| a49ea6d066 | |||
| 85edb9e9b1 | |||
| f0887a99e2 | |||
| bd12d64641 | |||
| 108527c951 | |||
| 607cd37b48 | |||
| 2cc4cf3644 | |||
| 518d0df201 | |||
| 93af92c878 | |||
| 5e8a3cde94 | |||
| 26b73a7bbd | |||
| 530fc99947 | |||
| 72385979c4 | |||
| c836613bad | |||
| e224e72bbc | |||
| ab428c9dbd | |||
| 67bb1c6a70 | |||
| 17956a5ae5 | |||
| fc2f79701d | |||
| a049c16ca7 | |||
| 33087f9eaa | |||
| 7c44a07810 | |||
| 62533d0d26 | |||
| abe37659cc | |||
| 78badcd651 | |||
| 89e4118b30 | |||
| 17d6083e01 | |||
| ce1b6e2137 | |||
| d4a1936c2d | |||
| 80470f9cf6 | |||
| 7f818e9bc3 | |||
| 6126788535 | |||
| 2e2ca58b70 | |||
| d210132b99 | |||
| 316e6a8f2b | |||
| 776728ef2a | |||
| d156f5af6d | |||
| 67e9708621 | |||
| 9a5e9d3442 | |||
| a8608bd0ac | |||
| f57f39276a | |||
| f0e3940558 | |||
| c52a77b90f | |||
| 579499d900 | |||
| 002a79bfc4 | |||
| 7804d57f8b | |||
| 33173d900a | |||
| 437927b7bb | |||
| 5a268dd27c | |||
| 68883775fb | |||
| 0ea572d772 | |||
| 2bacd8b702 | |||
| 153ac43d3b | |||
| 3ab3367310 | |||
| c9db91ace5 | |||
| df9c75b270 | |||
| 40eea303ec | |||
| aa170cfb5b | |||
| 68165b1af0 | |||
| 8e54845049 | |||
| b4498d1d48 | |||
| 63584bffda | |||
| 04433b2d2b | |||
| 169351b01d | |||
| cfabf32492 | |||
| 48d82fd911 | |||
| a8bfab3cb7 | |||
| 6667cea0f4 | |||
| 72727111c7 | |||
| 47b092e527 | |||
| 4a37ac303a | |||
| e6f6905868 | |||
| 50fa809a96 | |||
| 5022a0fae3 | |||
| 766600529b | |||
| ec3c68c8ea | |||
| bd5e4c6c49 | |||
| 15738bf7ef | |||
| 5ee398bfd6 | |||
| 0a2d22bf31 | |||
| ab2749d648 | |||
| 4910242732 | |||
| 52ba76143c | |||
| c83455d8a4 | |||
| 0f7fbe4458 | |||
| c43e32854a | |||
| 09f9b35bc6 | |||
| 7f7064e3b9 | |||
| fea4396023 | |||
| 7249622ce7 | |||
| 694d7726b5 | |||
| a0459c2352 | |||
| 6598b97b96 | |||
| c19b6ed20e | |||
| d940093fb5 | |||
| cf5dd88cf2 | |||
| ec99f96c62 | |||
| 2f8b5731da | |||
| fa1ed5580d | |||
| 73bfcf856d | |||
| 0e1b37675c | |||
| 7032a5a46c | |||
| ab1a37d564 | |||
| 8d4a76925c | |||
| 31291ced11 | |||
| 00367cfb00 | |||
| e63d7de87c | |||
| 3ca7717e17 | |||
| 511ed4388e | |||
| 7ea1bf3cf0 | |||
| 3678020c28 | |||
| 0ec54982b5 | |||
| 976da2f3d3 | |||
| 3d7a457c97 | |||
| 0d2fab86b4 | |||
| 651b13f72a | |||
| bea46c90b5 | |||
| 0b4eb6a964 | |||
| c6113c6cb3 | |||
| 8bd1efa523 | |||
| 934cb6c452 | |||
| 988b108858 | |||
| 44acfc38a1 | |||
| e30939f09b | |||
| 118b27f5b4 | |||
| f01bd6f978 | |||
| 165789bfcd | |||
| eded87de5b | |||
| 12207ac763 | |||
| 9eac451a3a | |||
| cba5235f08 | |||
| f77aa45cfb | |||
| 7fc764f5e5 | |||
| f0b0d4e867 | |||
| 06b335b2d7 | |||
| 62e0759ba2 | |||
| a46f119fdf | |||
| fa292c3d8d | |||
| c5b4b99350 | |||
| 9a371de93b | |||
| c9cb480844 | |||
| 1e46a99d9f | |||
| eb1dd1900b | |||
| c7dc884855 | |||
| 8ecb8c6a3d | |||
| 033aebe668 | |||
| ada2879faa | |||
| f3440888ef | |||
| ce0b808e3c | |||
| 746185652a | |||
| f16503743f | |||
| ea038436e6 | |||
| 6a93b43cae | |||
| 0ebde64701 | |||
| c30fef1f9d | |||
| a52979c37f | |||
| 2756ae2051 | |||
| cafcfc4d0f | |||
| 55bff44810 | |||
| 00e3c246fe | |||
| f1e44fa5ca | |||
| f13e05cdcb | |||
| 75a1743f35 | |||
| 83b7fe1b82 | |||
| 46d672dcc3 | |||
| 7e2f7f45d7 | |||
| 1f72873c55 | |||
| 12e1d7fc2b | |||
| ed5d71b45f | |||
| 7e56cfafbc | |||
| 6f798b1ba7 | |||
| 6ecd553810 | |||
| 55a714c83b | |||
| dd67ea0210 | |||
| 1d557e6702 | |||
| 4612b4b827 | |||
| d16e0b377f | |||
| 10f89b9c8b | |||
| 4a24ecd176 | |||
| f64dfeb222 | |||
| 2cf6cea90f | |||
| c607dadc49 | |||
| 83e2731c94 | |||
| 87972d0d7c | |||
| 63e508abd2 | |||
| 006956c324 | |||
| ff2d76ec0d | |||
| bc7b21609a | |||
| f0547e5e05 | |||
| ea5b411c0f | |||
| 67b562d543 | |||
| 6c118ebc51 | |||
| 09674623cf | |||
| ecfb1ab4f8 | |||
| a0a8fb4fd9 | |||
| 6c59e39f7c | |||
| 313a0ad255 | |||
| e96de8821c | |||
| b382984810 | |||
| 2b4241c10b | |||
| 1e5694e082 | |||
| 120b3a1e77 | |||
| e8376c789d | |||
| 1f638a3e5b | |||
| e4a9c0f184 | |||
| 5e47aa6300 | |||
| e1b5a547cc | |||
| 7ac5c367e9 | |||
| e2558e5ee5 | |||
| d67c9aabff | |||
| bb5a22c504 | |||
| 03db61b33b | |||
| 029a8c443a | |||
| a068ccbf51 | |||
| 616c348536 | |||
| 3a8e15fad9 | |||
| c4e49463a9 | |||
| b42c268164 | |||
| 1a5fcd715d | |||
| a9c7db7518 | |||
| eba1be711c | |||
| 4e7f62fd24 | |||
| c74fed1fcf | |||
| 7c9caab1fb | |||
| a82dd8ce48 | |||
| eb240cc206 | |||
| aa76ef9a98 | |||
| 78f660024b | |||
| 11b01cd8b9 | |||
| 19a2495067 | |||
| 77275031ab | |||
| 99475e2976 | |||
| 349ff631a5 | |||
| e50ef2dab5 | |||
| 629461c836 | |||
| df9aa8898d | |||
| 35eb972e9a | |||
| 72e095b8a5 | |||
| 07d5f56707 | |||
| 3ccaa5294e | |||
| 9c780260c2 | |||
| 849228ac6a | |||
| 9e47672b2b | |||
| e2c7adc7c4 | |||
| d54aa307fd | |||
| 36afd4ef55 | |||
| abf905154f | |||
| 1ad69aba35 | |||
| 0e1bf58195 | |||
| 4c66614e07 | |||
| b1a28a52fa | |||
| 38db7a78df | |||
| b1443bc1bc | |||
| 5efd2056f0 | |||
| f6a8ac2f6c | |||
| 12279e2631 | |||
| 01f31dc007 | |||
| e362c3fb38 | |||
| 03b1d133df | |||
| 1f94b7dfc9 | |||
| ef01044b2f | |||
| 220de14077 | |||
| 4ffeb01cfd | |||
| e9be486534 | |||
| 787815fd00 | |||
| 59cf62ad9e | |||
| 87210690c2 | |||
| 50b291995a | |||
| f0d4ccc6cf | |||
| a5378186e5 | |||
| d9d9de75db | |||
| 347d5b96f3 | |||
| eda084e123 | |||
| c2341fd446 | |||
| 897d0a9aaf | |||
| c35fd55b0e | |||
| fa075c50a1 | |||
| 2d47dd7038 | |||
| e7e00201f1 | |||
| 9fc90f4069 | |||
| c1aee0c312 | |||
| dfdb09386f | |||
| 2df7242646 | |||
| 30f73623ce | |||
| 3e51da38fb | |||
| 71f871fafd | |||
| 4ebe76098e | |||
| c80faff42f | |||
| c9103730b6 | |||
| ab1ef08f0e | |||
| 4509fe55c2 | |||
| 2daa14e3c7 | |||
| e8d3ebecc7 | |||
| b62e59aac0 | |||
| 5658ba0002 | |||
| dacf63a888 | |||
| 0f22df2b0d | |||
| 06746ba645 | |||
| 043b917c7d | |||
| e6aa8ce932 | |||
| cbf3c1fbf1 | |||
| a134e068ef | |||
| c1bf453266 | |||
| c68cbfced3 | |||
| 0e3bbd7026 | |||
| a941d25f6d | |||
| 5662294319 | |||
| 599bcfb591 | |||
| cc0a94c536 | |||
| 507ea95265 | |||
| 2162aab0e9 | |||
| f9d3c49023 | |||
| f9422f60a6 | |||
| 16629bff4c | |||
| 6880dbfd95 | |||
| 3c596184e4 | |||
| f97e38d8a6 | |||
| f0f741b796 | |||
| 26c8b3a38e | |||
| 649935596e | |||
| 0e5b0677c9 | |||
| 5d50917961 | |||
| 59876cfb34 | |||
| c6e91e4736 | |||
| 86ec0fc813 | |||
| 55bbca2d09 | |||
| 47d903d968 | |||
| 05ee15f108 | |||
| 61f79c2632 | |||
| 3cfc22ae4e | |||
| f3f0e06c4d | |||
| 0e243541f9 | |||
| b046210296 | |||
| 5042ab1f32 | |||
| ba5bec1de2 | |||
| eada0f4b48 | |||
| 503bd38963 | |||
| 59250e8288 | |||
| de55126b69 | |||
| e6420bde73 | |||
| d37220e8ff | |||
| d8c9bb777e | |||
| 4bf1df7da3 | |||
| 7bd9b2ac26 | |||
| 35e1b322cb | |||
| 3bd364fce3 | |||
| a13e6ab79f | |||
| 232c37e827 | |||
| 9c7e0bfd33 | |||
| 7ee1d5f69b | |||
| 10d1b3a534 | |||
| 86888bdf77 | |||
| 3e24822fff | |||
| 33b9e4b4a3 | |||
| 36db97068c | |||
| 32b25de583 | |||
| 6b2c621d20 | |||
| dc91be86b2 | |||
| 5580d08c6e | |||
| 46e8d9d02d | |||
| 1909978f7d | |||
| 82a198a8f2 | |||
| 22d3faaeb9 | |||
| c20cab9ec1 | |||
| 2421ac3958 | |||
| 6d500cc6f7 | |||
| d27ed856f2 | |||
| 4fb5680d91 | |||
| 1f8b41f390 | |||
| dcc4d3640b | |||
| 8114e071c2 | |||
| 2d71c094b3 | |||
| d93161812b | |||
| f3d1001c5d | |||
| 751264f88a | |||
| 9badfa1f83 | |||
| ba0ab8edb0 | |||
| c2319285a9 | |||
| 92f855f0c3 | |||
| 01123aaa36 | |||
| 493679dc56 | |||
| e42057c487 | |||
| cd01d705c9 | |||
| 5c0a4878d7 | |||
| dfe6adebb9 | |||
| 580559e1e6 | |||
| 640c9667c7 | |||
| 51e2a8ec96 | |||
| e68a55cca2 | |||
| 46e40343f2 | |||
| caf3ed284d | |||
| 9cdb330452 | |||
| cccdcac0c8 | |||
| 4211d8fbd9 | |||
| 6b986489ec | |||
| 34afc72c23 | |||
| 6823b36974 | |||
| f5c729396d | |||
| 7c3d5b056a | |||
| f27a886314 | |||
| bb12293251 | |||
| 42079b899c | |||
| 3d7872b904 | |||
| 4db12032dc | |||
| b4830d896c | |||
| 0265247504 | |||
| d9ef5bb5a7 | |||
| f52126725f | |||
| d97f7da7a9 | |||
| fe644ede19 | |||
| 9cc80a68db | |||
| 76c415ff49 | |||
| 04abffeb16 | |||
| 8603c58f37 | |||
| 0b678c2451 | |||
| 3bd8211a72 | |||
| f7ec4a5c47 | |||
| 8d24a83c9c | |||
| 5ca3d855a2 | |||
| 8da0e2b707 | |||
| d453a598f8 | |||
| 3e173b701e | |||
| 3d25d70627 | |||
| 650762419c | |||
| d17f40dc1f | |||
| 32394df42d | |||
| 79384beb60 | |||
| 160c964e4b | |||
| baa6ab1967 | |||
| 82c67abbfa | |||
| 39b852f51d | |||
| 9a109440df | |||
| aa5767421a | |||
| 1f6b719776 | |||
| 26e8c6216f | |||
| d5513f522b | |||
| cb8743f9aa | |||
| 4f4a95299a | |||
| 6202f54a18 | |||
| 05a47d9014 | |||
| 87eb1b8fcc | |||
| da58425fbc | |||
| 6f9ca3d77c | |||
| ce0941160e | |||
| 2cd7a913ed | |||
| f3c56f8310 | |||
| e18224110c | |||
| 3e5a69d8ba | |||
| dba0f9fc8f | |||
| 9e10c09f2d | |||
| a7d12aabab | |||
| 793e980876 | |||
| e11d998cfb | |||
| ef2f5999ed | |||
| 8230f1fd68 | |||
| f218dffce6 | |||
| 10cb660240 | |||
| e13e3be16e | |||
| 84257b57d0 | |||
| c2f540d090 | |||
| 80ef1f6753 | |||
| a26bed16e6 | |||
| dab8e920b0 | |||
| 7ba4212529 | |||
| 3bb6db522d | |||
| aa3c36f545 | |||
| 6a5a0fe803 | |||
| 7942494fb6 | |||
| 20aaa8fe77 | |||
| 92db6786a9 | |||
| 4eede18027 | |||
| 9cdd15e141 | |||
| 534f9623f2 | |||
| 3553e9379b | |||
| 36d33dd6c2 | |||
| ebbac3c66d | |||
| 8176e893c0 | |||
| 5ff59af09d | |||
| f4c5679db8 | |||
| 53bc93730c | |||
| 799d2dabd6 | |||
| 884b706b3a | |||
| ad7f2311c0 | |||
| 2a051a124f | |||
| 5522c14efc | |||
| 57992e0169 | |||
| fd5e180657 | |||
| 265148b974 | |||
| cb4fffc72a | |||
| c0dbc083ea | |||
| 65f63421fa | |||
| a28ad40c2a | |||
| f318b5bc9d | |||
| 1638341270 | |||
| befdef9685 | |||
| 512cb4fced | |||
| d2b4ee1e9b | |||
| 06df383675 | |||
| 3a1a3da782 | |||
| f104d5be8c | |||
| fd90efc9dd | |||
| 047d285b7d | |||
| df8e28283f | |||
| 4c2db3d6e7 | |||
| 8ab224746b | |||
| 19d470749b | |||
| 925178749a | |||
| 3578f0afe9 | |||
| 588658d1a3 | |||
| 026b13b3db | |||
| e6cc1be7e8 | |||
| 06738468af | |||
| c22d92c1cb | |||
| a7f69a37e3 | |||
| c4a31a1ab1 | |||
| 7a5c1babde | |||
| 2737e3c99b | |||
| c1ea6f3c42 | |||
| 89e3e448f5 | |||
| 1d9808e5d5 | |||
| 8b6c5ade0e | |||
| 6bfbcf02cb | |||
| f7f4593936 | |||
| 7ae547a208 | |||
| b56dce3965 | |||
| 8fd11f477b | |||
| e032b5f5d5 | |||
| b59c517f98 | |||
| 47d4f8cd61 | |||
| b970ec7dae | |||
| 43c29a6751 | |||
| 7369cfd9ec | |||
| f417c79d16 | |||
| 604a64b206 | |||
| a0bf7f82ba | |||
| dae04aacc3 | |||
| b66adc81a4 | |||
| b5755b1228 | |||
| 211d44cfc5 | |||
| b2379b51b5 | |||
| 34984328fd | |||
| d9556a998f | |||
| 2f9dad5ce8 | |||
| eb89f5207c | |||
| 29d1bce85f | |||
| 79eb3c5cde | |||
| befbe89bdf | |||
| eb45cf0c93 | |||
| 9b52b61451 | |||
| a01659825c | |||
| c098c18942 | |||
| 18ef25ec30 | |||
| 785acc1834 | |||
| 03773cb117 | |||
| 7b366df822 | |||
| cd02a7002b | |||
| ab691a4a24 | |||
| 0d477ffea1 | |||
| 1461ab41bc | |||
| b033a63e63 | |||
| b6d58d1d3b | |||
| d9013a85f1 | |||
| 8899ec1586 | |||
| ced81b9121 | |||
| e9bc737485 | |||
| e6d6a3a85b | |||
| bcd7151867 | |||
| e013f04669 | |||
| 96484e1ad7 | |||
| 4a63b3dd90 | |||
| a66db67b83 | |||
| 35494f81ef | |||
| 6119ae0ea9 | |||
| cb8ddb1179 | |||
| 629ddf0bf8 | |||
| bea2515f0e | |||
| 8592022bd8 | |||
| 838bb4bdeb | |||
| 444ab0ef0d | |||
| c735594178 | |||
| fd3a6f0db7 | |||
| a624ec167d | |||
| b72b256fda | |||
| b56b9c43dc | |||
| 77723db034 | |||
| f2a35d6388 | |||
| c6f208e1c8 | |||
| ed1ca00bf6 | |||
| bf860dbb31 | |||
| 49d1691a3e | |||
| c224cfa628 | |||
| 2c0c887f70 | |||
| 5ddff235bb | |||
| 46cb4e0cbc | |||
| f1b38c4198 | |||
| e090aa07db | |||
| d60be58a92 | |||
| 3cd50739ef | |||
| 3f95818252 | |||
| 5600bc54f4 | |||
| ac92d4c701 | |||
| 1b339eb0d4 | |||
| 990295644e | |||
| 42d45e0b02 | |||
| 9eb0e7d99b | |||
| aa5326c231 | |||
| a6ef45aa13 | |||
| 9828cd6086 | |||
| f23134ce01 | |||
| 9ec823d800 | |||
| 267241b889 | |||
| f9c5289483 | |||
| 6f055d7a76 | |||
| 616ec74beb | |||
| 7badc85b60 | |||
| 2d54581971 | |||
| f690440533 | |||
| 4f2b126b7b | |||
| 268c0caa7a | |||
| e8f79d6e1f | |||
| dbdc476b79 | |||
| 38913bf5f6 | |||
| 67484e027b | |||
| 566f783968 | |||
| 23e1b50837 | |||
| 06acb8b0ee | |||
| be29d628d3 | |||
| 4512d06484 | |||
| 824ed8a3ae | |||
| 1b3651d8ee | |||
| eb8c531791 | |||
| 188c506237 | |||
| ec6f977783 | |||
| a9a0ea3706 | |||
| c321330777 | |||
| ad23ef2a42 | |||
| 9d138b2bbe | |||
| c29583eacc | |||
| ee2df645f4 | |||
| 9b6feee1a5 | |||
| a6b53489e6 | |||
| aece433b15 | |||
| c65e5a1e7b | |||
| b3db990daa | |||
| 07e84c635a | |||
| 06434bedfd | |||
| 3b03044047 | |||
| 58de8bc917 | |||
| 01a66a2938 | |||
| c2f859569c | |||
| 8271bd5f14 | |||
| 1cee868e88 | |||
| def4f5e2a3 | |||
| d822d6f101 | |||
| 1dba47b77b | |||
| 572e4f5255 | |||
| 5848e75168 | |||
| 17f305140b | |||
| 137ff7eccb | |||
| 703e012a5b | |||
| 7a59435490 | |||
| d1710a8547 | |||
| 4ca695cab0 | |||
| f8d922ad3e | |||
| 5a3200d513 | |||
| 9a3895d842 | |||
| c747426fc1 | |||
| 271f60ba7a | |||
| bfc546d23c | |||
| 037ac27ec8 | |||
| fc10ffefb8 | |||
| 2cf3a6e26c | |||
| a3825acee4 | |||
| 2aab7b2926 | |||
| c165f07319 | |||
| 7daec9e9a8 | |||
| 2cd51c04e4 | |||
| 48df67a9c5 | |||
| bdc91c66c9 | |||
| fa2d79a15b | |||
| 6ef94b52ad | |||
| a8cb5c3983 | |||
| e23f7303a6 | |||
| 7f671406db | |||
| 0d5ffec521 | |||
| aa3c4ae5d2 | |||
| 97eac3f394 | |||
| 31f864a22b | |||
| bb3c0c066c | |||
| 9b9769169f | |||
| d170faeb5c | |||
| 6c2d77079f | |||
| 322b15a459 | |||
| 7df92bbb77 | |||
| 10a52220f0 | |||
| eeed9ce247 | |||
| 1f4586f3dd | |||
| c53398a438 | |||
| 5acd178790 | |||
| f77c68e0fa | |||
| e1efed1914 | |||
| 4c5de04efb | |||
| 6d368dc1e7 | |||
| 51530d4d8e | |||
| d17142b83d | |||
| 8541b7bf92 | |||
| b852108262 | |||
| 75534a4828 | |||
| 3747d2643f | |||
| 7d82171af4 | |||
| e6e817e613 | |||
| 0469c18726 | |||
| d6b54ff9d1 | |||
| e055b68ceb | |||
| 0b4534d4c9 | |||
| 0c1ab50643 | |||
| f5fecc7e9a | |||
| 4382970739 | |||
| 1ab8060b62 | |||
| d17740ec87 | |||
| 41b8ab086b | |||
| da34f1d58c | |||
| 91511c1521 | |||
| 2e3e106676 | |||
| 4b71921526 | |||
| a1798cb28e | |||
| 80df44bd75 | |||
| bb05af8ece | |||
| e34a7caabc | |||
| 4ceaf44fa0 | |||
| 6f5800e7df | |||
| 5005f5e88e | |||
| c764e0f114 | |||
| 9f1b20a794 | |||
| 61c22d5899 | |||
| fc696a9ff3 | |||
| 6f190bb907 | |||
| 068b1bc3d0 | |||
| 73042b32e1 | |||
| 3488fdcb43 | |||
| 569e1346f2 | |||
| 04c857a4e8 | |||
| a2f8a93bf5 | |||
| 6c12f20395 | |||
| a1d151924d | |||
| fa5705613d | |||
| f7d6d3cff5 | |||
| 491b84d463 | |||
| a7f9677378 | |||
| d67b450741 | |||
| 8c39b4e8b6 | |||
| 46ba9d30b9 | |||
| b211e1d989 | |||
| 70fdfa0bdb | |||
| d63a8ba018 | |||
| 6bd7a444bc | |||
| f1c8b4b965 | |||
| 953aafbd3d | |||
| f38fe76025 | |||
| da7a605224 | |||
| c1acbb02bc | |||
| 63a746c6ea | |||
| 7e03a8b279 | |||
| c6199fc3c1 | |||
| 5effebb5f5 | |||
| 85cf2d9671 | |||
| 67926fa028 | |||
| ede6d4482b | |||
| 9e1124d24a | |||
| ba2eee9cbd | |||
| cc05493730 | |||
| 8af175b81b | |||
| 4d3f9228aa | |||
| 9c5745383f | |||
| ac19420907 | |||
| 061a25447e | |||
| c2355d3a12 | |||
| e2c6ab0166 | |||
| b6833fdde7 | |||
| a51ab99a79 | |||
| e19c42dded | |||
| 8f5fd44fb2 | |||
| f8a100f3e0 | |||
| 6ba60a1e22 | |||
| 04b1822cff | |||
| bcb0ee3e4b | |||
| 9aa6528fd7 | |||
| 7efb09fb8f | |||
| 623b1db8d1 | |||
| 60803afe8f | |||
| d8c018289a | |||
| 157f35ef29 | |||
| ae89787984 | |||
| cf3a2e30cd | |||
| 259b9e093c | |||
| 5421d741bc | |||
| c4a63f6a86 | |||
| 20b6191842 | |||
| 64d679ecb4 | |||
| 9dc51a1aa4 | |||
| 2d3aa3861c | |||
| 0a5d6e10b9 | |||
| 244f126ff6 | |||
| f368b27f0a | |||
| a3668f1369 | |||
| 8ac93f9b6b | |||
| ef9669ba1a | |||
| 3b65b710b6 | |||
| 0dba5bdc4a | |||
| 79fc3a6203 | |||
| 46d39aff68 | |||
| 7193762d2d | |||
| d18ebfa8e8 | |||
| 2875ce60ea | |||
| 6bf4a7ce01 | |||
| dc21e2cc0e | |||
| fe5eaae102 | |||
| 846266fde4 | |||
| 3572ee278e | |||
| 49efc250d3 | |||
| 722c0fea41 | |||
| a66018d14d | |||
| b0ad84cfa2 | |||
| 4e851f5050 | |||
| c9f51d5eed | |||
| 0bd4fd3a87 | |||
| b7198ccf1c | |||
| 640e180efe | |||
| d060d30fa0 | |||
| bdfd29a0b8 | |||
| 034ef02409 | |||
| 80a40ae3d7 | |||
| 9c7ba6db90 | |||
| 2299e2ed1b | |||
| 87ae0f9990 | |||
| 63d8a61b9b | |||
| b14c314fc3 | |||
| 68c57a1e82 | |||
| eb8b4c58c7 | |||
| 65d64af2a8 | |||
| 291458a859 | |||
| 284b2fc1e7 | |||
| 30a8308f8e | |||
| 17713f6831 | |||
| b449b0bf71 | |||
| a1e5bd71f1 | |||
| b73490f86c | |||
| a2dec6c34e | |||
| f9f730c426 | |||
| 04884ebf45 | |||
| d1cfcfcafd | |||
| 8d97d0d631 | |||
| 0a16d93e1d | |||
| a43ef9a6cd | |||
| b4e4f13f9e | |||
| b70332d806 | |||
| 4d9698a4cf | |||
| 6e44f05e6f | |||
| eebf92ba58 | |||
| bff92da970 | |||
| d76226e21b | |||
| 6fe71bd27c | |||
| ae2b0b0098 | |||
| bfb1ba371c | |||
| 0470bb0e29 | |||
| 16869225ff | |||
| b9cdde6991 | |||
| 82e6edfba2 | |||
| 3940b6163b | |||
| 51cb6998ea | |||
| 0c02e5de25 | |||
| 6890aa0033 | |||
| a489d86e5f | |||
| ae036838dd | |||
| 6b8de222d7 | |||
| 40a740ff88 | |||
| dc28451b8a | |||
| 5f94a205d1 | |||
| 2a1d5c6d43 | |||
| af062b7c42 | |||
| 882971151d | |||
| 136e5eb804 | |||
| 1a43ed9893 | |||
| 24d8cbf940 | |||
| 80708008a4 | |||
| 7ce2ca2e0c | |||
| 9cafd50160 | |||
| 755ca4b7cf | |||
| dd6cf15a39 | |||
| bcb938efbb | |||
| c72a0a1295 | |||
| 5726e80f77 | |||
| 6b434befc9 | |||
| af1084eb58 | |||
| 91e4334227 | |||
| 18a59b48ba | |||
| ddc235172e | |||
| a5d989f346 | |||
| 799d7e7a50 | |||
| 0904f10ab5 | |||
| bfc843a5f5 | |||
| b5f717b6b3 | |||
| 6f12f1b3b5 | |||
| 6be7869ae8 | |||
| 4a4151ec97 | |||
| 4698d62125 | |||
| 8910508b83 | |||
| f9484bae8a | |||
| b47bec2ed0 | |||
| 4fafab3786 | |||
| 42e604abea | |||
| 3e854fa6e5 | |||
| 61c347fb76 | |||
| 357a856cf6 | |||
| 6f76e7b42d | |||
| 0ce8f1d5dd | |||
| c5bf1c108c | |||
| 4233539617 | |||
| adc15c2bba | |||
| a6c40abfb2 | |||
| 0764a23eb2 | |||
| 6b6cfa893d | |||
| 48196ad10b | |||
| 3ebfe60008 | |||
| 8e79de35a8 | |||
| b96762a48f | |||
| a5afcd9f11 | |||
| 553673eeed | |||
| fd8f2c8d23 | |||
| a87607e3ef | |||
| 290b93422c | |||
| 836635d2d5 | |||
| 4d7a593c25 | |||
| 9932cf41a4 | |||
| dca401d4cc | |||
| bbe8654c3d | |||
| 4f5896493e | |||
| f138b613b7 | |||
| 5252aa8fdd | |||
| 89b7c0dd93 | |||
| 2755ae5df9 | |||
| 1bb0c5747c | |||
| 95a55453df | |||
| 702a2a6ff6 | |||
| 5261fbe217 | |||
| 90c5dde887 | |||
| 9b31e6cd44 | |||
| 0084dee05b | |||
| fd0ab8eba1 | |||
| 1f8df38dba | |||
| 3eff05e3eb | |||
| e7475bff68 | |||
| e4608229f0 | |||
| 786e3b9eee | |||
| 45969bb3ae | |||
| 208831eb5d | |||
| efdfca7a11 | |||
| 70e22b682d | |||
| 06c138bd64 | |||
| 193e97a34a | |||
| 0eaeff0641 | |||
| 2879ff2098 | |||
| 5dbe73f94d | |||
| 182d74d33f | |||
| 451be9ed53 | |||
| 3cb49eac49 | |||
| 8f3492851e | |||
| 8660588fe9 | |||
| eb2e8a11fa | |||
| 75ed2f52f1 | |||
| 0e2cc5ef63 | |||
| d1d451c952 | |||
| 229aa62300 | |||
| 2f0fe5b87b | |||
| f21a94880e | |||
| 8e1918e86e | |||
| dc76e6b4a1 | |||
| f351540eda | |||
| 4a7289b22f | |||
| d9c5fbc9ba | |||
| 806e9241a6 | |||
| 1291bd1c4a | |||
| f404315368 | |||
| 66ed6a8a50 | |||
| b3e18d23a3 | |||
| f7a474180b | |||
| 86a3ed4162 | |||
| fde0185a77 | |||
| 22f42a639f | |||
| 4aa891e773 | |||
| 42f9ee3f3e | |||
| 60ce2b2e9f | |||
| da70b04262 | |||
| 3c1917771b | |||
| c1dad2178c | |||
| d4a1df85be | |||
| f9e942f9ef | |||
| b184d7f27b | |||
| a80ebfe28d | |||
| 0a3aca230c | |||
| ba4513503e | |||
| c9d8025fab | |||
| c00f0faf24 | |||
| 5527f2872d | |||
| b5248dbf3f | |||
| fa3f29f2b5 | |||
| 099ea91823 | |||
| 0692a674d1 | |||
| a600267b9f | |||
| 5c867463d2 | |||
| 72d5609a36 | |||
| 90920c2376 | |||
| 050cca0422 | |||
| 7ecbf45751 | |||
| 4376de7698 | |||
| be5b5a0471 | |||
| db85c35e69 | |||
| 29deff8707 | |||
| af8aa8a2fa | |||
| fb7e74c511 | |||
| eedf86402d | |||
| 68957b2757 | |||
| 767b28f2e3 | |||
| fbc69e444b | |||
| c1c3139368 | |||
| 409bd162ff | |||
| 37580687e6 | |||
| 68edda3350 | |||
| b9d68ef061 | |||
| 57b6850d74 | |||
| e6f6707558 | |||
| 7dc22b4ea6 | |||
| a228633d31 | |||
| bd5d8404c9 | |||
| ba5ebaa758 | |||
| 7a68e3d207 | |||
| 693129902d | |||
| a3aced20c1 | |||
| c9a4a82667 | |||
| ce0557ebb8 | |||
| 45cc8a5300 | |||
| 1db1a83410 | |||
| 48432502b6 | |||
| 3693facd9e | |||
| fe38aab84a | |||
| 31fb7c4fec | |||
| 48e7bc6b30 | |||
| 7dc549f166 | |||
| c78142acb0 | |||
| ff8b8ef24c | |||
| dbb7aa7856 | |||
| d695d4a0bf | |||
| 540a60fca7 | |||
| 653b99c9bd | |||
| e1a598c5b3 | |||
| 67cf0dabea | |||
| e75a257f92 | |||
| 73dfc4cb8c | |||
| 3845b96f6c | |||
| 52a339cba5 | |||
| 0f43345f9e | |||
| 16bfdbd22a | |||
| 6d83048ec3 | |||
| 681a8c6e18 | |||
| ced8e7a813 | |||
| 2b0c3eb170 | |||
| 1cf75c0cab | |||
| 8f6ebc2427 | |||
| 32eb38ec98 | |||
| 0406898b9a | |||
| 0ef16125ae | |||
| fd4461d543 | |||
| 0a90d6dde6 | |||
| 51dafc780b | |||
| 51421098dd | |||
| dc50dc7254 | |||
| 3e5890694e | |||
| 9b3c76a3db | |||
| f5330a44e8 | |||
| c7857e8c13 | |||
| 347a3dc520 | |||
| 31c8f2ec57 | |||
| 46d128e073 | |||
| 9c5bd85247 | |||
| b96923d5fa | |||
| f04a158268 | |||
| aa5311ea9f | |||
| 804b70b72f | |||
| 7b552c0493 | |||
| ea7b1bb3d2 | |||
| cd68cd43a2 | |||
| 10f2a038c2 | |||
| e013d31715 | |||
| 7e4dea968c | |||
| ad66233774 | |||
| efafd4a9e5 | |||
| 61976b8461 | |||
| 79eba54a4f | |||
| ddd3c062b5 | |||
| 7fd21d217a | |||
| fa0599448d | |||
| b939b4ae3b | |||
| 8bf616e4c7 | |||
| 634e8d37cc | |||
| bf4f15fb5f | |||
| 7faf1f6277 | |||
| ccbceb56c4 | |||
| cfc4621587 | |||
| ce42593fe6 | |||
| 7cbc4e88de | |||
| 4c1ed13846 | |||
| 72c327fef8 | |||
| 8754adc021 | |||
| af9368d35f | |||
| c35dab9046 | |||
| 3782c324c4 | |||
| 6f19ef8631 | |||
| 38cbe9873a | |||
| 9db28f332a | |||
| 891dbeabba | |||
| d27068f79a | |||
| e16d89e8d6 | |||
| 5cb2d1c20d | |||
| e460a29cab | |||
| da9bdf9c15 | |||
| 77df5948e7 | |||
| e35d98e566 | |||
| b7659c62f3 | |||
| edbff68843 | |||
| 394c74b349 | |||
| e6420c523d | |||
| b3cfe6b446 | |||
| ff9a0815b9 | |||
| de6d13088f | |||
| 2409812803 | |||
| 139a262072 | |||
| bcf4307345 | |||
| 689589ebaa | |||
| 95d7ecb33f | |||
| 13182da945 | |||
| a0a4f6c23d | |||
| 224124b69e | |||
| 768da4d95a | |||
| afd99c9c81 | |||
| 38ef8894b7 | |||
| 017a282c7a | |||
| 0d199b4048 | |||
| 44ecb727c5 | |||
| 6ad7b64912 | |||
| 01527c44fd | |||
| a8eab26bae | |||
| 63235f51f0 | |||
| 9885a671ee | |||
| 47d9b933f6 | |||
| cc529d971b | |||
| aeeb9f9e25 | |||
| a879e1fcd6 | |||
| 8236181c62 | |||
| 01a980aa9e | |||
| 01b225acb0 | |||
| 613a17355d | |||
| 029ffb7c2d | |||
| a6d64e254f | |||
| e8d26b02ac | |||
| 7358b44222 | |||
| 9a98cd6e65 | |||
| f60913ddd3 | |||
| 9211d1ac2d | |||
| 640a45d359 | |||
| a0bb74a086 | |||
| cfcf07acfa | |||
| 947fb74c18 | |||
| b6dafed5ba | |||
| 8cbb284b7b | |||
| f252687eae | |||
| 9fcb0b2201 | |||
| aad289a3a2 | |||
| f85aa929f1 | |||
| 70d462b352 | |||
| f74ef644bc | |||
| 1a89a03c7c | |||
| 10465c546a | |||
| c8e22c04c8 | |||
| 150e522bee | |||
| 510680a5df | |||
| 7629bb78a4 | |||
| 03bd82796d | |||
| 72e4f72a75 | |||
| 9b627a5e9f | |||
| 56754e907d | |||
| 1a5dfe421d | |||
| 7ce2c3574a | |||
| 4f36bc29d9 | |||
| ed1aa73dd3 | |||
| cce225f6e9 | |||
| e2f5001b11 | |||
| 915fb632fd | |||
| 8150c1b7e4 | |||
| 8b8c368148 | |||
| d1606b4aa3 | |||
| 3542da7167 | |||
| e0d991cf46 | |||
| 0fc248fb70 | |||
| 95e38e457f | |||
| fa272c43c2 | |||
| 8829e9f6c8 | |||
| f3f8b843b6 | |||
| a1de9e9ad5 | |||
| 88f993dbda | |||
| 1ce5165cb7 | |||
| 534bec3a90 | |||
| d68c688f22 | |||
| 3def7778dc | |||
| 1454843b81 | |||
| b92a46c130 | |||
| 6b00c4e337 | |||
| ecbe843061 | |||
| b4a535272c | |||
| dbe7634286 | |||
| b8d8b0568c | |||
| 630bdbf42f | |||
| eb247d826f | |||
| 9e69e2a07a | |||
| 7da3e98dfd | |||
| 55b9c0374c | |||
| 5f76072c62 | |||
| f297ec55ae | |||
| 01b624e359 | |||
| 91ab92c349 | |||
| 935e36bc72 | |||
| 0ee5c34f40 | |||
| 7acd28fbea | |||
| a0a3b8b56d | |||
| 879c0196d4 | |||
| a4b5641836 | |||
| 91587059ad | |||
| 290fbc0121 | |||
| a18bc9651d | |||
| 5d43d3ca88 | |||
| 863e9c699a | |||
| e55679079f | |||
| 3994cfbc59 | |||
| fa38ea6d50 | |||
| d9a322f606 | |||
| d02c291160 | |||
| 8bbce0a2a2 | |||
| e55f2b2602 | |||
| f7620dc7d1 | |||
| bbefc101de | |||
| 2806679781 | |||
| 9aef26e2ad | |||
| 261546f6f6 | |||
| 4f2cdc9bac | |||
| 511e79aef7 | |||
| 1cef6f9fb1 | |||
| bb4199b177 | |||
| dad536f490 | |||
| 281666887e | |||
| 7a35f4593e | |||
| 72aabb8a84 | |||
| 47a41449e3 | |||
| f7041bacc0 | |||
| 2d33063a59 | |||
| f1c062c30a | |||
| 5dc17f5d58 | |||
| 069dd8a068 | |||
| f8ccc115ef | |||
| 17fea0dd0a | |||
| 998aefd1d1 | |||
| 975a6299fa | |||
| eb8728d727 | |||
| 63dbe66b41 | |||
| 3cc27c769c | |||
| becbfa6281 | |||
| 8b44a42a40 | |||
| 3959329ef4 | |||
| 3170414ca8 | |||
| a0bfdb9bf1 | |||
| 1d68a89947 | |||
| 86b6c48712 | |||
| 48f95d92ae | |||
| 8b16b8b657 | |||
| 5dbdadb769 | |||
| 5a8363a44e | |||
| d534d04f25 | |||
| bfc27271e2 | |||
| ce992c8269 | |||
| e371901dd9 | |||
| b86088b89c | |||
| c1b6bf21d5 | |||
| 3e1f74f2ca | |||
| b10d4b05ed | |||
| 4b31b9cb8c | |||
| 44cc51dfb1 | |||
| 710d51bb41 | |||
| 9ff5a24f92 | |||
| 38f46eb3b4 | |||
| 412468e0ae | |||
| 5d099df578 | |||
| 3e4bb371c8 | |||
| b6ba1f226c | |||
| da44a2fac1 | |||
| 7daf26d398 | |||
| 34b02f6437 | |||
| af0040eab0 | |||
| 6ae4a9b09b | |||
| e91b818e3e | |||
| b6675ee2a8 | |||
| a078653ab4 | |||
| 530702c5f2 | |||
| feed2c074d | |||
| 390fa14a2a | |||
| e190d3fd36 | |||
| 563dc5aa38 | |||
| 721d0145e0 | |||
| 65b4d77959 | |||
| 9493a4ec4e | |||
| bdfa9fa14a | |||
| 4ab891e9e5 | |||
| 435615ba2e | |||
| 1aa83d324b | |||
| eb4c2cd59f | |||
| a0ccb46a7f | |||
| b0f617bc01 | |||
| ccda4bf008 | |||
| f44334285b | |||
| 0cd0e4749b | |||
| c684da3549 | |||
| 286fe261d0 | |||
| a098fb1803 | |||
| b8c6adc569 | |||
| cd1ffd169c | |||
| 11926dafb2 | |||
| a1ad1f0800 | |||
| 214cbabc40 | |||
| a138e5a6a5 | |||
| d8f7377122 | |||
| ede5b23753 | |||
| 1f5007f106 | |||
| 0a870faf28 | |||
| be7eb72051 | |||
| d950adc0d2 | |||
| 14b1e8c7f1 | |||
| 3dc2dbc17e | |||
| 64fd54ffb4 | |||
| 9145985ff4 | |||
| 130914d9f4 | |||
| 02ebc4368c | |||
| 75b80e5d7d | |||
| 25870fa66b | |||
| 3cf5c0b991 | |||
| 89dd828e3c | |||
| aa36898024 | |||
| 203a9acdbc | |||
| 483061e802 | |||
| 7cad2c6788 | |||
| 2f45942adc | |||
| 9cb48606ba | |||
| 8e93c19de3 | |||
| e85bacff7b | |||
| 112d63ae96 | |||
| 3d3b310ae1 | |||
| d3ac1bc314 | |||
| 0d19685f95 | |||
| fa749de0dc | |||
| 5aeeaa6fce | |||
| 45e0e5f8e9 | |||
| 6ae16ebec3 | |||
| c5c3fd4443 | |||
| 1c15776cf5 | |||
| 73b0827ec1 | |||
| 2cc11e2c6a | |||
| 69dc840583 | |||
| 67a2c4ecd5 | |||
| 5368f12b33 | |||
| d4df373999 | |||
| c1cd70e25a | |||
| 81d6842b8e |
@@ -0,0 +1,2 @@
|
||||
[tgit]
|
||||
icon = doc/opencv.ico
|
||||
@@ -0,0 +1,2 @@
|
||||
downloads/
|
||||
unpack/
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
#
|
||||
# The script downloads ICV package
|
||||
#
|
||||
# On return this will define:
|
||||
# OPENCV_ICV_PATH - path to unpacked downloaded package
|
||||
#
|
||||
|
||||
function(_icv_downloader)
|
||||
# Define actual ICV versions
|
||||
if(APPLE)
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_macosx_20140429.tgz")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "f2195a60829899983acd4a45794e1717")
|
||||
set(OPENCV_ICV_PLATFORM "macosx")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_osx")
|
||||
elseif(UNIX)
|
||||
if(ANDROID AND (NOT ANDROID_ABI STREQUAL x86))
|
||||
return()
|
||||
endif()
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_linux_20140513.tgz")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "d80cb24f3a565113a9d6dc56344142f6")
|
||||
set(OPENCV_ICV_PLATFORM "linux")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_lnx")
|
||||
elseif(WIN32 AND NOT ARM)
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_windows_20140429.zip")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "b5028a92224ec1fbc554010c52eb3ec8")
|
||||
set(OPENCV_ICV_PLATFORM "windows")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_win")
|
||||
else()
|
||||
return() # Not supported
|
||||
endif()
|
||||
|
||||
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_CURRENT_LIST_DIR}/unpack")
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")
|
||||
|
||||
if(DEFINED OPENCV_ICV_PACKAGE_DOWNLOADED
|
||||
AND OPENCV_ICV_PACKAGE_DOWNLOADED STREQUAL OPENCV_ICV_PACKAGE_HASH
|
||||
AND EXISTS ${OPENCV_ICV_PATH})
|
||||
# Package has been downloaded and checked by the previous build
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
|
||||
return()
|
||||
else()
|
||||
if(EXISTS ${OPENCV_ICV_UNPACK_PATH})
|
||||
message(STATUS "ICV: Removing previous unpacked package: ${OPENCV_ICV_UNPACK_PATH}")
|
||||
file(REMOVE_RECURSE ${OPENCV_ICV_UNPACK_PATH})
|
||||
endif()
|
||||
endif()
|
||||
unset(OPENCV_ICV_PACKAGE_DOWNLOADED CACHE)
|
||||
|
||||
set(OPENCV_ICV_PACKAGE_ARCHIVE "${CMAKE_CURRENT_LIST_DIR}/downloads/${OPENCV_ICV_PLATFORM}-${OPENCV_ICV_PACKAGE_HASH}/${OPENCV_ICV_PACKAGE_NAME}")
|
||||
get_filename_component(OPENCV_ICV_PACKAGE_ARCHIVE_DIR "${OPENCV_ICV_PACKAGE_ARCHIVE}" PATH)
|
||||
if(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
|
||||
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
|
||||
message(WARNING "ICV: Local copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
|
||||
file(REMOVE "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
file(REMOVE_RECURSE "${OPENCV_ICV_PACKAGE_ARCHIVE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
if(NOT DEFINED OPENCV_ICV_URL)
|
||||
if(DEFINED ENV{OPENCV_ICV_URL})
|
||||
set(OPENCV_ICV_URL $ENV{OPENCV_ICV_URL})
|
||||
else()
|
||||
set(OPENCV_ICV_URL "http://sourceforge.net/projects/opencvlibrary/files/3rdparty/ippicv")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY ${OPENCV_ICV_PACKAGE_ARCHIVE_DIR})
|
||||
message(STATUS "ICV: Downloading ${OPENCV_ICV_PACKAGE_NAME}...")
|
||||
file(DOWNLOAD "${OPENCV_ICV_URL}/${OPENCV_ICV_PACKAGE_NAME}" "${OPENCV_ICV_PACKAGE_ARCHIVE}"
|
||||
TIMEOUT 600 STATUS __status
|
||||
EXPECTED_MD5 ${OPENCV_ICV_PACKAGE_HASH})
|
||||
if(NOT __status EQUAL 0)
|
||||
message(FATAL_ERROR "ICV: Failed to download ICV package: ${OPENCV_ICV_PACKAGE_NAME}. Status=${__status}")
|
||||
else()
|
||||
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step
|
||||
# on wrong hash
|
||||
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
|
||||
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
|
||||
message(FATAL_ERROR "ICV: Downloaded copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
ocv_assert(NOT EXISTS "${OPENCV_ICV_UNPACK_PATH}")
|
||||
file(MAKE_DIRECTORY ${OPENCV_ICV_UNPACK_PATH})
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_UNPACK_PATH}")
|
||||
|
||||
message(STATUS "ICV: Unpacking ${OPENCV_ICV_PACKAGE_NAME} to ${OPENCV_ICV_UNPACK_PATH}...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${OPENCV_ICV_PACKAGE_ARCHIVE}"
|
||||
WORKING_DIRECTORY "${OPENCV_ICV_UNPACK_PATH}"
|
||||
RESULT_VARIABLE __result)
|
||||
|
||||
if(NOT __result EQUAL 0)
|
||||
message(FATAL_ERROR "ICV: Failed to unpack ICV package from ${OPENCV_ICV_PACKAGE_ARCHIVE} to ${OPENCV_ICV_UNPACK_PATH} with error ${__result}")
|
||||
endif()
|
||||
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_PATH}")
|
||||
|
||||
set(OPENCV_ICV_PACKAGE_DOWNLOADED "${OPENCV_ICV_PACKAGE_HASH}" CACHE INTERNAL "ICV package hash")
|
||||
|
||||
message(STATUS "ICV: Package successfully downloaded")
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
_icv_downloader()
|
||||
+2
-2
@@ -9,7 +9,7 @@
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
import re
|
||||
from _compat import text_type, string_types, int_types, \
|
||||
from ._compat import text_type, string_types, int_types, \
|
||||
unichr, PY2
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class _MarkupEscapeHelper(object):
|
||||
try:
|
||||
from _speedups import escape, escape_silent, soft_unicode
|
||||
except ImportError:
|
||||
from _native import escape, escape_silent, soft_unicode
|
||||
from ._native import escape, escape_silent, soft_unicode
|
||||
|
||||
if not PY2:
|
||||
soft_str = soft_unicode
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
:copyright: (c) 2010 by Armin Ronacher.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
from _compat import text_type
|
||||
from ._compat import text_type
|
||||
|
||||
|
||||
def escape(s):
|
||||
|
||||
Vendored
+1
-1
@@ -517,4 +517,4 @@ class Joiner(object):
|
||||
|
||||
|
||||
# Imported here because that's where it was in the past
|
||||
from markupsafe import Markup, escape, soft_unicode
|
||||
from .markupsafe import Markup, escape, soft_unicode
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
+1
-1
@@ -9,7 +9,7 @@ ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
file(GLOB lib_srcs *.c)
|
||||
file(GLOB lib_hdrs *.h)
|
||||
|
||||
if(ANDROID OR IOS)
|
||||
if(ANDROID OR IOS OR APPLE)
|
||||
ocv_list_filterout(lib_srcs jmemansi.c)
|
||||
else()
|
||||
ocv_list_filterout(lib_srcs jmemnobs.c)
|
||||
|
||||
+2
-10
@@ -54,7 +54,7 @@
|
||||
|
||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||
(Intel) */
|
||||
#define HOST_BIGENDIAN 0
|
||||
#define HOST_BIGENDIAN @WORDS_BIGENDIAN@
|
||||
|
||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
||||
@@ -156,15 +156,7 @@
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
#cmakedefine WORDS_BIGENDIAN 1
|
||||
|
||||
/* Support Deflate compression */
|
||||
#define ZIP_SUPPORT 1
|
||||
|
||||
Vendored
+5
-5
@@ -1,5 +1,5 @@
|
||||
This folder contains libraries and headers of a few very popular still image codecs
|
||||
used by highgui module.
|
||||
used by imgcodecs module.
|
||||
The libraries and headers are preferably to build Win32 and Win64 versions of OpenCV.
|
||||
On UNIX systems all the libraries are automatically detected by configure script.
|
||||
In order to use these versions of libraries instead of system ones on UNIX systems you
|
||||
@@ -11,7 +11,7 @@ libjpeg 8d (8.4) - The Independent JPEG Group's JPEG software.
|
||||
See IGJ home page http://www.ijg.org
|
||||
for details and links to the source code
|
||||
|
||||
HAVE_JPEG preprocessor flag must be set to make highgui use libjpeg.
|
||||
HAVE_JPEG preprocessor flag must be set to make imgcodecs use libjpeg.
|
||||
On UNIX systems configure script takes care of it.
|
||||
------------------------------------------------------------------------------------
|
||||
libpng 1.5.12 - Portable Network Graphics library.
|
||||
@@ -19,7 +19,7 @@ libpng 1.5.12 - Portable Network Graphics library.
|
||||
See libpng home page http://www.libpng.org
|
||||
for details and links to the source code
|
||||
|
||||
HAVE_PNG preprocessor flag must be set to make highgui use libpng.
|
||||
HAVE_PNG preprocessor flag must be set to make imgcodecs use libpng.
|
||||
On UNIX systems configure script takes care of it.
|
||||
------------------------------------------------------------------------------------
|
||||
libtiff 4.0.2 - Tag Image File Format (TIFF) Software
|
||||
@@ -28,7 +28,7 @@ libtiff 4.0.2 - Tag Image File Format (TIFF) Software
|
||||
See libtiff home page http://www.remotesensing.org/libtiff/
|
||||
for details and links to the source code
|
||||
|
||||
HAVE_TIFF preprocessor flag must be set to make highgui use libtiff.
|
||||
HAVE_TIFF preprocessor flag must be set to make imgcodecs use libtiff.
|
||||
On UNIX systems configure script takes care of it.
|
||||
In this build support for ZIP (LZ77 compression) is turned on.
|
||||
------------------------------------------------------------------------------------
|
||||
@@ -37,7 +37,7 @@ zlib 1.2.7 - General purpose LZ77 compression library
|
||||
See zlib home page http://www.zlib.net
|
||||
for details and links to the source code
|
||||
|
||||
No preprocessor definition is needed to make highgui use this library -
|
||||
No preprocessor definition is needed to make imgcodecs use this library -
|
||||
it is included automatically if either libpng or libtiff are used.
|
||||
------------------------------------------------------------------------------------
|
||||
jasper-1.900.1 - JasPer is a collection of software
|
||||
|
||||
+132
-32
@@ -6,6 +6,8 @@
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
include(cmake/OpenCVMinDepVersions.cmake)
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
|
||||
@@ -127,13 +129,15 @@ OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF )
|
||||
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
|
||||
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_IPP "Include Intel IPP support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_JPEG "Include JPEG support" ON)
|
||||
OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) )
|
||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID) )
|
||||
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_PNG "Include PNG support" ON)
|
||||
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
@@ -147,8 +151,8 @@ OCV_OPTION(WITH_TIFF "Include TIFF support" ON
|
||||
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_DSHOW "Build HighGUI with DirectShow support" ON IF (WIN32 AND NOT ARM) )
|
||||
OCV_OPTION(WITH_MSMF "Build HighGUI with Media Foundation support" OFF IF WIN32 )
|
||||
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM) )
|
||||
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" OFF IF WIN32 )
|
||||
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT APPLE) )
|
||||
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF)
|
||||
@@ -157,7 +161,8 @@ OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON
|
||||
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON IF WIN32 )
|
||||
OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF WIN32 )
|
||||
|
||||
OCV_OPTION(WITH_IPP_A "Include Intel IPP_A support" OFF IF (MSVC OR X86 OR X86_64) )
|
||||
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
@@ -174,6 +179,7 @@ OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for sta
|
||||
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
|
||||
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
|
||||
OCV_OPTION(BUILD_CUDA_STUBS "Build CUDA modules stubs when no CUDA SDK" OFF IF (NOT IOS) )
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE )
|
||||
@@ -198,6 +204,7 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
@@ -214,6 +221,7 @@ OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too no
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
|
||||
OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 )
|
||||
OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID )
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -253,13 +261,24 @@ if(WIN32)
|
||||
message(STATUS "Can't detect runtime and/or arch")
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
elseif(ANDROID)
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "sdk/native/")
|
||||
else()
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
|
||||
if(ANDROID)
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
endif()
|
||||
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
if(NOT OPENCV_TEST_INSTALL_PATH)
|
||||
set(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
endif()
|
||||
@@ -319,6 +338,9 @@ if(DEFINED CMAKE_DEBUG_POSTFIX)
|
||||
set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
|
||||
endif()
|
||||
|
||||
if(INSTALL_CREATE_DISTRIB AND BUILD_SHARED_LIBS AND NOT DEFINED BUILD_opencv_world)
|
||||
set(BUILD_opencv_world ON CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Path for build/platform -specific headers
|
||||
@@ -404,6 +426,19 @@ endif()
|
||||
include(cmake/OpenCVPCHSupport.cmake)
|
||||
include(cmake/OpenCVModule.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect endianness of build platform
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
# test_big_endian needs try_compile, which doesn't work for iOS
|
||||
# http://public.kitware.com/Bug/view.php?id=12288
|
||||
set(WORDS_BIGENDIAN 0)
|
||||
else()
|
||||
include(TestBigEndian)
|
||||
test_big_endian(WORDS_BIGENDIAN)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect 3rd-party libraries
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -413,7 +448,6 @@ include(cmake/OpenCVFindLibsGUI.cmake)
|
||||
include(cmake/OpenCVFindLibsVideo.cmake)
|
||||
include(cmake/OpenCVFindLibsPerf.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect other 3rd-party libraries/tools
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -524,7 +558,6 @@ endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# Finalization: generate configuration-based files
|
||||
# ----------------------------------------------------------------------------
|
||||
ocv_track_build_dependencies()
|
||||
|
||||
# Generate platform-dependent and configuration-dependent headers
|
||||
include(cmake/OpenCVGenHeaders.cmake)
|
||||
@@ -542,16 +575,46 @@ include(cmake/OpenCVGenConfig.cmake)
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
|
||||
# Generate environment setup file
|
||||
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX AND NOT ANDROID)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_testing.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh"
|
||||
DESTINATION /etc/profile.d/ COMPONENT tests)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
if(ANDROID)
|
||||
get_filename_component(TEST_PATH ${OPENCV_TEST_INSTALL_PATH} DIRECTORY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests_android.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT tests)
|
||||
else()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_testing.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh"
|
||||
DESTINATION /etc/profile.d/ COMPONENT tests)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests_unix.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_README_FILE)
|
||||
if(ANDROID)
|
||||
set(OPENCV_README_FILE ${CMAKE_CURRENT_SOURCE_DIR}/platforms/android/README.android)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_LICENSE_FILE)
|
||||
set(OPENCV_LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
|
||||
endif()
|
||||
|
||||
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
|
||||
if(ANDROID OR NOT UNIX)
|
||||
install(FILES ${OPENCV_LICENSE_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
if(OPENCV_README_FILE)
|
||||
install(FILES ${OPENCV_README_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -693,8 +756,14 @@ else()
|
||||
status(" Cocoa:" YES)
|
||||
endif()
|
||||
else()
|
||||
status(" GTK+ 2.x:" HAVE_GTK THEN "YES (ver ${ALIASOF_gtk+-2.0_VERSION})" ELSE NO)
|
||||
status(" GThread :" HAVE_GTHREAD THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})" ELSE NO)
|
||||
if(HAVE_GTK3)
|
||||
status(" GTK+ 3.x:" HAVE_GTK THEN "YES (ver ${ALIASOF_gtk+-3.0_VERSION})" ELSE NO)
|
||||
elseif(HAVE_GTK)
|
||||
status(" GTK+ 2.x:" HAVE_GTK THEN "YES (ver ${ALIASOF_gtk+-2.0_VERSION})" ELSE NO)
|
||||
else()
|
||||
status(" GTK+:" NO)
|
||||
endif()
|
||||
status(" GThread :" HAVE_GTHREAD THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})" ELSE NO)
|
||||
status(" GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${ALIASOF_gtkglext-1.0_VERSION})" ELSE NO)
|
||||
endif()
|
||||
endif()
|
||||
@@ -745,6 +814,12 @@ else()
|
||||
status(" OpenEXR:" "NO")
|
||||
endif()
|
||||
|
||||
if( WITH_GDAL )
|
||||
status(" GDAL:" GDAL_FOUND THEN "${GDAL_LIBRARY}")
|
||||
else()
|
||||
status(" GDAL:" "NO")
|
||||
endif()
|
||||
|
||||
# ========================== VIDEO IO ==========================
|
||||
status("")
|
||||
status(" Video I/O:")
|
||||
@@ -802,6 +877,11 @@ if(DEFINED WITH_OPENNI)
|
||||
THEN "YES (${OPENNI_PRIME_SENSOR_MODULE})" ELSE NO)
|
||||
endif(DEFINED WITH_OPENNI)
|
||||
|
||||
if(DEFINED WITH_OPENNI2)
|
||||
status(" OpenNI2:" HAVE_OPENNI2 THEN "YES (ver ${OPENNI2_VERSION_STRING}, build ${OPENNI2_VERSION_BUILD})"
|
||||
ELSE NO)
|
||||
endif(DEFINED WITH_OPENNI2)
|
||||
|
||||
if(DEFINED WITH_PVAPI)
|
||||
status(" PvAPI:" HAVE_PVAPI THEN YES ELSE NO)
|
||||
endif(DEFINED WITH_PVAPI)
|
||||
@@ -862,13 +942,17 @@ endif(DEFINED WITH_INTELPERC)
|
||||
status("")
|
||||
status(" Other third-party libraries:")
|
||||
|
||||
if(WITH_IPP AND IPP_FOUND)
|
||||
status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
|
||||
if(WITH_IPP AND HAVE_IPP)
|
||||
status(" Use IPP:" "${IPP_VERSION_STR} [${IPP_VERSION_MAJOR}.${IPP_VERSION_MINOR}.${IPP_VERSION_BUILD}]")
|
||||
status(" at:" "${IPP_ROOT_DIR}")
|
||||
else()
|
||||
status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
|
||||
status(" Use IPP:" WITH_IPP AND NOT HAVE_IPP THEN "IPP not found" ELSE NO)
|
||||
endif()
|
||||
|
||||
if(DEFINED WITH_IPP_A)
|
||||
status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
|
||||
endif(DEFINED WITH_IPP_A)
|
||||
|
||||
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
|
||||
status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
|
||||
status(" Use OpenMP:" HAVE_OPENMP THEN YES ELSE NO)
|
||||
@@ -924,18 +1008,34 @@ endif()
|
||||
|
||||
# ========================== python ==========================
|
||||
status("")
|
||||
status(" Python:")
|
||||
status(" Interpreter:" PYTHONINTERP_FOUND THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_STRING})" ELSE NO)
|
||||
if(BUILD_opencv_python)
|
||||
if(PYTHONLIBS_VERSION_STRING)
|
||||
status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO)
|
||||
status(" Python 2:")
|
||||
status(" Interpreter:" PYTHON2INTERP_FOUND THEN "${PYTHON2_EXECUTABLE} (ver ${PYTHON2_VERSION_STRING})" ELSE NO)
|
||||
if(BUILD_opencv_python2)
|
||||
if(PYTHON2LIBS_VERSION_STRING)
|
||||
status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES} (ver ${PYTHON2LIBS_VERSION_STRING})" ELSE NO)
|
||||
else()
|
||||
status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES}" ELSE NO)
|
||||
status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES}" ELSE NO)
|
||||
endif()
|
||||
status(" numpy:" PYTHON_NUMPY_INCLUDE_DIRS THEN "${PYTHON_NUMPY_INCLUDE_DIRS} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
|
||||
status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-")
|
||||
status(" numpy:" PYTHON2_NUMPY_INCLUDE_DIRS THEN "${PYTHON2_NUMPY_INCLUDE_DIRS} (ver ${PYTHON2_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
|
||||
status(" packages path:" PYTHON2_EXECUTABLE THEN "${PYTHON2_PACKAGES_PATH}" ELSE "-")
|
||||
endif()
|
||||
|
||||
status("")
|
||||
status(" Python 3:")
|
||||
status(" Interpreter:" PYTHON3INTERP_FOUND THEN "${PYTHON3_EXECUTABLE} (ver ${PYTHON3_VERSION_STRING})" ELSE NO)
|
||||
if(BUILD_opencv_python3)
|
||||
if(PYTHON3LIBS_VERSION_STRING)
|
||||
status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES} (ver ${PYTHON3LIBS_VERSION_STRING})" ELSE NO)
|
||||
else()
|
||||
status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES}" ELSE NO)
|
||||
endif()
|
||||
status(" numpy:" PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
|
||||
status(" packages path:" PYTHON3_EXECUTABLE THEN "${PYTHON3_PACKAGES_PATH}" ELSE "-")
|
||||
endif()
|
||||
|
||||
status("")
|
||||
status(" Python (for build):" PYTHON_DEFAULT_AVAILABLE THEN "${PYTHON_DEFAULT_EXECUTABLE}" ELSE NO)
|
||||
|
||||
# ========================== java ==========================
|
||||
status("")
|
||||
status(" Java:")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
### OpenCV: Open Source Computer Vision Library
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
|
||||
#### Resources
|
||||
|
||||
* Homepage: <http://opencv.org>
|
||||
@@ -18,6 +20,3 @@ Summary of guidelines:
|
||||
* Include tests and documentation;
|
||||
* Clean up "oops" commits before submitting;
|
||||
* Follow the coding style guide.
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org)
|
||||
@@ -1,6 +1,4 @@
|
||||
add_definitions(-D__OPENCV_BUILD=1)
|
||||
link_libraries(${OPENCV_LINKER_LIBS})
|
||||
|
||||
add_subdirectory(haartraining)
|
||||
add_subdirectory(traincascade)
|
||||
add_subdirectory(sft)
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
SET(OPENCV_HAARTRAINING_DEPS opencv_core opencv_imgproc opencv_photo opencv_ml opencv_highgui opencv_objdetect opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
|
||||
ocv_check_dependencies(${OPENCV_HAARTRAINING_DEPS})
|
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(haartraining)
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
|
||||
ocv_include_modules(${OPENCV_HAARTRAINING_DEPS})
|
||||
|
||||
if(WIN32)
|
||||
link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
link_libraries(${OPENCV_HAARTRAINING_DEPS} opencv_haartraining_engine)
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Library
|
||||
# -----------------------------------------------------------
|
||||
set(cvhaartraining_lib_src
|
||||
_cvcommon.h
|
||||
cvclassifier.h
|
||||
_cvhaartraining.h
|
||||
cvhaartraining.h
|
||||
cvboost.cpp
|
||||
cvcommon.cpp
|
||||
cvhaarclassifier.cpp
|
||||
cvhaartraining.cpp
|
||||
cvsamples.cpp
|
||||
)
|
||||
|
||||
add_library(opencv_haartraining_engine STATIC ${cvhaartraining_lib_src})
|
||||
set_target_properties(opencv_haartraining_engine PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||
INSTALL_NAME_DIR lib
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# haartraining
|
||||
# -----------------------------------------------------------
|
||||
|
||||
add_executable(opencv_haartraining cvhaartraining.h haartraining.cpp)
|
||||
set_target_properties(opencv_haartraining PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
OUTPUT_NAME "opencv_haartraining")
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# createsamples
|
||||
# -----------------------------------------------------------
|
||||
|
||||
add_executable(opencv_createsamples cvhaartraining.h createsamples.cpp)
|
||||
set_target_properties(opencv_createsamples PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
OUTPUT_NAME "opencv_createsamples")
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# performance
|
||||
# -----------------------------------------------------------
|
||||
add_executable(opencv_performance performance.cpp)
|
||||
set_target_properties(opencv_performance PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
OUTPUT_NAME "opencv_performance")
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Install part
|
||||
# -----------------------------------------------------------
|
||||
|
||||
if(INSTALL_CREATE_DISTRIB)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
|
||||
install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
|
||||
install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
|
||||
endif()
|
||||
else()
|
||||
install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
|
||||
install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
|
||||
install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(opencv_performance PROPERTIES FOLDER "applications")
|
||||
set_target_properties(opencv_createsamples PROPERTIES FOLDER "applications")
|
||||
set_target_properties(opencv_haartraining PROPERTIES FOLDER "applications")
|
||||
set_target_properties(opencv_haartraining_engine PROPERTIES FOLDER "applications")
|
||||
endif()
|
||||
@@ -1,92 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __CVCOMMON_H_
|
||||
#define __CVCOMMON_H_
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#include "cxcore.h"
|
||||
#include "cv.h"
|
||||
#include "cxmisc.h"
|
||||
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
#define __END__ __CV_END__
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 512
|
||||
#endif /* PATH_MAX */
|
||||
|
||||
int icvMkDir( const char* filename );
|
||||
|
||||
/* returns index at specified position from index matrix of any type.
|
||||
if matrix is NULL, then specified position is returned */
|
||||
CV_INLINE
|
||||
int icvGetIdxAt( CvMat* idx, int pos );
|
||||
|
||||
CV_INLINE
|
||||
int icvGetIdxAt( CvMat* idx, int pos )
|
||||
{
|
||||
if( idx == NULL )
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
CvScalar sc;
|
||||
int type;
|
||||
|
||||
type = CV_MAT_TYPE( idx->type );
|
||||
cvRawDataToScalar( idx->data.ptr + pos *
|
||||
( (idx->rows == 1) ? CV_ELEM_SIZE( type ) : idx->step ), type, &sc );
|
||||
|
||||
return (int) sc.val[0];
|
||||
}
|
||||
}
|
||||
|
||||
/* debug functions */
|
||||
|
||||
#define CV_DEBUG_SAVE( ptr ) icvSave( ptr, __FILE__, __LINE__ );
|
||||
|
||||
void icvSave( const CvArr* ptr, const char* filename, int line );
|
||||
|
||||
#endif /* __CVCOMMON_H_ */
|
||||
@@ -1,414 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* _cvhaartraining.h
|
||||
*
|
||||
* training of cascade of boosted classifiers based on haar features
|
||||
*/
|
||||
|
||||
#ifndef __CVHAARTRAINING_H_
|
||||
#define __CVHAARTRAINING_H_
|
||||
|
||||
#include "_cvcommon.h"
|
||||
#include "cvclassifier.h"
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
/* parameters for tree cascade classifier training */
|
||||
|
||||
/* max number of clusters */
|
||||
#define CV_MAX_CLUSTERS 3
|
||||
|
||||
/* term criteria for K-Means */
|
||||
#define CV_TERM_CRITERIA() cvTermCriteria( CV_TERMCRIT_EPS, 1000, 1E-5 )
|
||||
|
||||
/* print statistic info */
|
||||
#define CV_VERBOSE 1
|
||||
|
||||
#define CV_STAGE_CART_FILE_NAME "AdaBoostCARTHaarClassifier.txt"
|
||||
|
||||
#define CV_HAAR_FEATURE_MAX 3
|
||||
#define CV_HAAR_FEATURE_DESC_MAX 20
|
||||
|
||||
typedef int sum_type;
|
||||
typedef double sqsum_type;
|
||||
typedef short idx_type;
|
||||
|
||||
#define CV_SUM_MAT_TYPE CV_32SC1
|
||||
#define CV_SQSUM_MAT_TYPE CV_64FC1
|
||||
#define CV_IDX_MAT_TYPE CV_16SC1
|
||||
|
||||
#define CV_STUMP_TRAIN_PORTION 100
|
||||
|
||||
#define CV_THRESHOLD_EPS (0.00001F)
|
||||
|
||||
typedef struct CvTHaarFeature
|
||||
{
|
||||
char desc[CV_HAAR_FEATURE_DESC_MAX];
|
||||
int tilted;
|
||||
struct
|
||||
{
|
||||
CvRect r;
|
||||
float weight;
|
||||
} rect[CV_HAAR_FEATURE_MAX];
|
||||
} CvTHaarFeature;
|
||||
|
||||
typedef struct CvFastHaarFeature
|
||||
{
|
||||
int tilted;
|
||||
struct
|
||||
{
|
||||
int p0, p1, p2, p3;
|
||||
float weight;
|
||||
} rect[CV_HAAR_FEATURE_MAX];
|
||||
} CvFastHaarFeature;
|
||||
|
||||
typedef struct CvIntHaarFeatures
|
||||
{
|
||||
CvSize winsize;
|
||||
int count;
|
||||
CvTHaarFeature* feature;
|
||||
CvFastHaarFeature* fastfeature;
|
||||
} CvIntHaarFeatures;
|
||||
|
||||
CV_INLINE CvTHaarFeature cvHaarFeature( const char* desc,
|
||||
int x0, int y0, int w0, int h0, float wt0,
|
||||
int x1, int y1, int w1, int h1, float wt1,
|
||||
int x2 CV_DEFAULT( 0 ), int y2 CV_DEFAULT( 0 ),
|
||||
int w2 CV_DEFAULT( 0 ), int h2 CV_DEFAULT( 0 ),
|
||||
float wt2 CV_DEFAULT( 0.0F ) );
|
||||
|
||||
CV_INLINE CvTHaarFeature cvHaarFeature( const char* desc,
|
||||
int x0, int y0, int w0, int h0, float wt0,
|
||||
int x1, int y1, int w1, int h1, float wt1,
|
||||
int x2, int y2, int w2, int h2, float wt2 )
|
||||
{
|
||||
CvTHaarFeature hf;
|
||||
|
||||
assert( CV_HAAR_FEATURE_MAX >= 3 );
|
||||
assert( strlen( desc ) < CV_HAAR_FEATURE_DESC_MAX );
|
||||
|
||||
strcpy( &(hf.desc[0]), desc );
|
||||
hf.tilted = ( hf.desc[0] == 't' );
|
||||
|
||||
hf.rect[0].r.x = x0;
|
||||
hf.rect[0].r.y = y0;
|
||||
hf.rect[0].r.width = w0;
|
||||
hf.rect[0].r.height = h0;
|
||||
hf.rect[0].weight = wt0;
|
||||
|
||||
hf.rect[1].r.x = x1;
|
||||
hf.rect[1].r.y = y1;
|
||||
hf.rect[1].r.width = w1;
|
||||
hf.rect[1].r.height = h1;
|
||||
hf.rect[1].weight = wt1;
|
||||
|
||||
hf.rect[2].r.x = x2;
|
||||
hf.rect[2].r.y = y2;
|
||||
hf.rect[2].r.width = w2;
|
||||
hf.rect[2].r.height = h2;
|
||||
hf.rect[2].weight = wt2;
|
||||
|
||||
return hf;
|
||||
}
|
||||
|
||||
/* Prepared for training samples */
|
||||
typedef struct CvHaarTrainingData
|
||||
{
|
||||
CvSize winsize; /* training image size */
|
||||
int maxnum; /* maximum number of samples */
|
||||
CvMat sum; /* sum images (each row represents image) */
|
||||
CvMat tilted; /* tilted sum images (each row represents image) */
|
||||
CvMat normfactor; /* normalization factor */
|
||||
CvMat cls; /* classes. 1.0 - object, 0.0 - background */
|
||||
CvMat weights; /* weights */
|
||||
|
||||
CvMat* valcache; /* precalculated feature values (CV_32FC1) */
|
||||
CvMat* idxcache; /* presorted indices (CV_IDX_MAT_TYPE) */
|
||||
} CvHaarTrainigData;
|
||||
|
||||
|
||||
/* Passed to callback functions */
|
||||
typedef struct CvUserdata
|
||||
{
|
||||
CvHaarTrainingData* trainingData;
|
||||
CvIntHaarFeatures* haarFeatures;
|
||||
} CvUserdata;
|
||||
|
||||
CV_INLINE
|
||||
CvUserdata cvUserdata( CvHaarTrainingData* trainingData,
|
||||
CvIntHaarFeatures* haarFeatures );
|
||||
|
||||
CV_INLINE
|
||||
CvUserdata cvUserdata( CvHaarTrainingData* trainingData,
|
||||
CvIntHaarFeatures* haarFeatures )
|
||||
{
|
||||
CvUserdata userdata;
|
||||
|
||||
userdata.trainingData = trainingData;
|
||||
userdata.haarFeatures = haarFeatures;
|
||||
|
||||
return userdata;
|
||||
}
|
||||
|
||||
|
||||
#define CV_INT_HAAR_CLASSIFIER_FIELDS() \
|
||||
float (*eval)( CvIntHaarClassifier*, sum_type*, sum_type*, float ); \
|
||||
void (*save)( CvIntHaarClassifier*, FILE* file ); \
|
||||
void (*release)( CvIntHaarClassifier** );
|
||||
|
||||
/* internal weak classifier*/
|
||||
typedef struct CvIntHaarClassifier
|
||||
{
|
||||
CV_INT_HAAR_CLASSIFIER_FIELDS()
|
||||
} CvIntHaarClassifier;
|
||||
|
||||
/*
|
||||
* CART classifier
|
||||
*/
|
||||
typedef struct CvCARTHaarClassifier
|
||||
{
|
||||
CV_INT_HAAR_CLASSIFIER_FIELDS()
|
||||
|
||||
int count;
|
||||
int* compidx;
|
||||
CvTHaarFeature* feature;
|
||||
CvFastHaarFeature* fastfeature;
|
||||
float* threshold;
|
||||
int* left;
|
||||
int* right;
|
||||
float* val;
|
||||
} CvCARTHaarClassifier;
|
||||
|
||||
/* internal stage classifier */
|
||||
typedef struct CvStageHaarClassifier
|
||||
{
|
||||
CV_INT_HAAR_CLASSIFIER_FIELDS()
|
||||
|
||||
int count;
|
||||
float threshold;
|
||||
CvIntHaarClassifier** classifier;
|
||||
} CvStageHaarClassifier;
|
||||
|
||||
/* internal cascade classifier */
|
||||
typedef struct CvCascadeHaarClassifier
|
||||
{
|
||||
CV_INT_HAAR_CLASSIFIER_FIELDS()
|
||||
|
||||
int count;
|
||||
CvIntHaarClassifier** classifier;
|
||||
} CvCascadeHaarClassifier;
|
||||
|
||||
|
||||
/* internal tree cascade classifier node */
|
||||
typedef struct CvTreeCascadeNode
|
||||
{
|
||||
CvStageHaarClassifier* stage;
|
||||
|
||||
struct CvTreeCascadeNode* next;
|
||||
struct CvTreeCascadeNode* child;
|
||||
struct CvTreeCascadeNode* parent;
|
||||
|
||||
struct CvTreeCascadeNode* next_same_level;
|
||||
struct CvTreeCascadeNode* child_eval;
|
||||
int idx;
|
||||
int leaf;
|
||||
} CvTreeCascadeNode;
|
||||
|
||||
/* internal tree cascade classifier */
|
||||
typedef struct CvTreeCascadeClassifier
|
||||
{
|
||||
CV_INT_HAAR_CLASSIFIER_FIELDS()
|
||||
|
||||
CvTreeCascadeNode* root; /* root of the tree */
|
||||
CvTreeCascadeNode* root_eval; /* root node for the filtering */
|
||||
|
||||
int next_idx;
|
||||
} CvTreeCascadeClassifier;
|
||||
|
||||
|
||||
CV_INLINE float cvEvalFastHaarFeature( const CvFastHaarFeature* feature,
|
||||
const sum_type* sum, const sum_type* tilted )
|
||||
{
|
||||
const sum_type* img = feature->tilted ? tilted : sum;
|
||||
float ret = feature->rect[0].weight*
|
||||
(img[feature->rect[0].p0] - img[feature->rect[0].p1] -
|
||||
img[feature->rect[0].p2] + img[feature->rect[0].p3]) +
|
||||
feature->rect[1].weight*
|
||||
(img[feature->rect[1].p0] - img[feature->rect[1].p1] -
|
||||
img[feature->rect[1].p2] + img[feature->rect[1].p3]);
|
||||
|
||||
if( feature->rect[2].weight != 0.0f )
|
||||
ret += feature->rect[2].weight *
|
||||
( img[feature->rect[2].p0] - img[feature->rect[2].p1] -
|
||||
img[feature->rect[2].p2] + img[feature->rect[2].p3] );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct CvSampleDistortionData
|
||||
{
|
||||
IplImage* src;
|
||||
IplImage* erode;
|
||||
IplImage* dilate;
|
||||
IplImage* mask;
|
||||
IplImage* img;
|
||||
IplImage* maskimg;
|
||||
int dx;
|
||||
int dy;
|
||||
int bgcolor;
|
||||
} CvSampleDistortionData;
|
||||
|
||||
/*
|
||||
* icvConvertToFastHaarFeature
|
||||
*
|
||||
* Convert to fast representation of haar features
|
||||
*
|
||||
* haarFeature - input array
|
||||
* fastHaarFeature - output array
|
||||
* size - size of arrays
|
||||
* step - row step for the integral image
|
||||
*/
|
||||
void icvConvertToFastHaarFeature( CvTHaarFeature* haarFeature,
|
||||
CvFastHaarFeature* fastHaarFeature,
|
||||
int size, int step );
|
||||
|
||||
|
||||
void icvWriteVecHeader( FILE* file, int count, int width, int height );
|
||||
void icvWriteVecSample( FILE* file, CvArr* sample );
|
||||
void icvPlaceDistortedSample( CvArr* background,
|
||||
int inverse, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int inscribe, double maxshiftf, double maxscalef,
|
||||
CvSampleDistortionData* data );
|
||||
void icvEndSampleDistortion( CvSampleDistortionData* data );
|
||||
|
||||
int icvStartSampleDistortion( const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
CvSampleDistortionData* data );
|
||||
|
||||
typedef int (*CvGetHaarTrainingDataCallback)( CvMat* img, void* userdata );
|
||||
|
||||
typedef struct CvVecFile
|
||||
{
|
||||
FILE* input;
|
||||
int count;
|
||||
int vecsize;
|
||||
int last;
|
||||
short* vector;
|
||||
} CvVecFile;
|
||||
|
||||
int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata );
|
||||
|
||||
/*
|
||||
* icvGetHaarTrainingDataFromVec
|
||||
*
|
||||
* Fill <data> with samples from .vec file, passed <cascade>
|
||||
int icvGetHaarTrainingDataFromVec( CvHaarTrainingData* data, int first, int count,
|
||||
CvIntHaarClassifier* cascade,
|
||||
const char* filename,
|
||||
int* consumed );
|
||||
*/
|
||||
|
||||
CvIntHaarClassifier* icvCreateCARTHaarClassifier( int count );
|
||||
|
||||
void icvReleaseHaarClassifier( CvIntHaarClassifier** classifier );
|
||||
|
||||
void icvInitCARTHaarClassifier( CvCARTHaarClassifier* carthaar, CvCARTClassifier* cart,
|
||||
CvIntHaarFeatures* intHaarFeatures );
|
||||
|
||||
float icvEvalCARTHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor );
|
||||
|
||||
CvIntHaarClassifier* icvCreateStageHaarClassifier( int count, float threshold );
|
||||
|
||||
void icvReleaseStageHaarClassifier( CvIntHaarClassifier** classifier );
|
||||
|
||||
float icvEvalStageHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor );
|
||||
|
||||
CvIntHaarClassifier* icvCreateCascadeHaarClassifier( int count );
|
||||
|
||||
void icvReleaseCascadeHaarClassifier( CvIntHaarClassifier** classifier );
|
||||
|
||||
float icvEvalCascadeHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor );
|
||||
|
||||
void icvSaveHaarFeature( CvTHaarFeature* feature, FILE* file );
|
||||
|
||||
void icvLoadHaarFeature( CvTHaarFeature* feature, FILE* file );
|
||||
|
||||
void icvSaveCARTHaarClassifier( CvIntHaarClassifier* classifier, FILE* file );
|
||||
|
||||
CvIntHaarClassifier* icvLoadCARTHaarClassifier( FILE* file, int step );
|
||||
|
||||
void icvSaveStageHaarClassifier( CvIntHaarClassifier* classifier, FILE* file );
|
||||
|
||||
CvIntHaarClassifier* icvLoadCARTStageHaarClassifier( const char* filename, int step );
|
||||
|
||||
|
||||
/* tree cascade classifier */
|
||||
|
||||
float icvEvalTreeCascadeClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor );
|
||||
|
||||
void icvSetLeafNode( CvTreeCascadeClassifier* tree, CvTreeCascadeNode* leaf );
|
||||
|
||||
float icvEvalTreeCascadeClassifierFilter( CvIntHaarClassifier* classifier, sum_type* sum,
|
||||
sum_type* tilted, float normfactor );
|
||||
|
||||
CvTreeCascadeNode* icvCreateTreeCascadeNode();
|
||||
|
||||
void icvReleaseTreeCascadeNodes( CvTreeCascadeNode** node );
|
||||
|
||||
void icvReleaseTreeCascadeClassifier( CvIntHaarClassifier** classifier );
|
||||
|
||||
/* Prints out current tree structure to <stdout> */
|
||||
void icvPrintTreeCascade( CvTreeCascadeNode* root );
|
||||
|
||||
/* Loads tree cascade classifier */
|
||||
CvIntHaarClassifier* icvLoadTreeCascadeClassifier( const char* filename, int step,
|
||||
int* splits );
|
||||
|
||||
/* Finds leaves belonging to maximal level and connects them via leaf->next_same_level */
|
||||
CvTreeCascadeNode* icvFindDeepestLeaves( CvTreeCascadeClassifier* tree );
|
||||
|
||||
#endif /* __CVHAARTRAINING_H_ */
|
||||
@@ -1,245 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* createsamples.cpp
|
||||
*
|
||||
* Create test/training samples
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "cvhaartraining.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
int i = 0;
|
||||
char* nullname = (char*)"(NULL)";
|
||||
char* vecname = NULL; /* .vec file name */
|
||||
char* infoname = NULL; /* file name with marked up image descriptions */
|
||||
char* imagename = NULL; /* single sample image */
|
||||
char* bgfilename = NULL; /* background */
|
||||
int num = 1000;
|
||||
int bgcolor = 0;
|
||||
int bgthreshold = 80;
|
||||
int invert = 0;
|
||||
int maxintensitydev = 40;
|
||||
double maxxangle = 1.1;
|
||||
double maxyangle = 1.1;
|
||||
double maxzangle = 0.5;
|
||||
int showsamples = 0;
|
||||
/* the samples are adjusted to this scale in the sample preview window */
|
||||
double scale = 4.0;
|
||||
int width = 24;
|
||||
int height = 24;
|
||||
|
||||
srand((unsigned int)time(0));
|
||||
|
||||
if( argc == 1 )
|
||||
{
|
||||
printf( "Usage: %s\n [-info <collection_file_name>]\n"
|
||||
" [-img <image_file_name>]\n"
|
||||
" [-vec <vec_file_name>]\n"
|
||||
" [-bg <background_file_name>]\n [-num <number_of_samples = %d>]\n"
|
||||
" [-bgcolor <background_color = %d>]\n"
|
||||
" [-inv] [-randinv] [-bgthresh <background_color_threshold = %d>]\n"
|
||||
" [-maxidev <max_intensity_deviation = %d>]\n"
|
||||
" [-maxxangle <max_x_rotation_angle = %f>]\n"
|
||||
" [-maxyangle <max_y_rotation_angle = %f>]\n"
|
||||
" [-maxzangle <max_z_rotation_angle = %f>]\n"
|
||||
" [-show [<scale = %f>]]\n"
|
||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n",
|
||||
argv[0], num, bgcolor, bgthreshold, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, scale, width, height );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for( i = 1; i < argc; ++i )
|
||||
{
|
||||
if( !strcmp( argv[i], "-info" ) )
|
||||
{
|
||||
infoname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-img" ) )
|
||||
{
|
||||
imagename = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-vec" ) )
|
||||
{
|
||||
vecname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bg" ) )
|
||||
{
|
||||
bgfilename = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-num" ) )
|
||||
{
|
||||
num = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bgcolor" ) )
|
||||
{
|
||||
bgcolor = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bgthresh" ) )
|
||||
{
|
||||
bgthreshold = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-inv" ) )
|
||||
{
|
||||
invert = 1;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-randinv" ) )
|
||||
{
|
||||
invert = CV_RANDOM_INVERT;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxidev" ) )
|
||||
{
|
||||
maxintensitydev = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxxangle" ) )
|
||||
{
|
||||
maxxangle = atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxyangle" ) )
|
||||
{
|
||||
maxyangle = atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxzangle" ) )
|
||||
{
|
||||
maxzangle = atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-show" ) )
|
||||
{
|
||||
showsamples = 1;
|
||||
if( i+1 < argc && strlen( argv[i+1] ) > 0 && argv[i+1][0] != '-' )
|
||||
{
|
||||
double d;
|
||||
d = strtod( argv[i+1], 0 );
|
||||
if( d != -HUGE_VAL && d != HUGE_VAL && d > 0 ) scale = d;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
else if( !strcmp( argv[i], "-w" ) )
|
||||
{
|
||||
width = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-h" ) )
|
||||
{
|
||||
height = atoi( argv[++i] );
|
||||
}
|
||||
}
|
||||
|
||||
printf( "Info file name: %s\n", ((infoname == NULL) ? nullname : infoname ) );
|
||||
printf( "Img file name: %s\n", ((imagename == NULL) ? nullname : imagename ) );
|
||||
printf( "Vec file name: %s\n", ((vecname == NULL) ? nullname : vecname ) );
|
||||
printf( "BG file name: %s\n", ((bgfilename == NULL) ? nullname : bgfilename ) );
|
||||
printf( "Num: %d\n", num );
|
||||
printf( "BG color: %d\n", bgcolor );
|
||||
printf( "BG threshold: %d\n", bgthreshold );
|
||||
printf( "Invert: %s\n", (invert == CV_RANDOM_INVERT) ? "RANDOM"
|
||||
: ( (invert) ? "TRUE" : "FALSE" ) );
|
||||
printf( "Max intensity deviation: %d\n", maxintensitydev );
|
||||
printf( "Max x angle: %g\n", maxxangle );
|
||||
printf( "Max y angle: %g\n", maxyangle );
|
||||
printf( "Max z angle: %g\n", maxzangle );
|
||||
printf( "Show samples: %s\n", (showsamples) ? "TRUE" : "FALSE" );
|
||||
if( showsamples )
|
||||
{
|
||||
printf( "Scale: %g\n", scale );
|
||||
}
|
||||
printf( "Width: %d\n", width );
|
||||
printf( "Height: %d\n", height );
|
||||
|
||||
/* determine action */
|
||||
if( imagename && vecname )
|
||||
{
|
||||
printf( "Create training samples from single image applying distortions...\n" );
|
||||
|
||||
cvCreateTrainingSamples( vecname, imagename, bgcolor, bgthreshold, bgfilename,
|
||||
num, invert, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle,
|
||||
showsamples, width, height );
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
else if( imagename && bgfilename && infoname )
|
||||
{
|
||||
printf( "Create test samples from single image applying distortions...\n" );
|
||||
|
||||
cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||
invert, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, showsamples, width, height );
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
else if( infoname && vecname )
|
||||
{
|
||||
int total;
|
||||
|
||||
printf( "Create training samples from images collection...\n" );
|
||||
|
||||
total = cvCreateTrainingSamplesFromInfo( infoname, vecname, num, showsamples,
|
||||
width, height );
|
||||
|
||||
printf( "Done. Created %d samples\n", total );
|
||||
}
|
||||
else if( vecname )
|
||||
{
|
||||
printf( "View samples from vec file (press ESC to exit)...\n" );
|
||||
|
||||
cvShowVecSamples( vecname, width, height, scale );
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Nothing to do\n" );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,729 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* File cvclassifier.h
|
||||
*
|
||||
* Classifier types
|
||||
*/
|
||||
|
||||
#ifndef _CVCLASSIFIER_H_
|
||||
#define _CVCLASSIFIER_H_
|
||||
|
||||
#include <cmath>
|
||||
#include "cxcore.h"
|
||||
|
||||
#define CV_BOOST_API
|
||||
|
||||
/* Convert matrix to vector */
|
||||
#define CV_MAT2VEC( mat, vdata, vstep, num ) \
|
||||
assert( (mat).rows == 1 || (mat).cols == 1 ); \
|
||||
(vdata) = ((mat).data.ptr); \
|
||||
if( (mat).rows == 1 ) \
|
||||
{ \
|
||||
(vstep) = CV_ELEM_SIZE( (mat).type ); \
|
||||
(num) = (mat).cols; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(vstep) = (mat).step; \
|
||||
(num) = (mat).rows; \
|
||||
}
|
||||
|
||||
/* Set up <sample> matrix header to be <num> sample of <trainData> samples matrix */
|
||||
#define CV_GET_SAMPLE( trainData, tdflags, num, sample ) \
|
||||
if( CV_IS_ROW_SAMPLE( tdflags ) ) \
|
||||
{ \
|
||||
cvInitMatHeader( &(sample), 1, (trainData).cols, \
|
||||
CV_MAT_TYPE( (trainData).type ), \
|
||||
((trainData).data.ptr + (num) * (trainData).step), \
|
||||
(trainData).step ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
cvInitMatHeader( &(sample), (trainData).rows, 1, \
|
||||
CV_MAT_TYPE( (trainData).type ), \
|
||||
((trainData).data.ptr + (num) * CV_ELEM_SIZE( (trainData).type )), \
|
||||
(trainData).step ); \
|
||||
}
|
||||
|
||||
#define CV_GET_SAMPLE_STEP( trainData, tdflags, sstep ) \
|
||||
(sstep) = ( ( CV_IS_ROW_SAMPLE( tdflags ) ) \
|
||||
? (trainData).step : CV_ELEM_SIZE( (trainData).type ) );
|
||||
|
||||
|
||||
#define CV_LOGRATIO_THRESHOLD 0.00001F
|
||||
|
||||
/* log( val / (1 - val ) ) */
|
||||
CV_INLINE float cvLogRatio( float val );
|
||||
|
||||
CV_INLINE float cvLogRatio( float val )
|
||||
{
|
||||
float tval;
|
||||
|
||||
tval = MAX(CV_LOGRATIO_THRESHOLD, MIN( 1.0F - CV_LOGRATIO_THRESHOLD, (val) ));
|
||||
return logf( tval / (1.0F - tval) );
|
||||
}
|
||||
|
||||
|
||||
/* flags values for classifier consturctor flags parameter */
|
||||
|
||||
/* each trainData matrix column is a sample */
|
||||
#define CV_COL_SAMPLE 0
|
||||
|
||||
/* each trainData matrix row is a sample */
|
||||
#define CV_ROW_SAMPLE 1
|
||||
|
||||
#ifndef CV_IS_ROW_SAMPLE
|
||||
# define CV_IS_ROW_SAMPLE( flags ) ( ( flags ) & CV_ROW_SAMPLE )
|
||||
#endif
|
||||
|
||||
/* Classifier supports tune function */
|
||||
#define CV_TUNABLE (1 << 1)
|
||||
|
||||
#define CV_IS_TUNABLE( flags ) ( (flags) & CV_TUNABLE )
|
||||
|
||||
|
||||
/* classifier fields common to all classifiers */
|
||||
#define CV_CLASSIFIER_FIELDS() \
|
||||
int flags; \
|
||||
float(*eval)( struct CvClassifier*, CvMat* ); \
|
||||
void (*tune)( struct CvClassifier*, CvMat*, int flags, CvMat*, CvMat*, CvMat*, \
|
||||
CvMat*, CvMat* ); \
|
||||
int (*save)( struct CvClassifier*, const char* file_name ); \
|
||||
void (*release)( struct CvClassifier** );
|
||||
|
||||
typedef struct CvClassifier
|
||||
{
|
||||
CV_CLASSIFIER_FIELDS()
|
||||
} CvClassifier;
|
||||
|
||||
#define CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
typedef struct CvClassifierTrainParams
|
||||
{
|
||||
CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
} CvClassifierTrainParams;
|
||||
|
||||
|
||||
/*
|
||||
Common classifier constructor:
|
||||
CvClassifier* cvCreateMyClassifier( CvMat* trainData,
|
||||
int flags,
|
||||
CvMat* trainClasses,
|
||||
CvMat* typeMask,
|
||||
CvMat* missedMeasurementsMask CV_DEFAULT(0),
|
||||
CvCompIdx* compIdx CV_DEFAULT(0),
|
||||
CvMat* sampleIdx CV_DEFAULT(0),
|
||||
CvMat* weights CV_DEFAULT(0),
|
||||
CvClassifierTrainParams* trainParams CV_DEFAULT(0)
|
||||
)
|
||||
|
||||
*/
|
||||
|
||||
typedef CvClassifier* (*CvClassifierConstructor)( CvMat*, int, CvMat*, CvMat*, CvMat*,
|
||||
CvMat*, CvMat*, CvMat*,
|
||||
CvClassifierTrainParams* );
|
||||
|
||||
typedef enum CvStumpType
|
||||
{
|
||||
CV_CLASSIFICATION = 0,
|
||||
CV_CLASSIFICATION_CLASS = 1,
|
||||
CV_REGRESSION = 2
|
||||
} CvStumpType;
|
||||
|
||||
typedef enum CvStumpError
|
||||
{
|
||||
CV_MISCLASSIFICATION = 0,
|
||||
CV_GINI = 1,
|
||||
CV_ENTROPY = 2,
|
||||
CV_SQUARE = 3
|
||||
} CvStumpError;
|
||||
|
||||
|
||||
typedef struct CvStumpTrainParams
|
||||
{
|
||||
CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
CvStumpType type;
|
||||
CvStumpError error;
|
||||
} CvStumpTrainParams;
|
||||
|
||||
typedef struct CvMTStumpTrainParams
|
||||
{
|
||||
CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
CvStumpType type;
|
||||
CvStumpError error;
|
||||
int portion; /* number of components calculated in each thread */
|
||||
int numcomp; /* total number of components */
|
||||
|
||||
/* callback which fills <mat> with components [first, first+num[ */
|
||||
void (*getTrainData)( CvMat* mat, CvMat* sampleIdx, CvMat* compIdx,
|
||||
int first, int num, void* userdata );
|
||||
CvMat* sortedIdx; /* presorted samples indices */
|
||||
void* userdata; /* passed to callback */
|
||||
} CvMTStumpTrainParams;
|
||||
|
||||
typedef struct CvStumpClassifier
|
||||
{
|
||||
CV_CLASSIFIER_FIELDS()
|
||||
int compidx;
|
||||
|
||||
float lerror; /* impurity of the right node */
|
||||
float rerror; /* impurity of the left node */
|
||||
|
||||
float threshold;
|
||||
float left;
|
||||
float right;
|
||||
} CvStumpClassifier;
|
||||
|
||||
typedef struct CvCARTTrainParams
|
||||
{
|
||||
CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
/* desired number of internal nodes */
|
||||
int count;
|
||||
CvClassifierTrainParams* stumpTrainParams;
|
||||
CvClassifierConstructor stumpConstructor;
|
||||
|
||||
/*
|
||||
* Split sample indices <idx>
|
||||
* on the "left" indices <left> and "right" indices <right>
|
||||
* according to samples components <compidx> values and <threshold>.
|
||||
*
|
||||
* NOTE: Matrices <left> and <right> must be allocated using cvCreateMat function
|
||||
* since they are freed using cvReleaseMat function
|
||||
*
|
||||
* If it is NULL then the default implementation which evaluates training
|
||||
* samples from <trainData> passed to classifier constructor is used
|
||||
*/
|
||||
void (*splitIdx)( int compidx, float threshold,
|
||||
CvMat* idx, CvMat** left, CvMat** right,
|
||||
void* userdata );
|
||||
void* userdata;
|
||||
} CvCARTTrainParams;
|
||||
|
||||
typedef struct CvCARTClassifier
|
||||
{
|
||||
CV_CLASSIFIER_FIELDS()
|
||||
/* number of internal nodes */
|
||||
int count;
|
||||
|
||||
/* internal nodes (each array of <count> elements) */
|
||||
int* compidx;
|
||||
float* threshold;
|
||||
int* left;
|
||||
int* right;
|
||||
|
||||
/* leaves (array of <count>+1 elements) */
|
||||
float* val;
|
||||
} CvCARTClassifier;
|
||||
|
||||
CV_BOOST_API
|
||||
void cvGetSortedIndices( CvMat* val, CvMat* idx, int sortcols CV_DEFAULT( 0 ) );
|
||||
|
||||
CV_BOOST_API
|
||||
void cvReleaseStumpClassifier( CvClassifier** classifier );
|
||||
|
||||
CV_BOOST_API
|
||||
float cvEvalStumpClassifier( CvClassifier* classifier, CvMat* sample );
|
||||
|
||||
CV_BOOST_API
|
||||
CvClassifier* cvCreateStumpClassifier( CvMat* trainData,
|
||||
int flags,
|
||||
CvMat* trainClasses,
|
||||
CvMat* typeMask,
|
||||
CvMat* missedMeasurementsMask CV_DEFAULT(0),
|
||||
CvMat* compIdx CV_DEFAULT(0),
|
||||
CvMat* sampleIdx CV_DEFAULT(0),
|
||||
CvMat* weights CV_DEFAULT(0),
|
||||
CvClassifierTrainParams* trainParams CV_DEFAULT(0) );
|
||||
|
||||
/*
|
||||
* cvCreateMTStumpClassifier
|
||||
*
|
||||
* Multithreaded stump classifier constructor
|
||||
* Includes huge train data support through callback function
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvClassifier* cvCreateMTStumpClassifier( CvMat* trainData,
|
||||
int flags,
|
||||
CvMat* trainClasses,
|
||||
CvMat* typeMask,
|
||||
CvMat* missedMeasurementsMask,
|
||||
CvMat* compIdx,
|
||||
CvMat* sampleIdx,
|
||||
CvMat* weights,
|
||||
CvClassifierTrainParams* trainParams );
|
||||
|
||||
/*
|
||||
* cvCreateCARTClassifier
|
||||
*
|
||||
* CART classifier constructor
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvClassifier* cvCreateCARTClassifier( CvMat* trainData,
|
||||
int flags,
|
||||
CvMat* trainClasses,
|
||||
CvMat* typeMask,
|
||||
CvMat* missedMeasurementsMask,
|
||||
CvMat* compIdx,
|
||||
CvMat* sampleIdx,
|
||||
CvMat* weights,
|
||||
CvClassifierTrainParams* trainParams );
|
||||
|
||||
CV_BOOST_API
|
||||
void cvReleaseCARTClassifier( CvClassifier** classifier );
|
||||
|
||||
CV_BOOST_API
|
||||
float cvEvalCARTClassifier( CvClassifier* classifier, CvMat* sample );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Boosting *
|
||||
\****************************************************************************************/
|
||||
|
||||
/*
|
||||
* CvBoostType
|
||||
*
|
||||
* The CvBoostType enumeration specifies the boosting type.
|
||||
*
|
||||
* Remarks
|
||||
* Four different boosting variants for 2 class classification problems are supported:
|
||||
* Discrete AdaBoost, Real AdaBoost, LogitBoost and Gentle AdaBoost.
|
||||
* The L2 (2 class classification problems) and LK (K class classification problems)
|
||||
* algorithms are close to LogitBoost but more numerically stable than last one.
|
||||
* For regression three different loss functions are supported:
|
||||
* Least square, least absolute deviation and huber loss.
|
||||
*/
|
||||
typedef enum CvBoostType
|
||||
{
|
||||
CV_DABCLASS = 0, /* 2 class Discrete AdaBoost */
|
||||
CV_RABCLASS = 1, /* 2 class Real AdaBoost */
|
||||
CV_LBCLASS = 2, /* 2 class LogitBoost */
|
||||
CV_GABCLASS = 3, /* 2 class Gentle AdaBoost */
|
||||
CV_L2CLASS = 4, /* classification (2 class problem) */
|
||||
CV_LKCLASS = 5, /* classification (K class problem) */
|
||||
CV_LSREG = 6, /* least squares regression */
|
||||
CV_LADREG = 7, /* least absolute deviation regression */
|
||||
CV_MREG = 8 /* M-regression (Huber loss) */
|
||||
} CvBoostType;
|
||||
|
||||
/****************************************************************************************\
|
||||
* Iterative training functions *
|
||||
\****************************************************************************************/
|
||||
|
||||
/*
|
||||
* CvBoostTrainer
|
||||
*
|
||||
* The CvBoostTrainer structure represents internal boosting trainer.
|
||||
*/
|
||||
typedef struct CvBoostTrainer CvBoostTrainer;
|
||||
|
||||
/*
|
||||
* cvBoostStartTraining
|
||||
*
|
||||
* The cvBoostStartTraining function starts training process and calculates
|
||||
* response values and weights for the first weak classifier training.
|
||||
*
|
||||
* Parameters
|
||||
* trainClasses
|
||||
* Vector of classes of training samples classes. Each element must be 0 or 1 and
|
||||
* of type CV_32FC1.
|
||||
* weakTrainVals
|
||||
* Vector of response values for the first trained weak classifier.
|
||||
* Must be of type CV_32FC1.
|
||||
* weights
|
||||
* Weight vector of training samples for the first trained weak classifier.
|
||||
* Must be of type CV_32FC1.
|
||||
* type
|
||||
* Boosting type. CV_DABCLASS, CV_RABCLASS, CV_LBCLASS, CV_GABCLASS
|
||||
* types are supported.
|
||||
*
|
||||
* Return Values
|
||||
* The return value is a pointer to internal trainer structure which is used
|
||||
* to perform next training iterations.
|
||||
*
|
||||
* Remarks
|
||||
* weakTrainVals and weights must be allocated before calling the function
|
||||
* and of the same size as trainingClasses. Usually weights should be initialized
|
||||
* with 1.0 value.
|
||||
* The function calculates response values and weights for the first weak
|
||||
* classifier training and stores them into weakTrainVals and weights
|
||||
* respectively.
|
||||
* Note, the training of the weak classifier using weakTrainVals, weight,
|
||||
* trainingData is outside of this function.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvBoostTrainer* cvBoostStartTraining( CvMat* trainClasses,
|
||||
CvMat* weakTrainVals,
|
||||
CvMat* weights,
|
||||
CvMat* sampleIdx,
|
||||
CvBoostType type );
|
||||
/*
|
||||
* cvBoostNextWeakClassifier
|
||||
*
|
||||
* The cvBoostNextWeakClassifier function performs next training
|
||||
* iteration and caluclates response values and weights for the next weak
|
||||
* classifier training.
|
||||
*
|
||||
* Parameters
|
||||
* weakEvalVals
|
||||
* Vector of values obtained by evaluation of each sample with
|
||||
* the last trained weak classifier (iteration i). Must be of CV_32FC1 type.
|
||||
* trainClasses
|
||||
* Vector of classes of training samples. Each element must be 0 or 1,
|
||||
* and of type CV_32FC1.
|
||||
* weakTrainVals
|
||||
* Vector of response values for the next weak classifier training
|
||||
* (iteration i+1). Must be of type CV_32FC1.
|
||||
* weights
|
||||
* Weight vector of training samples for the next weak classifier training
|
||||
* (iteration i+1). Must be of type CV_32FC1.
|
||||
* trainer
|
||||
* A pointer to internal trainer returned by the cvBoostStartTraining
|
||||
* function call.
|
||||
*
|
||||
* Return Values
|
||||
* The return value is the coefficient for the last trained weak classifier.
|
||||
*
|
||||
* Remarks
|
||||
* weakTrainVals and weights must be exactly the same vectors as used in
|
||||
* the cvBoostStartTraining function call and should not be modified.
|
||||
* The function calculates response values and weights for the next weak
|
||||
* classifier training and stores them into weakTrainVals and weights
|
||||
* respectively.
|
||||
* Note, the training of the weak classifier of iteration i+1 using
|
||||
* weakTrainVals, weight, trainingData is outside of this function.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
float cvBoostNextWeakClassifier( CvMat* weakEvalVals,
|
||||
CvMat* trainClasses,
|
||||
CvMat* weakTrainVals,
|
||||
CvMat* weights,
|
||||
CvBoostTrainer* trainer );
|
||||
|
||||
/*
|
||||
* cvBoostEndTraining
|
||||
*
|
||||
* The cvBoostEndTraining function finishes training process and releases
|
||||
* internally allocated memory.
|
||||
*
|
||||
* Parameters
|
||||
* trainer
|
||||
* A pointer to a pointer to internal trainer returned by the cvBoostStartTraining
|
||||
* function call.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
void cvBoostEndTraining( CvBoostTrainer** trainer );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Boosted tree models *
|
||||
\****************************************************************************************/
|
||||
|
||||
/*
|
||||
* CvBtClassifier
|
||||
*
|
||||
* The CvBtClassifier structure represents boosted tree model.
|
||||
*
|
||||
* Members
|
||||
* flags
|
||||
* Flags. If CV_IS_TUNABLE( flags ) != 0 then the model supports tuning.
|
||||
* eval
|
||||
* Evaluation function. Returns sample predicted class (0, 1, etc.)
|
||||
* for classification or predicted value for regression.
|
||||
* tune
|
||||
* Tune function. If the model supports tuning then tune call performs
|
||||
* one more boosting iteration if passed to the function flags parameter
|
||||
* is CV_TUNABLE otherwise releases internally allocated for tuning memory
|
||||
* and makes the model untunable.
|
||||
* NOTE: Since tuning uses the pointers to parameters,
|
||||
* passed to the cvCreateBtClassifier function, they should not be modified
|
||||
* or released between tune calls.
|
||||
* save
|
||||
* This function stores the model into given file.
|
||||
* release
|
||||
* This function releases the model.
|
||||
* type
|
||||
* Boosted tree model type.
|
||||
* numclasses
|
||||
* Number of classes for CV_LKCLASS type or 1 for all other types.
|
||||
* numiter
|
||||
* Number of iterations. Number of weak classifiers is equal to number
|
||||
* of iterations for all types except CV_LKCLASS. For CV_LKCLASS type
|
||||
* number of weak classifiers is (numiter * numclasses).
|
||||
* numfeatures
|
||||
* Number of features in sample.
|
||||
* trees
|
||||
* Stores weak classifiers when the model does not support tuning.
|
||||
* seq
|
||||
* Stores weak classifiers when the model supports tuning.
|
||||
* trainer
|
||||
* Pointer to internal tuning parameters if the model supports tuning.
|
||||
*/
|
||||
typedef struct CvBtClassifier
|
||||
{
|
||||
CV_CLASSIFIER_FIELDS()
|
||||
|
||||
CvBoostType type;
|
||||
int numclasses;
|
||||
int numiter;
|
||||
int numfeatures;
|
||||
union
|
||||
{
|
||||
CvCARTClassifier** trees;
|
||||
CvSeq* seq;
|
||||
};
|
||||
void* trainer;
|
||||
} CvBtClassifier;
|
||||
|
||||
/*
|
||||
* CvBtClassifierTrainParams
|
||||
*
|
||||
* The CvBtClassifierTrainParams structure stores training parameters for
|
||||
* boosted tree model.
|
||||
*
|
||||
* Members
|
||||
* type
|
||||
* Boosted tree model type.
|
||||
* numiter
|
||||
* Desired number of iterations.
|
||||
* param
|
||||
* Parameter Model Type Parameter Meaning
|
||||
* param[0] Any Shrinkage factor
|
||||
* param[1] CV_MREG alpha. (1-alpha) determines "break-down" point of
|
||||
* the training procedure, i.e. the fraction of samples
|
||||
* that can be arbitrary modified without serious
|
||||
* degrading the quality of the result.
|
||||
* CV_DABCLASS, Weight trimming factor.
|
||||
* CV_RABCLASS,
|
||||
* CV_LBCLASS,
|
||||
* CV_GABCLASS,
|
||||
* CV_L2CLASS,
|
||||
* CV_LKCLASS
|
||||
* numsplits
|
||||
* Desired number of splits in each tree.
|
||||
*/
|
||||
typedef struct CvBtClassifierTrainParams
|
||||
{
|
||||
CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
|
||||
|
||||
CvBoostType type;
|
||||
int numiter;
|
||||
float param[2];
|
||||
int numsplits;
|
||||
} CvBtClassifierTrainParams;
|
||||
|
||||
/*
|
||||
* cvCreateBtClassifier
|
||||
*
|
||||
* The cvCreateBtClassifier function creates boosted tree model.
|
||||
*
|
||||
* Parameters
|
||||
* trainData
|
||||
* Matrix of feature values. Must have CV_32FC1 type.
|
||||
* flags
|
||||
* Determines how samples are stored in trainData.
|
||||
* One of CV_ROW_SAMPLE or CV_COL_SAMPLE.
|
||||
* Optionally may be combined with CV_TUNABLE to make tunable model.
|
||||
* trainClasses
|
||||
* Vector of responses for regression or classes (0, 1, 2, etc.) for classification.
|
||||
* typeMask,
|
||||
* missedMeasurementsMask,
|
||||
* compIdx
|
||||
* Not supported. Must be NULL.
|
||||
* sampleIdx
|
||||
* Indices of samples used in training. If NULL then all samples are used.
|
||||
* For CV_DABCLASS, CV_RABCLASS, CV_LBCLASS and CV_GABCLASS must be NULL.
|
||||
* weights
|
||||
* Not supported. Must be NULL.
|
||||
* trainParams
|
||||
* A pointer to CvBtClassifierTrainParams structure. Training parameters.
|
||||
* See CvBtClassifierTrainParams description for details.
|
||||
*
|
||||
* Return Values
|
||||
* The return value is a pointer to created boosted tree model of type CvBtClassifier.
|
||||
*
|
||||
* Remarks
|
||||
* The function performs trainParams->numiter training iterations.
|
||||
* If CV_TUNABLE flag is specified then created model supports tuning.
|
||||
* In this case additional training iterations may be performed by
|
||||
* tune function call.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvClassifier* cvCreateBtClassifier( CvMat* trainData,
|
||||
int flags,
|
||||
CvMat* trainClasses,
|
||||
CvMat* typeMask,
|
||||
CvMat* missedMeasurementsMask,
|
||||
CvMat* compIdx,
|
||||
CvMat* sampleIdx,
|
||||
CvMat* weights,
|
||||
CvClassifierTrainParams* trainParams );
|
||||
|
||||
/*
|
||||
* cvCreateBtClassifierFromFile
|
||||
*
|
||||
* The cvCreateBtClassifierFromFile function restores previously saved
|
||||
* boosted tree model from file.
|
||||
*
|
||||
* Parameters
|
||||
* filename
|
||||
* The name of the file with boosted tree model.
|
||||
*
|
||||
* Remarks
|
||||
* The restored model does not support tuning.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvClassifier* cvCreateBtClassifierFromFile( const char* filename );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Utility functions *
|
||||
\****************************************************************************************/
|
||||
|
||||
/*
|
||||
* cvTrimWeights
|
||||
*
|
||||
* The cvTrimWeights function performs weight trimming.
|
||||
*
|
||||
* Parameters
|
||||
* weights
|
||||
* Weights vector.
|
||||
* idx
|
||||
* Indices vector of weights that should be considered.
|
||||
* If it is NULL then all weights are used.
|
||||
* factor
|
||||
* Weight trimming factor. Must be in [0, 1] range.
|
||||
*
|
||||
* Return Values
|
||||
* The return value is a vector of indices. If all samples should be used then
|
||||
* it is equal to idx. In other case the cvReleaseMat function should be called
|
||||
* to release it.
|
||||
*
|
||||
* Remarks
|
||||
*/
|
||||
CV_BOOST_API
|
||||
CvMat* cvTrimWeights( CvMat* weights, CvMat* idx, float factor );
|
||||
|
||||
/*
|
||||
* cvReadTrainData
|
||||
*
|
||||
* The cvReadTrainData function reads feature values and responses from file.
|
||||
*
|
||||
* Parameters
|
||||
* filename
|
||||
* The name of the file to be read.
|
||||
* flags
|
||||
* One of CV_ROW_SAMPLE or CV_COL_SAMPLE. Determines how feature values
|
||||
* will be stored.
|
||||
* trainData
|
||||
* A pointer to a pointer to created matrix with feature values.
|
||||
* cvReleaseMat function should be used to destroy created matrix.
|
||||
* trainClasses
|
||||
* A pointer to a pointer to created matrix with response values.
|
||||
* cvReleaseMat function should be used to destroy created matrix.
|
||||
*
|
||||
* Remarks
|
||||
* File format:
|
||||
* ============================================
|
||||
* m n
|
||||
* value_1_1 value_1_2 ... value_1_n response_1
|
||||
* value_2_1 value_2_2 ... value_2_n response_2
|
||||
* ...
|
||||
* value_m_1 value_m_2 ... value_m_n response_m
|
||||
* ============================================
|
||||
* m
|
||||
* Number of samples
|
||||
* n
|
||||
* Number of features in each sample
|
||||
* value_i_j
|
||||
* Value of j-th feature of i-th sample
|
||||
* response_i
|
||||
* Response value of i-th sample
|
||||
* For classification problems responses represent classes (0, 1, etc.)
|
||||
* All values and classes are integer or real numbers.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
void cvReadTrainData( const char* filename,
|
||||
int flags,
|
||||
CvMat** trainData,
|
||||
CvMat** trainClasses );
|
||||
|
||||
|
||||
/*
|
||||
* cvWriteTrainData
|
||||
*
|
||||
* The cvWriteTrainData function stores feature values and responses into file.
|
||||
*
|
||||
* Parameters
|
||||
* filename
|
||||
* The name of the file.
|
||||
* flags
|
||||
* One of CV_ROW_SAMPLE or CV_COL_SAMPLE. Determines how feature values
|
||||
* are stored.
|
||||
* trainData
|
||||
* Feature values matrix.
|
||||
* trainClasses
|
||||
* Response values vector.
|
||||
* sampleIdx
|
||||
* Vector of idicies of the samples that should be stored. If it is NULL
|
||||
* then all samples will be stored.
|
||||
*
|
||||
* Remarks
|
||||
* See the cvReadTrainData function for file format description.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
void cvWriteTrainData( const char* filename,
|
||||
int flags,
|
||||
CvMat* trainData,
|
||||
CvMat* trainClasses,
|
||||
CvMat* sampleIdx );
|
||||
|
||||
/*
|
||||
* cvRandShuffle
|
||||
*
|
||||
* The cvRandShuffle function perfroms random shuffling of given vector.
|
||||
*
|
||||
* Parameters
|
||||
* vector
|
||||
* Vector that should be shuffled.
|
||||
* Must have CV_8UC1, CV_16SC1, CV_32SC1 or CV_32FC1 type.
|
||||
*/
|
||||
CV_BOOST_API
|
||||
void cvRandShuffleVec( CvMat* vector );
|
||||
|
||||
#endif /* _CVCLASSIFIER_H_ */
|
||||
@@ -1,125 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "_cvcommon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
int icvMkDir( const char* filename )
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char* p;
|
||||
int pos;
|
||||
|
||||
#ifdef _WIN32
|
||||
struct _stat st;
|
||||
#else /* _WIN32 */
|
||||
struct stat st;
|
||||
mode_t mode;
|
||||
|
||||
mode = 0755;
|
||||
#endif /* _WIN32 */
|
||||
|
||||
strcpy( path, filename );
|
||||
|
||||
p = path;
|
||||
for( ; ; )
|
||||
{
|
||||
pos = (int)strcspn( p, "/\\" );
|
||||
|
||||
if( pos == (int) strlen( p ) ) break;
|
||||
if( pos != 0 )
|
||||
{
|
||||
p[pos] = '\0';
|
||||
|
||||
#ifdef _WIN32
|
||||
if( p[pos-1] != ':' )
|
||||
{
|
||||
if( _stat( path, &st ) != 0 )
|
||||
{
|
||||
if( _mkdir( path ) != 0 ) return 0;
|
||||
}
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
if( stat( path, &st ) != 0 )
|
||||
{
|
||||
if( mkdir( path, mode ) != 0 ) return 0;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
p[pos] = '/';
|
||||
|
||||
p += pos + 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* debug functions */
|
||||
void icvSave( const CvArr* ptr, const char* filename, int line )
|
||||
{
|
||||
CvFileStorage* fs;
|
||||
char buf[PATH_MAX];
|
||||
const char* name;
|
||||
|
||||
name = strrchr( filename, '\\' );
|
||||
if( !name ) name = strrchr( filename, '/' );
|
||||
if( !name ) name = filename;
|
||||
else name++; /* skip '/' or '\\' */
|
||||
|
||||
sprintf( buf, "%s-%d-%d", name, line, time( NULL ) );
|
||||
fs = cvOpenFileStorage( buf, NULL, CV_STORAGE_WRITE_TEXT );
|
||||
if( !fs ) return;
|
||||
cvWrite( fs, "debug", ptr );
|
||||
cvReleaseFileStorage( &fs );
|
||||
}
|
||||
#endif // #if 0
|
||||
|
||||
/* End of file. */
|
||||
@@ -1,835 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* cvhaarclassifier.cpp
|
||||
*
|
||||
* haar classifiers (stump, CART, stage, cascade)
|
||||
*/
|
||||
|
||||
#include "_cvhaartraining.h"
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvCreateCARTHaarClassifier( int count )
|
||||
{
|
||||
CvCARTHaarClassifier* cart;
|
||||
size_t datasize;
|
||||
|
||||
datasize = sizeof( *cart ) +
|
||||
( sizeof( int ) +
|
||||
sizeof( CvTHaarFeature ) + sizeof( CvFastHaarFeature ) +
|
||||
sizeof( float ) + sizeof( int ) + sizeof( int ) ) * count +
|
||||
sizeof( float ) * (count + 1);
|
||||
|
||||
cart = (CvCARTHaarClassifier*) cvAlloc( datasize );
|
||||
memset( cart, 0, datasize );
|
||||
|
||||
cart->feature = (CvTHaarFeature*) (cart + 1);
|
||||
cart->fastfeature = (CvFastHaarFeature*) (cart->feature + count);
|
||||
cart->threshold = (float*) (cart->fastfeature + count);
|
||||
cart->left = (int*) (cart->threshold + count);
|
||||
cart->right = (int*) (cart->left + count);
|
||||
cart->val = (float*) (cart->right + count);
|
||||
cart->compidx = (int*) (cart->val + count + 1 );
|
||||
cart->count = count;
|
||||
cart->eval = icvEvalCARTHaarClassifier;
|
||||
cart->save = icvSaveCARTHaarClassifier;
|
||||
cart->release = icvReleaseHaarClassifier;
|
||||
|
||||
return (CvIntHaarClassifier*) cart;
|
||||
}
|
||||
|
||||
|
||||
void icvReleaseHaarClassifier( CvIntHaarClassifier** classifier )
|
||||
{
|
||||
cvFree( classifier );
|
||||
*classifier = NULL;
|
||||
}
|
||||
|
||||
|
||||
void icvInitCARTHaarClassifier( CvCARTHaarClassifier* carthaar, CvCARTClassifier* cart,
|
||||
CvIntHaarFeatures* intHaarFeatures )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < cart->count; i++ )
|
||||
{
|
||||
carthaar->feature[i] = intHaarFeatures->feature[cart->compidx[i]];
|
||||
carthaar->fastfeature[i] = intHaarFeatures->fastfeature[cart->compidx[i]];
|
||||
carthaar->threshold[i] = cart->threshold[i];
|
||||
carthaar->left[i] = cart->left[i];
|
||||
carthaar->right[i] = cart->right[i];
|
||||
carthaar->val[i] = cart->val[i];
|
||||
carthaar->compidx[i] = cart->compidx[i];
|
||||
}
|
||||
carthaar->count = cart->count;
|
||||
carthaar->val[cart->count] = cart->val[cart->count];
|
||||
}
|
||||
|
||||
|
||||
float icvEvalCARTHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor )
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if( cvEvalFastHaarFeature(
|
||||
((CvCARTHaarClassifier*) classifier)->fastfeature + idx, sum, tilted )
|
||||
< (((CvCARTHaarClassifier*) classifier)->threshold[idx] * normfactor) )
|
||||
{
|
||||
idx = ((CvCARTHaarClassifier*) classifier)->left[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
idx = ((CvCARTHaarClassifier*) classifier)->right[idx];
|
||||
}
|
||||
} while( idx > 0 );
|
||||
|
||||
return ((CvCARTHaarClassifier*) classifier)->val[-idx];
|
||||
}
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvCreateStageHaarClassifier( int count, float threshold )
|
||||
{
|
||||
CvStageHaarClassifier* stage;
|
||||
size_t datasize;
|
||||
|
||||
datasize = sizeof( *stage ) + sizeof( CvIntHaarClassifier* ) * count;
|
||||
stage = (CvStageHaarClassifier*) cvAlloc( datasize );
|
||||
memset( stage, 0, datasize );
|
||||
|
||||
stage->count = count;
|
||||
stage->threshold = threshold;
|
||||
stage->classifier = (CvIntHaarClassifier**) (stage + 1);
|
||||
|
||||
stage->eval = icvEvalStageHaarClassifier;
|
||||
stage->save = icvSaveStageHaarClassifier;
|
||||
stage->release = icvReleaseStageHaarClassifier;
|
||||
|
||||
return (CvIntHaarClassifier*) stage;
|
||||
}
|
||||
|
||||
|
||||
void icvReleaseStageHaarClassifier( CvIntHaarClassifier** classifier )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ((CvStageHaarClassifier*) *classifier)->count; i++ )
|
||||
{
|
||||
if( ((CvStageHaarClassifier*) *classifier)->classifier[i] != NULL )
|
||||
{
|
||||
((CvStageHaarClassifier*) *classifier)->classifier[i]->release(
|
||||
&(((CvStageHaarClassifier*) *classifier)->classifier[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
cvFree( classifier );
|
||||
*classifier = NULL;
|
||||
}
|
||||
|
||||
|
||||
float icvEvalStageHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor )
|
||||
{
|
||||
int i;
|
||||
float stage_sum;
|
||||
|
||||
stage_sum = 0.0F;
|
||||
for( i = 0; i < ((CvStageHaarClassifier*) classifier)->count; i++ )
|
||||
{
|
||||
stage_sum +=
|
||||
((CvStageHaarClassifier*) classifier)->classifier[i]->eval(
|
||||
((CvStageHaarClassifier*) classifier)->classifier[i],
|
||||
sum, tilted, normfactor );
|
||||
}
|
||||
|
||||
return stage_sum;
|
||||
}
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvCreateCascadeHaarClassifier( int count )
|
||||
{
|
||||
CvCascadeHaarClassifier* ptr;
|
||||
size_t datasize;
|
||||
|
||||
datasize = sizeof( *ptr ) + sizeof( CvIntHaarClassifier* ) * count;
|
||||
ptr = (CvCascadeHaarClassifier*) cvAlloc( datasize );
|
||||
memset( ptr, 0, datasize );
|
||||
|
||||
ptr->count = count;
|
||||
ptr->classifier = (CvIntHaarClassifier**) (ptr + 1);
|
||||
|
||||
ptr->eval = icvEvalCascadeHaarClassifier;
|
||||
ptr->save = NULL;
|
||||
ptr->release = icvReleaseCascadeHaarClassifier;
|
||||
|
||||
return (CvIntHaarClassifier*) ptr;
|
||||
}
|
||||
|
||||
|
||||
void icvReleaseCascadeHaarClassifier( CvIntHaarClassifier** classifier )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ((CvCascadeHaarClassifier*) *classifier)->count; i++ )
|
||||
{
|
||||
if( ((CvCascadeHaarClassifier*) *classifier)->classifier[i] != NULL )
|
||||
{
|
||||
((CvCascadeHaarClassifier*) *classifier)->classifier[i]->release(
|
||||
&(((CvCascadeHaarClassifier*) *classifier)->classifier[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
cvFree( classifier );
|
||||
*classifier = NULL;
|
||||
}
|
||||
|
||||
|
||||
float icvEvalCascadeHaarClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ((CvCascadeHaarClassifier*) classifier)->count; i++ )
|
||||
{
|
||||
if( ((CvCascadeHaarClassifier*) classifier)->classifier[i]->eval(
|
||||
((CvCascadeHaarClassifier*) classifier)->classifier[i],
|
||||
sum, tilted, normfactor )
|
||||
< ( ((CvStageHaarClassifier*)
|
||||
((CvCascadeHaarClassifier*) classifier)->classifier[i])->threshold
|
||||
- CV_THRESHOLD_EPS) )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
||||
void icvSaveHaarFeature( CvTHaarFeature* feature, FILE* file )
|
||||
{
|
||||
fprintf( file, "%d\n", ( ( feature->rect[2].weight == 0.0F ) ? 2 : 3) );
|
||||
fprintf( file, "%d %d %d %d %d %d\n",
|
||||
feature->rect[0].r.x,
|
||||
feature->rect[0].r.y,
|
||||
feature->rect[0].r.width,
|
||||
feature->rect[0].r.height,
|
||||
0,
|
||||
(int) (feature->rect[0].weight) );
|
||||
fprintf( file, "%d %d %d %d %d %d\n",
|
||||
feature->rect[1].r.x,
|
||||
feature->rect[1].r.y,
|
||||
feature->rect[1].r.width,
|
||||
feature->rect[1].r.height,
|
||||
0,
|
||||
(int) (feature->rect[1].weight) );
|
||||
if( feature->rect[2].weight != 0.0F )
|
||||
{
|
||||
fprintf( file, "%d %d %d %d %d %d\n",
|
||||
feature->rect[2].r.x,
|
||||
feature->rect[2].r.y,
|
||||
feature->rect[2].r.width,
|
||||
feature->rect[2].r.height,
|
||||
0,
|
||||
(int) (feature->rect[2].weight) );
|
||||
}
|
||||
fprintf( file, "%s\n", &(feature->desc[0]) );
|
||||
}
|
||||
|
||||
|
||||
void icvLoadHaarFeature( CvTHaarFeature* feature, FILE* file )
|
||||
{
|
||||
int nrect;
|
||||
int j;
|
||||
int tmp;
|
||||
int weight;
|
||||
|
||||
nrect = 0;
|
||||
int values_read = fscanf( file, "%d", &nrect );
|
||||
CV_Assert(values_read == 1);
|
||||
|
||||
assert( nrect <= CV_HAAR_FEATURE_MAX );
|
||||
|
||||
for( j = 0; j < nrect; j++ )
|
||||
{
|
||||
values_read = fscanf( file, "%d %d %d %d %d %d",
|
||||
&(feature->rect[j].r.x),
|
||||
&(feature->rect[j].r.y),
|
||||
&(feature->rect[j].r.width),
|
||||
&(feature->rect[j].r.height),
|
||||
&tmp, &weight );
|
||||
CV_Assert(values_read == 6);
|
||||
feature->rect[j].weight = (float) weight;
|
||||
}
|
||||
for( j = nrect; j < CV_HAAR_FEATURE_MAX; j++ )
|
||||
{
|
||||
feature->rect[j].r.x = 0;
|
||||
feature->rect[j].r.y = 0;
|
||||
feature->rect[j].r.width = 0;
|
||||
feature->rect[j].r.height = 0;
|
||||
feature->rect[j].weight = 0.0f;
|
||||
}
|
||||
values_read = fscanf( file, "%s", &(feature->desc[0]) );
|
||||
CV_Assert(values_read == 1);
|
||||
feature->tilted = ( feature->desc[0] == 't' );
|
||||
}
|
||||
|
||||
|
||||
void icvSaveCARTHaarClassifier( CvIntHaarClassifier* classifier, FILE* file )
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
|
||||
count = ((CvCARTHaarClassifier*) classifier)->count;
|
||||
fprintf( file, "%d\n", count );
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
icvSaveHaarFeature( &(((CvCARTHaarClassifier*) classifier)->feature[i]), file );
|
||||
fprintf( file, "%e %d %d\n",
|
||||
((CvCARTHaarClassifier*) classifier)->threshold[i],
|
||||
((CvCARTHaarClassifier*) classifier)->left[i],
|
||||
((CvCARTHaarClassifier*) classifier)->right[i] );
|
||||
}
|
||||
for( i = 0; i <= count; i++ )
|
||||
{
|
||||
fprintf( file, "%e ", ((CvCARTHaarClassifier*) classifier)->val[i] );
|
||||
}
|
||||
fprintf( file, "\n" );
|
||||
}
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvLoadCARTHaarClassifier( FILE* file, int step )
|
||||
{
|
||||
CvCARTHaarClassifier* ptr;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
ptr = NULL;
|
||||
int values_read = fscanf( file, "%d", &count );
|
||||
CV_Assert(values_read == 1);
|
||||
|
||||
if( count > 0 )
|
||||
{
|
||||
ptr = (CvCARTHaarClassifier*) icvCreateCARTHaarClassifier( count );
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
icvLoadHaarFeature( &(ptr->feature[i]), file );
|
||||
values_read = fscanf( file, "%f %d %d", &(ptr->threshold[i]), &(ptr->left[i]),
|
||||
&(ptr->right[i]) );
|
||||
CV_Assert(values_read == 3);
|
||||
}
|
||||
for( i = 0; i <= count; i++ )
|
||||
{
|
||||
values_read = fscanf( file, "%f", &(ptr->val[i]) );
|
||||
CV_Assert(values_read == 1);
|
||||
}
|
||||
icvConvertToFastHaarFeature( ptr->feature, ptr->fastfeature, ptr->count, step );
|
||||
}
|
||||
|
||||
return (CvIntHaarClassifier*) ptr;
|
||||
}
|
||||
|
||||
|
||||
void icvSaveStageHaarClassifier( CvIntHaarClassifier* classifier, FILE* file )
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
float threshold;
|
||||
|
||||
count = ((CvStageHaarClassifier*) classifier)->count;
|
||||
fprintf( file, "%d\n", count );
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
((CvStageHaarClassifier*) classifier)->classifier[i]->save(
|
||||
((CvStageHaarClassifier*) classifier)->classifier[i], file );
|
||||
}
|
||||
|
||||
threshold = ((CvStageHaarClassifier*) classifier)->threshold;
|
||||
|
||||
/* to be compatible with the previous implementation */
|
||||
/* threshold = 2.0F * ((CvStageHaarClassifier*) classifier)->threshold - count; */
|
||||
|
||||
fprintf( file, "%e\n", threshold );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static CvIntHaarClassifier* icvLoadCARTStageHaarClassifierF( FILE* file, int step )
|
||||
{
|
||||
CvStageHaarClassifier* ptr = NULL;
|
||||
|
||||
//CV_FUNCNAME( "icvLoadCARTStageHaarClassifierF" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
if( file != NULL )
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
float threshold;
|
||||
|
||||
count = 0;
|
||||
int values_read = fscanf( file, "%d", &count );
|
||||
CV_Assert(values_read == 1);
|
||||
if( count > 0 )
|
||||
{
|
||||
ptr = (CvStageHaarClassifier*) icvCreateStageHaarClassifier( count, 0.0F );
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
ptr->classifier[i] = icvLoadCARTHaarClassifier( file, step );
|
||||
}
|
||||
|
||||
values_read = fscanf( file, "%f", &threshold );
|
||||
CV_Assert(values_read == 1);
|
||||
|
||||
ptr->threshold = threshold;
|
||||
/* to be compatible with the previous implementation */
|
||||
/* ptr->threshold = 0.5F * (threshold + count); */
|
||||
}
|
||||
if( feof( file ) )
|
||||
{
|
||||
ptr->release( (CvIntHaarClassifier**) &ptr );
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
__END__;
|
||||
|
||||
return (CvIntHaarClassifier*) ptr;
|
||||
}
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvLoadCARTStageHaarClassifier( const char* filename, int step )
|
||||
{
|
||||
CvIntHaarClassifier* ptr = NULL;
|
||||
|
||||
CV_FUNCNAME( "icvLoadCARTStageHaarClassifier" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
FILE* file;
|
||||
|
||||
file = fopen( filename, "r" );
|
||||
if( file )
|
||||
{
|
||||
CV_CALL( ptr = icvLoadCARTStageHaarClassifierF( file, step ) );
|
||||
fclose( file );
|
||||
}
|
||||
|
||||
__END__;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* tree cascade classifier */
|
||||
|
||||
/* evaluates a tree cascade classifier */
|
||||
|
||||
float icvEvalTreeCascadeClassifier( CvIntHaarClassifier* classifier,
|
||||
sum_type* sum, sum_type* tilted, float normfactor )
|
||||
{
|
||||
CvTreeCascadeNode* ptr;
|
||||
|
||||
ptr = ((CvTreeCascadeClassifier*) classifier)->root;
|
||||
|
||||
while( ptr )
|
||||
{
|
||||
if( ptr->stage->eval( (CvIntHaarClassifier*) ptr->stage,
|
||||
sum, tilted, normfactor )
|
||||
>= ptr->stage->threshold - CV_THRESHOLD_EPS )
|
||||
{
|
||||
ptr = ptr->child;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( ptr && ptr->next == NULL ) ptr = ptr->parent;
|
||||
if( ptr == NULL ) return 0.0F;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
/* sets path int the tree form the root to the leaf node */
|
||||
|
||||
void icvSetLeafNode( CvTreeCascadeClassifier* tcc, CvTreeCascadeNode* leaf )
|
||||
{
|
||||
CV_FUNCNAME( "icvSetLeafNode" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
CvTreeCascadeNode* ptr;
|
||||
|
||||
ptr = NULL;
|
||||
while( leaf )
|
||||
{
|
||||
leaf->child_eval = ptr;
|
||||
ptr = leaf;
|
||||
leaf = leaf->parent;
|
||||
}
|
||||
|
||||
leaf = tcc->root;
|
||||
while( leaf && leaf != ptr ) leaf = leaf->next;
|
||||
if( leaf != ptr )
|
||||
CV_ERROR( CV_StsError, "Invalid tcc or leaf node." );
|
||||
|
||||
tcc->root_eval = ptr;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
/* evaluates a tree cascade classifier. used in filtering */
|
||||
|
||||
float icvEvalTreeCascadeClassifierFilter( CvIntHaarClassifier* classifier, sum_type* sum,
|
||||
sum_type* tilted, float normfactor )
|
||||
{
|
||||
CvTreeCascadeNode* ptr;
|
||||
//CvTreeCascadeClassifier* tree;
|
||||
|
||||
//tree = (CvTreeCascadeClassifier*) classifier;
|
||||
|
||||
|
||||
|
||||
ptr = ((CvTreeCascadeClassifier*) classifier)->root_eval;
|
||||
while( ptr )
|
||||
{
|
||||
if( ptr->stage->eval( (CvIntHaarClassifier*) ptr->stage,
|
||||
sum, tilted, normfactor )
|
||||
< ptr->stage->threshold - CV_THRESHOLD_EPS )
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
ptr = ptr->child_eval;
|
||||
}
|
||||
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
/* creates tree cascade node */
|
||||
|
||||
CvTreeCascadeNode* icvCreateTreeCascadeNode()
|
||||
{
|
||||
CvTreeCascadeNode* ptr = NULL;
|
||||
|
||||
CV_FUNCNAME( "icvCreateTreeCascadeNode" );
|
||||
|
||||
__BEGIN__;
|
||||
size_t data_size;
|
||||
|
||||
data_size = sizeof( *ptr );
|
||||
CV_CALL( ptr = (CvTreeCascadeNode*) cvAlloc( data_size ) );
|
||||
memset( ptr, 0, data_size );
|
||||
|
||||
__END__;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* releases all tree cascade nodes accessible via links */
|
||||
|
||||
void icvReleaseTreeCascadeNodes( CvTreeCascadeNode** node )
|
||||
{
|
||||
//CV_FUNCNAME( "icvReleaseTreeCascadeNodes" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
if( node && *node )
|
||||
{
|
||||
CvTreeCascadeNode* ptr;
|
||||
CvTreeCascadeNode* ptr_;
|
||||
|
||||
ptr = *node;
|
||||
|
||||
while( ptr )
|
||||
{
|
||||
while( ptr->child ) ptr = ptr->child;
|
||||
|
||||
if( ptr->stage ) ptr->stage->release( (CvIntHaarClassifier**) &ptr->stage );
|
||||
ptr_ = ptr;
|
||||
|
||||
while( ptr && ptr->next == NULL ) ptr = ptr->parent;
|
||||
if( ptr ) ptr = ptr->next;
|
||||
|
||||
cvFree( &ptr_ );
|
||||
}
|
||||
}
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
|
||||
/* releases tree cascade classifier */
|
||||
|
||||
void icvReleaseTreeCascadeClassifier( CvIntHaarClassifier** classifier )
|
||||
{
|
||||
if( classifier && *classifier )
|
||||
{
|
||||
icvReleaseTreeCascadeNodes( &((CvTreeCascadeClassifier*) *classifier)->root );
|
||||
cvFree( classifier );
|
||||
*classifier = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void icvPrintTreeCascade( CvTreeCascadeNode* root )
|
||||
{
|
||||
//CV_FUNCNAME( "icvPrintTreeCascade" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
CvTreeCascadeNode* node;
|
||||
CvTreeCascadeNode* n;
|
||||
char buf0[256];
|
||||
char buf[256];
|
||||
int level;
|
||||
int i;
|
||||
int max_level;
|
||||
|
||||
node = root;
|
||||
level = max_level = 0;
|
||||
while( node )
|
||||
{
|
||||
while( node->child ) { node = node->child; level++; }
|
||||
if( level > max_level ) { max_level = level; }
|
||||
while( node && !node->next ) { node = node->parent; level--; }
|
||||
if( node ) node = node->next;
|
||||
}
|
||||
|
||||
printf( "\nTree Classifier\n" );
|
||||
printf( "Stage\n" );
|
||||
for( i = 0; i <= max_level; i++ ) printf( "+---" );
|
||||
printf( "+\n" );
|
||||
for( i = 0; i <= max_level; i++ ) printf( "|%3d", i );
|
||||
printf( "|\n" );
|
||||
for( i = 0; i <= max_level; i++ ) printf( "+---" );
|
||||
printf( "+\n\n" );
|
||||
|
||||
node = root;
|
||||
|
||||
buf[0] = 0;
|
||||
while( node )
|
||||
{
|
||||
sprintf( buf + strlen( buf ), "%3d", node->idx );
|
||||
while( node->child )
|
||||
{
|
||||
node = node->child;
|
||||
sprintf( buf + strlen( buf ),
|
||||
((node->idx < 10) ? "---%d" : ((node->idx < 100) ? "--%d" : "-%d")),
|
||||
node->idx );
|
||||
}
|
||||
printf( " %s\n", buf );
|
||||
|
||||
while( node && !node->next ) { node = node->parent; }
|
||||
if( node )
|
||||
{
|
||||
node = node->next;
|
||||
|
||||
n = node->parent;
|
||||
buf[0] = 0;
|
||||
while( n )
|
||||
{
|
||||
if( n->next )
|
||||
sprintf( buf0, " | %s", buf );
|
||||
else
|
||||
sprintf( buf0, " %s", buf );
|
||||
strcpy( buf, buf0 );
|
||||
n = n->parent;
|
||||
}
|
||||
printf( " %s |\n", buf );
|
||||
}
|
||||
}
|
||||
printf( "\n" );
|
||||
fflush( stdout );
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvLoadTreeCascadeClassifier( const char* filename, int step,
|
||||
int* splits )
|
||||
{
|
||||
CvTreeCascadeClassifier* ptr = NULL;
|
||||
CvTreeCascadeNode** nodes = NULL;
|
||||
|
||||
CV_FUNCNAME( "icvLoadTreeCascadeClassifier" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
size_t data_size;
|
||||
CvStageHaarClassifier* stage;
|
||||
char stage_name[PATH_MAX];
|
||||
char* suffix;
|
||||
int i, num;
|
||||
FILE* f;
|
||||
int result, parent=0, next=0;
|
||||
int stub;
|
||||
|
||||
if( !splits ) splits = &stub;
|
||||
|
||||
*splits = 0;
|
||||
|
||||
data_size = sizeof( *ptr );
|
||||
|
||||
CV_CALL( ptr = (CvTreeCascadeClassifier*) cvAlloc( data_size ) );
|
||||
memset( ptr, 0, data_size );
|
||||
|
||||
ptr->eval = icvEvalTreeCascadeClassifier;
|
||||
ptr->release = icvReleaseTreeCascadeClassifier;
|
||||
|
||||
sprintf( stage_name, "%s/", filename );
|
||||
suffix = stage_name + strlen( stage_name );
|
||||
|
||||
for( i = 0; ; i++ )
|
||||
{
|
||||
sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
|
||||
f = fopen( stage_name, "r" );
|
||||
if( !f ) break;
|
||||
fclose( f );
|
||||
}
|
||||
num = i;
|
||||
|
||||
if( num < 1 ) EXIT;
|
||||
|
||||
data_size = sizeof( *nodes ) * num;
|
||||
CV_CALL( nodes = (CvTreeCascadeNode**) cvAlloc( data_size ) );
|
||||
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
|
||||
f = fopen( stage_name, "r" );
|
||||
CV_CALL( stage = (CvStageHaarClassifier*)
|
||||
icvLoadCARTStageHaarClassifierF( f, step ) );
|
||||
|
||||
result = ( f && stage ) ? fscanf( f, "%d%d", &parent, &next ) : 0;
|
||||
if( f ) fclose( f );
|
||||
|
||||
if( result != 2 )
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
|
||||
printf( "Stage %d loaded\n", i );
|
||||
|
||||
if( parent >= i || (next != -1 && next != i + 1) )
|
||||
CV_ERROR( CV_StsError, "Invalid tree links" );
|
||||
|
||||
CV_CALL( nodes[i] = icvCreateTreeCascadeNode() );
|
||||
nodes[i]->stage = stage;
|
||||
nodes[i]->idx = i;
|
||||
nodes[i]->parent = (parent != -1 ) ? nodes[parent] : NULL;
|
||||
nodes[i]->next = ( next != -1 ) ? nodes[i] : NULL;
|
||||
nodes[i]->child = NULL;
|
||||
}
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
if( nodes[i]->next )
|
||||
{
|
||||
(*splits)++;
|
||||
nodes[i]->next = nodes[i+1];
|
||||
}
|
||||
if( nodes[i]->parent && nodes[i]->parent->child == NULL )
|
||||
{
|
||||
nodes[i]->parent->child = nodes[i];
|
||||
}
|
||||
}
|
||||
ptr->root = nodes[0];
|
||||
ptr->next_idx = num;
|
||||
|
||||
__END__;
|
||||
|
||||
cvFree( &nodes );
|
||||
|
||||
return (CvIntHaarClassifier*) ptr;
|
||||
}
|
||||
|
||||
|
||||
CvTreeCascadeNode* icvFindDeepestLeaves( CvTreeCascadeClassifier* tcc )
|
||||
{
|
||||
CvTreeCascadeNode* leaves;
|
||||
|
||||
//CV_FUNCNAME( "icvFindDeepestLeaves" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
int level, cur_level;
|
||||
CvTreeCascadeNode* ptr;
|
||||
CvTreeCascadeNode* last;
|
||||
|
||||
leaves = last = NULL;
|
||||
|
||||
ptr = tcc->root;
|
||||
level = -1;
|
||||
cur_level = 0;
|
||||
|
||||
/* find leaves with maximal level */
|
||||
while( ptr )
|
||||
{
|
||||
if( ptr->child ) { ptr = ptr->child; cur_level++; }
|
||||
else
|
||||
{
|
||||
if( cur_level == level )
|
||||
{
|
||||
last->next_same_level = ptr;
|
||||
ptr->next_same_level = NULL;
|
||||
last = ptr;
|
||||
}
|
||||
if( cur_level > level )
|
||||
{
|
||||
level = cur_level;
|
||||
leaves = last = ptr;
|
||||
ptr->next_same_level = NULL;
|
||||
}
|
||||
while( ptr && ptr->next == NULL ) { ptr = ptr->parent; cur_level--; }
|
||||
if( ptr ) ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
__END__;
|
||||
|
||||
return leaves;
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,192 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* cvhaartraining.h
|
||||
*
|
||||
* haar training functions
|
||||
*/
|
||||
|
||||
#ifndef _CVHAARTRAINING_H_
|
||||
#define _CVHAARTRAINING_H_
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamples
|
||||
*
|
||||
* Create training samples applying random distortions to sample image and
|
||||
* store them in .vec file
|
||||
*
|
||||
* filename - .vec file name
|
||||
* imgfilename - sample image file name
|
||||
* bgcolor - background color for sample image
|
||||
* bgthreshold - background color threshold. Pixels those colors are in range
|
||||
* [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent
|
||||
* bgfilename - background description file name. If not NULL samples
|
||||
* will be put on arbitrary background
|
||||
* count - desired number of samples
|
||||
* invert - if not 0 sample foreground pixels will be inverted
|
||||
* if invert == CV_RANDOM_INVERT then samples will be inverted randomly
|
||||
* maxintensitydev - desired max intensity deviation of foreground samples pixels
|
||||
* maxxangle - max rotation angles
|
||||
* maxyangle
|
||||
* maxzangle
|
||||
* showsamples - if not 0 samples will be shown
|
||||
* winwidth - desired samples width
|
||||
* winheight - desired samples height
|
||||
*/
|
||||
#define CV_RANDOM_INVERT 0x7FFFFFFF
|
||||
|
||||
void cvCreateTrainingSamples( const char* filename,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert = 0, int maxintensitydev = 40,
|
||||
double maxxangle = 1.1,
|
||||
double maxyangle = 1.1,
|
||||
double maxzangle = 0.5,
|
||||
int showsamples = 0,
|
||||
int winwidth = 24, int winheight = 24 );
|
||||
|
||||
void cvCreateTestSamples( const char* infoname,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
int winwidth, int winheight );
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamplesFromInfo
|
||||
*
|
||||
* Create training samples from a set of marked up images and store them into .vec file
|
||||
* infoname - file in which marked up image descriptions are stored
|
||||
* num - desired number of samples
|
||||
* showsamples - if not 0 samples will be shown
|
||||
* winwidth - sample width
|
||||
* winheight - sample height
|
||||
*
|
||||
* Return number of successfully created samples
|
||||
*/
|
||||
int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
|
||||
int num,
|
||||
int showsamples,
|
||||
int winwidth, int winheight );
|
||||
|
||||
/*
|
||||
* cvShowVecSamples
|
||||
*
|
||||
* Shows samples stored in .vec file
|
||||
*
|
||||
* filename
|
||||
* .vec file name
|
||||
* winwidth
|
||||
* sample width
|
||||
* winheight
|
||||
* sample height
|
||||
* scale
|
||||
* the scale each sample is adjusted to
|
||||
*/
|
||||
void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale );
|
||||
|
||||
|
||||
/*
|
||||
* cvCreateCascadeClassifier
|
||||
*
|
||||
* Create cascade classifier
|
||||
* dirname - directory name in which cascade classifier will be created.
|
||||
* It must exist and contain subdirectories 0, 1, 2, ... (nstages-1).
|
||||
* vecfilename - name of .vec file with object's images
|
||||
* bgfilename - name of background description file
|
||||
* bg_vecfile - true if bgfilename represents a vec file with discrete negatives
|
||||
* npos - number of positive samples used in training of each stage
|
||||
* nneg - number of negative samples used in training of each stage
|
||||
* nstages - number of stages
|
||||
* numprecalculated - number of features being precalculated. Each precalculated feature
|
||||
* requires (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory
|
||||
* numsplits - number of binary splits in each weak classifier
|
||||
* 1 - stumps, 2 and more - trees.
|
||||
* minhitrate - desired min hit rate of each stage
|
||||
* maxfalsealarm - desired max false alarm of each stage
|
||||
* weightfraction - weight trimming parameter
|
||||
* mode - 0 - BASIC = Viola
|
||||
* 1 - CORE = All upright
|
||||
* 2 - ALL = All features
|
||||
* symmetric - if not 0 vertical symmetry is assumed
|
||||
* equalweights - if not 0 initial weights of all samples will be equal
|
||||
* winwidth - sample width
|
||||
* winheight - sample height
|
||||
* boosttype - type of applied boosting algorithm
|
||||
* 0 - Discrete AdaBoost
|
||||
* 1 - Real AdaBoost
|
||||
* 2 - LogitBoost
|
||||
* 3 - Gentle AdaBoost
|
||||
* stumperror - type of used error if Discrete AdaBoost algorithm is applied
|
||||
* 0 - misclassification error
|
||||
* 1 - gini error
|
||||
* 2 - entropy error
|
||||
*/
|
||||
void cvCreateCascadeClassifier( const char* dirname,
|
||||
const char* vecfilename,
|
||||
const char* bgfilename,
|
||||
int npos, int nneg, int nstages,
|
||||
int numprecalculated,
|
||||
int numsplits,
|
||||
float minhitrate = 0.995F, float maxfalsealarm = 0.5F,
|
||||
float weightfraction = 0.95F,
|
||||
int mode = 0, int symmetric = 1,
|
||||
int equalweights = 1,
|
||||
int winwidth = 24, int winheight = 24,
|
||||
int boosttype = 3, int stumperror = 0 );
|
||||
|
||||
void cvCreateTreeCascadeClassifier( const char* dirname,
|
||||
const char* vecfilename,
|
||||
const char* bgfilename,
|
||||
int npos, int nneg, int nstages,
|
||||
int numprecalculated,
|
||||
int numsplits,
|
||||
float minhitrate, float maxfalsealarm,
|
||||
float weightfraction,
|
||||
int mode, int symmetric,
|
||||
int equalweights,
|
||||
int winwidth, int winheight,
|
||||
int boosttype, int stumperror,
|
||||
int maxtreesplits, int minpos, bool bg_vecfile = false );
|
||||
|
||||
#endif /* _CVHAARTRAINING_H_ */
|
||||
@@ -1,953 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* cvsamples.cpp
|
||||
*
|
||||
* support functions for training and test samples creation.
|
||||
*/
|
||||
|
||||
#include "cvhaartraining.h"
|
||||
#include "_cvhaartraining.h"
|
||||
|
||||
/* if ipl.h file is included then iplWarpPerspectiveQ function
|
||||
is used for image transformation during samples creation;
|
||||
otherwise internal cvWarpPerspective function is used */
|
||||
|
||||
//#include <ipl.h>
|
||||
|
||||
#include "cv.h"
|
||||
#include "highgui.h"
|
||||
|
||||
/* Calculates coefficients of perspective transformation
|
||||
* which maps <quad> into rectangle ((0,0), (w,0), (w,h), (h,0)):
|
||||
*
|
||||
* c00*xi + c01*yi + c02
|
||||
* ui = ---------------------
|
||||
* c20*xi + c21*yi + c22
|
||||
*
|
||||
* c10*xi + c11*yi + c12
|
||||
* vi = ---------------------
|
||||
* c20*xi + c21*yi + c22
|
||||
*
|
||||
* Coefficients are calculated by solving linear system:
|
||||
* / x0 y0 1 0 0 0 -x0*u0 -y0*u0 \ /c00\ /u0\
|
||||
* | x1 y1 1 0 0 0 -x1*u1 -y1*u1 | |c01| |u1|
|
||||
* | x2 y2 1 0 0 0 -x2*u2 -y2*u2 | |c02| |u2|
|
||||
* | x3 y3 1 0 0 0 -x3*u3 -y3*u3 |.|c10|=|u3|,
|
||||
* | 0 0 0 x0 y0 1 -x0*v0 -y0*v0 | |c11| |v0|
|
||||
* | 0 0 0 x1 y1 1 -x1*v1 -y1*v1 | |c12| |v1|
|
||||
* | 0 0 0 x2 y2 1 -x2*v2 -y2*v2 | |c20| |v2|
|
||||
* \ 0 0 0 x3 y3 1 -x3*v3 -y3*v3 / \c21/ \v3/
|
||||
*
|
||||
* where:
|
||||
* (xi, yi) = (quad[i][0], quad[i][1])
|
||||
* cij - coeffs[i][j], coeffs[2][2] = 1
|
||||
* (ui, vi) - rectangle vertices
|
||||
*/
|
||||
static void cvGetPerspectiveTransform( CvSize src_size, double quad[4][2],
|
||||
double coeffs[3][3] )
|
||||
{
|
||||
//CV_FUNCNAME( "cvWarpPerspective" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
double a[8][8];
|
||||
double b[8];
|
||||
|
||||
CvMat A = cvMat( 8, 8, CV_64FC1, a );
|
||||
CvMat B = cvMat( 8, 1, CV_64FC1, b );
|
||||
CvMat X = cvMat( 8, 1, CV_64FC1, coeffs );
|
||||
|
||||
int i;
|
||||
for( i = 0; i < 4; ++i )
|
||||
{
|
||||
a[i][0] = quad[i][0]; a[i][1] = quad[i][1]; a[i][2] = 1;
|
||||
a[i][3] = a[i][4] = a[i][5] = a[i][6] = a[i][7] = 0;
|
||||
b[i] = 0;
|
||||
}
|
||||
for( i = 4; i < 8; ++i )
|
||||
{
|
||||
a[i][3] = quad[i-4][0]; a[i][4] = quad[i-4][1]; a[i][5] = 1;
|
||||
a[i][0] = a[i][1] = a[i][2] = a[i][6] = a[i][7] = 0;
|
||||
b[i] = 0;
|
||||
}
|
||||
|
||||
int u = src_size.width - 1;
|
||||
int v = src_size.height - 1;
|
||||
|
||||
a[1][6] = -quad[1][0] * u; a[1][7] = -quad[1][1] * u;
|
||||
a[2][6] = -quad[2][0] * u; a[2][7] = -quad[2][1] * u;
|
||||
b[1] = b[2] = u;
|
||||
|
||||
a[6][6] = -quad[2][0] * v; a[6][7] = -quad[2][1] * v;
|
||||
a[7][6] = -quad[3][0] * v; a[7][7] = -quad[3][1] * v;
|
||||
b[6] = b[7] = v;
|
||||
|
||||
cvSolve( &A, &B, &X );
|
||||
|
||||
coeffs[2][2] = 1;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
/* Warps source into destination by a perspective transform */
|
||||
static void cvWarpPerspective( CvArr* src, CvArr* dst, double quad[4][2] )
|
||||
{
|
||||
CV_FUNCNAME( "cvWarpPerspective" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
#ifdef __IPL_H__
|
||||
IplImage src_stub, dst_stub;
|
||||
IplImage* src_img;
|
||||
IplImage* dst_img;
|
||||
CV_CALL( src_img = cvGetImage( src, &src_stub ) );
|
||||
CV_CALL( dst_img = cvGetImage( dst, &dst_stub ) );
|
||||
iplWarpPerspectiveQ( src_img, dst_img, quad, IPL_WARP_R_TO_Q,
|
||||
IPL_INTER_CUBIC | IPL_SMOOTH_EDGE );
|
||||
#else
|
||||
|
||||
int fill_value = 0;
|
||||
|
||||
double c[3][3]; /* transformation coefficients */
|
||||
double q[4][2]; /* rearranged quad */
|
||||
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int next_right = 0;
|
||||
int next_left = 0;
|
||||
double y_min = 0;
|
||||
double y_max = 0;
|
||||
double k_left, b_left, k_right, b_right;
|
||||
|
||||
uchar* src_data;
|
||||
int src_step;
|
||||
CvSize src_size;
|
||||
|
||||
uchar* dst_data;
|
||||
int dst_step;
|
||||
CvSize dst_size;
|
||||
|
||||
double d = 0;
|
||||
int direction = 0;
|
||||
int i;
|
||||
|
||||
if( !src || (!CV_IS_IMAGE( src ) && !CV_IS_MAT( src )) ||
|
||||
cvGetElemType( src ) != CV_8UC1 ||
|
||||
cvGetDims( src ) != 2 )
|
||||
{
|
||||
CV_ERROR( CV_StsBadArg,
|
||||
"Source must be two-dimensional array of CV_8UC1 type." );
|
||||
}
|
||||
if( !dst || (!CV_IS_IMAGE( dst ) && !CV_IS_MAT( dst )) ||
|
||||
cvGetElemType( dst ) != CV_8UC1 ||
|
||||
cvGetDims( dst ) != 2 )
|
||||
{
|
||||
CV_ERROR( CV_StsBadArg,
|
||||
"Destination must be two-dimensional array of CV_8UC1 type." );
|
||||
}
|
||||
|
||||
CV_CALL( cvGetRawData( src, &src_data, &src_step, &src_size ) );
|
||||
CV_CALL( cvGetRawData( dst, &dst_data, &dst_step, &dst_size ) );
|
||||
|
||||
CV_CALL( cvGetPerspectiveTransform( src_size, quad, c ) );
|
||||
|
||||
/* if direction > 0 then vertices in quad follow in a CW direction,
|
||||
otherwise they follow in a CCW direction */
|
||||
direction = 0;
|
||||
for( i = 0; i < 4; ++i )
|
||||
{
|
||||
int ni = i + 1; if( ni == 4 ) ni = 0;
|
||||
int pi = i - 1; if( pi == -1 ) pi = 3;
|
||||
|
||||
d = (quad[i][0] - quad[pi][0])*(quad[ni][1] - quad[i][1]) -
|
||||
(quad[i][1] - quad[pi][1])*(quad[ni][0] - quad[i][0]);
|
||||
int cur_direction = CV_SIGN(d);
|
||||
if( direction == 0 )
|
||||
{
|
||||
direction = cur_direction;
|
||||
}
|
||||
else if( direction * cur_direction < 0 )
|
||||
{
|
||||
direction = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( direction == 0 )
|
||||
{
|
||||
CV_ERROR( CV_StsBadArg, "Quadrangle is nonconvex or degenerated." );
|
||||
}
|
||||
|
||||
/* <left> is the index of the topmost quad vertice
|
||||
if there are two such vertices <left> is the leftmost one */
|
||||
left = 0;
|
||||
for( i = 1; i < 4; ++i )
|
||||
{
|
||||
if( (quad[i][1] < quad[left][1]) ||
|
||||
((quad[i][1] == quad[left][1]) && (quad[i][0] < quad[left][0])) )
|
||||
{
|
||||
left = i;
|
||||
}
|
||||
}
|
||||
/* rearrange <quad> vertices in such way that they follow in a CW
|
||||
direction and the first vertice is the topmost one and put them
|
||||
into <q> */
|
||||
if( direction > 0 )
|
||||
{
|
||||
for( i = left; i < 4; ++i )
|
||||
{
|
||||
q[i-left][0] = quad[i][0];
|
||||
q[i-left][1] = quad[i][1];
|
||||
}
|
||||
for( i = 0; i < left; ++i )
|
||||
{
|
||||
q[4-left+i][0] = quad[i][0];
|
||||
q[4-left+i][1] = quad[i][1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = left; i >= 0; --i )
|
||||
{
|
||||
q[left-i][0] = quad[i][0];
|
||||
q[left-i][1] = quad[i][1];
|
||||
}
|
||||
for( i = 3; i > left; --i )
|
||||
{
|
||||
q[4+left-i][0] = quad[i][0];
|
||||
q[4+left-i][1] = quad[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
left = right = 0;
|
||||
/* if there are two topmost points, <right> is the index of the rightmost one
|
||||
otherwise <right> */
|
||||
if( q[left][1] == q[left+1][1] )
|
||||
{
|
||||
right = 1;
|
||||
}
|
||||
|
||||
/* <next_left> follows <left> in a CCW direction */
|
||||
next_left = 3;
|
||||
/* <next_right> follows <right> in a CW direction */
|
||||
next_right = right + 1;
|
||||
|
||||
/* subtraction of 1 prevents skipping of the first row */
|
||||
y_min = q[left][1] - 1;
|
||||
|
||||
/* left edge equation: y = k_left * x + b_left */
|
||||
k_left = (q[left][0] - q[next_left][0]) /
|
||||
(q[left][1] - q[next_left][1]);
|
||||
b_left = (q[left][1] * q[next_left][0] -
|
||||
q[left][0] * q[next_left][1]) /
|
||||
(q[left][1] - q[next_left][1]);
|
||||
|
||||
/* right edge equation: y = k_right * x + b_right */
|
||||
k_right = (q[right][0] - q[next_right][0]) /
|
||||
(q[right][1] - q[next_right][1]);
|
||||
b_right = (q[right][1] * q[next_right][0] -
|
||||
q[right][0] * q[next_right][1]) /
|
||||
(q[right][1] - q[next_right][1]);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
y_max = MIN( q[next_left][1], q[next_right][1] );
|
||||
|
||||
int iy_min = MAX( cvRound(y_min), 0 ) + 1;
|
||||
int iy_max = MIN( cvRound(y_max), dst_size.height - 1 );
|
||||
|
||||
double x_min = k_left * iy_min + b_left;
|
||||
double x_max = k_right * iy_min + b_right;
|
||||
|
||||
/* walk through the destination quadrangle row by row */
|
||||
for( y = iy_min; y <= iy_max; ++y )
|
||||
{
|
||||
int ix_min = MAX( cvRound( x_min ), 0 );
|
||||
int ix_max = MIN( cvRound( x_max ), dst_size.width - 1 );
|
||||
|
||||
for( x = ix_min; x <= ix_max; ++x )
|
||||
{
|
||||
/* calculate coordinates of the corresponding source array point */
|
||||
double div = (c[2][0] * x + c[2][1] * y + c[2][2]);
|
||||
double src_x = (c[0][0] * x + c[0][1] * y + c[0][2]) / div;
|
||||
double src_y = (c[1][0] * x + c[1][1] * y + c[1][2]) / div;
|
||||
|
||||
int isrc_x = cvFloor( src_x );
|
||||
int isrc_y = cvFloor( src_y );
|
||||
double delta_x = src_x - isrc_x;
|
||||
double delta_y = src_y - isrc_y;
|
||||
|
||||
uchar* s = src_data + isrc_y * src_step + isrc_x;
|
||||
|
||||
int i00, i10, i01, i11;
|
||||
i00 = i10 = i01 = i11 = (int) fill_value;
|
||||
|
||||
/* linear interpolation using 2x2 neighborhood */
|
||||
if( isrc_x >= 0 && isrc_x <= src_size.width &&
|
||||
isrc_y >= 0 && isrc_y <= src_size.height )
|
||||
{
|
||||
i00 = s[0];
|
||||
}
|
||||
if( isrc_x >= -1 && isrc_x < src_size.width &&
|
||||
isrc_y >= 0 && isrc_y <= src_size.height )
|
||||
{
|
||||
i10 = s[1];
|
||||
}
|
||||
if( isrc_x >= 0 && isrc_x <= src_size.width &&
|
||||
isrc_y >= -1 && isrc_y < src_size.height )
|
||||
{
|
||||
i01 = s[src_step];
|
||||
}
|
||||
if( isrc_x >= -1 && isrc_x < src_size.width &&
|
||||
isrc_y >= -1 && isrc_y < src_size.height )
|
||||
{
|
||||
i11 = s[src_step+1];
|
||||
}
|
||||
|
||||
double i0 = i00 + (i10 - i00)*delta_x;
|
||||
double i1 = i01 + (i11 - i01)*delta_x;
|
||||
|
||||
((uchar*)(dst_data + y * dst_step))[x] = (uchar) (i0 + (i1 - i0)*delta_y);
|
||||
}
|
||||
x_min += k_left;
|
||||
x_max += k_right;
|
||||
}
|
||||
|
||||
if( (next_left == next_right) ||
|
||||
(next_left+1 == next_right && q[next_left][1] == q[next_right][1]) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if( y_max == q[next_left][1] )
|
||||
{
|
||||
left = next_left;
|
||||
next_left = left - 1;
|
||||
|
||||
k_left = (q[left][0] - q[next_left][0]) /
|
||||
(q[left][1] - q[next_left][1]);
|
||||
b_left = (q[left][1] * q[next_left][0] -
|
||||
q[left][0] * q[next_left][1]) /
|
||||
(q[left][1] - q[next_left][1]);
|
||||
}
|
||||
if( y_max == q[next_right][1] )
|
||||
{
|
||||
right = next_right;
|
||||
next_right = right + 1;
|
||||
|
||||
k_right = (q[right][0] - q[next_right][0]) /
|
||||
(q[right][1] - q[next_right][1]);
|
||||
b_right = (q[right][1] * q[next_right][0] -
|
||||
q[right][0] * q[next_right][1]) /
|
||||
(q[right][1] - q[next_right][1]);
|
||||
}
|
||||
y_min = y_max;
|
||||
}
|
||||
#endif /* #ifndef __IPL_H__ */
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
static
|
||||
void icvRandomQuad( int width, int height, double quad[4][2],
|
||||
double maxxangle,
|
||||
double maxyangle,
|
||||
double maxzangle )
|
||||
{
|
||||
double distfactor = 3.0;
|
||||
double distfactor2 = 1.0;
|
||||
|
||||
double halfw, halfh;
|
||||
int i;
|
||||
|
||||
double rotVectData[3];
|
||||
double vectData[3];
|
||||
double rotMatData[9];
|
||||
|
||||
CvMat rotVect;
|
||||
CvMat rotMat;
|
||||
CvMat vect;
|
||||
|
||||
double d;
|
||||
|
||||
rotVect = cvMat( 3, 1, CV_64FC1, &rotVectData[0] );
|
||||
rotMat = cvMat( 3, 3, CV_64FC1, &rotMatData[0] );
|
||||
vect = cvMat( 3, 1, CV_64FC1, &vectData[0] );
|
||||
|
||||
rotVectData[0] = maxxangle * (2.0 * rand() / RAND_MAX - 1.0);
|
||||
rotVectData[1] = ( maxyangle - fabs( rotVectData[0] ) )
|
||||
* (2.0 * rand() / RAND_MAX - 1.0);
|
||||
rotVectData[2] = maxzangle * (2.0 * rand() / RAND_MAX - 1.0);
|
||||
d = (distfactor + distfactor2 * (2.0 * rand() / RAND_MAX - 1.0)) * width;
|
||||
|
||||
/*
|
||||
rotVectData[0] = maxxangle;
|
||||
rotVectData[1] = maxyangle;
|
||||
rotVectData[2] = maxzangle;
|
||||
|
||||
d = distfactor * width;
|
||||
*/
|
||||
|
||||
cvRodrigues2( &rotVect, &rotMat );
|
||||
|
||||
halfw = 0.5 * width;
|
||||
halfh = 0.5 * height;
|
||||
|
||||
quad[0][0] = -halfw;
|
||||
quad[0][1] = -halfh;
|
||||
quad[1][0] = halfw;
|
||||
quad[1][1] = -halfh;
|
||||
quad[2][0] = halfw;
|
||||
quad[2][1] = halfh;
|
||||
quad[3][0] = -halfw;
|
||||
quad[3][1] = halfh;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
rotVectData[0] = quad[i][0];
|
||||
rotVectData[1] = quad[i][1];
|
||||
rotVectData[2] = 0.0;
|
||||
cvMatMulAdd( &rotMat, &rotVect, 0, &vect );
|
||||
quad[i][0] = vectData[0] * d / (d + vectData[2]) + halfw;
|
||||
quad[i][1] = vectData[1] * d / (d + vectData[2]) + halfh;
|
||||
|
||||
/*
|
||||
quad[i][0] += halfw;
|
||||
quad[i][1] += halfh;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int icvStartSampleDistortion( const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
CvSampleDistortionData* data )
|
||||
{
|
||||
memset( data, 0, sizeof( *data ) );
|
||||
data->src = cvLoadImage( imgfilename, 0 );
|
||||
if( data->src != NULL && data->src->nChannels == 1
|
||||
&& data->src->depth == IPL_DEPTH_8U )
|
||||
{
|
||||
int r, c;
|
||||
uchar* pmask;
|
||||
uchar* psrc;
|
||||
uchar* perode;
|
||||
uchar* pdilate;
|
||||
uchar dd, de;
|
||||
|
||||
data->dx = data->src->width / 2;
|
||||
data->dy = data->src->height / 2;
|
||||
data->bgcolor = bgcolor;
|
||||
|
||||
data->mask = cvCloneImage( data->src );
|
||||
data->erode = cvCloneImage( data->src );
|
||||
data->dilate = cvCloneImage( data->src );
|
||||
|
||||
/* make mask image */
|
||||
for( r = 0; r < data->mask->height; r++ )
|
||||
{
|
||||
for( c = 0; c < data->mask->width; c++ )
|
||||
{
|
||||
pmask = ( (uchar*) (data->mask->imageData + r * data->mask->widthStep)
|
||||
+ c );
|
||||
if( bgcolor - bgthreshold <= (int) (*pmask) &&
|
||||
(int) (*pmask) <= bgcolor + bgthreshold )
|
||||
{
|
||||
*pmask = (uchar) 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pmask = (uchar) 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* extend borders of source image */
|
||||
cvErode( data->src, data->erode, 0, 1 );
|
||||
cvDilate( data->src, data->dilate, 0, 1 );
|
||||
for( r = 0; r < data->mask->height; r++ )
|
||||
{
|
||||
for( c = 0; c < data->mask->width; c++ )
|
||||
{
|
||||
pmask = ( (uchar*) (data->mask->imageData + r * data->mask->widthStep)
|
||||
+ c );
|
||||
if( (*pmask) == 0 )
|
||||
{
|
||||
psrc = ( (uchar*) (data->src->imageData + r * data->src->widthStep)
|
||||
+ c );
|
||||
perode =
|
||||
( (uchar*) (data->erode->imageData + r * data->erode->widthStep)
|
||||
+ c );
|
||||
pdilate =
|
||||
( (uchar*)(data->dilate->imageData + r * data->dilate->widthStep)
|
||||
+ c );
|
||||
de = (uchar)(bgcolor - (*perode));
|
||||
dd = (uchar)((*pdilate) - bgcolor);
|
||||
if( de >= dd && de > bgthreshold )
|
||||
{
|
||||
(*psrc) = (*perode);
|
||||
}
|
||||
if( dd > de && dd > bgthreshold )
|
||||
{
|
||||
(*psrc) = (*pdilate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data->img = cvCreateImage( cvSize( data->src->width + 2 * data->dx,
|
||||
data->src->height + 2 * data->dy ),
|
||||
IPL_DEPTH_8U, 1 );
|
||||
data->maskimg = cvCloneImage( data->img );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icvPlaceDistortedSample( CvArr* background,
|
||||
int inverse, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int inscribe, double maxshiftf, double maxscalef,
|
||||
CvSampleDistortionData* data )
|
||||
{
|
||||
double quad[4][2];
|
||||
int r, c;
|
||||
uchar* pimg;
|
||||
uchar* pbg;
|
||||
uchar* palpha;
|
||||
uchar chartmp;
|
||||
int forecolordev;
|
||||
float scale;
|
||||
IplImage* img;
|
||||
IplImage* maskimg;
|
||||
CvMat stub;
|
||||
CvMat* bgimg;
|
||||
|
||||
CvRect cr;
|
||||
CvRect roi;
|
||||
|
||||
double xshift, yshift, randscale;
|
||||
|
||||
icvRandomQuad( data->src->width, data->src->height, quad,
|
||||
maxxangle, maxyangle, maxzangle );
|
||||
quad[0][0] += (double) data->dx;
|
||||
quad[0][1] += (double) data->dy;
|
||||
quad[1][0] += (double) data->dx;
|
||||
quad[1][1] += (double) data->dy;
|
||||
quad[2][0] += (double) data->dx;
|
||||
quad[2][1] += (double) data->dy;
|
||||
quad[3][0] += (double) data->dx;
|
||||
quad[3][1] += (double) data->dy;
|
||||
|
||||
cvSet( data->img, cvScalar( data->bgcolor ) );
|
||||
cvSet( data->maskimg, cvScalar( 0.0 ) );
|
||||
|
||||
cvWarpPerspective( data->src, data->img, quad );
|
||||
cvWarpPerspective( data->mask, data->maskimg, quad );
|
||||
|
||||
cvSmooth( data->maskimg, data->maskimg, CV_GAUSSIAN, 3, 3 );
|
||||
|
||||
bgimg = cvGetMat( background, &stub );
|
||||
|
||||
cr.x = data->dx;
|
||||
cr.y = data->dy;
|
||||
cr.width = data->src->width;
|
||||
cr.height = data->src->height;
|
||||
|
||||
if( inscribe )
|
||||
{
|
||||
/* quad's circumscribing rectangle */
|
||||
cr.x = (int) MIN( quad[0][0], quad[3][0] );
|
||||
cr.y = (int) MIN( quad[0][1], quad[1][1] );
|
||||
cr.width = (int) (MAX( quad[1][0], quad[2][0] ) + 0.5F ) - cr.x;
|
||||
cr.height = (int) (MAX( quad[2][1], quad[3][1] ) + 0.5F ) - cr.y;
|
||||
}
|
||||
|
||||
xshift = maxshiftf * rand() / RAND_MAX;
|
||||
yshift = maxshiftf * rand() / RAND_MAX;
|
||||
|
||||
cr.x -= (int) ( xshift * cr.width );
|
||||
cr.y -= (int) ( yshift * cr.height );
|
||||
cr.width = (int) ((1.0 + maxshiftf) * cr.width );
|
||||
cr.height = (int) ((1.0 + maxshiftf) * cr.height);
|
||||
|
||||
randscale = maxscalef * rand() / RAND_MAX;
|
||||
cr.x -= (int) ( 0.5 * randscale * cr.width );
|
||||
cr.y -= (int) ( 0.5 * randscale * cr.height );
|
||||
cr.width = (int) ((1.0 + randscale) * cr.width );
|
||||
cr.height = (int) ((1.0 + randscale) * cr.height);
|
||||
|
||||
scale = MAX( ((float) cr.width) / bgimg->cols, ((float) cr.height) / bgimg->rows );
|
||||
|
||||
roi.x = (int) (-0.5F * (scale * bgimg->cols - cr.width) + cr.x);
|
||||
roi.y = (int) (-0.5F * (scale * bgimg->rows - cr.height) + cr.y);
|
||||
roi.width = (int) (scale * bgimg->cols);
|
||||
roi.height = (int) (scale * bgimg->rows);
|
||||
|
||||
img = cvCreateImage( cvSize( bgimg->cols, bgimg->rows ), IPL_DEPTH_8U, 1 );
|
||||
maskimg = cvCreateImage( cvSize( bgimg->cols, bgimg->rows ), IPL_DEPTH_8U, 1 );
|
||||
|
||||
cvSetImageROI( data->img, roi );
|
||||
cvResize( data->img, img );
|
||||
cvResetImageROI( data->img );
|
||||
cvSetImageROI( data->maskimg, roi );
|
||||
cvResize( data->maskimg, maskimg );
|
||||
cvResetImageROI( data->maskimg );
|
||||
|
||||
forecolordev = (int) (maxintensitydev * (2.0 * rand() / RAND_MAX - 1.0));
|
||||
|
||||
for( r = 0; r < img->height; r++ )
|
||||
{
|
||||
for( c = 0; c < img->width; c++ )
|
||||
{
|
||||
pimg = (uchar*) img->imageData + r * img->widthStep + c;
|
||||
pbg = (uchar*) bgimg->data.ptr + r * bgimg->step + c;
|
||||
palpha = (uchar*) maskimg->imageData + r * maskimg->widthStep + c;
|
||||
chartmp = (uchar) MAX( 0, MIN( 255, forecolordev + (*pimg) ) );
|
||||
if( inverse )
|
||||
{
|
||||
chartmp ^= 0xFF;
|
||||
}
|
||||
*pbg = (uchar) (( chartmp*(*palpha )+(255 - (*palpha) )*(*pbg) ) / 255);
|
||||
}
|
||||
}
|
||||
|
||||
cvReleaseImage( &img );
|
||||
cvReleaseImage( &maskimg );
|
||||
}
|
||||
|
||||
void icvEndSampleDistortion( CvSampleDistortionData* data )
|
||||
{
|
||||
if( data->src )
|
||||
{
|
||||
cvReleaseImage( &data->src );
|
||||
}
|
||||
if( data->mask )
|
||||
{
|
||||
cvReleaseImage( &data->mask );
|
||||
}
|
||||
if( data->erode )
|
||||
{
|
||||
cvReleaseImage( &data->erode );
|
||||
}
|
||||
if( data->dilate )
|
||||
{
|
||||
cvReleaseImage( &data->dilate );
|
||||
}
|
||||
if( data->img )
|
||||
{
|
||||
cvReleaseImage( &data->img );
|
||||
}
|
||||
if( data->maskimg )
|
||||
{
|
||||
cvReleaseImage( &data->maskimg );
|
||||
}
|
||||
}
|
||||
|
||||
void icvWriteVecHeader( FILE* file, int count, int width, int height )
|
||||
{
|
||||
int vecsize;
|
||||
short tmp;
|
||||
|
||||
/* number of samples */
|
||||
fwrite( &count, sizeof( count ), 1, file );
|
||||
/* vector size */
|
||||
vecsize = width * height;
|
||||
fwrite( &vecsize, sizeof( vecsize ), 1, file );
|
||||
/* min/max values */
|
||||
tmp = 0;
|
||||
fwrite( &tmp, sizeof( tmp ), 1, file );
|
||||
fwrite( &tmp, sizeof( tmp ), 1, file );
|
||||
}
|
||||
|
||||
void icvWriteVecSample( FILE* file, CvArr* sample )
|
||||
{
|
||||
CvMat* mat, stub;
|
||||
int r, c;
|
||||
short tmp;
|
||||
uchar chartmp;
|
||||
|
||||
mat = cvGetMat( sample, &stub );
|
||||
chartmp = 0;
|
||||
fwrite( &chartmp, sizeof( chartmp ), 1, file );
|
||||
for( r = 0; r < mat->rows; r++ )
|
||||
{
|
||||
for( c = 0; c < mat->cols; c++ )
|
||||
{
|
||||
tmp = (short) (CV_MAT_ELEM( *mat, uchar, r, c ));
|
||||
fwrite( &tmp, sizeof( tmp ), 1, file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
|
||||
int num,
|
||||
int showsamples,
|
||||
int winwidth, int winheight )
|
||||
{
|
||||
char fullname[PATH_MAX];
|
||||
char* filename;
|
||||
|
||||
FILE* info;
|
||||
FILE* vec;
|
||||
IplImage* src=0;
|
||||
IplImage* sample;
|
||||
int line;
|
||||
int error;
|
||||
int i;
|
||||
int x, y, width, height;
|
||||
int total;
|
||||
|
||||
assert( infoname != NULL );
|
||||
assert( vecfilename != NULL );
|
||||
|
||||
total = 0;
|
||||
if( !icvMkDir( vecfilename ) )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", vecfilename );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
info = fopen( infoname, "r" );
|
||||
if( info == NULL )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to open file: %s\n", infoname );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
vec = fopen( vecfilename, "wb" );
|
||||
if( vec == NULL )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to open file: %s\n", vecfilename );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
fclose( info );
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
sample = cvCreateImage( cvSize( winwidth, winheight ), IPL_DEPTH_8U, 1 );
|
||||
|
||||
icvWriteVecHeader( vec, num, sample->width, sample->height );
|
||||
|
||||
if( showsamples )
|
||||
{
|
||||
cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
|
||||
}
|
||||
|
||||
strcpy( fullname, infoname );
|
||||
filename = strrchr( fullname, '\\' );
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = strrchr( fullname, '/' );
|
||||
}
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = fullname;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename++;
|
||||
}
|
||||
|
||||
for( line = 1, error = 0, total = 0; total < num ;line++ )
|
||||
{
|
||||
int count;
|
||||
|
||||
error = ( fscanf( info, "%s %d", filename, &count ) != 2 );
|
||||
if( !error )
|
||||
{
|
||||
src = cvLoadImage( fullname, 0 );
|
||||
error = ( src == NULL );
|
||||
if( error )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to open image: %s\n", fullname );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
}
|
||||
}
|
||||
for( i = 0; (i < count) && (total < num); i++, total++ )
|
||||
{
|
||||
error = ( fscanf( info, "%d %d %d %d", &x, &y, &width, &height ) != 4 );
|
||||
if( error ) break;
|
||||
cvSetImageROI( src, cvRect( x, y, width, height ) );
|
||||
cvResize( src, sample, width >= sample->width &&
|
||||
height >= sample->height ? CV_INTER_AREA : CV_INTER_LINEAR );
|
||||
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Sample", sample );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
}
|
||||
icvWriteVecSample( vec, sample );
|
||||
}
|
||||
|
||||
if( src )
|
||||
{
|
||||
cvReleaseImage( &src );
|
||||
}
|
||||
|
||||
if( error )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "%s(%d) : parse error", infoname, line );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( sample )
|
||||
{
|
||||
cvReleaseImage( &sample );
|
||||
}
|
||||
|
||||
fclose( vec );
|
||||
fclose( info );
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
void cvShowVecSamples( const char* filename, int winwidth, int winheight,
|
||||
double scale )
|
||||
{
|
||||
CvVecFile file;
|
||||
short tmp;
|
||||
int i;
|
||||
CvMat* sample;
|
||||
|
||||
tmp = 0;
|
||||
file.input = fopen( filename, "rb" );
|
||||
|
||||
if( file.input != NULL )
|
||||
{
|
||||
size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
|
||||
size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
|
||||
size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
|
||||
size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
|
||||
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
|
||||
|
||||
if( file.vecsize != winwidth * winheight )
|
||||
{
|
||||
int guessed_w = 0;
|
||||
int guessed_h = 0;
|
||||
|
||||
fprintf( stderr, "Warning: specified sample width=%d and height=%d "
|
||||
"does not correspond to .vec file vector size=%d.\n",
|
||||
winwidth, winheight, file.vecsize );
|
||||
if( file.vecsize > 0 )
|
||||
{
|
||||
guessed_w = cvFloor( sqrt( (float) file.vecsize ) );
|
||||
if( guessed_w > 0 )
|
||||
{
|
||||
guessed_h = file.vecsize / guessed_w;
|
||||
}
|
||||
}
|
||||
|
||||
if( guessed_w <= 0 || guessed_h <= 0 || guessed_w * guessed_h != file.vecsize)
|
||||
{
|
||||
fprintf( stderr, "Error: failed to guess sample width and height\n" );
|
||||
fclose( file.input );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
winwidth = guessed_w;
|
||||
winheight = guessed_h;
|
||||
fprintf( stderr, "Guessed width=%d, guessed height=%d\n",
|
||||
winwidth, winheight );
|
||||
}
|
||||
}
|
||||
|
||||
if( !feof( file.input ) && scale > 0 )
|
||||
{
|
||||
CvMat* scaled_sample = 0;
|
||||
|
||||
file.last = 0;
|
||||
file.vector = (short*) cvAlloc( sizeof( *file.vector ) * file.vecsize );
|
||||
sample = scaled_sample = cvCreateMat( winheight, winwidth, CV_8UC1 );
|
||||
if( scale != 1.0 )
|
||||
{
|
||||
scaled_sample = cvCreateMat( MAX( 1, cvCeil( scale * winheight ) ),
|
||||
MAX( 1, cvCeil( scale * winwidth ) ),
|
||||
CV_8UC1 );
|
||||
}
|
||||
cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
|
||||
for( i = 0; i < file.count; i++ )
|
||||
{
|
||||
icvGetHaarTraininDataFromVecCallback( sample, &file );
|
||||
if( scale != 1.0 ) cvResize( sample, scaled_sample, CV_INTER_LINEAR);
|
||||
cvShowImage( "Sample", scaled_sample );
|
||||
if( cvWaitKey( 0 ) == 27 ) break;
|
||||
}
|
||||
if( scaled_sample && scaled_sample != sample ) cvReleaseMat( &scaled_sample );
|
||||
cvReleaseMat( &sample );
|
||||
cvFree( &file.vector );
|
||||
}
|
||||
fclose( file.input );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file. */
|
||||
@@ -1,284 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* haartraining.cpp
|
||||
*
|
||||
* Train cascade classifier
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "cvhaartraining.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
int i = 0;
|
||||
char* nullname = (char*)"(NULL)";
|
||||
|
||||
char* vecname = NULL;
|
||||
char* dirname = NULL;
|
||||
char* bgname = NULL;
|
||||
|
||||
bool bg_vecfile = false;
|
||||
int npos = 2000;
|
||||
int nneg = 2000;
|
||||
int nstages = 14;
|
||||
int mem = 200;
|
||||
int nsplits = 1;
|
||||
float minhitrate = 0.995F;
|
||||
float maxfalsealarm = 0.5F;
|
||||
float weightfraction = 0.95F;
|
||||
int mode = 0;
|
||||
int symmetric = 1;
|
||||
int equalweights = 0;
|
||||
int width = 24;
|
||||
int height = 24;
|
||||
const char* boosttypes[] = { "DAB", "RAB", "LB", "GAB" };
|
||||
int boosttype = 3;
|
||||
const char* stumperrors[] = { "misclass", "gini", "entropy" };
|
||||
int stumperror = 0;
|
||||
int maxtreesplits = 0;
|
||||
int minpos = 500;
|
||||
|
||||
if( argc == 1 )
|
||||
{
|
||||
printf( "Usage: %s\n -data <dir_name>\n"
|
||||
" -vec <vec_file_name>\n"
|
||||
" -bg <background_file_name>\n"
|
||||
" [-bg-vecfile]\n"
|
||||
" [-npos <number_of_positive_samples = %d>]\n"
|
||||
" [-nneg <number_of_negative_samples = %d>]\n"
|
||||
" [-nstages <number_of_stages = %d>]\n"
|
||||
" [-nsplits <number_of_splits = %d>]\n"
|
||||
" [-mem <memory_in_MB = %d>]\n"
|
||||
" [-sym (default)] [-nonsym]\n"
|
||||
" [-minhitrate <min_hit_rate = %f>]\n"
|
||||
" [-maxfalsealarm <max_false_alarm_rate = %f>]\n"
|
||||
" [-weighttrimming <weight_trimming = %f>]\n"
|
||||
" [-eqw]\n"
|
||||
" [-mode <BASIC (default) | CORE | ALL>]\n"
|
||||
" [-w <sample_width = %d>]\n"
|
||||
" [-h <sample_height = %d>]\n"
|
||||
" [-bt <DAB | RAB | LB | GAB (default)>]\n"
|
||||
" [-err <misclass (default) | gini | entropy>]\n"
|
||||
" [-maxtreesplits <max_number_of_splits_in_tree_cascade = %d>]\n"
|
||||
" [-minpos <min_number_of_positive_samples_per_cluster = %d>]\n",
|
||||
argv[0], npos, nneg, nstages, nsplits, mem,
|
||||
minhitrate, maxfalsealarm, weightfraction, width, height,
|
||||
maxtreesplits, minpos );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
if( !strcmp( argv[i], "-data" ) )
|
||||
{
|
||||
dirname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-vec" ) )
|
||||
{
|
||||
vecname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bg" ) )
|
||||
{
|
||||
bgname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bg-vecfile" ) )
|
||||
{
|
||||
bg_vecfile = true;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-npos" ) )
|
||||
{
|
||||
npos = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-nneg" ) )
|
||||
{
|
||||
nneg = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-nstages" ) )
|
||||
{
|
||||
nstages = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-nsplits" ) )
|
||||
{
|
||||
nsplits = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-mem" ) )
|
||||
{
|
||||
mem = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-sym" ) )
|
||||
{
|
||||
symmetric = 1;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-nonsym" ) )
|
||||
{
|
||||
symmetric = 0;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-minhitrate" ) )
|
||||
{
|
||||
minhitrate = (float) atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxfalsealarm" ) )
|
||||
{
|
||||
maxfalsealarm = (float) atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-weighttrimming" ) )
|
||||
{
|
||||
weightfraction = (float) atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-eqw" ) )
|
||||
{
|
||||
equalweights = 1;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-mode" ) )
|
||||
{
|
||||
char* tmp = argv[++i];
|
||||
|
||||
if( !strcmp( tmp, "CORE" ) )
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
else if( !strcmp( tmp, "ALL" ) )
|
||||
{
|
||||
mode = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = 0;
|
||||
}
|
||||
}
|
||||
else if( !strcmp( argv[i], "-w" ) )
|
||||
{
|
||||
width = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-h" ) )
|
||||
{
|
||||
height = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-bt" ) )
|
||||
{
|
||||
i++;
|
||||
if( !strcmp( argv[i], boosttypes[0] ) )
|
||||
{
|
||||
boosttype = 0;
|
||||
}
|
||||
else if( !strcmp( argv[i], boosttypes[1] ) )
|
||||
{
|
||||
boosttype = 1;
|
||||
}
|
||||
else if( !strcmp( argv[i], boosttypes[2] ) )
|
||||
{
|
||||
boosttype = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
boosttype = 3;
|
||||
}
|
||||
}
|
||||
else if( !strcmp( argv[i], "-err" ) )
|
||||
{
|
||||
i++;
|
||||
if( !strcmp( argv[i], stumperrors[0] ) )
|
||||
{
|
||||
stumperror = 0;
|
||||
}
|
||||
else if( !strcmp( argv[i], stumperrors[1] ) )
|
||||
{
|
||||
stumperror = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stumperror = 2;
|
||||
}
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxtreesplits" ) )
|
||||
{
|
||||
maxtreesplits = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-minpos" ) )
|
||||
{
|
||||
minpos = atoi( argv[++i] );
|
||||
}
|
||||
}
|
||||
|
||||
printf( "Data dir name: %s\n", ((dirname == NULL) ? nullname : dirname ) );
|
||||
printf( "Vec file name: %s\n", ((vecname == NULL) ? nullname : vecname ) );
|
||||
printf( "BG file name: %s, is a vecfile: %s\n", ((bgname == NULL) ? nullname : bgname ), bg_vecfile ? "yes" : "no" );
|
||||
printf( "Num pos: %d\n", npos );
|
||||
printf( "Num neg: %d\n", nneg );
|
||||
printf( "Num stages: %d\n", nstages );
|
||||
printf( "Num splits: %d (%s as weak classifier)\n", nsplits,
|
||||
(nsplits == 1) ? "stump" : "tree" );
|
||||
printf( "Mem: %d MB\n", mem );
|
||||
printf( "Symmetric: %s\n", (symmetric) ? "TRUE" : "FALSE" );
|
||||
printf( "Min hit rate: %f\n", minhitrate );
|
||||
printf( "Max false alarm rate: %f\n", maxfalsealarm );
|
||||
printf( "Weight trimming: %f\n", weightfraction );
|
||||
printf( "Equal weights: %s\n", (equalweights) ? "TRUE" : "FALSE" );
|
||||
printf( "Mode: %s\n", ( (mode == 0) ? "BASIC" : ( (mode == 1) ? "CORE" : "ALL") ) );
|
||||
printf( "Width: %d\n", width );
|
||||
printf( "Height: %d\n", height );
|
||||
//printf( "Max num of precalculated features: %d\n", numprecalculated );
|
||||
printf( "Applied boosting algorithm: %s\n", boosttypes[boosttype] );
|
||||
printf( "Error (valid only for Discrete and Real AdaBoost): %s\n",
|
||||
stumperrors[stumperror] );
|
||||
|
||||
printf( "Max number of splits in tree cascade: %d\n", maxtreesplits );
|
||||
printf( "Min number of positive samples per cluster: %d\n", minpos );
|
||||
|
||||
cvCreateTreeCascadeClassifier( dirname, vecname, bgname,
|
||||
npos, nneg, nstages, mem,
|
||||
nsplits,
|
||||
minhitrate, maxfalsealarm, weightfraction,
|
||||
mode, symmetric,
|
||||
equalweights, width, height,
|
||||
boosttype, stumperror,
|
||||
maxtreesplits, minpos, bg_vecfile );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,377 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
/*
|
||||
* performance.cpp
|
||||
*
|
||||
* Measure performance of classifier
|
||||
*/
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#include "cv.h"
|
||||
#include "highgui.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* use clock() function insted of time() */
|
||||
#define time( arg ) (((double) clock()) / CLOCKS_PER_SEC)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 512
|
||||
#endif /* PATH_MAX */
|
||||
|
||||
typedef struct HidCascade
|
||||
{
|
||||
int size;
|
||||
int count;
|
||||
} HidCascade;
|
||||
|
||||
typedef struct ObjectPos
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
int found; /* for reference */
|
||||
int neghbors;
|
||||
} ObjectPos;
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
int i, j;
|
||||
char* classifierdir = NULL;
|
||||
//char* samplesdir = NULL;
|
||||
|
||||
int saveDetected = 1;
|
||||
double scale_factor = 1.2;
|
||||
float maxSizeDiff = 1.5F;
|
||||
float maxPosDiff = 0.3F;
|
||||
|
||||
/* number of stages. if <=0 all stages are used */
|
||||
int nos = -1, nos0;
|
||||
|
||||
int width = 24;
|
||||
int height = 24;
|
||||
|
||||
int rocsize;
|
||||
|
||||
FILE* info;
|
||||
char* infoname;
|
||||
char fullname[PATH_MAX];
|
||||
char detfilename[PATH_MAX];
|
||||
char* filename;
|
||||
char detname[] = "det-";
|
||||
|
||||
CvHaarClassifierCascade* cascade;
|
||||
CvMemStorage* storage;
|
||||
CvSeq* objects;
|
||||
|
||||
double totaltime;
|
||||
|
||||
infoname = (char*)"";
|
||||
rocsize = 40;
|
||||
if( argc == 1 )
|
||||
{
|
||||
printf( "Usage: %s\n -data <classifier_directory_name>\n"
|
||||
" -info <collection_file_name>\n"
|
||||
" [-maxSizeDiff <max_size_difference = %f>]\n"
|
||||
" [-maxPosDiff <max_position_difference = %f>]\n"
|
||||
" [-sf <scale_factor = %f>]\n"
|
||||
" [-ni]\n"
|
||||
" [-nos <number_of_stages = %d>]\n"
|
||||
" [-rs <roc_size = %d>]\n"
|
||||
" [-w <sample_width = %d>]\n"
|
||||
" [-h <sample_height = %d>]\n",
|
||||
argv[0], maxSizeDiff, maxPosDiff, scale_factor, nos, rocsize,
|
||||
width, height );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
if( !strcmp( argv[i], "-data" ) )
|
||||
{
|
||||
classifierdir = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-info" ) )
|
||||
{
|
||||
infoname = argv[++i];
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxSizeDiff" ) )
|
||||
{
|
||||
maxSizeDiff = (float) atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-maxPosDiff" ) )
|
||||
{
|
||||
maxPosDiff = (float) atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-sf" ) )
|
||||
{
|
||||
scale_factor = atof( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-ni" ) )
|
||||
{
|
||||
saveDetected = 0;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-nos" ) )
|
||||
{
|
||||
nos = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-rs" ) )
|
||||
{
|
||||
rocsize = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-w" ) )
|
||||
{
|
||||
width = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-h" ) )
|
||||
{
|
||||
height = atoi( argv[++i] );
|
||||
}
|
||||
}
|
||||
|
||||
cascade = cvLoadHaarClassifierCascade( classifierdir, cvSize( width, height ) );
|
||||
if( cascade == NULL )
|
||||
{
|
||||
printf( "Unable to load classifier from %s\n", classifierdir );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int* numclassifiers = new int[cascade->count];
|
||||
numclassifiers[0] = cascade->stage_classifier[0].count;
|
||||
for( i = 1; i < cascade->count; i++ )
|
||||
{
|
||||
numclassifiers[i] = numclassifiers[i-1] + cascade->stage_classifier[i].count;
|
||||
}
|
||||
|
||||
storage = cvCreateMemStorage();
|
||||
|
||||
nos0 = cascade->count;
|
||||
if( nos <= 0 )
|
||||
nos = nos0;
|
||||
|
||||
strcpy( fullname, infoname );
|
||||
filename = strrchr( fullname, '\\' );
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = strrchr( fullname, '/' );
|
||||
}
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = fullname;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename++;
|
||||
}
|
||||
|
||||
info = fopen( infoname, "r" );
|
||||
totaltime = 0.0;
|
||||
if( info != NULL )
|
||||
{
|
||||
int x, y;
|
||||
IplImage* img;
|
||||
int hits, missed, falseAlarms;
|
||||
int totalHits, totalMissed, totalFalseAlarms;
|
||||
int found;
|
||||
float distance;
|
||||
|
||||
int refcount;
|
||||
ObjectPos* ref;
|
||||
int detcount;
|
||||
ObjectPos* det;
|
||||
int error=0;
|
||||
|
||||
int* pos;
|
||||
int* neg;
|
||||
|
||||
pos = (int*) cvAlloc( rocsize * sizeof( *pos ) );
|
||||
neg = (int*) cvAlloc( rocsize * sizeof( *neg ) );
|
||||
for( i = 0; i < rocsize; i++ ) { pos[i] = neg[i] = 0; }
|
||||
|
||||
printf( "+================================+======+======+======+\n" );
|
||||
printf( "| File Name | Hits |Missed| False|\n" );
|
||||
printf( "+================================+======+======+======+\n" );
|
||||
|
||||
totalHits = totalMissed = totalFalseAlarms = 0;
|
||||
while( !feof( info ) )
|
||||
{
|
||||
if( fscanf( info, "%s %d", filename, &refcount ) != 2 || refcount <= 0 ) break;
|
||||
|
||||
img = cvLoadImage( fullname );
|
||||
if( !img ) continue;
|
||||
|
||||
ref = (ObjectPos*) cvAlloc( refcount * sizeof( *ref ) );
|
||||
for( i = 0; i < refcount; i++ )
|
||||
{
|
||||
int w, h;
|
||||
error = (fscanf( info, "%d %d %d %d", &x, &y, &w, &h ) != 4);
|
||||
if( error ) break;
|
||||
ref[i].x = 0.5F * w + x;
|
||||
ref[i].y = 0.5F * h + y;
|
||||
ref[i].width = sqrtf( 0.5F * (w * w + h * h) );
|
||||
ref[i].found = 0;
|
||||
ref[i].neghbors = 0;
|
||||
}
|
||||
if( !error )
|
||||
{
|
||||
cvClearMemStorage( storage );
|
||||
|
||||
cascade->count = nos;
|
||||
totaltime -= time( 0 );
|
||||
objects = cvHaarDetectObjects( img, cascade, storage, scale_factor, 1 );
|
||||
totaltime += time( 0 );
|
||||
cascade->count = nos0;
|
||||
|
||||
detcount = ( objects ? objects->total : 0);
|
||||
det = (detcount > 0) ?
|
||||
( (ObjectPos*)cvAlloc( detcount * sizeof( *det )) ) : NULL;
|
||||
hits = missed = falseAlarms = 0;
|
||||
for( i = 0; i < detcount; i++ )
|
||||
{
|
||||
CvAvgComp r = *((CvAvgComp*) cvGetSeqElem( objects, i ));
|
||||
det[i].x = 0.5F * r.rect.width + r.rect.x;
|
||||
det[i].y = 0.5F * r.rect.height + r.rect.y;
|
||||
det[i].width = sqrtf( 0.5F * (r.rect.width * r.rect.width +
|
||||
r.rect.height * r.rect.height) );
|
||||
det[i].neghbors = r.neighbors;
|
||||
|
||||
if( saveDetected )
|
||||
{
|
||||
cvRectangle( img, cvPoint( r.rect.x, r.rect.y ),
|
||||
cvPoint( r.rect.x + r.rect.width, r.rect.y + r.rect.height ),
|
||||
CV_RGB( 255, 0, 0 ), 3 );
|
||||
}
|
||||
|
||||
found = 0;
|
||||
for( j = 0; j < refcount; j++ )
|
||||
{
|
||||
distance = sqrtf( (det[i].x - ref[j].x) * (det[i].x - ref[j].x) +
|
||||
(det[i].y - ref[j].y) * (det[i].y - ref[j].y) );
|
||||
if( (distance < ref[j].width * maxPosDiff) &&
|
||||
(det[i].width > ref[j].width / maxSizeDiff) &&
|
||||
(det[i].width < ref[j].width * maxSizeDiff) )
|
||||
{
|
||||
ref[j].found = 1;
|
||||
ref[j].neghbors = MAX( ref[j].neghbors, det[i].neghbors );
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if( !found )
|
||||
{
|
||||
falseAlarms++;
|
||||
neg[MIN(det[i].neghbors, rocsize - 1)]++;
|
||||
}
|
||||
}
|
||||
for( j = 0; j < refcount; j++ )
|
||||
{
|
||||
if( ref[j].found )
|
||||
{
|
||||
hits++;
|
||||
pos[MIN(ref[j].neghbors, rocsize - 1)]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
missed++;
|
||||
}
|
||||
}
|
||||
|
||||
totalHits += hits;
|
||||
totalMissed += missed;
|
||||
totalFalseAlarms += falseAlarms;
|
||||
printf( "|%32.32s|%6d|%6d|%6d|\n", filename, hits, missed, falseAlarms );
|
||||
printf( "+--------------------------------+------+------+------+\n" );
|
||||
fflush( stdout );
|
||||
|
||||
if( saveDetected )
|
||||
{
|
||||
strcpy( detfilename, detname );
|
||||
strcat( detfilename, filename );
|
||||
strcpy( filename, detfilename );
|
||||
cvvSaveImage( fullname, img );
|
||||
}
|
||||
|
||||
if( det ) { cvFree( &det ); det = NULL; }
|
||||
} /* if( !error ) */
|
||||
|
||||
cvReleaseImage( &img );
|
||||
cvFree( &ref );
|
||||
}
|
||||
fclose( info );
|
||||
|
||||
printf( "|%32.32s|%6d|%6d|%6d|\n", "Total",
|
||||
totalHits, totalMissed, totalFalseAlarms );
|
||||
printf( "+================================+======+======+======+\n" );
|
||||
printf( "Number of stages: %d\n", nos );
|
||||
printf( "Number of weak classifiers: %d\n", numclassifiers[nos - 1] );
|
||||
printf( "Total time: %f\n", totaltime );
|
||||
|
||||
/* print ROC to stdout */
|
||||
for( i = rocsize - 1; i > 0; i-- )
|
||||
{
|
||||
pos[i-1] += pos[i];
|
||||
neg[i-1] += neg[i];
|
||||
}
|
||||
fprintf( stderr, "%d\n", nos );
|
||||
for( i = 0; i < rocsize; i++ )
|
||||
{
|
||||
fprintf( stderr, "\t%d\t%d\t%f\t%f\n", pos[i], neg[i],
|
||||
((float)pos[i]) / (totalHits + totalMissed),
|
||||
((float)neg[i]) / (totalHits + totalMissed) );
|
||||
}
|
||||
|
||||
cvFree( &pos );
|
||||
cvFree( &neg );
|
||||
}
|
||||
|
||||
delete[] numclassifiers;
|
||||
|
||||
cvReleaseHaarClassifierCascade( &cascade );
|
||||
cvReleaseMemStorage( &storage );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
set(name sft)
|
||||
set(the_target opencv_${name})
|
||||
|
||||
set(OPENCV_${the_target}_DEPS opencv_core opencv_softcascade opencv_highgui opencv_imgproc opencv_ml)
|
||||
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
|
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(${the_target})
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${OpenCV_SOURCE_DIR}/include/opencv")
|
||||
ocv_include_modules(${OPENCV_${the_target}_DEPS})
|
||||
|
||||
file(GLOB ${the_target}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
|
||||
add_executable(${the_target} ${${the_target}_SOURCES})
|
||||
|
||||
target_link_libraries(${the_target} ${OPENCV_${the_target}_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||
INSTALL_NAME_DIR lib
|
||||
OUTPUT_NAME "opencv_trainsoftcascade")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
|
||||
endif()
|
||||
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
|
||||
@@ -1,162 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <sft/config.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
sft::Config::Config(): seed(0) {}
|
||||
|
||||
void sft::Config::write(cv::FileStorage& fs) const
|
||||
{
|
||||
fs << "{"
|
||||
<< "trainPath" << trainPath
|
||||
<< "testPath" << testPath
|
||||
|
||||
<< "modelWinSize" << modelWinSize
|
||||
<< "offset" << offset
|
||||
<< "octaves" << octaves
|
||||
|
||||
<< "positives" << positives
|
||||
<< "negatives" << negatives
|
||||
<< "btpNegatives" << btpNegatives
|
||||
|
||||
<< "shrinkage" << shrinkage
|
||||
|
||||
<< "treeDepth" << treeDepth
|
||||
<< "weaks" << weaks
|
||||
<< "poolSize" << poolSize
|
||||
|
||||
<< "cascadeName" << cascadeName
|
||||
<< "outXmlPath" << outXmlPath
|
||||
|
||||
<< "seed" << seed
|
||||
<< "featureType" << featureType
|
||||
<< "}";
|
||||
}
|
||||
|
||||
void sft::Config::read(const cv::FileNode& node)
|
||||
{
|
||||
trainPath = (string)node["trainPath"];
|
||||
testPath = (string)node["testPath"];
|
||||
|
||||
cv::FileNodeIterator nIt = node["modelWinSize"].end();
|
||||
modelWinSize = cv::Size((int)*(--nIt), (int)*(--nIt));
|
||||
|
||||
nIt = node["offset"].end();
|
||||
offset = cv::Point2i((int)*(--nIt), (int)*(--nIt));
|
||||
|
||||
node["octaves"] >> octaves;
|
||||
|
||||
positives = (int)node["positives"];
|
||||
negatives = (int)node["negatives"];
|
||||
btpNegatives = (int)node["btpNegatives"];
|
||||
|
||||
shrinkage = (int)node["shrinkage"];
|
||||
|
||||
treeDepth = (int)node["treeDepth"];
|
||||
weaks = (int)node["weaks"];
|
||||
poolSize = (int)node["poolSize"];
|
||||
|
||||
cascadeName = (std::string)node["cascadeName"];
|
||||
outXmlPath = (std::string)node["outXmlPath"];
|
||||
|
||||
seed = (int)node["seed"];
|
||||
featureType = (std::string)node["featureType"];
|
||||
}
|
||||
|
||||
void sft::write(cv::FileStorage& fs, const string&, const Config& x)
|
||||
{
|
||||
x.write(fs);
|
||||
}
|
||||
|
||||
void sft::read(const cv::FileNode& node, Config& x, const Config& default_value)
|
||||
{
|
||||
x = default_value;
|
||||
|
||||
if(!node.empty())
|
||||
x.read(node);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct Out
|
||||
{
|
||||
Out(std::ostream& _out): out(_out) {}
|
||||
template<typename T>
|
||||
void operator ()(const T a) const {out << a << " ";}
|
||||
|
||||
std::ostream& out;
|
||||
private:
|
||||
Out& operator=(Out const& other);
|
||||
};
|
||||
}
|
||||
|
||||
std::ostream& sft::operator<<(std::ostream& out, const Config& m)
|
||||
{
|
||||
out << std::setw(14) << std::left << "trainPath" << m.trainPath << std::endl
|
||||
<< std::setw(14) << std::left << "testPath" << m.testPath << std::endl
|
||||
|
||||
<< std::setw(14) << std::left << "modelWinSize" << m.modelWinSize << std::endl
|
||||
<< std::setw(14) << std::left << "offset" << m.offset << std::endl
|
||||
<< std::setw(14) << std::left << "octaves";
|
||||
|
||||
Out o(out);
|
||||
for_each(m.octaves.begin(), m.octaves.end(), o);
|
||||
|
||||
out << std::endl
|
||||
<< std::setw(14) << std::left << "positives" << m.positives << std::endl
|
||||
<< std::setw(14) << std::left << "negatives" << m.negatives << std::endl
|
||||
<< std::setw(14) << std::left << "btpNegatives" << m.btpNegatives << std::endl
|
||||
|
||||
<< std::setw(14) << std::left << "shrinkage" << m.shrinkage << std::endl
|
||||
|
||||
<< std::setw(14) << std::left << "treeDepth" << m.treeDepth << std::endl
|
||||
<< std::setw(14) << std::left << "weaks" << m.weaks << std::endl
|
||||
<< std::setw(14) << std::left << "poolSize" << m.poolSize << std::endl
|
||||
|
||||
<< std::setw(14) << std::left << "cascadeName" << m.cascadeName << std::endl
|
||||
<< std::setw(14) << std::left << "outXmlPath" << m.outXmlPath << std::endl
|
||||
<< std::setw(14) << std::left << "seed" << m.seed << std::endl
|
||||
<< std::setw(14) << std::left << "featureType" << m.featureType << std::endl;
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <sft/dataset.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
// in the default case data folders should be aligned as following:
|
||||
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
|
||||
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
|
||||
sft::ScaledDataset::ScaledDataset(const string& path, const int oct)
|
||||
{
|
||||
dprintf("%s\n", "get dataset file names...");
|
||||
dprintf("%s\n", "Positives globing...");
|
||||
cv::glob(path + "/pos/octave_" + cv::format("%d", oct) + "/*.png", pos);
|
||||
|
||||
dprintf("%s\n", "Negatives globing...");
|
||||
cv::glob(path + "/neg/octave_" + cv::format("%d", oct) + "/*.png", neg);
|
||||
|
||||
// Check: files not empty
|
||||
CV_Assert(pos.size() != size_t(0));
|
||||
CV_Assert(neg.size() != size_t(0));
|
||||
}
|
||||
|
||||
cv::Mat sft::ScaledDataset::get(SampleType type, int idx) const
|
||||
{
|
||||
const std::string& src = (type == POSITIVE)? pos[idx]: neg[idx];
|
||||
return cv::imread(src);
|
||||
}
|
||||
|
||||
int sft::ScaledDataset::available(SampleType type) const
|
||||
{
|
||||
return (int)((type == POSITIVE)? pos.size():neg.size());
|
||||
}
|
||||
|
||||
sft::ScaledDataset::~ScaledDataset(){}
|
||||
@@ -1,138 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __SFT_CONFIG_HPP__
|
||||
#define __SFT_CONFIG_HPP__
|
||||
|
||||
#include <sft/common.hpp>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace sft {
|
||||
|
||||
struct Config
|
||||
{
|
||||
Config();
|
||||
|
||||
void write(cv::FileStorage& fs) const;
|
||||
|
||||
void read(const cv::FileNode& node);
|
||||
|
||||
// Scaled and shrunk model size.
|
||||
cv::Size model(ivector::const_iterator it) const
|
||||
{
|
||||
float octave = powf(2.f, (float)(*it));
|
||||
return cv::Size( cvRound(modelWinSize.width * octave) / shrinkage,
|
||||
cvRound(modelWinSize.height * octave) / shrinkage );
|
||||
}
|
||||
|
||||
// Scaled but, not shrunk bounding box for object in sample image.
|
||||
cv::Rect bbox(ivector::const_iterator it) const
|
||||
{
|
||||
float octave = powf(2.f, (float)(*it));
|
||||
return cv::Rect( cvRound(offset.x * octave), cvRound(offset.y * octave),
|
||||
cvRound(modelWinSize.width * octave), cvRound(modelWinSize.height * octave));
|
||||
}
|
||||
|
||||
string resPath(ivector::const_iterator it) const
|
||||
{
|
||||
return cv::format("%s%d.xml",cascadeName.c_str(), *it);
|
||||
}
|
||||
|
||||
// Paths to a rescaled data
|
||||
string trainPath;
|
||||
string testPath;
|
||||
|
||||
// Original model size.
|
||||
cv::Size modelWinSize;
|
||||
|
||||
// example offset into positive image
|
||||
cv::Point2i offset;
|
||||
|
||||
// List of octaves for which have to be trained cascades (a list of powers of two)
|
||||
ivector octaves;
|
||||
|
||||
// Maximum number of positives that should be used during training
|
||||
int positives;
|
||||
|
||||
// Initial number of negatives used during training.
|
||||
int negatives;
|
||||
|
||||
// Number of weak negatives to add each bootstrapping step.
|
||||
int btpNegatives;
|
||||
|
||||
// Inverse of scale for feature resizing
|
||||
int shrinkage;
|
||||
|
||||
// Depth on weak classifier's decision tree
|
||||
int treeDepth;
|
||||
|
||||
// Weak classifiers number in resulted cascade
|
||||
int weaks;
|
||||
|
||||
// Feature random pool size
|
||||
int poolSize;
|
||||
|
||||
// file name to store cascade
|
||||
string cascadeName;
|
||||
|
||||
// path to resulting cascade
|
||||
string outXmlPath;
|
||||
|
||||
// seed for random generation
|
||||
int seed;
|
||||
|
||||
// channel feature type
|
||||
string featureType;
|
||||
|
||||
// // bounding rectangle for actual example into example window
|
||||
// cv::Rect exampleWindow;
|
||||
};
|
||||
|
||||
// required for cv::FileStorage serialization
|
||||
void write(cv::FileStorage& fs, const string&, const Config& x);
|
||||
void read(const cv::FileNode& node, Config& x, const Config& default_value);
|
||||
std::ostream& operator<<(std::ostream& out, const Config& m);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,67 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __SFT_OCTAVE_HPP__
|
||||
#define __SFT_OCTAVE_HPP__
|
||||
|
||||
#include <sft/common.hpp>
|
||||
namespace sft
|
||||
{
|
||||
|
||||
using cv::softcascade::Dataset;
|
||||
|
||||
class ScaledDataset : public Dataset
|
||||
{
|
||||
public:
|
||||
ScaledDataset(const sft::string& path, const int octave);
|
||||
|
||||
virtual cv::Mat get(SampleType type, int idx) const;
|
||||
virtual int available(SampleType type) const;
|
||||
virtual ~ScaledDataset();
|
||||
|
||||
private:
|
||||
svector pos;
|
||||
svector neg;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,168 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
// Training application for Soft Cascades.
|
||||
|
||||
#include <sft/common.hpp>
|
||||
#include <iostream>
|
||||
#include <sft/dataset.hpp>
|
||||
#include <sft/config.hpp>
|
||||
|
||||
#include <opencv2/core/core_c.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace sft;
|
||||
|
||||
const string keys =
|
||||
"{help h usage ? | | print this message }"
|
||||
"{config c | | path to configuration xml }"
|
||||
;
|
||||
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
parser.about("Soft cascade training application.");
|
||||
|
||||
if (parser.has("help"))
|
||||
{
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!parser.check())
|
||||
{
|
||||
parser.printErrors();
|
||||
return 1;
|
||||
}
|
||||
|
||||
string configPath = parser.get<string>("config");
|
||||
if (configPath.empty())
|
||||
{
|
||||
std::cout << "Configuration file is missing or empty. Could not start training." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "Read configuration from file " << configPath << std::endl;
|
||||
cv::FileStorage fs(configPath, cv::FileStorage::READ);
|
||||
if(!fs.isOpened())
|
||||
{
|
||||
std::cout << "Configuration file " << configPath << " can't be opened." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 1. load config
|
||||
sft::Config cfg;
|
||||
fs["config"] >> cfg;
|
||||
std::cout << std::endl << "Training will be executed for configuration:" << std::endl << cfg << std::endl;
|
||||
|
||||
// 2. check and open output file
|
||||
cv::FileStorage fso(cfg.outXmlPath, cv::FileStorage::WRITE);
|
||||
if(!fso.isOpened())
|
||||
{
|
||||
std::cout << "Training stopped. Output classifier Xml file " << cfg.outXmlPath << " can't be opened." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
fso << cfg.cascadeName
|
||||
<< "{"
|
||||
<< "stageType" << "BOOST"
|
||||
<< "featureType" << cfg.featureType
|
||||
<< "octavesNum" << (int)cfg.octaves.size()
|
||||
<< "width" << cfg.modelWinSize.width
|
||||
<< "height" << cfg.modelWinSize.height
|
||||
<< "shrinkage" << cfg.shrinkage
|
||||
<< "octaves" << "[";
|
||||
|
||||
// 3. Train all octaves
|
||||
for (ivector::const_iterator it = cfg.octaves.begin(); it != cfg.octaves.end(); ++it)
|
||||
{
|
||||
// a. create random feature pool
|
||||
int nfeatures = cfg.poolSize;
|
||||
cv::Size model = cfg.model(it);
|
||||
std::cout << "Model " << model << std::endl;
|
||||
|
||||
int nchannels = (cfg.featureType == "HOG6MagLuv") ? 10: 8;
|
||||
|
||||
std::cout << "number of feature channels is " << nchannels << std::endl;
|
||||
|
||||
cv::Ptr<cv::FeaturePool> pool = cv::FeaturePool::create(model, nfeatures, nchannels);
|
||||
nfeatures = pool->size();
|
||||
|
||||
|
||||
int npositives = cfg.positives;
|
||||
int nnegatives = cfg.negatives;
|
||||
int shrinkage = cfg.shrinkage;
|
||||
cv::Rect boundingBox = cfg.bbox(it);
|
||||
std::cout << "Object bounding box" << boundingBox << std::endl;
|
||||
|
||||
typedef cv::Octave Octave;
|
||||
|
||||
cv::Ptr<cv::ChannelFeatureBuilder> builder = cv::ChannelFeatureBuilder::create(cfg.featureType);
|
||||
std::cout << "Channel builder " << builder->info()->name() << std::endl;
|
||||
cv::Ptr<Octave> boost = Octave::create(boundingBox, npositives, nnegatives, *it, shrinkage, builder);
|
||||
|
||||
std::string path = cfg.trainPath;
|
||||
sft::ScaledDataset dataset(path, *it);
|
||||
|
||||
if (boost->train(&dataset, pool, cfg.weaks, cfg.treeDepth))
|
||||
{
|
||||
CvFileStorage* fout = cvOpenFileStorage(cfg.resPath(it).c_str(), 0, CV_STORAGE_WRITE);
|
||||
boost->write(fout, cfg.cascadeName);
|
||||
|
||||
cvReleaseFileStorage( &fout);
|
||||
|
||||
cv::Mat thresholds;
|
||||
boost->setRejectThresholds(thresholds);
|
||||
|
||||
boost->write(fso, pool, thresholds);
|
||||
|
||||
cv::FileStorage tfs(("thresholds." + cfg.resPath(it)).c_str(), cv::FileStorage::WRITE);
|
||||
tfs << "thresholds" << thresholds;
|
||||
|
||||
std::cout << "Octave " << *it << " was successfully trained..." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
fso << "]" << "}";
|
||||
fso.release();
|
||||
std::cout << "Training complete..." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
set(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_photo opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
|
||||
set(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d)
|
||||
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})
|
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
@@ -6,21 +6,18 @@ if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
endif()
|
||||
|
||||
project(traincascade)
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
|
||||
ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS})
|
||||
|
||||
set(traincascade_files traincascade.cpp
|
||||
cascadeclassifier.cpp cascadeclassifier.h
|
||||
boost.cpp boost.h features.cpp traincascade_features.h
|
||||
haarfeatures.cpp haarfeatures.h
|
||||
lbpfeatures.cpp lbpfeatures.h
|
||||
HOGfeatures.cpp HOGfeatures.h
|
||||
imagestorage.cpp imagestorage.h)
|
||||
|
||||
set(the_target opencv_traincascade)
|
||||
add_executable(${the_target} ${traincascade_files})
|
||||
target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS} opencv_haartraining_engine)
|
||||
|
||||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
|
||||
ocv_target_include_modules(${the_target} ${OPENCV_TRAINCASCADE_DEPS})
|
||||
|
||||
file(GLOB SRCS *.cpp)
|
||||
file(GLOB HDRS *.h*)
|
||||
|
||||
set(traincascade_files ${SRCS} ${HDRS})
|
||||
|
||||
ocv_add_executable(${the_target} ${traincascade_files})
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
|
||||
@@ -187,11 +187,11 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
|
||||
|
||||
for( y = 0; y < gradSize.height; y++ )
|
||||
{
|
||||
const uchar* currPtr = img.data + img.step*ymap[y];
|
||||
const uchar* prevPtr = img.data + img.step*ymap[y-1];
|
||||
const uchar* nextPtr = img.data + img.step*ymap[y+1];
|
||||
float* gradPtr = (float*)grad.ptr(y);
|
||||
uchar* qanglePtr = (uchar*)qangle.ptr(y);
|
||||
const uchar* currPtr = img.ptr(ymap[y]);
|
||||
const uchar* prevPtr = img.ptr(ymap[y-1]);
|
||||
const uchar* nextPtr = img.ptr(ymap[y+1]);
|
||||
float* gradPtr = grad.ptr<float>(y);
|
||||
uchar* qanglePtr = qangle.ptr(y);
|
||||
|
||||
for( x = 0; x < width; x++ )
|
||||
{
|
||||
@@ -226,9 +226,9 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
|
||||
int magStep = (int)( grad.step / sizeof(float) );
|
||||
for( binIdx = 0; binIdx < nbins; binIdx++ )
|
||||
{
|
||||
histBuf = (float*)histogram[binIdx].data;
|
||||
magBuf = (const float*)grad.data;
|
||||
binsBuf = (const uchar*)qangle.data;
|
||||
histBuf = histogram[binIdx].ptr<float>();
|
||||
magBuf = grad.ptr<float>();
|
||||
binsBuf = qangle.ptr();
|
||||
|
||||
memset( histBuf, 0, histSize.width * sizeof(histBuf[0]) );
|
||||
histBuf += histStep + 1;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define _OPENCV_BOOST_H_
|
||||
|
||||
#include "traincascade_features.h"
|
||||
#include "ml.h"
|
||||
#include "old_ml.hpp"
|
||||
|
||||
struct CvCascadeBoostParams : CvBoostParams
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "lbpfeatures.h"
|
||||
#include "HOGfeatures.h" //new
|
||||
#include "boost.h"
|
||||
#include "cv.h"
|
||||
#include "cxcore.h"
|
||||
|
||||
#define CC_CASCADE_FILENAME "cascade.xml"
|
||||
#define CC_PARAMS_FILENAME "params.xml"
|
||||
|
||||
@@ -13,9 +13,9 @@ float calcNormFactor( const Mat& sum, const Mat& sqSum )
|
||||
size_t p0, p1, p2, p3;
|
||||
CV_SUM_OFFSETS( p0, p1, p2, p3, normrect, sum.step1() )
|
||||
double area = normrect.width * normrect.height;
|
||||
const int *sp = (const int*)sum.data;
|
||||
const int *sp = sum.ptr<int>();
|
||||
int valSum = sp[p0] - sp[p1] - sp[p2] + sp[p3];
|
||||
const double *sqp = (const double *)sqSum.data;
|
||||
const double *sqp = sqSum.ptr<double>();
|
||||
double valSqSum = sqp[p0] - sqp[p1] - sqp[p2] + sqp[p3];
|
||||
return (float) sqrt( (double) (area * valSqSum - (double)valSum * valSum) );
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
#include "imagestorage.h"
|
||||
#include <stdio.h>
|
||||
@@ -97,7 +98,7 @@ bool CvCascadeImageReader::NegReader::get( Mat& _img )
|
||||
return false;
|
||||
|
||||
Mat mat( winSize.height, winSize.width, CV_8UC1,
|
||||
(void*)(img.data + point.y * img.step + point.x * img.elemSize()), img.step );
|
||||
(void*)(img.ptr(point.y) + point.x * img.elemSize()), img.step );
|
||||
mat.copyTo(_img);
|
||||
|
||||
if( (int)( point.x + (1.0F + stepFactor ) * winSize.width ) < img.cols )
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#ifndef _OPENCV_IMAGESTORAGE_H_
|
||||
#define _OPENCV_IMAGESTORAGE_H_
|
||||
|
||||
#include "highgui.h"
|
||||
|
||||
|
||||
|
||||
class CvCascadeImageReader
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,792 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "old_ml_precomp.hpp"
|
||||
#include <ctype.h>
|
||||
|
||||
#define MISS_VAL FLT_MAX
|
||||
#define CV_VAR_MISS 0
|
||||
|
||||
CvTrainTestSplit::CvTrainTestSplit()
|
||||
{
|
||||
train_sample_part_mode = CV_COUNT;
|
||||
train_sample_part.count = -1;
|
||||
mix = false;
|
||||
}
|
||||
|
||||
CvTrainTestSplit::CvTrainTestSplit( int _train_sample_count, bool _mix )
|
||||
{
|
||||
train_sample_part_mode = CV_COUNT;
|
||||
train_sample_part.count = _train_sample_count;
|
||||
mix = _mix;
|
||||
}
|
||||
|
||||
CvTrainTestSplit::CvTrainTestSplit( float _train_sample_portion, bool _mix )
|
||||
{
|
||||
train_sample_part_mode = CV_PORTION;
|
||||
train_sample_part.portion = _train_sample_portion;
|
||||
mix = _mix;
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
||||
CvMLData::CvMLData()
|
||||
{
|
||||
values = missing = var_types = var_idx_mask = response_out = var_idx_out = var_types_out = 0;
|
||||
train_sample_idx = test_sample_idx = 0;
|
||||
header_lines_number = 0;
|
||||
sample_idx = 0;
|
||||
response_idx = -1;
|
||||
|
||||
train_sample_count = -1;
|
||||
|
||||
delimiter = ',';
|
||||
miss_ch = '?';
|
||||
//flt_separator = '.';
|
||||
|
||||
rng = &cv::theRNG();
|
||||
}
|
||||
|
||||
CvMLData::~CvMLData()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void CvMLData::free_train_test_idx()
|
||||
{
|
||||
cvReleaseMat( &train_sample_idx );
|
||||
cvReleaseMat( &test_sample_idx );
|
||||
sample_idx = 0;
|
||||
}
|
||||
|
||||
void CvMLData::clear()
|
||||
{
|
||||
class_map.clear();
|
||||
|
||||
cvReleaseMat( &values );
|
||||
cvReleaseMat( &missing );
|
||||
cvReleaseMat( &var_types );
|
||||
cvReleaseMat( &var_idx_mask );
|
||||
|
||||
cvReleaseMat( &response_out );
|
||||
cvReleaseMat( &var_idx_out );
|
||||
cvReleaseMat( &var_types_out );
|
||||
|
||||
free_train_test_idx();
|
||||
|
||||
total_class_count = 0;
|
||||
|
||||
response_idx = -1;
|
||||
|
||||
train_sample_count = -1;
|
||||
}
|
||||
|
||||
|
||||
void CvMLData::set_header_lines_number( int idx )
|
||||
{
|
||||
header_lines_number = std::max(0, idx);
|
||||
}
|
||||
|
||||
int CvMLData::get_header_lines_number() const
|
||||
{
|
||||
return header_lines_number;
|
||||
}
|
||||
|
||||
static char *fgets_chomp(char *str, int n, FILE *stream)
|
||||
{
|
||||
char *head = fgets(str, n, stream);
|
||||
if( head )
|
||||
{
|
||||
for(char *tail = head + strlen(head) - 1; tail >= head; --tail)
|
||||
{
|
||||
if( *tail != '\r' && *tail != '\n' )
|
||||
break;
|
||||
*tail = '\0';
|
||||
}
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
|
||||
int CvMLData::read_csv(const char* filename)
|
||||
{
|
||||
const int M = 1000000;
|
||||
const char str_delimiter[3] = { ' ', delimiter, '\0' };
|
||||
FILE* file = 0;
|
||||
CvMemStorage* storage;
|
||||
CvSeq* seq;
|
||||
char *ptr;
|
||||
float* el_ptr;
|
||||
CvSeqReader reader;
|
||||
int cols_count = 0;
|
||||
uchar *var_types_ptr = 0;
|
||||
|
||||
clear();
|
||||
|
||||
file = fopen( filename, "rt" );
|
||||
|
||||
if( !file )
|
||||
return -1;
|
||||
|
||||
std::vector<char> _buf(M);
|
||||
char* buf = &_buf[0];
|
||||
|
||||
// skip header lines
|
||||
for( int i = 0; i < header_lines_number; i++ )
|
||||
{
|
||||
if( fgets( buf, M, file ) == 0 )
|
||||
{
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// read the first data line and determine the number of variables
|
||||
if( !fgets_chomp( buf, M, file ))
|
||||
{
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = buf;
|
||||
while( *ptr == ' ' )
|
||||
ptr++;
|
||||
for( ; *ptr != '\0'; )
|
||||
{
|
||||
if(*ptr == delimiter || *ptr == ' ')
|
||||
{
|
||||
cols_count++;
|
||||
ptr++;
|
||||
while( *ptr == ' ' ) ptr++;
|
||||
}
|
||||
else
|
||||
ptr++;
|
||||
}
|
||||
|
||||
cols_count++;
|
||||
|
||||
if ( cols_count == 0)
|
||||
{
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// create temporary memory storage to store the whole database
|
||||
el_ptr = new float[cols_count];
|
||||
storage = cvCreateMemStorage();
|
||||
seq = cvCreateSeq( 0, sizeof(*seq), cols_count*sizeof(float), storage );
|
||||
|
||||
var_types = cvCreateMat( 1, cols_count, CV_8U );
|
||||
cvZero( var_types );
|
||||
var_types_ptr = var_types->data.ptr;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
char *token = NULL;
|
||||
int type;
|
||||
token = strtok(buf, str_delimiter);
|
||||
if (!token)
|
||||
break;
|
||||
for (int i = 0; i < cols_count-1; i++)
|
||||
{
|
||||
str_to_flt_elem( token, el_ptr[i], type);
|
||||
var_types_ptr[i] |= type;
|
||||
token = strtok(NULL, str_delimiter);
|
||||
if (!token)
|
||||
{
|
||||
fclose(file);
|
||||
delete [] el_ptr;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
str_to_flt_elem( token, el_ptr[cols_count-1], type);
|
||||
var_types_ptr[cols_count-1] |= type;
|
||||
cvSeqPush( seq, el_ptr );
|
||||
if( !fgets_chomp( buf, M, file ) )
|
||||
break;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
values = cvCreateMat( seq->total, cols_count, CV_32FC1 );
|
||||
missing = cvCreateMat( seq->total, cols_count, CV_8U );
|
||||
var_idx_mask = cvCreateMat( 1, values->cols, CV_8UC1 );
|
||||
cvSet( var_idx_mask, cvRealScalar(1) );
|
||||
train_sample_count = seq->total;
|
||||
|
||||
cvStartReadSeq( seq, &reader );
|
||||
for(int i = 0; i < seq->total; i++ )
|
||||
{
|
||||
const float* sdata = (float*)reader.ptr;
|
||||
float* ddata = values->data.fl + cols_count*i;
|
||||
uchar* dm = missing->data.ptr + cols_count*i;
|
||||
|
||||
for( int j = 0; j < cols_count; j++ )
|
||||
{
|
||||
ddata[j] = sdata[j];
|
||||
dm[j] = ( fabs( MISS_VAL - sdata[j] ) <= FLT_EPSILON );
|
||||
}
|
||||
CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
|
||||
}
|
||||
|
||||
if ( cvNorm( missing, 0, CV_L1 ) <= FLT_EPSILON )
|
||||
cvReleaseMat( &missing );
|
||||
|
||||
cvReleaseMemStorage( &storage );
|
||||
delete []el_ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_values() const
|
||||
{
|
||||
return values;
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_missing() const
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_missing" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
__END__;
|
||||
|
||||
return missing;
|
||||
}
|
||||
|
||||
const std::map<cv::String, int>& CvMLData::get_class_labels_map() const
|
||||
{
|
||||
return class_map;
|
||||
}
|
||||
|
||||
void CvMLData::str_to_flt_elem( const char* token, float& flt_elem, int& type)
|
||||
{
|
||||
|
||||
char* stopstring = NULL;
|
||||
flt_elem = (float)strtod( token, &stopstring );
|
||||
assert( stopstring );
|
||||
type = CV_VAR_ORDERED;
|
||||
if ( *stopstring == miss_ch && strlen(stopstring) == 1 ) // missed value
|
||||
{
|
||||
flt_elem = MISS_VAL;
|
||||
type = CV_VAR_MISS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (*stopstring != 0) && (*stopstring != '\n') && (strcmp(stopstring, "\r\n") != 0) ) // class label
|
||||
{
|
||||
int idx = class_map[token];
|
||||
if ( idx == 0)
|
||||
{
|
||||
total_class_count++;
|
||||
idx = total_class_count;
|
||||
class_map[token] = idx;
|
||||
}
|
||||
flt_elem = (float)idx;
|
||||
type = CV_VAR_CATEGORICAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CvMLData::set_delimiter(char ch)
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::set_delimited" );
|
||||
__BEGIN__;
|
||||
|
||||
if (ch == miss_ch /*|| ch == flt_separator*/)
|
||||
CV_ERROR(CV_StsBadArg, "delimited, miss_character and flt_separator must be different");
|
||||
|
||||
delimiter = ch;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
char CvMLData::get_delimiter() const
|
||||
{
|
||||
return delimiter;
|
||||
}
|
||||
|
||||
void CvMLData::set_miss_ch(char ch)
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::set_miss_ch" );
|
||||
__BEGIN__;
|
||||
|
||||
if (ch == delimiter/* || ch == flt_separator*/)
|
||||
CV_ERROR(CV_StsBadArg, "delimited, miss_character and flt_separator must be different");
|
||||
|
||||
miss_ch = ch;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
char CvMLData::get_miss_ch() const
|
||||
{
|
||||
return miss_ch;
|
||||
}
|
||||
|
||||
void CvMLData::set_response_idx( int idx )
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::set_response_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
if ( idx >= values->cols)
|
||||
CV_ERROR( CV_StsBadArg, "idx value is not correct" );
|
||||
|
||||
if ( response_idx >= 0 )
|
||||
chahge_var_idx( response_idx, true );
|
||||
if ( idx >= 0 )
|
||||
chahge_var_idx( idx, false );
|
||||
response_idx = idx;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
int CvMLData::get_response_idx() const
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_response_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
__END__;
|
||||
return response_idx;
|
||||
}
|
||||
|
||||
void CvMLData::change_var_type( int var_idx, int type )
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::change_var_type" );
|
||||
__BEGIN__;
|
||||
|
||||
int var_count = 0;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
var_count = values->cols;
|
||||
|
||||
if ( var_idx < 0 || var_idx >= var_count)
|
||||
CV_ERROR( CV_StsBadArg, "var_idx is not correct" );
|
||||
|
||||
if ( type != CV_VAR_ORDERED && type != CV_VAR_CATEGORICAL)
|
||||
CV_ERROR( CV_StsBadArg, "type is not correct" );
|
||||
|
||||
assert( var_types );
|
||||
if ( var_types->data.ptr[var_idx] == CV_VAR_CATEGORICAL && type == CV_VAR_ORDERED)
|
||||
CV_ERROR( CV_StsBadArg, "it`s impossible to assign CV_VAR_ORDERED type to categorical variable" );
|
||||
var_types->data.ptr[var_idx] = (uchar)type;
|
||||
|
||||
__END__;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CvMLData::set_var_types( const char* str )
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::set_var_types" );
|
||||
__BEGIN__;
|
||||
|
||||
const char* ord = 0, *cat = 0;
|
||||
int var_count = 0, set_var_type_count = 0;
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
var_count = values->cols;
|
||||
|
||||
assert( var_types );
|
||||
|
||||
ord = strstr( str, "ord" );
|
||||
cat = strstr( str, "cat" );
|
||||
if ( !ord && !cat )
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
if ( !ord && strlen(cat) == 3 ) // str == "cat"
|
||||
{
|
||||
cvSet( var_types, cvScalarAll(CV_VAR_CATEGORICAL) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !cat && strlen(ord) == 3 ) // str == "ord"
|
||||
{
|
||||
cvSet( var_types, cvScalarAll(CV_VAR_ORDERED) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ord ) // parse ord str
|
||||
{
|
||||
char* stopstring = NULL;
|
||||
if ( ord[3] != '[')
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
ord += 4; // pass "ord["
|
||||
do
|
||||
{
|
||||
int b1 = (int)strtod( ord, &stopstring );
|
||||
if ( *stopstring == 0 || (*stopstring != ',' && *stopstring != ']' && *stopstring != '-') )
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
ord = stopstring + 1;
|
||||
if ( (stopstring[0] == ',') || (stopstring[0] == ']'))
|
||||
{
|
||||
if ( var_types->data.ptr[b1] == CV_VAR_CATEGORICAL)
|
||||
CV_ERROR( CV_StsBadArg, "it`s impossible to assign CV_VAR_ORDERED type to categorical variable" );
|
||||
var_types->data.ptr[b1] = CV_VAR_ORDERED;
|
||||
set_var_type_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( stopstring[0] == '-')
|
||||
{
|
||||
int b2 = (int)strtod( ord, &stopstring);
|
||||
if ( (*stopstring == 0) || (*stopstring != ',' && *stopstring != ']') )
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
ord = stopstring + 1;
|
||||
for (int i = b1; i <= b2; i++)
|
||||
{
|
||||
if ( var_types->data.ptr[i] == CV_VAR_CATEGORICAL)
|
||||
CV_ERROR( CV_StsBadArg, "it`s impossible to assign CV_VAR_ORDERED type to categorical variable" );
|
||||
var_types->data.ptr[i] = CV_VAR_ORDERED;
|
||||
}
|
||||
set_var_type_count += b2 - b1 + 1;
|
||||
}
|
||||
else
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
}
|
||||
}
|
||||
while (*stopstring != ']');
|
||||
|
||||
if ( stopstring[1] != '\0' && stopstring[1] != ',')
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
}
|
||||
|
||||
if ( cat ) // parse cat str
|
||||
{
|
||||
char* stopstring = NULL;
|
||||
if ( cat[3] != '[')
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
cat += 4; // pass "cat["
|
||||
do
|
||||
{
|
||||
int b1 = (int)strtod( cat, &stopstring );
|
||||
if ( *stopstring == 0 || (*stopstring != ',' && *stopstring != ']' && *stopstring != '-') )
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
cat = stopstring + 1;
|
||||
if ( (stopstring[0] == ',') || (stopstring[0] == ']'))
|
||||
{
|
||||
var_types->data.ptr[b1] = CV_VAR_CATEGORICAL;
|
||||
set_var_type_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( stopstring[0] == '-')
|
||||
{
|
||||
int b2 = (int)strtod( cat, &stopstring);
|
||||
if ( (*stopstring == 0) || (*stopstring != ',' && *stopstring != ']') )
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
cat = stopstring + 1;
|
||||
for (int i = b1; i <= b2; i++)
|
||||
var_types->data.ptr[i] = CV_VAR_CATEGORICAL;
|
||||
set_var_type_count += b2 - b1 + 1;
|
||||
}
|
||||
else
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
}
|
||||
}
|
||||
while (*stopstring != ']');
|
||||
|
||||
if ( stopstring[1] != '\0' && stopstring[1] != ',')
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
}
|
||||
|
||||
if (set_var_type_count != var_count)
|
||||
CV_ERROR( CV_StsBadArg, "types string is not correct" );
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_var_types()
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_var_types" );
|
||||
__BEGIN__;
|
||||
|
||||
uchar *var_types_out_ptr = 0;
|
||||
int avcount, vt_size;
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
assert( var_idx_mask );
|
||||
|
||||
avcount = cvFloor( cvNorm( var_idx_mask, 0, CV_L1 ) );
|
||||
vt_size = avcount + (response_idx >= 0);
|
||||
|
||||
if ( avcount == values->cols || (avcount == values->cols-1 && response_idx == values->cols-1) )
|
||||
return var_types;
|
||||
|
||||
if ( !var_types_out || ( var_types_out && var_types_out->cols != vt_size ) )
|
||||
{
|
||||
cvReleaseMat( &var_types_out );
|
||||
var_types_out = cvCreateMat( 1, vt_size, CV_8UC1 );
|
||||
}
|
||||
|
||||
var_types_out_ptr = var_types_out->data.ptr;
|
||||
for( int i = 0; i < var_types->cols; i++)
|
||||
{
|
||||
if (i == response_idx || !var_idx_mask->data.ptr[i]) continue;
|
||||
*var_types_out_ptr = var_types->data.ptr[i];
|
||||
var_types_out_ptr++;
|
||||
}
|
||||
if ( response_idx >= 0 )
|
||||
*var_types_out_ptr = var_types->data.ptr[response_idx];
|
||||
|
||||
__END__;
|
||||
|
||||
return var_types_out;
|
||||
}
|
||||
|
||||
int CvMLData::get_var_type( int var_idx ) const
|
||||
{
|
||||
return var_types->data.ptr[var_idx];
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_responses()
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_responses_ptr" );
|
||||
__BEGIN__;
|
||||
|
||||
int var_count = 0;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
var_count = values->cols;
|
||||
|
||||
if ( response_idx < 0 || response_idx >= var_count )
|
||||
return 0;
|
||||
if ( !response_out )
|
||||
response_out = cvCreateMatHeader( values->rows, 1, CV_32FC1 );
|
||||
else
|
||||
cvInitMatHeader( response_out, values->rows, 1, CV_32FC1);
|
||||
cvGetCol( values, response_out, response_idx );
|
||||
|
||||
__END__;
|
||||
|
||||
return response_out;
|
||||
}
|
||||
|
||||
void CvMLData::set_train_test_split( const CvTrainTestSplit * spl)
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::set_division" );
|
||||
__BEGIN__;
|
||||
|
||||
int sample_count = 0;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
sample_count = values->rows;
|
||||
|
||||
float train_sample_portion;
|
||||
|
||||
if (spl->train_sample_part_mode == CV_COUNT)
|
||||
{
|
||||
train_sample_count = spl->train_sample_part.count;
|
||||
if (train_sample_count > sample_count)
|
||||
CV_ERROR( CV_StsBadArg, "train samples count is not correct" );
|
||||
train_sample_count = train_sample_count<=0 ? sample_count : train_sample_count;
|
||||
}
|
||||
else // dtype.train_sample_part_mode == CV_PORTION
|
||||
{
|
||||
train_sample_portion = spl->train_sample_part.portion;
|
||||
if ( train_sample_portion > 1)
|
||||
CV_ERROR( CV_StsBadArg, "train samples count is not correct" );
|
||||
train_sample_portion = train_sample_portion <= FLT_EPSILON ||
|
||||
1 - train_sample_portion <= FLT_EPSILON ? 1 : train_sample_portion;
|
||||
train_sample_count = std::max(1, cvFloor( train_sample_portion * sample_count ));
|
||||
}
|
||||
|
||||
if ( train_sample_count == sample_count )
|
||||
{
|
||||
free_train_test_idx();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( train_sample_idx && train_sample_idx->cols != train_sample_count )
|
||||
free_train_test_idx();
|
||||
|
||||
if ( !sample_idx)
|
||||
{
|
||||
int test_sample_count = sample_count- train_sample_count;
|
||||
sample_idx = (int*)cvAlloc( sample_count * sizeof(sample_idx[0]) );
|
||||
for (int i = 0; i < sample_count; i++ )
|
||||
sample_idx[i] = i;
|
||||
train_sample_idx = cvCreateMatHeader( 1, train_sample_count, CV_32SC1 );
|
||||
*train_sample_idx = cvMat( 1, train_sample_count, CV_32SC1, &sample_idx[0] );
|
||||
|
||||
CV_Assert(test_sample_count > 0);
|
||||
test_sample_idx = cvCreateMatHeader( 1, test_sample_count, CV_32SC1 );
|
||||
*test_sample_idx = cvMat( 1, test_sample_count, CV_32SC1, &sample_idx[train_sample_count] );
|
||||
}
|
||||
|
||||
mix = spl->mix;
|
||||
if ( mix )
|
||||
mix_train_and_test_idx();
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_train_sample_idx() const
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_train_sample_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
__END__;
|
||||
|
||||
return train_sample_idx;
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_test_sample_idx() const
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_test_sample_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
__END__;
|
||||
|
||||
return test_sample_idx;
|
||||
}
|
||||
|
||||
void CvMLData::mix_train_and_test_idx()
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::mix_train_and_test_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
__END__;
|
||||
|
||||
if ( !sample_idx)
|
||||
return;
|
||||
|
||||
if ( train_sample_count > 0 && train_sample_count < values->rows )
|
||||
{
|
||||
int n = values->rows;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int a = (*rng)(n);
|
||||
int b = (*rng)(n);
|
||||
int t;
|
||||
CV_SWAP( sample_idx[a], sample_idx[b], t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CvMat* CvMLData::get_var_idx()
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::get_var_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
int avcount = 0;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
assert( var_idx_mask );
|
||||
|
||||
avcount = cvFloor( cvNorm( var_idx_mask, 0, CV_L1 ) );
|
||||
int* vidx;
|
||||
|
||||
if ( avcount == values->cols )
|
||||
return 0;
|
||||
|
||||
if ( !var_idx_out || ( var_idx_out && var_idx_out->cols != avcount ) )
|
||||
{
|
||||
cvReleaseMat( &var_idx_out );
|
||||
var_idx_out = cvCreateMat( 1, avcount, CV_32SC1);
|
||||
if ( response_idx >=0 )
|
||||
var_idx_mask->data.ptr[response_idx] = 0;
|
||||
}
|
||||
|
||||
vidx = var_idx_out->data.i;
|
||||
|
||||
for(int i = 0; i < var_idx_mask->cols; i++)
|
||||
if ( var_idx_mask->data.ptr[i] )
|
||||
{
|
||||
*vidx = i;
|
||||
vidx++;
|
||||
}
|
||||
|
||||
__END__;
|
||||
|
||||
return var_idx_out;
|
||||
}
|
||||
|
||||
void CvMLData::chahge_var_idx( int vi, bool state )
|
||||
{
|
||||
change_var_idx( vi, state );
|
||||
}
|
||||
|
||||
void CvMLData::change_var_idx( int vi, bool state )
|
||||
{
|
||||
CV_FUNCNAME( "CvMLData::change_var_idx" );
|
||||
__BEGIN__;
|
||||
|
||||
int var_count = 0;
|
||||
|
||||
if ( !values )
|
||||
CV_ERROR( CV_StsInternal, "data is empty" );
|
||||
|
||||
var_count = values->cols;
|
||||
|
||||
if ( vi < 0 || vi >= var_count)
|
||||
CV_ERROR( CV_StsBadArg, "variable index is not correct" );
|
||||
|
||||
assert( var_idx_mask );
|
||||
var_idx_mask->data.ptr[vi] = state;
|
||||
|
||||
__END__;
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,376 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "old_ml.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define ML_IMPL CV_IMPL
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
#define __END__ __CV_END__
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#define CV_MAT_ELEM_FLAG( mat, type, comp, vect, tflag ) \
|
||||
(( tflag == CV_ROW_SAMPLE ) \
|
||||
? (CV_MAT_ELEM( mat, type, comp, vect )) \
|
||||
: (CV_MAT_ELEM( mat, type, vect, comp )))
|
||||
|
||||
/* Convert matrix to vector */
|
||||
#define ICV_MAT2VEC( mat, vdata, vstep, num ) \
|
||||
if( MIN( (mat).rows, (mat).cols ) != 1 ) \
|
||||
CV_ERROR( CV_StsBadArg, "" ); \
|
||||
(vdata) = ((mat).data.ptr); \
|
||||
if( (mat).rows == 1 ) \
|
||||
{ \
|
||||
(vstep) = CV_ELEM_SIZE( (mat).type ); \
|
||||
(num) = (mat).cols; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(vstep) = (mat).step; \
|
||||
(num) = (mat).rows; \
|
||||
}
|
||||
|
||||
/* get raw data */
|
||||
#define ICV_RAWDATA( mat, flags, rdata, sstep, cstep, m, n ) \
|
||||
(rdata) = (mat).data.ptr; \
|
||||
if( CV_IS_ROW_SAMPLE( flags ) ) \
|
||||
{ \
|
||||
(sstep) = (mat).step; \
|
||||
(cstep) = CV_ELEM_SIZE( (mat).type ); \
|
||||
(m) = (mat).rows; \
|
||||
(n) = (mat).cols; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(cstep) = (mat).step; \
|
||||
(sstep) = CV_ELEM_SIZE( (mat).type ); \
|
||||
(n) = (mat).rows; \
|
||||
(m) = (mat).cols; \
|
||||
}
|
||||
|
||||
#define ICV_IS_MAT_OF_TYPE( mat, mat_type) \
|
||||
(CV_IS_MAT( mat ) && CV_MAT_TYPE( mat->type ) == (mat_type) && \
|
||||
(mat)->cols > 0 && (mat)->rows > 0)
|
||||
|
||||
/*
|
||||
uchar* data; int sstep, cstep; - trainData->data
|
||||
uchar* classes; int clstep; int ncl;- trainClasses
|
||||
uchar* tmask; int tmstep; int ntm; - typeMask
|
||||
uchar* missed;int msstep, mcstep; -missedMeasurements...
|
||||
int mm, mn; == m,n == size,dim
|
||||
uchar* sidx;int sistep; - sampleIdx
|
||||
uchar* cidx;int cistep; - compIdx
|
||||
int k, l; == n,m == dim,size (length of cidx, sidx)
|
||||
int m, n; == size,dim
|
||||
*/
|
||||
#define ICV_DECLARE_TRAIN_ARGS() \
|
||||
uchar* data; \
|
||||
int sstep, cstep; \
|
||||
uchar* classes; \
|
||||
int clstep; \
|
||||
int ncl; \
|
||||
uchar* tmask; \
|
||||
int tmstep; \
|
||||
int ntm; \
|
||||
uchar* missed; \
|
||||
int msstep, mcstep; \
|
||||
int mm, mn; \
|
||||
uchar* sidx; \
|
||||
int sistep; \
|
||||
uchar* cidx; \
|
||||
int cistep; \
|
||||
int k, l; \
|
||||
int m, n; \
|
||||
\
|
||||
data = classes = tmask = missed = sidx = cidx = NULL; \
|
||||
sstep = cstep = clstep = ncl = tmstep = ntm = msstep = mcstep = mm = mn = 0; \
|
||||
sistep = cistep = k = l = m = n = 0;
|
||||
|
||||
#define ICV_TRAIN_DATA_REQUIRED( param, flags ) \
|
||||
if( !ICV_IS_MAT_OF_TYPE( (param), CV_32FC1 ) ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ICV_RAWDATA( *(param), (flags), data, sstep, cstep, m, n ); \
|
||||
k = n; \
|
||||
l = m; \
|
||||
}
|
||||
|
||||
#define ICV_TRAIN_CLASSES_REQUIRED( param ) \
|
||||
if( !ICV_IS_MAT_OF_TYPE( (param), CV_32FC1 ) ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ICV_MAT2VEC( *(param), classes, clstep, ncl ); \
|
||||
if( m != ncl ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Unmatched sizes" ); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ICV_ARG_NULL( param ) \
|
||||
if( (param) != NULL ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, #param " parameter must be NULL" ); \
|
||||
}
|
||||
|
||||
#define ICV_MISSED_MEASUREMENTS_OPTIONAL( param, flags ) \
|
||||
if( param ) \
|
||||
{ \
|
||||
if( !ICV_IS_MAT_OF_TYPE( param, CV_8UC1 ) ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ICV_RAWDATA( *(param), (flags), missed, msstep, mcstep, mm, mn ); \
|
||||
if( mm != m || mn != n ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Unmatched sizes" ); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ICV_COMP_IDX_OPTIONAL( param ) \
|
||||
if( param ) \
|
||||
{ \
|
||||
if( !ICV_IS_MAT_OF_TYPE( param, CV_32SC1 ) ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ICV_MAT2VEC( *(param), cidx, cistep, k ); \
|
||||
if( k > n ) \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ICV_SAMPLE_IDX_OPTIONAL( param ) \
|
||||
if( param ) \
|
||||
{ \
|
||||
if( !ICV_IS_MAT_OF_TYPE( param, CV_32SC1 ) ) \
|
||||
{ \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ICV_MAT2VEC( *sampleIdx, sidx, sistep, l ); \
|
||||
if( l > m ) \
|
||||
CV_ERROR( CV_StsBadArg, "Invalid " #param " parameter" ); \
|
||||
} \
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
#define ICV_CONVERT_FLOAT_ARRAY_TO_MATRICE( array, matrice ) \
|
||||
{ \
|
||||
CvMat a, b; \
|
||||
int dims = (matrice)->cols; \
|
||||
int nsamples = (matrice)->rows; \
|
||||
int type = CV_MAT_TYPE((matrice)->type); \
|
||||
int i, offset = dims; \
|
||||
\
|
||||
CV_ASSERT( type == CV_32FC1 || type == CV_64FC1 ); \
|
||||
offset *= ((type == CV_32FC1) ? sizeof(float) : sizeof(double));\
|
||||
\
|
||||
b = cvMat( 1, dims, CV_32FC1 ); \
|
||||
cvGetRow( matrice, &a, 0 ); \
|
||||
for( i = 0; i < nsamples; i++, a.data.ptr += offset ) \
|
||||
{ \
|
||||
b.data.fl = (float*)array[i]; \
|
||||
CV_CALL( cvConvert( &b, &a ) ); \
|
||||
} \
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
* Auxiliary functions declarations *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* Generates a set of classes centers in quantity <num_of_clusters> that are generated as
|
||||
uniform random vectors in parallelepiped, where <data> is concentrated. Vectors in
|
||||
<data> should have horizontal orientation. If <centers> != NULL, the function doesn't
|
||||
allocate any memory and stores generated centers in <centers>, returns <centers>.
|
||||
If <centers> == NULL, the function allocates memory and creates the matrice. Centers
|
||||
are supposed to be oriented horizontally. */
|
||||
CvMat* icvGenerateRandomClusterCenters( int seed,
|
||||
const CvMat* data,
|
||||
int num_of_clusters,
|
||||
CvMat* centers CV_DEFAULT(0));
|
||||
|
||||
/* Fills the <labels> using <probs> by choosing the maximal probability. Outliers are
|
||||
fixed by <oulier_tresh> and have cluster label (-1). Function also controls that there
|
||||
weren't "empty" clusters by filling empty clusters with the maximal probability vector.
|
||||
If probs_sums != NULL, filles it with the sums of probabilities for each sample (it is
|
||||
useful for normalizing probabilities' matrice of FCM) */
|
||||
void icvFindClusterLabels( const CvMat* probs, float outlier_thresh, float r,
|
||||
const CvMat* labels );
|
||||
|
||||
typedef struct CvSparseVecElem32f
|
||||
{
|
||||
int idx;
|
||||
float val;
|
||||
}
|
||||
CvSparseVecElem32f;
|
||||
|
||||
/* Prepare training data and related parameters */
|
||||
#define CV_TRAIN_STATMODEL_DEFRAGMENT_TRAIN_DATA 1
|
||||
#define CV_TRAIN_STATMODEL_SAMPLES_AS_ROWS 2
|
||||
#define CV_TRAIN_STATMODEL_SAMPLES_AS_COLUMNS 4
|
||||
#define CV_TRAIN_STATMODEL_CATEGORICAL_RESPONSE 8
|
||||
#define CV_TRAIN_STATMODEL_ORDERED_RESPONSE 16
|
||||
#define CV_TRAIN_STATMODEL_RESPONSES_ON_OUTPUT 32
|
||||
#define CV_TRAIN_STATMODEL_ALWAYS_COPY_TRAIN_DATA 64
|
||||
#define CV_TRAIN_STATMODEL_SPARSE_AS_SPARSE 128
|
||||
|
||||
int
|
||||
cvPrepareTrainData( const char* /*funcname*/,
|
||||
const CvMat* train_data, int tflag,
|
||||
const CvMat* responses, int response_type,
|
||||
const CvMat* var_idx,
|
||||
const CvMat* sample_idx,
|
||||
bool always_copy_data,
|
||||
const float*** out_train_samples,
|
||||
int* _sample_count,
|
||||
int* _var_count,
|
||||
int* _var_all,
|
||||
CvMat** out_responses,
|
||||
CvMat** out_response_map,
|
||||
CvMat** out_var_idx,
|
||||
CvMat** out_sample_idx=0 );
|
||||
|
||||
void
|
||||
cvSortSamplesByClasses( const float** samples, const CvMat* classes,
|
||||
int* class_ranges, const uchar** mask CV_DEFAULT(0) );
|
||||
|
||||
void
|
||||
cvCombineResponseMaps (CvMat* _responses,
|
||||
const CvMat* old_response_map,
|
||||
CvMat* new_response_map,
|
||||
CvMat** out_response_map);
|
||||
|
||||
void
|
||||
cvPreparePredictData( const CvArr* sample, int dims_all, const CvMat* comp_idx,
|
||||
int class_count, const CvMat* prob, float** row_sample,
|
||||
int as_sparse CV_DEFAULT(0) );
|
||||
|
||||
/* copies clustering [or batch "predict"] results
|
||||
(labels and/or centers and/or probs) back to the output arrays */
|
||||
void
|
||||
cvWritebackLabels( const CvMat* labels, CvMat* dst_labels,
|
||||
const CvMat* centers, CvMat* dst_centers,
|
||||
const CvMat* probs, CvMat* dst_probs,
|
||||
const CvMat* sample_idx, int samples_all,
|
||||
const CvMat* comp_idx, int dims_all );
|
||||
#define cvWritebackResponses cvWritebackLabels
|
||||
|
||||
#define XML_FIELD_NAME "_name"
|
||||
CvFileNode* icvFileNodeGetChild(CvFileNode* father, const char* name);
|
||||
CvFileNode* icvFileNodeGetChildArrayElem(CvFileNode* father, const char* name,int index);
|
||||
CvFileNode* icvFileNodeGetNext(CvFileNode* n, const char* name);
|
||||
|
||||
|
||||
void cvCheckTrainData( const CvMat* train_data, int tflag,
|
||||
const CvMat* missing_mask,
|
||||
int* var_all, int* sample_all );
|
||||
|
||||
CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, bool check_for_duplicates=false );
|
||||
|
||||
CvMat* cvPreprocessVarType( const CvMat* type_mask, const CvMat* var_idx,
|
||||
int var_all, int* response_type );
|
||||
|
||||
CvMat* cvPreprocessOrderedResponses( const CvMat* responses,
|
||||
const CvMat* sample_idx, int sample_all );
|
||||
|
||||
CvMat* cvPreprocessCategoricalResponses( const CvMat* responses,
|
||||
const CvMat* sample_idx, int sample_all,
|
||||
CvMat** out_response_map, CvMat** class_counts=0 );
|
||||
|
||||
const float** cvGetTrainSamples( const CvMat* train_data, int tflag,
|
||||
const CvMat* var_idx, const CvMat* sample_idx,
|
||||
int* _var_count, int* _sample_count,
|
||||
bool always_copy_data=false );
|
||||
|
||||
namespace cv
|
||||
{
|
||||
struct DTreeBestSplitFinder
|
||||
{
|
||||
DTreeBestSplitFinder(){ splitSize = 0, tree = 0; node = 0; }
|
||||
DTreeBestSplitFinder( CvDTree* _tree, CvDTreeNode* _node);
|
||||
DTreeBestSplitFinder( const DTreeBestSplitFinder& finder, Split );
|
||||
virtual ~DTreeBestSplitFinder() {}
|
||||
virtual void operator()(const BlockedRange& range);
|
||||
void join( DTreeBestSplitFinder& rhs );
|
||||
Ptr<CvDTreeSplit> bestSplit;
|
||||
Ptr<CvDTreeSplit> split;
|
||||
int splitSize;
|
||||
CvDTree* tree;
|
||||
CvDTreeNode* node;
|
||||
};
|
||||
|
||||
struct ForestTreeBestSplitFinder : DTreeBestSplitFinder
|
||||
{
|
||||
ForestTreeBestSplitFinder() : DTreeBestSplitFinder() {}
|
||||
ForestTreeBestSplitFinder( CvForestTree* _tree, CvDTreeNode* _node );
|
||||
ForestTreeBestSplitFinder( const ForestTreeBestSplitFinder& finder, Split );
|
||||
virtual void operator()(const BlockedRange& range);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __ML_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,4 @@
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#include "cv.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -13,6 +11,7 @@ int main( int argc, char* argv[] )
|
||||
int numPos = 2000;
|
||||
int numNeg = 1000;
|
||||
int numStages = 20;
|
||||
int numThreads = getNumThreads();
|
||||
int precalcValBufSize = 256,
|
||||
precalcIdxBufSize = 256;
|
||||
bool baseFormatSave = false;
|
||||
@@ -36,6 +35,7 @@ int main( int argc, char* argv[] )
|
||||
cout << " [-precalcValBufSize <precalculated_vals_buffer_size_in_Mb = " << precalcValBufSize << ">]" << endl;
|
||||
cout << " [-precalcIdxBufSize <precalculated_idxs_buffer_size_in_Mb = " << precalcIdxBufSize << ">]" << endl;
|
||||
cout << " [-baseFormatSave]" << endl;
|
||||
cout << " [-numThreads <max_number_of_threads = " << numThreads << ">]" << endl;
|
||||
cascadeParams.printDefaults();
|
||||
stageParams.printDefaults();
|
||||
for( int fi = 0; fi < fc; fi++ )
|
||||
@@ -82,6 +82,10 @@ int main( int argc, char* argv[] )
|
||||
{
|
||||
baseFormatSave = true;
|
||||
}
|
||||
else if( !strcmp( argv[i], "-numThreads" ) )
|
||||
{
|
||||
numThreads = atoi(argv[++i]);
|
||||
}
|
||||
else if ( cascadeParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
|
||||
else if ( stageParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
|
||||
else if ( !set )
|
||||
@@ -98,6 +102,7 @@ int main( int argc, char* argv[] )
|
||||
}
|
||||
}
|
||||
|
||||
setNumThreads( numThreads );
|
||||
classifier.train( cascadeDirName,
|
||||
vecName,
|
||||
bgName,
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#define _OPENCV_FEATURES_H_
|
||||
|
||||
#include "imagestorage.h"
|
||||
#include "cxcore.h"
|
||||
#include "cv.h"
|
||||
#include "ml.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define FEATURES "features"
|
||||
|
||||
@@ -185,6 +185,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
add_extra_compiler_option(-ffunction-sections)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
|
||||
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
|
||||
endif()
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Or you can search for specific OpenCV modules:
|
||||
#
|
||||
# FIND_PACKAGE(OpenCV REQUIRED core highgui)
|
||||
# FIND_PACKAGE(OpenCV REQUIRED core imgcodecs)
|
||||
#
|
||||
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
|
||||
#
|
||||
|
||||
@@ -280,9 +280,6 @@ macro(add_android_project target path)
|
||||
string(REGEX REPLACE "LOCAL_MODULE[ ]*:=[ ]*([a-zA-Z_][a-zA-Z_0-9]*)[ ]*" "\\1" JNI_LIB_NAME "${JNI_LIB_NAME}")
|
||||
|
||||
if(JNI_LIB_NAME)
|
||||
ocv_include_modules_recurse(${android_proj_NATIVE_DEPS})
|
||||
ocv_include_directories("${path}/jni")
|
||||
|
||||
if(NATIVE_APP_GLUE)
|
||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||
list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
||||
@@ -291,7 +288,9 @@ macro(add_android_project target path)
|
||||
endif()
|
||||
|
||||
add_library(${JNI_LIB_NAME} MODULE ${android_proj_jni_files})
|
||||
target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
|
||||
ocv_target_include_modules_recurse(${JNI_LIB_NAME} ${android_proj_NATIVE_DEPS})
|
||||
ocv_target_include_directories(${JNI_LIB_NAME} "${path}/jni")
|
||||
ocv_target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
|
||||
|
||||
set_target_properties(${JNI_LIB_NAME} PROPERTIES
|
||||
OUTPUT_NAME "${JNI_LIB_NAME}"
|
||||
@@ -335,6 +334,16 @@ macro(add_android_project target path)
|
||||
add_dependencies(${target} ${android_proj_native_deps})
|
||||
endif()
|
||||
|
||||
if(ANDROID_EXAMPLES_WITH_LIBS)
|
||||
add_custom_target(
|
||||
${target}_copy_libs
|
||||
COMMAND ${CMAKE_COMMAND} -DSRC_DIR=${OpenCV_BINARY_DIR}/lib -DDST_DIR=${android_proj_bin_dir}/libs -P ${OpenCV_SOURCE_DIR}/cmake/copyAndroidLibs.cmake
|
||||
WORKING_DIRECTORY ${OpenCV_BINARY_DIR}/lib
|
||||
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" opencv_java
|
||||
)
|
||||
add_dependencies(${target} ${target}_copy_libs)
|
||||
endif()
|
||||
|
||||
if(__android_project_chain)
|
||||
add_dependencies(${target} ${__android_project_chain})
|
||||
endif()
|
||||
@@ -365,7 +374,7 @@ macro(add_android_project target path)
|
||||
endif()
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND ${ANDROID_EXECUTABLE} --silent update project --path . --target \"${android_proj_sdk_target}\" --name \"${target}\" ${inst_lib_opt}
|
||||
WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}\"
|
||||
)" COMPONENT dev)
|
||||
)" COMPONENT samples)
|
||||
#empty 'gen'
|
||||
install(CODE "MAKE_DIRECTORY(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}/gen\")" COMPONENT samples)
|
||||
endif()
|
||||
|
||||
@@ -178,9 +178,8 @@ if(CUDA_FOUND)
|
||||
# we remove -Wsign-promo as it generates warnings under linux
|
||||
string(REPLACE "-Wsign-promo" "" ${var} "${${var}}")
|
||||
|
||||
# we remove -fvisibility-inlines-hidden because it's used for C++ compiler
|
||||
# but NVCC uses C compiler by default
|
||||
string(REPLACE "-fvisibility-inlines-hidden" "" ${var} "${${var}}")
|
||||
# we remove -Wno-sign-promo as it generates warnings under linux
|
||||
string(REPLACE "-Wno-sign-promo" "" ${var} "${${var}}")
|
||||
|
||||
# we remove -Wno-delete-non-virtual-dtor because it's used for C++ compiler
|
||||
# but NVCC uses C compiler by default
|
||||
@@ -189,6 +188,8 @@ if(CUDA_FOUND)
|
||||
# we remove -frtti because it's used for C++ compiler
|
||||
# but NVCC uses C compiler by default
|
||||
string(REPLACE "-frtti" "" ${var} "${${var}}")
|
||||
|
||||
string(REPLACE "-fvisibility-inlines-hidden" "" ${var} "${${var}}")
|
||||
endforeach()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@@ -218,3 +219,42 @@ else()
|
||||
unset(CUDA_ARCH_BIN CACHE)
|
||||
unset(CUDA_ARCH_PTX CACHE)
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
set(CUDA_LIBS_PATH "")
|
||||
foreach(p ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
|
||||
if(HAVE_CUBLAS)
|
||||
foreach(p ${CUDA_cublas_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(HAVE_CUFFT)
|
||||
foreach(p ${CUDA_cufft_LIBRARY})
|
||||
get_filename_component(_tmp ${p} PATH)
|
||||
list(APPEND CUDA_LIBS_PATH ${_tmp})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES CUDA_LIBS_PATH)
|
||||
link_directories(${CUDA_LIBS_PATH})
|
||||
|
||||
set(CUDA_LIBRARIES_ABS ${CUDA_LIBRARIES})
|
||||
ocv_convert_to_lib_name(CUDA_LIBRARIES ${CUDA_LIBRARIES})
|
||||
set(CUDA_npp_LIBRARY_ABS ${CUDA_npp_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
|
||||
if(HAVE_CUBLAS)
|
||||
set(CUDA_cublas_LIBRARY_ABS ${CUDA_cublas_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_CUFFT)
|
||||
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
|
||||
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+233
-94
@@ -1,101 +1,240 @@
|
||||
if(WIN32 AND NOT PYTHON_EXECUTABLE)
|
||||
# search for executable with the same bitness as resulting binaries
|
||||
# standard FindPythonInterp always prefers executable from system path
|
||||
# this is really important because we are using the interpreter for numpy search and for choosing the install location
|
||||
foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} 2.7 "${MIN_VER_PYTHON}")
|
||||
find_host_program(PYTHON_EXECUTABLE
|
||||
NAMES python${_CURRENT_VERSION} python
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
find_host_package(PythonInterp 2.7)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
find_host_package(PythonInterp "${MIN_VER_PYTHON}")
|
||||
# Find specified Python version
|
||||
# Arguments:
|
||||
# preferred_version (value): Version to check for first
|
||||
# min_version (value): Minimum supported version
|
||||
# library_env (value): Name of Python library ENV variable to check
|
||||
# include_dir_env (value): Name of Python include directory ENV variable to check
|
||||
# found (variable): Set if interpreter found
|
||||
# executable (variable): Output of executable found
|
||||
# version_string (variable): Output of found version
|
||||
# version_major (variable): Output of found major version
|
||||
# version_minor (variable): Output of found minor version
|
||||
# libs_found (variable): Set if libs found
|
||||
# libs_version_string (variable): Output of found libs version
|
||||
# libraries (variable): Output of found Python libraries
|
||||
# library (variable): Output of found Python library
|
||||
# debug_libraries (variable): Output of found Python debug libraries
|
||||
# debug_library (variable): Output of found Python debug library
|
||||
# include_path (variable): Output of found Python include path
|
||||
# include_dir (variable): Output of found Python include dir
|
||||
# include_dir2 (variable): Output of found Python include dir2
|
||||
# packages_path (variable): Output of found Python packages path
|
||||
# numpy_include_dirs (variable): Output of found Python Numpy include dirs
|
||||
# numpy_version (variable): Output of found Python Numpy version
|
||||
function(find_python preferred_version min_version library_env include_dir_env
|
||||
found executable version_string version_major version_minor
|
||||
libs_found libs_version_string libraries library debug_libraries
|
||||
debug_library include_path include_dir include_dir2 packages_path
|
||||
numpy_include_dirs numpy_version)
|
||||
|
||||
ocv_check_environment_variables(${executable})
|
||||
if(${executable})
|
||||
set(PYTHON_EXECUTABLE "${${executable}}")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT ${executable})
|
||||
# search for executable with the same bitness as resulting binaries
|
||||
# standard FindPythonInterp always prefers executable from system path
|
||||
# this is really important because we are using the interpreter for numpy search and for choosing the install location
|
||||
foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} "${preferred_version}" "${min_version}")
|
||||
find_host_program(executable
|
||||
NAMES python${_CURRENT_VERSION} python
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
find_host_package(PythonInterp "${preferred_version}")
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
find_host_package(PythonInterp "${min_version}")
|
||||
endif()
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
# Copy outputs
|
||||
set(_found ${PYTHONINTERP_FOUND})
|
||||
set(_executable ${PYTHON_EXECUTABLE})
|
||||
set(_version_string ${PYTHON_VERSION_STRING})
|
||||
set(_version_major ${PYTHON_VERSION_MAJOR})
|
||||
set(_version_minor ${PYTHON_VERSION_MINOR})
|
||||
set(_version_patch ${PYTHON_VERSION_PATCH})
|
||||
|
||||
# Clear find_host_package side effects
|
||||
unset(PYTHONINTERP_FOUND)
|
||||
unset(PYTHON_EXECUTABLE CACHE)
|
||||
unset(PYTHON_VERSION_STRING)
|
||||
unset(PYTHON_VERSION_MAJOR)
|
||||
unset(PYTHON_VERSION_MINOR)
|
||||
unset(PYTHON_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
if(_found)
|
||||
set(_version_major_minor "${_version_major}.${_version_minor}")
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
ocv_check_environment_variables(${library_env} ${include_dir_env})
|
||||
if(${library})
|
||||
set(PYTHON_LIBRARY "${${library_env}}")
|
||||
endif()
|
||||
if(${include_dir})
|
||||
set(PYTHON_INCLUDE_DIR "${${include_dir_env}}")
|
||||
endif()
|
||||
|
||||
# not using _version_string here, because it might not conform to the CMake version format
|
||||
find_host_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT)
|
||||
|
||||
if(PYTHONLIBS_FOUND)
|
||||
# Copy outputs
|
||||
set(_libs_found ${PYTHONLIBS_FOUND})
|
||||
set(_libraries ${PYTHON_LIBRARIES})
|
||||
set(_include_path ${PYTHON_INCLUDE_PATH})
|
||||
set(_include_dirs ${PYTHON_INCLUDE_DIRS})
|
||||
set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES})
|
||||
set(_libs_version_string ${PYTHONLIBS_VERSION_STRING})
|
||||
set(_debug_library ${PYTHON_DEBUG_LIBRARY})
|
||||
set(_library ${PYTHON_LIBRARY})
|
||||
set(_library_debug ${PYTHON_LIBRARY_DEBUG})
|
||||
set(_library_release ${PYTHON_LIBRARY_RELEASE})
|
||||
set(_include_dir ${PYTHON_INCLUDE_DIR})
|
||||
set(_include_dir2 ${PYTHON_INCLUDE_DIR2})
|
||||
|
||||
# Clear find_host_package side effects
|
||||
unset(PYTHONLIBS_FOUND)
|
||||
unset(PYTHON_LIBRARIES)
|
||||
unset(PYTHON_INCLUDE_PATH)
|
||||
unset(PYTHON_INCLUDE_DIRS)
|
||||
unset(PYTHON_DEBUG_LIBRARIES)
|
||||
unset(PYTHONLIBS_VERSION_STRING)
|
||||
unset(PYTHON_DEBUG_LIBRARY CACHE)
|
||||
unset(PYTHON_LIBRARY)
|
||||
unset(PYTHON_LIBRARY_DEBUG)
|
||||
unset(PYTHON_LIBRARY_RELEASE)
|
||||
unset(PYTHON_LIBRARY CACHE)
|
||||
unset(PYTHON_LIBRARY_DEBUG CACHE)
|
||||
unset(PYTHON_LIBRARY_RELEASE CACHE)
|
||||
unset(PYTHON_INCLUDE_DIR CACHE)
|
||||
unset(PYTHON_INCLUDE_DIR2 CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
if(CMAKE_HOST_UNIX)
|
||||
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
|
||||
RESULT_VARIABLE _cvpy_process
|
||||
OUTPUT_VARIABLE _std_packages_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if("${_std_packages_path}" MATCHES "site-packages")
|
||||
set(_packages_path "python${_version_major_minor}/site-packages")
|
||||
else() #debian based assumed, install to the dist-packages.
|
||||
set(_packages_path "python${_version_major_minor}/dist-packages")
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}")
|
||||
set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}")
|
||||
else()
|
||||
set(_packages_path "lib/${_packages_path}")
|
||||
endif()
|
||||
elseif(CMAKE_HOST_WIN32)
|
||||
get_filename_component(_path "${_executable}" PATH)
|
||||
file(TO_CMAKE_PATH "${_path}" _path)
|
||||
if(NOT EXISTS "${_path}/Lib/site-packages")
|
||||
unset(_path)
|
||||
get_filename_component(_path "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_version_major_minor}\\InstallPath]" ABSOLUTE)
|
||||
if(NOT _path)
|
||||
get_filename_component(_path "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_version_major_minor}\\InstallPath]" ABSOLUTE)
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "${_path}" _path)
|
||||
endif()
|
||||
set(_packages_path "${_path}/Lib/site-packages")
|
||||
unset(_path)
|
||||
endif()
|
||||
|
||||
set(_numpy_include_dirs ${${numpy_include_dirs}})
|
||||
|
||||
if(NOT _numpy_include_dirs)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)")
|
||||
message(STATUS "If you want to enable Python/Numpy support, set the following variables:")
|
||||
message(STATUS " PYTHON2_INCLUDE_PATH")
|
||||
message(STATUS " PYTHON2_LIBRARIES")
|
||||
message(STATUS " PYTHON2_NUMPY_INCLUDE_DIRS")
|
||||
message(STATUS " PYTHON3_INCLUDE_PATH")
|
||||
message(STATUS " PYTHON3_LIBRARIES")
|
||||
message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
|
||||
else()
|
||||
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
|
||||
execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))"
|
||||
RESULT_VARIABLE _numpy_process
|
||||
OUTPUT_VARIABLE _numpy_include_dirs
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT _numpy_process EQUAL 0)
|
||||
unset(_numpy_include_dirs)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(_numpy_include_dirs)
|
||||
file(TO_CMAKE_PATH "${_numpy_include_dirs}" _numpy_include_dirs)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(NOT _numpy_version)
|
||||
set(_numpy_version "undefined - cannot be probed because of the cross-compilation")
|
||||
endif()
|
||||
else()
|
||||
execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.version.version)"
|
||||
RESULT_VARIABLE _numpy_process
|
||||
OUTPUT_VARIABLE _numpy_version
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
endif(NOT ANDROID AND NOT IOS)
|
||||
endif()
|
||||
|
||||
# Export return values
|
||||
set(${found} "${_found}" PARENT_SCOPE)
|
||||
set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor")
|
||||
set(${version_string} "${_version_string}" PARENT_SCOPE)
|
||||
set(${version_major} "${_version_major}" PARENT_SCOPE)
|
||||
set(${version_minor} "${_version_minor}" PARENT_SCOPE)
|
||||
set(${libs_found} "${_libs_found}" PARENT_SCOPE)
|
||||
set(${libs_version_string} "${_libs_version_string}" PARENT_SCOPE)
|
||||
set(${libraries} "${_libraries}" PARENT_SCOPE)
|
||||
set(${library} "${_library}" CACHE FILEPATH "Path to Python library")
|
||||
set(${debug_libraries} "${_debug_libraries}" PARENT_SCOPE)
|
||||
set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug")
|
||||
set(${include_path} "${_include_path}" PARENT_SCOPE)
|
||||
set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir")
|
||||
set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2")
|
||||
set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.")
|
||||
set(${numpy_include_dirs} ${_numpy_include_dirs} CACHE PATH "Path to numpy headers")
|
||||
set(${numpy_version} "${_numpy_version}" PARENT_SCOPE)
|
||||
endfunction(find_python)
|
||||
|
||||
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
|
||||
PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
|
||||
PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
|
||||
PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
|
||||
PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
|
||||
PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH
|
||||
PYTHON2_NUMPY_INCLUDE_DIRS PYTHON2_NUMPY_VERSION)
|
||||
|
||||
find_python(3.4 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
|
||||
PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
|
||||
PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND
|
||||
PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY
|
||||
PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH
|
||||
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH
|
||||
PYTHON3_NUMPY_INCLUDE_DIRS PYTHON3_NUMPY_VERSION)
|
||||
|
||||
# Use Python 2 as default Python interpreter
|
||||
if(PYTHON2LIBS_FOUND)
|
||||
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
|
||||
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
unset(HAVE_SPHINX CACHE)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
|
||||
# not using PYTHON_VERSION_STRING here, because it might not conform to the CMake version format
|
||||
find_host_package(PythonLibs "${PYTHON_VERSION_MAJOR_MINOR}.${PYTHON_VERSION_PATCH}" EXACT)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
if(CMAKE_HOST_UNIX)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print(get_python_lib())"
|
||||
RESULT_VARIABLE PYTHON_CVPY_PROCESS
|
||||
OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages")
|
||||
set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/site-packages")
|
||||
else() #debian based assumed, install to the dist-packages.
|
||||
set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages")
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${PYTHON_PACKAGES_PATH}")
|
||||
set(_PYTHON_PACKAGES_PATH "lib${LIB_SUFFIX}/${_PYTHON_PACKAGES_PATH}")
|
||||
else()
|
||||
set(_PYTHON_PACKAGES_PATH "lib/${_PYTHON_PACKAGES_PATH}")
|
||||
endif()
|
||||
elseif(CMAKE_HOST_WIN32)
|
||||
get_filename_component(PYTHON_PATH "${PYTHON_EXECUTABLE}" PATH)
|
||||
file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
|
||||
if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages")
|
||||
unset(PYTHON_PATH)
|
||||
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
|
||||
if(NOT PYTHON_PATH)
|
||||
get_filename_component(PYTHON_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
|
||||
endif()
|
||||
set(_PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
|
||||
endif()
|
||||
SET(PYTHON_PACKAGES_PATH "${_PYTHON_PACKAGES_PATH}" CACHE PATH "Where to install the python packages.")
|
||||
|
||||
if(NOT PYTHON_NUMPY_INCLUDE_DIRS)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)")
|
||||
message(STATUS "If you want to enable Python/Numpy support, set the following variables:")
|
||||
message(STATUS " PYTHON_INCLUDE_PATH")
|
||||
message(STATUS " PYTHON_LIBRARIES")
|
||||
message(STATUS " PYTHON_NUMPY_INCLUDE_DIRS")
|
||||
else()
|
||||
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
|
||||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))"
|
||||
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
|
||||
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT PYTHON_NUMPY_PROCESS EQUAL 0)
|
||||
unset(PYTHON_NUMPY_INCLUDE_DIRS)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PYTHON_NUMPY_INCLUDE_DIRS)
|
||||
file(TO_CMAKE_PATH "${PYTHON_NUMPY_INCLUDE_DIRS}" _PYTHON_NUMPY_INCLUDE_DIRS)
|
||||
set(PYTHON_NUMPY_INCLUDE_DIRS ${_PYTHON_NUMPY_INCLUDE_DIRS} CACHE PATH "Path to numpy headers")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(NOT PYTHON_NUMPY_VERSION)
|
||||
set(PYTHON_NUMPY_VERSION "undefined - cannot be probed because of the cross-compilation")
|
||||
endif()
|
||||
else()
|
||||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy; print(numpy.version.version)"
|
||||
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
|
||||
OUTPUT_VARIABLE PYTHON_NUMPY_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
endif(NOT ANDROID AND NOT IOS)
|
||||
endif()
|
||||
|
||||
if(BUILD_DOCS)
|
||||
find_host_program(SPHINX_BUILD sphinx-build)
|
||||
find_host_program(PLANTUML plantuml)
|
||||
|
||||
@@ -63,6 +63,8 @@ if(NOT HAVE_TBB)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
|
||||
elseif(MSVC11)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc11")
|
||||
elseif(MSVC12)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc12")
|
||||
endif()
|
||||
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
|
||||
link_directories("${TBB_LIB_DIR}")
|
||||
|
||||
+44
-12
@@ -2,20 +2,52 @@ if(NOT WITH_VTK OR ANDROID OR IOS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture vtkIOExport NO_MODULE)
|
||||
# VTK 6.x components
|
||||
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
||||
|
||||
if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
|
||||
find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
|
||||
# VTK 5.x components
|
||||
if(NOT VTK_FOUND)
|
||||
find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
|
||||
find_package(VTK 5.8 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
|
||||
endif()
|
||||
|
||||
if(VTK_FOUND)
|
||||
set(HAVE_VTK ON)
|
||||
message(STATUS "Found VTK ver. ${VTK_VERSION} (usefile: ${VTK_USE_FILE})")
|
||||
else()
|
||||
if(NOT VTK_FOUND)
|
||||
set(HAVE_VTK OFF)
|
||||
message(STATUS "VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or set $VTK_DIR enviroment variable to VTK install subdirectory with VTKConfig.cmake file (for windows)")
|
||||
message(STATUS "VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Don't support ealier VTKs
|
||||
if(${VTK_VERSION} VERSION_LESS "5.8.0")
|
||||
message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together
|
||||
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_LESS "6.0.0")
|
||||
if(VTK_USE_QT)
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together. VTK 6.0.0 doesn't provide a way to get Qt version it was linked with
|
||||
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
|
||||
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
|
||||
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together
|
||||
if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
|
||||
if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5")
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(HAVE_VTK ON)
|
||||
message(STATUS "Found VTK ver. ${VTK_VERSION} (usefile: ${VTK_USE_FILE})")
|
||||
|
||||
+184
-290
@@ -2,335 +2,229 @@
|
||||
# The script to detect Intel(R) Integrated Performance Primitives (IPP)
|
||||
# installation/package
|
||||
#
|
||||
# This will try to find Intel IPP libraries, and include path by automatic
|
||||
# search through typical install locations and if failed it will
|
||||
# examine IPPROOT environment variable.
|
||||
# Note, IPPROOT is not set by IPP installer, it should be set manually.
|
||||
# By default, ICV version will be used.
|
||||
# To use standalone IPP update cmake command line:
|
||||
# cmake ... -DIPPROOT=<path> ...
|
||||
#
|
||||
# Note: Backward compatibility is broken, IPPROOT environment path is ignored
|
||||
#
|
||||
#
|
||||
# On return this will define:
|
||||
#
|
||||
# IPP_FOUND - True if Intel IPP found
|
||||
# IPP_ROOT_DIR - root of IPP installation
|
||||
# IPP_INCLUDE_DIRS - IPP include folder
|
||||
# IPP_LIBRARY_DIRS - IPP libraries folder
|
||||
# IPP_LIBRARIES - IPP libraries names that are used by OpenCV
|
||||
# IPP_LATEST_VERSION_STR - string with the newest detected IPP version
|
||||
# IPP_LATEST_VERSION_MAJOR - numbers of IPP version (MAJOR.MINOR.BUILD)
|
||||
# IPP_LATEST_VERSION_MINOR
|
||||
# IPP_LATEST_VERSION_BUILD
|
||||
# HAVE_IPP - True if Intel IPP found
|
||||
# HAVE_IPP_ICV_ONLY - True if Intel IPP ICV version is available
|
||||
# IPP_ROOT_DIR - root of IPP installation
|
||||
# IPP_INCLUDE_DIRS - IPP include folder
|
||||
# IPP_LIBRARIES - IPP libraries that are used by OpenCV
|
||||
# IPP_VERSION_STR - string with the newest detected IPP version
|
||||
# IPP_VERSION_MAJOR - numbers of IPP version (MAJOR.MINOR.BUILD)
|
||||
# IPP_VERSION_MINOR
|
||||
# IPP_VERSION_BUILD
|
||||
#
|
||||
# Created: 30 Dec 2010 by Vladimir Dudnik (vladimir.dudnik@intel.com)
|
||||
#
|
||||
|
||||
set(IPP_FOUND)
|
||||
set(IPP_VERSION_STR "5.3.0.0") # will not detect earlier versions
|
||||
set(IPP_VERSION_MAJOR 0)
|
||||
set(IPP_VERSION_MINOR 0)
|
||||
set(IPP_VERSION_BUILD 0)
|
||||
set(IPP_ROOT_DIR)
|
||||
set(IPP_INCLUDE_DIRS)
|
||||
set(IPP_LIBRARY_DIRS)
|
||||
set(IPP_LIBRARIES)
|
||||
set(IPP_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(IPP_PREFIX "ipp")
|
||||
set(IPP_SUFFIX "_l")
|
||||
set(IPPCORE "core") # core functionality
|
||||
set(IPPS "s") # signal processing
|
||||
set(IPPI "i") # image processing
|
||||
set(IPPCC "cc") # color conversion
|
||||
set(IPPCV "cv") # computer vision
|
||||
set(IPPVM "vm") # vector math
|
||||
unset(HAVE_IPP CACHE)
|
||||
unset(HAVE_IPP_ICV_ONLY)
|
||||
unset(IPP_ROOT_DIR)
|
||||
unset(IPP_INCLUDE_DIRS)
|
||||
unset(IPP_LIBRARIES)
|
||||
unset(IPP_VERSION_STR)
|
||||
unset(IPP_VERSION_MAJOR)
|
||||
unset(IPP_VERSION_MINOR)
|
||||
unset(IPP_VERSION_BUILD)
|
||||
|
||||
set(IPP_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
set(IPP_X64 0)
|
||||
if (CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(IPP_X64 1)
|
||||
endif()
|
||||
if (CMAKE_CL_64)
|
||||
if(CMAKE_CL_64)
|
||||
set(IPP_X64 1)
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This function detect IPP version by analyzing ippversion.h file
|
||||
# Note, ippversion.h file was inroduced since IPP 5.3
|
||||
# ------------------------------------------------------------------------
|
||||
function(get_ipp_version _ROOT_DIR)
|
||||
set(_VERSION_STR)
|
||||
set(_MAJOR)
|
||||
set(_MINOR)
|
||||
set(_BUILD)
|
||||
# This function detects IPP version by analyzing .h file
|
||||
macro(ipp_get_version VERSION_FILE)
|
||||
unset(_VERSION_STR)
|
||||
unset(_MAJOR)
|
||||
unset(_MINOR)
|
||||
unset(_BUILD)
|
||||
|
||||
# read IPP version info from file
|
||||
file(STRINGS ${_ROOT_DIR}/include/ippversion.h STR1 REGEX "IPP_VERSION_MAJOR")
|
||||
file(STRINGS ${_ROOT_DIR}/include/ippversion.h STR2 REGEX "IPP_VERSION_MINOR")
|
||||
file(STRINGS ${_ROOT_DIR}/include/ippversion.h STR3 REGEX "IPP_VERSION_BUILD")
|
||||
if("${STR3}" STREQUAL "")
|
||||
file(STRINGS ${_ROOT_DIR}/include/ippversion.h STR3 REGEX "IPP_VERSION_UPDATE")
|
||||
# read IPP version info from file
|
||||
file(STRINGS ${VERSION_FILE} STR1 REGEX "IPP_VERSION_MAJOR")
|
||||
file(STRINGS ${VERSION_FILE} STR2 REGEX "IPP_VERSION_MINOR")
|
||||
file(STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_BUILD")
|
||||
if("${STR3}" STREQUAL "")
|
||||
file(STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_UPDATE")
|
||||
endif()
|
||||
file(STRINGS ${VERSION_FILE} STR4 REGEX "IPP_VERSION_STR")
|
||||
|
||||
# extract info and assign to variables
|
||||
string(REGEX MATCHALL "[0-9]+" _MAJOR ${STR1})
|
||||
string(REGEX MATCHALL "[0-9]+" _MINOR ${STR2})
|
||||
string(REGEX MATCHALL "[0-9]+" _BUILD ${STR3})
|
||||
string(REGEX MATCHALL "[0-9]+[.]+[0-9]+[^\"]+|[0-9]+[.]+[0-9]+" _VERSION_STR ${STR4})
|
||||
|
||||
# export info to parent scope
|
||||
set(IPP_VERSION_STR ${_VERSION_STR})
|
||||
set(IPP_VERSION_MAJOR ${_MAJOR})
|
||||
set(IPP_VERSION_MINOR ${_MINOR})
|
||||
set(IPP_VERSION_BUILD ${_BUILD})
|
||||
endmacro()
|
||||
|
||||
macro(_ipp_not_supported)
|
||||
message(STATUS ${ARGN})
|
||||
unset(HAVE_IPP)
|
||||
unset(HAVE_IPP_ICV_ONLY)
|
||||
unset(IPP_VERSION_STR)
|
||||
return()
|
||||
endmacro()
|
||||
|
||||
# This macro uses IPP_ROOT_DIR variable
|
||||
# TODO Cleanup code after ICV package stabilization
|
||||
macro(ipp_detect_version)
|
||||
set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include)
|
||||
|
||||
set(__msg)
|
||||
if(EXISTS ${IPP_ROOT_DIR}/include/ippicv_redefs.h)
|
||||
set(__msg " (ICV version)")
|
||||
set(HAVE_IPP_ICV_ONLY 1)
|
||||
elseif(EXISTS ${IPP_ROOT_DIR}/include/ipp.h)
|
||||
# nothing
|
||||
else()
|
||||
_ipp_not_supported("Can't resolve IPP directory: ${IPP_ROOT_DIR}")
|
||||
endif()
|
||||
|
||||
ipp_get_version(${IPP_INCLUDE_DIRS}/ippversion.h)
|
||||
ocv_assert(IPP_VERSION_STR VERSION_GREATER "1.0")
|
||||
|
||||
message(STATUS "found IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
|
||||
message(STATUS "at: ${IPP_ROOT_DIR}")
|
||||
|
||||
if(${IPP_VERSION_STR} VERSION_LESS "7.0")
|
||||
_ipp_not_supported("IPP ${IPP_VERSION_STR} is not supported")
|
||||
endif()
|
||||
|
||||
set(HAVE_IPP 1)
|
||||
|
||||
macro(_ipp_set_library_dir DIR)
|
||||
if(NOT EXISTS ${DIR})
|
||||
_ipp_not_supported("IPP library directory not found")
|
||||
endif()
|
||||
file(STRINGS ${_ROOT_DIR}/include/ippversion.h STR4 REGEX "IPP_VERSION_STR")
|
||||
set(IPP_LIBRARY_DIR ${DIR})
|
||||
endmacro()
|
||||
|
||||
# extract info and assign to variables
|
||||
string(REGEX MATCHALL "[0-9]+" _MAJOR ${STR1})
|
||||
string(REGEX MATCHALL "[0-9]+" _MINOR ${STR2})
|
||||
string(REGEX MATCHALL "[0-9]+" _BUILD ${STR3})
|
||||
string(REGEX MATCHALL "[0-9]+[.]+[0-9]+[^\"]+|[0-9]+[.]+[0-9]+" _VERSION_STR ${STR4})
|
||||
if(APPLE)
|
||||
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib)
|
||||
elseif(IPP_X64)
|
||||
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib/intel64)
|
||||
else()
|
||||
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib/ia32)
|
||||
endif()
|
||||
|
||||
# export info to parent scope
|
||||
set(IPP_VERSION_STR ${_VERSION_STR} PARENT_SCOPE)
|
||||
set(IPP_VERSION_MAJOR ${_MAJOR} PARENT_SCOPE)
|
||||
set(IPP_VERSION_MINOR ${_MINOR} PARENT_SCOPE)
|
||||
set(IPP_VERSION_BUILD ${_BUILD} PARENT_SCOPE)
|
||||
|
||||
message(STATUS "found IPP: ${_MAJOR}.${_MINOR}.${_BUILD} [${_VERSION_STR}]")
|
||||
message(STATUS "at: ${_ROOT_DIR}")
|
||||
|
||||
return()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This is auxiliary function called from set_ipp_variables()
|
||||
# to set IPP_LIBRARIES variable in IPP 6.x style (IPP 5.3 should also work)
|
||||
# ------------------------------------------------------------------------
|
||||
function(set_ipp_old_libraries)
|
||||
set(IPP_PREFIX "ipp")
|
||||
set(IPP_SUFFIX) # old style static core libs suffix
|
||||
set(IPP_ARCH) # architecture suffix
|
||||
set(IPP_DISP "emerged") # old style dipatcher and cpu-specific
|
||||
set(IPP_MRGD "merged") # static libraries
|
||||
set(IPPCORE "core") # core functionality
|
||||
set(IPPSP "s") # signal processing
|
||||
set(IPPIP "i") # image processing
|
||||
set(IPPCC "cc") # color conversion
|
||||
set(IPPCV "cv") # computer vision
|
||||
set(IPPVM "vm") # vector math
|
||||
|
||||
if (IPP_X64)
|
||||
set(IPP_ARCH "em64t")
|
||||
macro(_ipp_add_library name)
|
||||
if (EXISTS ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
|
||||
add_library(ipp${name} STATIC IMPORTED)
|
||||
set_target_properties(ipp${name} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ""
|
||||
IMPORTED_LOCATION ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
)
|
||||
list(APPEND IPP_LIBRARIES ipp${name})
|
||||
# CMake doesn't support "install(TARGETS ipp${name} " command with imported targets
|
||||
install(FILES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
|
||||
string(TOUPPER ${name} uname)
|
||||
set(IPP${uname}_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
set(IPP${uname}_LOCATION_PATH "${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
message(STATUS "Can't find IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(IPP_PREFIX "ipp")
|
||||
if(${IPP_VERSION_STR} VERSION_LESS "8.0")
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x
|
||||
else()
|
||||
if(WIN32)
|
||||
set(IPP_SUFFIX "l")
|
||||
endif()
|
||||
|
||||
set(IPP_LIBRARIES
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPVM}${IPP_MRGD}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPVM}${IPP_DISP}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCC}${IPP_MRGD}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCC}${IPP_DISP}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_MRGD}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_DISP}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPIP}${IPP_MRGD}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPIP}${IPP_DISP}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPSP}${IPP_MRGD}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPSP}${IPP_DISP}${IPP_ARCH}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_ARCH}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
PARENT_SCOPE)
|
||||
|
||||
return()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This is auxiliary function called from set_ipp_variables()
|
||||
# to set IPP_LIBRARIES variable in IPP 7.x and 8.x style
|
||||
# ------------------------------------------------------------------------
|
||||
function(set_ipp_new_libraries _LATEST_VERSION)
|
||||
set(IPP_PREFIX "ipp")
|
||||
|
||||
if(${_LATEST_VERSION} VERSION_LESS "8.0")
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x
|
||||
set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows
|
||||
else()
|
||||
if(WIN32)
|
||||
set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows
|
||||
else()
|
||||
set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X
|
||||
endif()
|
||||
set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X
|
||||
endif()
|
||||
set(IPPCORE "core") # core functionality
|
||||
set(IPPSP "s") # signal processing
|
||||
set(IPPIP "i") # image processing
|
||||
set(IPPCC "cc") # color conversion
|
||||
set(IPPCV "cv") # computer vision
|
||||
set(IPPVM "vm") # vector math
|
||||
endif()
|
||||
|
||||
set(IPP_LIBRARIES
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPVM}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCC}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
PARENT_SCOPE)
|
||||
if(HAVE_IPP_ICV_ONLY)
|
||||
_ipp_add_library(icv)
|
||||
else()
|
||||
_ipp_add_library(core)
|
||||
_ipp_add_library(s)
|
||||
_ipp_add_library(i)
|
||||
_ipp_add_library(cc)
|
||||
_ipp_add_library(cv)
|
||||
_ipp_add_library(vm)
|
||||
_ipp_add_library(m)
|
||||
|
||||
return()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This function will set
|
||||
# IPP_INCLUDE_DIRS, IPP_LIBRARY_DIRS and IPP_LIBRARIES variables depending
|
||||
# on IPP version parameter.
|
||||
# Since IPP 7.0 version library names and install folder structure
|
||||
# was changed
|
||||
# ------------------------------------------------------------------------
|
||||
function(set_ipp_variables _LATEST_VERSION)
|
||||
if(${_LATEST_VERSION} VERSION_LESS "7.0")
|
||||
# message(STATUS "old")
|
||||
|
||||
# set INCLUDE and LIB folders
|
||||
set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include PARENT_SCOPE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
|
||||
|
||||
if (IPP_X64)
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/../em64t)
|
||||
message(SEND_ERROR "IPP EM64T libraries not found")
|
||||
endif()
|
||||
if(UNIX)
|
||||
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH)
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR})
|
||||
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../compiler/lib REALPATH)
|
||||
endif()
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR})
|
||||
_ipp_not_supported("IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
if(IPP_X64)
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
|
||||
message(SEND_ERROR "Intel compiler EM64T libraries not found")
|
||||
endif()
|
||||
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
|
||||
else()
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/../ia32)
|
||||
message(SEND_ERROR "IPP IA32 libraries not found")
|
||||
endif()
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
|
||||
message(SEND_ERROR "Intel compiler IA32 libraries not found")
|
||||
endif()
|
||||
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set IPP_LIBRARIES variable (6.x lib names)
|
||||
set_ipp_old_libraries()
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
|
||||
message(STATUS "IPP libs: ${IPP_LIBRARIES}")
|
||||
|
||||
else()
|
||||
# message(STATUS "new")
|
||||
|
||||
# set INCLUDE and LIB folders
|
||||
set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include PARENT_SCOPE)
|
||||
|
||||
if (APPLE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
|
||||
elseif (IPP_X64)
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)
|
||||
message(SEND_ERROR "IPP EM64T libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64 PARENT_SCOPE)
|
||||
macro(_ipp_add_compiler_library name)
|
||||
if (EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
list(APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
else()
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/ia32)
|
||||
message(SEND_ERROR "IPP IA32 libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32 PARENT_SCOPE)
|
||||
message(STATUS "Can't find compiler library: ${name}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# set IPP_LIBRARIES variable (7.x or 8.x lib names)
|
||||
set_ipp_new_libraries(${_LATEST_VERSION})
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
|
||||
message(STATUS "IPP libs: ${IPP_LIBRARIES}")
|
||||
_ipp_add_compiler_library(irc)
|
||||
_ipp_add_compiler_library(imf)
|
||||
_ipp_add_compiler_library(svml)
|
||||
endif(UNIX)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
#message(STATUS "IPP libs: ${IPP_LIBRARIES}")
|
||||
endmacro()
|
||||
|
||||
# OPENCV_IPP_PATH is an environment variable for internal usage only, do not use it
|
||||
if(DEFINED ENV{OPENCV_IPP_PATH} AND NOT DEFINED IPPROOT)
|
||||
set(IPPROOT "$ENV{OPENCV_IPP_PATH}")
|
||||
endif()
|
||||
if(NOT DEFINED IPPROOT)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/downloader.cmake")
|
||||
if(DEFINED OPENCV_ICV_PATH)
|
||||
set(IPPROOT "${OPENCV_ICV_PATH}")
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This section will look for IPP through IPPROOT env variable
|
||||
# Note, IPPROOT is not set by IPP installer, you may need to set it manually
|
||||
# ------------------------------------------------------------------------
|
||||
find_path(
|
||||
IPP_H_PATH
|
||||
NAMES ippversion.h
|
||||
PATHS $ENV{IPPROOT}
|
||||
PATH_SUFFIXES include
|
||||
DOC "The path to Intel(R) IPP header files"
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_PATH)
|
||||
|
||||
if(IPP_H_PATH)
|
||||
set(IPP_FOUND 1)
|
||||
|
||||
# traverse up to IPPROOT level
|
||||
get_filename_component(IPP_ROOT_DIR ${IPP_H_PATH} PATH)
|
||||
|
||||
# extract IPP version info
|
||||
get_ipp_version(${IPP_ROOT_DIR})
|
||||
|
||||
# keep info in the same vars for auto search and search by IPPROOT
|
||||
set(IPP_LATEST_VERSION_STR ${IPP_VERSION_STR})
|
||||
set(IPP_LATEST_VERSION_MAJOR ${IPP_VERSION_MAJOR})
|
||||
set(IPP_LATEST_VERSION_MINOR ${IPP_VERSION_MINOR})
|
||||
set(IPP_LATEST_VERSION_BUILD ${IPP_VERSION_BUILD})
|
||||
|
||||
# set IPP INCLUDE, LIB dirs and library names
|
||||
set_ipp_variables(${IPP_LATEST_VERSION_STR})
|
||||
file(TO_CMAKE_PATH "${IPPROOT}" __IPPROOT)
|
||||
if(EXISTS "${__IPPROOT}/include/ippversion.h")
|
||||
set(IPP_ROOT_DIR ${__IPPROOT})
|
||||
ipp_detect_version()
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT IPP_FOUND)
|
||||
# reset var from previous search
|
||||
set(IPP_H_PATH)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# This section will look for IPP through system program folders
|
||||
# Note, if several IPP installations found the newest version will be
|
||||
# selected
|
||||
# ------------------------------------------------------------------------
|
||||
foreach(curdir ${CMAKE_SYSTEM_PREFIX_PATH})
|
||||
set(curdir ${curdir}/intel)
|
||||
file(TO_CMAKE_PATH ${curdir} CURDIR)
|
||||
|
||||
if(EXISTS ${curdir})
|
||||
file(GLOB_RECURSE IPP_H_DIR ${curdir}/ippversion.h)
|
||||
|
||||
if(IPP_H_DIR)
|
||||
set(IPP_FOUND 1)
|
||||
endif()
|
||||
|
||||
# init IPP_LATEST_VERSION version with oldest detectable version (5.3.0.0)
|
||||
# IPP prior 5.3 did not have ippversion.h file
|
||||
set(IPP_LATEST_VERSION_STR ${IPP_VERSION_STR})
|
||||
|
||||
# look through all dirs where ippversion.h was found
|
||||
foreach(item ${IPP_H_DIR})
|
||||
|
||||
# traverse up to IPPROOT level
|
||||
get_filename_component(_FILE_PATH ${item} PATH)
|
||||
get_filename_component(_ROOT_DIR ${_FILE_PATH} PATH)
|
||||
|
||||
# extract IPP version info
|
||||
get_ipp_version(${_ROOT_DIR})
|
||||
|
||||
# remember the latest version (if many found)
|
||||
if(${IPP_LATEST_VERSION_STR} VERSION_LESS ${IPP_VERSION_STR})
|
||||
set(IPP_LATEST_VERSION_STR ${IPP_VERSION_STR})
|
||||
set(IPP_LATEST_VERSION_MAJOR ${IPP_VERSION_MAJOR})
|
||||
set(IPP_LATEST_VERSION_MINOR ${IPP_VERSION_MINOR})
|
||||
set(IPP_LATEST_VERSION_BUILD ${IPP_VERSION_BUILD})
|
||||
set(IPP_ROOT_DIR ${_ROOT_DIR})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(IPP_FOUND)
|
||||
# set IPP INCLUDE, LIB dirs and library names
|
||||
set_ipp_variables(${IPP_LATEST_VERSION_STR})
|
||||
|
||||
# set CACHE variable IPP_H_PATH,
|
||||
# path to IPP header files for the latest version
|
||||
find_path(
|
||||
IPP_H_PATH
|
||||
NAMES ippversion.h
|
||||
PATHS ${IPP_ROOT_DIR}
|
||||
PATH_SUFFIXES include
|
||||
DOC "The path to Intel(R) IPP header files"
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_PATH)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND MINGW AND NOT IPP_LATEST_VERSION_MAJOR LESS 7)
|
||||
if(WIN32 AND MINGW AND NOT IPP_VERSION_MAJOR LESS 7)
|
||||
# Since IPP built with Microsoft compiler and /GS option
|
||||
# ======================================================
|
||||
# From Windows SDK 7.1
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Main variables:
|
||||
# IPP_A_LIBRARIES and IPP_A_INCLUDE to use IPP Async
|
||||
# HAVE_IPP_A for conditional compilation OpenCV with/without IPP Async
|
||||
|
||||
# IPP_ASYNC_ROOT - root of IPP Async installation
|
||||
|
||||
if(X86_64)
|
||||
find_path(
|
||||
IPP_A_INCLUDE_DIR
|
||||
NAMES ipp_async_defs.h
|
||||
PATHS $ENV{IPP_ASYNC_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
DOC "Path to Intel IPP Async interface headers")
|
||||
|
||||
find_file(
|
||||
IPP_A_LIBRARIES
|
||||
NAMES ipp_async_preview.lib
|
||||
PATHS $ENV{IPP_ASYNC_ROOT}
|
||||
PATH_SUFFIXES lib/intel64
|
||||
DOC "Path to Intel IPP Async interface libraries")
|
||||
|
||||
else()
|
||||
find_path(
|
||||
IPP_A_INCLUDE_DIR
|
||||
NAMES ipp_async_defs.h
|
||||
PATHS $ENV{IPP_ASYNC_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
DOC "Path to Intel IPP Async interface headers")
|
||||
|
||||
find_file(
|
||||
IPP_A_LIBRARIES
|
||||
NAMES ipp_async_preview.lib
|
||||
PATHS $ENV{IPP_ASYNC_ROOT}
|
||||
PATH_SUFFIXES lib/ia32
|
||||
DOC "Path to Intel IPP Async interface libraries")
|
||||
endif()
|
||||
|
||||
if(IPP_A_INCLUDE_DIR AND IPP_A_LIBRARIES)
|
||||
set(HAVE_IPP_A TRUE)
|
||||
else()
|
||||
set(HAVE_IPP_A FALSE)
|
||||
message(WARNING "Intel IPP Async library directory (set by IPP_A_LIBRARIES_DIR variable) is not found or does not have Intel IPP Async libraries.")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FORCE IPP_A_LIBRARIES IPP_A_INCLUDE_DIR)
|
||||
@@ -39,11 +39,26 @@ if(WITH_QT)
|
||||
endif()
|
||||
|
||||
# --- GTK ---
|
||||
ocv_clear_vars(HAVE_GTK HAVE_GTHREAD HAVE_GTKGLEXT)
|
||||
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
|
||||
if(WITH_GTK AND NOT HAVE_QT)
|
||||
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
|
||||
if(NOT WITH_GTK_2_X)
|
||||
CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
|
||||
if(HAVE_GTK3)
|
||||
set(HAVE_GTK TRUE)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT HAVE_GTK)
|
||||
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
|
||||
if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK))
|
||||
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)")
|
||||
set(HAVE_GTK FALSE)
|
||||
endif()
|
||||
endif()
|
||||
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
|
||||
if(WITH_OPENGL)
|
||||
if(HAVE_GTK AND NOT HAVE_GTHREAD)
|
||||
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
|
||||
endif()
|
||||
if(WITH_OPENGL AND NOT HAVE_GTK3)
|
||||
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
|
||||
endif()
|
||||
endif()
|
||||
@@ -69,7 +84,7 @@ endif(WITH_OPENGL)
|
||||
if(APPLE)
|
||||
if(WITH_CARBON)
|
||||
set(HAVE_CARBON YES)
|
||||
elseif(NOT IOS)
|
||||
elseif(NOT IOS AND CMAKE_COMPILER_IS_CLANGCXX)
|
||||
set(HAVE_COCOA YES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -198,3 +198,15 @@ if(WITH_OPENEXR)
|
||||
|
||||
set(HAVE_OPENEXR YES)
|
||||
endif()
|
||||
|
||||
# --- GDAL (optional) ---
|
||||
if(WITH_GDAL)
|
||||
find_package(GDAL)
|
||||
|
||||
if(NOT GDAL_FOUND)
|
||||
ocv_clear_vars(GDAL_LIBRARY GDAL_INCLUDE_DIR)
|
||||
set(HAVE_GDAL NO)
|
||||
else()
|
||||
set(HAVE_GDAL YES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -8,16 +8,24 @@ if(WITH_TBB)
|
||||
endif(WITH_TBB)
|
||||
|
||||
# --- IPP ---
|
||||
ocv_clear_vars(IPP_FOUND)
|
||||
if(WITH_IPP)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPP.cmake")
|
||||
if(IPP_FOUND)
|
||||
add_definitions(-DHAVE_IPP)
|
||||
if(HAVE_IPP)
|
||||
ocv_include_directories(${IPP_INCLUDE_DIRS})
|
||||
link_directories(${IPP_LIBRARY_DIRS})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
|
||||
list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
|
||||
endif()
|
||||
endif(WITH_IPP)
|
||||
endif()
|
||||
|
||||
# --- IPP Async ---
|
||||
|
||||
if(WITH_IPP_A)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPAsync.cmake")
|
||||
if(IPP_A_INCLUDE_DIR AND IPP_A_LIBRARIES)
|
||||
ocv_include_directories(${IPP_A_INCLUDE_DIR})
|
||||
link_directories(${IPP_A_LIBRARIES})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_A_LIBRARIES})
|
||||
endif()
|
||||
endif(WITH_IPP_A)
|
||||
|
||||
# --- CUDA ---
|
||||
if(WITH_CUDA)
|
||||
|
||||
@@ -131,7 +131,7 @@ if(WITH_1394)
|
||||
if(HAVE_DC1394_2)
|
||||
ocv_parse_pkg("libdc1394-2" "${DC1394_2_LIB_DIR}/pkgconfig" "")
|
||||
ocv_include_directories(${DC1394_2_INCLUDE_PATH})
|
||||
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES}
|
||||
set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES}
|
||||
"${DC1394_2_LIB_DIR}/libdc1394.a"
|
||||
"${CMU1394_LIB_DIR}/lib1394camera.a")
|
||||
endif(HAVE_DC1394_2)
|
||||
@@ -166,6 +166,11 @@ if(WITH_OPENNI)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI.cmake")
|
||||
endif(WITH_OPENNI)
|
||||
|
||||
ocv_clear_vars(HAVE_OPENNI2)
|
||||
if(WITH_OPENNI2)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI2.cmake")
|
||||
endif(WITH_OPENNI2)
|
||||
|
||||
# --- XIMEA ---
|
||||
ocv_clear_vars(HAVE_XIMEA)
|
||||
if(WITH_XIMEA)
|
||||
@@ -234,7 +239,7 @@ if(WITH_FFMPEG)
|
||||
endif()
|
||||
endif(FFMPEG_INCLUDE_DIR)
|
||||
if(HAVE_FFMPEG)
|
||||
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a"
|
||||
set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a"
|
||||
"${FFMPEG_LIB_DIR}/libavformat.a" "${FFMPEG_LIB_DIR}/libavutil.a"
|
||||
"${FFMPEG_LIB_DIR}/libswscale.a")
|
||||
ocv_include_directories(${FFMPEG_INCLUDE_DIR})
|
||||
@@ -253,14 +258,15 @@ if(WITH_MSMF)
|
||||
check_include_file(Mfapi.h HAVE_MSMF)
|
||||
endif(WITH_MSMF)
|
||||
|
||||
# --- Extra HighGUI libs on Windows ---
|
||||
# --- Extra HighGUI and VideoIO libs on Windows ---
|
||||
if(WIN32)
|
||||
list(APPEND HIGHGUI_LIBRARIES comctl32 gdi32 ole32 setupapi ws2_32 vfw32)
|
||||
list(APPEND HIGHGUI_LIBRARIES comctl32 gdi32 ole32 setupapi ws2_32)
|
||||
list(APPEND VIDEOIO_LIBRARIES vfw32)
|
||||
if(MINGW64)
|
||||
list(APPEND HIGHGUI_LIBRARIES avifil32 avicap32 winmm msvfw32)
|
||||
list(REMOVE_ITEM HIGHGUI_LIBRARIES vfw32)
|
||||
list(APPEND VIDEOIO_LIBRARIES avifil32 avicap32 winmm msvfw32)
|
||||
list(REMOVE_ITEM VIDEOIO_LIBRARIES vfw32)
|
||||
elseif(MINGW)
|
||||
list(APPEND HIGHGUI_LIBRARIES winmm)
|
||||
list(APPEND VIDEOIO_LIBRARIES winmm)
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
@@ -273,7 +279,7 @@ endif()
|
||||
if (NOT IOS)
|
||||
if(WITH_QUICKTIME)
|
||||
set(HAVE_QUICKTIME YES)
|
||||
elseif(APPLE)
|
||||
elseif(APPLE AND CMAKE_COMPILER_IS_CLANGCXX)
|
||||
set(HAVE_QTKIT YES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Main variables:
|
||||
# OPENNI2_LIBRARY and OPENNI2_INCLUDES to link OpenCV modules with OpenNI2
|
||||
# HAVE_OPENNI2 for conditional compilation OpenCV with/without OpenNI2
|
||||
|
||||
if(NOT "${OPENNI2_LIB_DIR}" STREQUAL "${OPENNI2_LIB_DIR_INTERNAL}")
|
||||
unset(OPENNI2_LIBRARY CACHE)
|
||||
unset(OPENNI2_LIB_DIR CACHE)
|
||||
endif()
|
||||
|
||||
if(NOT "${OPENNI2_INCLUDE_DIR}" STREQUAL "${OPENNI2_INCLUDE_DIR_INTERNAL}")
|
||||
unset(OPENNI2_INCLUDES CACHE)
|
||||
unset(OPENNI2_INCLUDE_DIR CACHE)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(NOT (MSVC64 OR MINGW64))
|
||||
find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS "$ENV{OPEN_NI_INSTALL_PATH}Include" DOC "OpenNI2 c++ interface header")
|
||||
find_library(OPENNI2_LIBRARY "OpenNI2" PATHS $ENV{OPENNI2_LIB} DOC "OpenNI2 library")
|
||||
else()
|
||||
find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS "$ENV{OPEN_NI_INSTALL_PATH64}Include" DOC "OpenNI2 c++ interface header")
|
||||
find_library(OPENNI2_LIBRARY "OpenNI2" PATHS $ENV{OPENNI2_LIB64} DOC "OpenNI2 library")
|
||||
endif()
|
||||
elseif(UNIX OR APPLE)
|
||||
find_file(OPENNI2_INCLUDES "OpenNI.h" PATHS "/usr/include/ni2" "/usr/include/openni2" DOC "OpenNI2 c++ interface header")
|
||||
find_library(OPENNI2_LIBRARY "OpenNI2" PATHS "/usr/lib" DOC "OpenNI2 library")
|
||||
endif()
|
||||
|
||||
if(OPENNI2_LIBRARY AND OPENNI2_INCLUDES)
|
||||
set(HAVE_OPENNI2 TRUE)
|
||||
endif() #if(OPENNI2_LIBRARY AND OPENNI2_INCLUDES)
|
||||
|
||||
get_filename_component(OPENNI2_LIB_DIR "${OPENNI2_LIBRARY}" PATH)
|
||||
get_filename_component(OPENNI2_INCLUDE_DIR ${OPENNI2_INCLUDES} PATH)
|
||||
|
||||
if(HAVE_OPENNI2)
|
||||
set(OPENNI2_LIB_DIR "${OPENNI2_LIB_DIR}" CACHE PATH "Path to OpenNI2 libraries" FORCE)
|
||||
set(OPENNI2_INCLUDE_DIR "${OPENNI2_INCLUDE_DIR}" CACHE PATH "Path to OpenNI2 headers" FORCE)
|
||||
endif()
|
||||
|
||||
if(OPENNI2_LIBRARY)
|
||||
set(OPENNI2_LIB_DIR_INTERNAL "${OPENNI2_LIB_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI_LIB_DIR was set successfully." FORCE)
|
||||
else()
|
||||
message( WARNING, " OpenNI2 library directory (set by OPENNI2_LIB_DIR variable) is not found or does not have OpenNI2 libraries." )
|
||||
endif()
|
||||
|
||||
if(OPENNI2_INCLUDES)
|
||||
set(OPENNI2_INCLUDE_DIR_INTERNAL "${OPENNI2_INCLUDE_DIR}" CACHE INTERNAL "This is the value of the last time OPENNI2_INCLUDE_DIR was set successfully." FORCE)
|
||||
else()
|
||||
message( WARNING, " OpenNI2 include directory (set by OPENNI2_INCLUDE_DIR variable) is not found or does not have OpenNI2 include files." )
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FORCE OPENNI2_LIBRARY)
|
||||
mark_as_advanced(FORCE OPENNI2_INCLUDES)
|
||||
|
||||
if(HAVE_OPENNI2)
|
||||
ocv_parse_header("${OPENNI2_INCLUDE_DIR}/OniVersion.h" ONI_VERSION_LINE ONI_VERSION_MAJOR ONI_VERSION_MINOR ONI_VERSION_MAINTENANCE ONI_VERSION_BUILD)
|
||||
if(ONI_VERSION_MAJOR)
|
||||
set(OPENNI2_VERSION_STRING ${ONI_VERSION_MAJOR}.${ONI_VERSION_MINOR}.${ONI_VERSION_MAINTENANCE} CACHE INTERNAL "OpenNI2 version")
|
||||
set(OPENNI2_VERSION_BUILD ${ONI_VERSION_BUILD} CACHE INTERNAL "OpenNI2 build version")
|
||||
endif()
|
||||
endif()
|
||||
@@ -83,6 +83,14 @@ endif()
|
||||
|
||||
export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules${modules_file_suffix}.cmake")
|
||||
|
||||
if(TARGET ippicv)
|
||||
set(USE_IPPICV TRUE)
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH})
|
||||
else()
|
||||
set(USE_IPPICV FALSE)
|
||||
set(INSTALL_PATH_RELATIVE_IPPICV "non-existed-path")
|
||||
endif()
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
|
||||
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
|
||||
@@ -98,9 +106,6 @@ if(INSTALL_TO_MANGLED_PATHS)
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE}\"")
|
||||
endif()
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
|
||||
if(UNIX) # ANDROID configuration is created here also
|
||||
#http://www.vtk.org/Wiki/CMake/Tutorials/Packaging reference
|
||||
# For a command "find_package(<name> [major[.minor]] [EXACT] [REQUIRED|QUIET])"
|
||||
@@ -108,6 +113,15 @@ if(UNIX) # ANDROID configuration is created here also
|
||||
# <prefix>/(share|lib)/cmake/<name>*/ (U)
|
||||
# <prefix>/(share|lib)/<name>*/ (U)
|
||||
# <prefix>/(share|lib)/<name>*/(cmake|CMake)/ (U)
|
||||
if(USE_IPPICV)
|
||||
if(INSTALL_TO_MANGLED_PATHS)
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/" ${IPPICV_INSTALL_PATH})
|
||||
else()
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}/" ${IPPICV_INSTALL_PATH})
|
||||
endif()
|
||||
endif()
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
if(INSTALL_TO_MANGLED_PATHS)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/ COMPONENT dev)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/ COMPONENT dev)
|
||||
@@ -131,6 +145,13 @@ if(WIN32)
|
||||
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
||||
|
||||
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
|
||||
if(USE_IPPICV)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}lib" ${IPPICV_INSTALL_PATH})
|
||||
else()
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" ${IPPICV_INSTALL_PATH})
|
||||
endif()
|
||||
endif()
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
if(IOS)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
|
||||
"${CMAKE_BINARY_DIR}/ios/Info.plist")
|
||||
elseif(APPLE)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/platforms/osx/Info.plist.in"
|
||||
"${CMAKE_BINARY_DIR}/osx/Info.plist")
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
set(MIN_VER_CMAKE 2.8.7)
|
||||
set(MIN_VER_CUDA 4.2)
|
||||
set(MIN_VER_PYTHON 2.6)
|
||||
set(MIN_VER_PYTHON2 2.6)
|
||||
set(MIN_VER_PYTHON3 3.2)
|
||||
set(MIN_VER_ZLIB 1.2.3)
|
||||
set(MIN_VER_GTK 2.18.0)
|
||||
|
||||
+238
-187
@@ -6,16 +6,19 @@
|
||||
# Global variables:
|
||||
#
|
||||
# OPENCV_MODULE_${the_module}_LOCATION
|
||||
# OPENCV_MODULE_${the_module}_BINARY_DIR
|
||||
# OPENCV_MODULE_${the_module}_DESCRIPTION
|
||||
# OPENCV_MODULE_${the_module}_CLASS - PUBLIC|INTERNAL|BINDINGS
|
||||
# OPENCV_MODULE_${the_module}_HEADERS
|
||||
# OPENCV_MODULE_${the_module}_SOURCES
|
||||
# OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies
|
||||
# OPENCV_MODULE_${the_module}_DEPS_TO_LINK - differs from above for world build only
|
||||
# OPENCV_MODULE_${the_module}_DEPS_EXT - non-module dependencies
|
||||
# OPENCV_MODULE_${the_module}_REQ_DEPS
|
||||
# OPENCV_MODULE_${the_module}_OPT_DEPS
|
||||
# OPENCV_MODULE_${the_module}_PRIVATE_REQ_DEPS
|
||||
# OPENCV_MODULE_${the_module}_PRIVATE_OPT_DEPS
|
||||
# OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD
|
||||
# HAVE_${the_module} - for fast check of module availability
|
||||
|
||||
# To control the setup of the module you could also set:
|
||||
@@ -27,7 +30,8 @@
|
||||
# The verbose template for OpenCV module:
|
||||
#
|
||||
# ocv_add_module(modname <dependencies>)
|
||||
# ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
|
||||
# ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
|
||||
# or glob them manually and ocv_set_module_sources(...)
|
||||
# ocv_module_include_directories(<extra include directories>)
|
||||
# ocv_create_module()
|
||||
# <add extra link dependencies, compiler options, etc>
|
||||
@@ -52,6 +56,7 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
|
||||
unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE)
|
||||
endforeach()
|
||||
|
||||
# clean modules info which needs to be recalculated
|
||||
@@ -60,6 +65,7 @@ set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules incl
|
||||
set(OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
|
||||
set(OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
|
||||
set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
|
||||
unset(OPENCV_WORLD_MODULES CACHE)
|
||||
|
||||
# adds dependencies to OpenCV module
|
||||
# Usage:
|
||||
@@ -67,6 +73,7 @@ set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules whic
|
||||
# Notes:
|
||||
# * <list of dependencies> - can include full names of modules or full pathes to shared/static libraries or cmake targets
|
||||
macro(ocv_add_dependencies full_modname)
|
||||
ocv_debug_message("ocv_add_dependencies(" ${full_modname} ${ARGN} ")")
|
||||
#we don't clean the dependencies here to allow this macro several times for every module
|
||||
foreach(d "REQUIRED" ${ARGN})
|
||||
if(d STREQUAL "REQUIRED")
|
||||
@@ -104,6 +111,7 @@ endmacro()
|
||||
# Example:
|
||||
# ocv_add_module(yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_cuda)
|
||||
macro(ocv_add_module _name)
|
||||
ocv_debug_message("ocv_add_module(" ${_name} ${ARGN} ")")
|
||||
string(TOLOWER "${_name}" name)
|
||||
string(REGEX REPLACE "^opencv_" "" ${name} "${name}")
|
||||
set(the_module opencv_${name})
|
||||
@@ -133,15 +141,17 @@ macro(ocv_add_module _name)
|
||||
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
|
||||
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
|
||||
|
||||
set(OPENCV_MODULE_${the_module}_LINK_DEPS "" CACHE INTERNAL "")
|
||||
|
||||
# parse list of dependencies
|
||||
if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The cathegory of the module")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The category of the module")
|
||||
set(__ocv_argn__ ${ARGN})
|
||||
list(REMOVE_AT __ocv_argn__ 0)
|
||||
ocv_add_dependencies(${the_module} ${__ocv_argn__})
|
||||
unset(__ocv_argn__)
|
||||
else()
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The cathegory of the module")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The category of the module")
|
||||
ocv_add_dependencies(${the_module} ${ARGN})
|
||||
if(BUILD_${the_module})
|
||||
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export")
|
||||
@@ -149,8 +159,14 @@ macro(ocv_add_module _name)
|
||||
endif()
|
||||
|
||||
# add self to the world dependencies
|
||||
if(NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS" OR OPENCV_MODULE_IS_PART_OF_WORLD)
|
||||
if((NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS"
|
||||
AND NOT OPENCV_PROCESSING_EXTRA_MODULES)
|
||||
OR OPENCV_MODULE_IS_PART_OF_WORLD
|
||||
)
|
||||
set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD ON CACHE INTERNAL "")
|
||||
ocv_add_dependencies(opencv_world OPTIONAL ${the_module})
|
||||
else()
|
||||
set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OFF CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(BUILD_${the_module})
|
||||
@@ -163,12 +179,15 @@ macro(ocv_add_module _name)
|
||||
|
||||
# stop processing of current file
|
||||
return()
|
||||
else(OPENCV_INITIAL_PASS)
|
||||
else()
|
||||
set(OPENCV_MODULE_${the_module}_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "")
|
||||
if(NOT BUILD_${the_module})
|
||||
return() # extra protection from redefinition
|
||||
endif()
|
||||
project(${the_module})
|
||||
endif(OPENCV_INITIAL_PASS)
|
||||
if((NOT OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD AND NOT ${the_module} STREQUAL opencv_world) OR NOT ${BUILD_opencv_world})
|
||||
project(${the_module})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# excludes module from current configuration
|
||||
@@ -199,7 +218,11 @@ macro(ocv_glob_modules)
|
||||
|
||||
# collect modules
|
||||
set(OPENCV_INITIAL_PASS ON)
|
||||
set(OPENCV_PROCESSING_EXTRA_MODULES 0)
|
||||
foreach(__path ${ARGN})
|
||||
if("${__path}" STREQUAL "EXTRA")
|
||||
set(OPENCV_PROCESSING_EXTRA_MODULES 1)
|
||||
endif()
|
||||
get_filename_component(__path "${__path}" ABSOLUTE)
|
||||
|
||||
list(FIND __directories_observed "${__path}" __pathIdx)
|
||||
@@ -221,16 +244,7 @@ macro(ocv_glob_modules)
|
||||
endif()
|
||||
list(APPEND __directories_observed "${__modpath}")
|
||||
|
||||
if(OCV_MODULE_RELOCATE_ON_INITIAL_PASS)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
file(COPY "${__modpath}/CMakeLists.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
set(OPENCV_MODULE_opencv_${mod}_LOCATION "${__modpath}" CACHE PATH "" FORCE)
|
||||
endif()
|
||||
else()
|
||||
add_subdirectory("${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
endif()
|
||||
add_subdirectory("${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
@@ -243,15 +257,31 @@ macro(ocv_glob_modules)
|
||||
# create modules
|
||||
set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
|
||||
set(OPENCV_INITIAL_PASS OFF)
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
if(m MATCHES "^opencv_")
|
||||
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
|
||||
else()
|
||||
message(WARNING "Check module name: ${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(${BUILD_opencv_world})
|
||||
add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world")
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
if(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world)
|
||||
message(STATUS "Processing module ${m}...")
|
||||
if(m MATCHES "^opencv_")
|
||||
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
|
||||
else()
|
||||
message(WARNING "Check module name: ${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
if(m MATCHES "^opencv_")
|
||||
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
|
||||
else()
|
||||
message(WARNING "Check module name: ${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(__shortname)
|
||||
endmacro()
|
||||
|
||||
@@ -393,11 +423,36 @@ function(__ocv_resolve_dependencies)
|
||||
__ocv_sort_modules_by_deps(OPENCV_MODULE_${m}_DEPS)
|
||||
ocv_list_sort(OPENCV_MODULE_${m}_DEPS_EXT)
|
||||
|
||||
set(LINK_DEPS ${OPENCV_MODULE_${m}_DEPS})
|
||||
|
||||
# process world
|
||||
if(BUILD_opencv_world)
|
||||
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
|
||||
list(APPEND OPENCV_WORLD_MODULES ${m})
|
||||
endif()
|
||||
foreach(m2 ${OPENCV_MODULES_BUILD})
|
||||
if(OPENCV_MODULE_${m2}_IS_PART_OF_WORLD)
|
||||
if(";${LINK_DEPS};" MATCHES ";${m2};")
|
||||
list(REMOVE_ITEM LINK_DEPS ${m2})
|
||||
if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;") AND NOT (${m} STREQUAL opencv_world))
|
||||
list(APPEND LINK_DEPS opencv_world)
|
||||
endif()
|
||||
endif()
|
||||
if(${m} STREQUAL opencv_world)
|
||||
list(APPEND OPENCV_MODULE_opencv_world_DEPS_EXT ${OPENCV_MODULE_${m2}_DEPS_EXT})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
|
||||
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module")
|
||||
set(OPENCV_MODULE_${m}_DEPS_TO_LINK ${LINK_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module (for linker)")
|
||||
|
||||
# message(STATUS " module deps: ${OPENCV_MODULE_${m}_DEPS}")
|
||||
# message(STATUS " extra deps: ${OPENCV_MODULE_${m}_DEPS_EXT}")
|
||||
# message(STATUS " module deps of ${m}: ${OPENCV_MODULE_${m}_DEPS}")
|
||||
# message(STATUS " module link deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_TO_LINK}")
|
||||
# message(STATUS " extra deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_EXT}")
|
||||
# message(STATUS "")
|
||||
endforeach()
|
||||
|
||||
__ocv_sort_modules_by_deps(OPENCV_MODULES_BUILD)
|
||||
@@ -405,6 +460,7 @@ function(__ocv_resolve_dependencies)
|
||||
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
|
||||
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} CACHE INTERNAL "List of OpenCV modules included into the build")
|
||||
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
|
||||
set(OPENCV_WORLD_MODULES ${OPENCV_WORLD_MODULES} CACHE INTERNAL "List of OpenCV modules included into the world")
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -421,18 +477,31 @@ macro(ocv_include_modules)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# setup include paths for the list of passed modules and recursively add dependent modules
|
||||
macro(ocv_include_modules_recurse)
|
||||
# setup include paths for the list of passed modules
|
||||
macro(ocv_target_include_modules target)
|
||||
foreach(d ${ARGN})
|
||||
if(d MATCHES "^opencv_" AND HAVE_${d})
|
||||
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
|
||||
ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
|
||||
endif()
|
||||
if(OPENCV_MODULE_${d}_DEPS)
|
||||
ocv_include_modules(${OPENCV_MODULE_${d}_DEPS})
|
||||
ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include")
|
||||
endif()
|
||||
elseif(EXISTS "${d}")
|
||||
ocv_include_directories("${d}")
|
||||
ocv_target_include_directories(${target} "${d}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# setup include paths for the list of passed modules and recursively add dependent modules
|
||||
macro(ocv_target_include_modules_recurse target)
|
||||
foreach(d ${ARGN})
|
||||
if(d MATCHES "^opencv_" AND HAVE_${d})
|
||||
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
|
||||
ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include")
|
||||
endif()
|
||||
if(OPENCV_MODULE_${d}_DEPS)
|
||||
ocv_target_include_modules(${target} ${OPENCV_MODULE_${d}_DEPS})
|
||||
endif()
|
||||
elseif(EXISTS "${d}")
|
||||
ocv_target_include_directories(${target} "${d}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
@@ -440,11 +509,12 @@ endmacro()
|
||||
# setup include path for OpenCV headers for specified module
|
||||
# ocv_module_include_directories(<extra include directories/extra include modules>)
|
||||
macro(ocv_module_include_directories)
|
||||
ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
|
||||
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
|
||||
)
|
||||
ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
|
||||
ocv_target_include_directories(${the_module}
|
||||
"${OPENCV_MODULE_${the_module}_LOCATION}/include"
|
||||
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
|
||||
)
|
||||
ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
|
||||
@@ -453,6 +523,8 @@ endmacro()
|
||||
# Usage:
|
||||
# ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
|
||||
macro(ocv_set_module_sources)
|
||||
ocv_debug_message("ocv_set_module_sources(" ${ARGN} ")")
|
||||
|
||||
set(OPENCV_MODULE_${the_module}_HEADERS "")
|
||||
set(OPENCV_MODULE_${the_module}_SOURCES "")
|
||||
|
||||
@@ -478,71 +550,109 @@ endmacro()
|
||||
|
||||
# finds and sets headers and sources for the standard OpenCV module
|
||||
# Usage:
|
||||
# ocv_glob_module_sources(<extra sources&headers in the same format as used in ocv_set_module_sources>)
|
||||
# ocv_glob_module_sources([EXCLUDE_CUDA] <extra sources&headers in the same format as used in ocv_set_module_sources>)
|
||||
macro(ocv_glob_module_sources)
|
||||
file(GLOB_RECURSE lib_srcs "src/*.cpp")
|
||||
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
|
||||
file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
|
||||
|
||||
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
|
||||
|
||||
file(GLOB lib_cuda_srcs "src/cuda/*.cu")
|
||||
set(cuda_objs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
if(HAVE_CUDA AND lib_cuda_srcs)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
|
||||
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
ocv_debug_message("ocv_glob_module_sources(" ${ARGN} ")")
|
||||
set(_argn ${ARGN})
|
||||
list(FIND _argn "EXCLUDE_CUDA" exclude_cuda)
|
||||
if(NOT exclude_cuda EQUAL -1)
|
||||
list(REMOVE_AT _argn ${exclude_cuda})
|
||||
endif()
|
||||
|
||||
file(GLOB cl_kernels "src/opencl/*.cl")
|
||||
file(GLOB_RECURSE lib_srcs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
||||
)
|
||||
file(GLOB_RECURSE lib_int_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/*.h"
|
||||
)
|
||||
file(GLOB lib_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
|
||||
)
|
||||
file(GLOB lib_hdrs_detail
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.h"
|
||||
)
|
||||
if (APPLE)
|
||||
file(GLOB_RECURSE lib_srcs_apple
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/*.mm"
|
||||
)
|
||||
list(APPEND lib_srcs ${lib_srcs_apple})
|
||||
endif()
|
||||
|
||||
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
|
||||
|
||||
set(lib_cuda_srcs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
if(HAVE_CUDA AND exclude_cuda EQUAL -1)
|
||||
file(GLOB lib_cuda_srcs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu"
|
||||
)
|
||||
file(GLOB lib_cuda_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
|
||||
)
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
|
||||
file(GLOB cl_kernels
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/opencl/*.cl"
|
||||
)
|
||||
if(cl_kernels)
|
||||
set(OCL_NAME opencl_kernels_${name})
|
||||
ocv_include_directories(${OPENCL_INCLUDE_DIRS})
|
||||
string(REGEX REPLACE "opencv_" "" the_module_barename "${the_module}")
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp"
|
||||
COMMAND ${CMAKE_COMMAND} -DMODULE_NAME="${the_module_barename}" -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp"
|
||||
COMMAND ${CMAKE_COMMAND} -DMODULE_NAME="${name}" -DCL_DIR="${CMAKE_CURRENT_LIST_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
|
||||
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake")
|
||||
ocv_source_group("Src\\opencl\\kernels" FILES ${cl_kernels})
|
||||
ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp")
|
||||
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp")
|
||||
endif()
|
||||
|
||||
ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endmacro()
|
||||
|
||||
# creates OpenCV module in current folder
|
||||
# creates new target, configures standard dependencies, compilers flags, install rules
|
||||
# Usage:
|
||||
# ocv_create_module(<extra link dependencies>)
|
||||
# ocv_create_module(SKIP_LINK)
|
||||
# ocv_create_module()
|
||||
macro(ocv_create_module)
|
||||
ocv_debug_message("ocv_create_module(" ${ARGN} ")")
|
||||
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
|
||||
if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
|
||||
# nothing
|
||||
set(the_module_target opencv_world)
|
||||
else()
|
||||
_ocv_create_module(${ARGN})
|
||||
set(the_module_target ${the_module})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(_ocv_create_module)
|
||||
# The condition we ought to be testing here is whether ocv_add_precompiled_headers will
|
||||
# be called at some point in the future. We can't look into the future, though,
|
||||
# so this will have to do.
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp")
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" AND NOT ${the_module} STREQUAL opencv_world)
|
||||
get_native_precompiled_header(${the_module} precomp.hpp)
|
||||
endif()
|
||||
|
||||
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
|
||||
ocv_add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
|
||||
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp"
|
||||
${${the_module}_pch})
|
||||
if(NOT the_module STREQUAL opencv_ts)
|
||||
set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL)
|
||||
endif()
|
||||
|
||||
if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
|
||||
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
|
||||
target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS})
|
||||
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
if (HAVE_CUDA)
|
||||
target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
endif()
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
if (HAVE_CUDA)
|
||||
ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
endif()
|
||||
|
||||
add_dependencies(opencv_modules ${the_module})
|
||||
@@ -597,13 +707,16 @@ macro(ocv_create_module)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
_ocv_add_precompiled_headers(${the_module})
|
||||
endmacro()
|
||||
|
||||
# opencv precompiled headers macro (can add pch to modules and tests)
|
||||
# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
|
||||
# Usage:
|
||||
# ocv_add_precompiled_headers(${the_module})
|
||||
macro(ocv_add_precompiled_headers the_target)
|
||||
macro(_ocv_add_precompiled_headers the_target)
|
||||
ocv_debug_message("ocv_add_precompiled_headers(" ${the_target} ${ARGN} ")")
|
||||
|
||||
if("${the_target}" MATCHES "^opencv_test_.*$")
|
||||
SET(pch_path "test/test_")
|
||||
elseif("${the_target}" MATCHES "^opencv_perf_.*$")
|
||||
@@ -618,13 +731,22 @@ endmacro()
|
||||
# short command for adding simple OpenCV module
|
||||
# see ocv_add_module for argument details
|
||||
# Usage:
|
||||
# ocv_define_module(module_name [INTERNAL] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
|
||||
# ocv_define_module(module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
|
||||
macro(ocv_define_module module_name)
|
||||
ocv_add_module(${module_name} ${ARGN})
|
||||
ocv_debug_message("ocv_define_module(" ${module_name} ${ARGN} ")")
|
||||
set(_argn ${ARGN})
|
||||
set(exclude_cuda "")
|
||||
foreach(arg ${_argn})
|
||||
if("${arg}" STREQUAL "EXCLUDE_CUDA")
|
||||
set(exclude_cuda "${arg}")
|
||||
list(REMOVE_ITEM _argn ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
ocv_add_module(${module_name} ${_argn})
|
||||
ocv_glob_module_sources(${exclude_cuda})
|
||||
ocv_module_include_directories()
|
||||
ocv_glob_module_sources()
|
||||
ocv_create_module()
|
||||
ocv_add_precompiled_headers(${the_module})
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
@@ -659,7 +781,7 @@ macro(__ocv_parse_test_sources tests_type)
|
||||
set(__file_group_name "")
|
||||
set(__file_group_sources "")
|
||||
elseif(arg STREQUAL "DEPENDS_ON")
|
||||
set(__currentvar "OPENCV_TEST_${the_module}_DEPS")
|
||||
set(__currentvar "OPENCV_${tests_type}_${the_module}_DEPS")
|
||||
elseif("${__currentvar}" STREQUAL "__file_group_sources" AND NOT __file_group_name)
|
||||
set(__file_group_name "${arg}")
|
||||
else()
|
||||
@@ -674,20 +796,20 @@ endmacro()
|
||||
# this is a command for adding OpenCV performance tests to the module
|
||||
# ocv_add_perf_tests(<extra_dependencies>)
|
||||
function(ocv_add_perf_tests)
|
||||
set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf")
|
||||
ocv_debug_message("ocv_add_perf_tests(" ${ARGN} ")")
|
||||
|
||||
set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf")
|
||||
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
|
||||
__ocv_parse_test_sources(PERF ${ARGN})
|
||||
|
||||
# opencv_highgui is required for imread/imwrite
|
||||
set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
# opencv_imgcodecs is required for imread/imwrite
|
||||
set(perf_deps ${the_module} opencv_ts opencv_imgcodecs ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
ocv_check_dependencies(${perf_deps})
|
||||
|
||||
if(OCV_DEPENDENCIES_FOUND)
|
||||
set(the_target "opencv_perf_${name}")
|
||||
# project(${the_target})
|
||||
|
||||
ocv_module_include_directories(${perf_deps} "${perf_path}")
|
||||
|
||||
if(NOT OPENCV_PERF_${the_module}_SOURCES)
|
||||
file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp")
|
||||
file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h")
|
||||
@@ -696,10 +818,13 @@ function(ocv_add_perf_tests)
|
||||
set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs})
|
||||
endif()
|
||||
|
||||
get_native_precompiled_header(${the_target} perf_precomp.hpp)
|
||||
if(NOT BUILD_opencv_world)
|
||||
get_native_precompiled_header(${the_target} perf_precomp.hpp)
|
||||
endif()
|
||||
|
||||
add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS})
|
||||
ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
ocv_target_include_modules(${the_target} ${perf_deps} "${perf_path}")
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS})
|
||||
add_dependencies(opencv_perf_tests ${the_target})
|
||||
|
||||
# Additional target properties
|
||||
@@ -712,8 +837,9 @@ function(ocv_add_perf_tests)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
|
||||
endif()
|
||||
|
||||
ocv_add_precompiled_headers(${the_target})
|
||||
|
||||
if(NOT BUILD_opencv_world)
|
||||
_ocv_add_precompiled_headers(${the_target})
|
||||
endif()
|
||||
else(OCV_DEPENDENCIES_FOUND)
|
||||
# TODO: warn about unsatisfied dependencies
|
||||
endif(OCV_DEPENDENCIES_FOUND)
|
||||
@@ -726,21 +852,19 @@ endfunction()
|
||||
# this is a command for adding OpenCV accuracy/regression tests to the module
|
||||
# ocv_add_accuracy_tests([FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies>)
|
||||
function(ocv_add_accuracy_tests)
|
||||
set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test")
|
||||
ocv_check_dependencies(${test_deps})
|
||||
ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")")
|
||||
|
||||
set(test_path "${CMAKE_CURRENT_LIST_DIR}/test")
|
||||
if(BUILD_TESTS AND EXISTS "${test_path}")
|
||||
__ocv_parse_test_sources(TEST ${ARGN})
|
||||
|
||||
# opencv_highgui is required for imread/imwrite
|
||||
set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
# opencv_imgcodecs is required for imread/imwrite
|
||||
set(test_deps ${the_module} opencv_ts opencv_imgcodecs opencv_videoio ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
|
||||
ocv_check_dependencies(${test_deps})
|
||||
|
||||
if(OCV_DEPENDENCIES_FOUND)
|
||||
set(the_target "opencv_test_${name}")
|
||||
# project(${the_target})
|
||||
|
||||
ocv_module_include_directories(${test_deps} "${test_path}")
|
||||
|
||||
if(NOT OPENCV_TEST_${the_module}_SOURCES)
|
||||
file(GLOB_RECURSE test_srcs "${test_path}/*.cpp")
|
||||
file(GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h")
|
||||
@@ -749,10 +873,13 @@ function(ocv_add_accuracy_tests)
|
||||
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
|
||||
endif()
|
||||
|
||||
get_native_precompiled_header(${the_target} test_precomp.hpp)
|
||||
if(NOT BUILD_opencv_world)
|
||||
get_native_precompiled_header(${the_target} test_precomp.hpp)
|
||||
endif()
|
||||
|
||||
add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${test_deps} ${OPENCV_LINKER_LIBS})
|
||||
ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
|
||||
ocv_target_include_modules(${the_target} ${test_deps} "${test_path}")
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${test_deps} ${OPENCV_LINKER_LIBS})
|
||||
add_dependencies(opencv_tests ${the_target})
|
||||
|
||||
# Additional target properties
|
||||
@@ -769,7 +896,9 @@ function(ocv_add_accuracy_tests)
|
||||
get_target_property(LOC ${the_target} LOCATION)
|
||||
add_test(${the_target} "${LOC}")
|
||||
|
||||
ocv_add_precompiled_headers(${the_target})
|
||||
if(NOT BUILD_opencv_world)
|
||||
_ocv_add_precompiled_headers(${the_target})
|
||||
endif()
|
||||
else(OCV_DEPENDENCIES_FOUND)
|
||||
# TODO: warn about unsatisfied dependencies
|
||||
endif(OCV_DEPENDENCIES_FOUND)
|
||||
@@ -781,24 +910,25 @@ function(ocv_add_accuracy_tests)
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_samples)
|
||||
ocv_debug_message("ocv_add_samples(" ${ARGN} ")")
|
||||
|
||||
set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
||||
string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
|
||||
|
||||
if(BUILD_EXAMPLES AND EXISTS "${samples_path}")
|
||||
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_highgui ${ARGN})
|
||||
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ARGN})
|
||||
ocv_check_dependencies(${samples_deps})
|
||||
|
||||
if(OCV_DEPENDENCIES_FOUND)
|
||||
file(GLOB sample_sources "${samples_path}/*.cpp")
|
||||
ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS})
|
||||
|
||||
foreach(source ${sample_sources})
|
||||
get_filename_component(name "${source}" NAME_WE)
|
||||
set(the_target "example_${module_id}_${name}")
|
||||
|
||||
add_executable(${the_target} "${source}")
|
||||
target_link_libraries(${the_target} ${samples_deps})
|
||||
|
||||
ocv_add_executable(${the_target} "${source}")
|
||||
ocv_target_include_modules(${the_target} ${samples_deps})
|
||||
ocv_target_link_libraries(${the_target} ${samples_deps})
|
||||
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
@@ -821,82 +951,3 @@ function(ocv_add_samples)
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# internal macro; finds all link dependencies of the module
|
||||
# should be used at the end of CMake processing
|
||||
macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||
set(${the_module}_MODULE_DEPS_${optkind} "")
|
||||
set(${the_module}_EXTRA_DEPS_${optkind} "")
|
||||
|
||||
get_target_property(__module_type ${the_module} TYPE)
|
||||
if(__module_type STREQUAL "STATIC_LIBRARY")
|
||||
#in case of static library we have to inherit its dependencies (in right order!!!)
|
||||
if(NOT DEFINED ${the_module}_LIB_DEPENDS_${optkind})
|
||||
ocv_split_libs_list(${the_module}_LIB_DEPENDS ${the_module}_LIB_DEPENDS_DBG ${the_module}_LIB_DEPENDS_OPT)
|
||||
endif()
|
||||
|
||||
set(__resolved_deps "")
|
||||
set(__mod_depends ${${the_module}_LIB_DEPENDS_${optkind}})
|
||||
set(__has_cycle FALSE)
|
||||
|
||||
while(__mod_depends)
|
||||
list(GET __mod_depends 0 __dep)
|
||||
list(REMOVE_AT __mod_depends 0)
|
||||
if(__dep STREQUAL the_module)
|
||||
set(__has_cycle TRUE)
|
||||
else()#if("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
|
||||
ocv_regex_escape(__rdep "${__dep}")
|
||||
if(__resolved_deps MATCHES "(^|;)${__rdep}(;|$)")
|
||||
#all dependencies of this module are already resolved
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${__dep}")
|
||||
else()
|
||||
get_target_property(__module_type ${__dep} TYPE)
|
||||
if(__module_type STREQUAL "STATIC_LIBRARY")
|
||||
if(NOT DEFINED ${__dep}_LIB_DEPENDS_${optkind})
|
||||
ocv_split_libs_list(${__dep}_LIB_DEPENDS ${__dep}_LIB_DEPENDS_DBG ${__dep}_LIB_DEPENDS_OPT)
|
||||
endif()
|
||||
list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep})
|
||||
list(APPEND __resolved_deps "${__dep}")
|
||||
elseif(NOT __module_type)
|
||||
list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}")
|
||||
endif()
|
||||
endif()
|
||||
#else()
|
||||
# get_target_property(__dep_location "${__dep}" LOCATION)
|
||||
endif()
|
||||
endwhile()
|
||||
|
||||
ocv_list_unique(${the_module}_MODULE_DEPS_${optkind})
|
||||
#ocv_list_reverse(${the_module}_MODULE_DEPS_${optkind})
|
||||
ocv_list_unique(${the_module}_EXTRA_DEPS_${optkind})
|
||||
#ocv_list_reverse(${the_module}_EXTRA_DEPS_${optkind})
|
||||
|
||||
if(__has_cycle)
|
||||
# not sure if it can work
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}")
|
||||
endif()
|
||||
|
||||
unset(__dep_location)
|
||||
unset(__mod_depends)
|
||||
unset(__resolved_deps)
|
||||
unset(__has_cycle)
|
||||
unset(__rdep)
|
||||
endif()#STATIC_LIBRARY
|
||||
unset(__module_type)
|
||||
|
||||
#message("${the_module}_MODULE_DEPS_${optkind}")
|
||||
#message(" ${${the_module}_MODULE_DEPS_${optkind}}")
|
||||
#message(" ${OPENCV_MODULE_${the_module}_DEPS}")
|
||||
#message("")
|
||||
#message("${the_module}_EXTRA_DEPS_${optkind}")
|
||||
#message(" ${${the_module}_EXTRA_DEPS_${optkind}}")
|
||||
#message("")
|
||||
endmacro()
|
||||
|
||||
# creates lists of build dependencies needed for external projects
|
||||
macro(ocv_track_build_dependencies)
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
__ocv_track_module_link_dependencies("${m}" OPT)
|
||||
__ocv_track_module_link_dependencies("${m}" DBG)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
@@ -68,6 +68,15 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
endif()
|
||||
ENDFOREACH(item)
|
||||
|
||||
get_target_property(DIRINC ${_PCH_current_target} INCLUDE_DIRECTORIES )
|
||||
FOREACH(item ${DIRINC})
|
||||
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/")
|
||||
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"")
|
||||
else()
|
||||
LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"")
|
||||
endif()
|
||||
ENDFOREACH(item)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${OpenCV_SOURCE_DIR} DEFINITIONS)
|
||||
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" )
|
||||
@@ -254,6 +263,9 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(DIRINC ${_targetName} INCLUDE_DIRECTORIES)
|
||||
set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}")
|
||||
|
||||
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
|
||||
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
|
||||
|
||||
|
||||
+126
-11
@@ -42,6 +42,11 @@ macro(ocv_assert)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_debug_message)
|
||||
# string(REPLACE ";" " " __msg "${ARGN}")
|
||||
# message(STATUS "${__msg}")
|
||||
endmacro()
|
||||
|
||||
macro(ocv_check_environment_variables)
|
||||
foreach(_var ${ARGN})
|
||||
if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}})
|
||||
@@ -53,8 +58,18 @@ macro(ocv_check_environment_variables)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# rename modules target to world if needed
|
||||
macro(_ocv_fix_target target_var)
|
||||
if(BUILD_opencv_world)
|
||||
if(OPENCV_MODULE_${${target_var}}_IS_PART_OF_WORLD)
|
||||
set(${target_var} opencv_world)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# adds include directories in such way that directories from the OpenCV source tree go first
|
||||
function(ocv_include_directories)
|
||||
ocv_debug_message("ocv_include_directories( ${ARGN} )")
|
||||
set(__add_before "")
|
||||
foreach(dir ${ARGN})
|
||||
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
|
||||
@@ -67,6 +82,30 @@ function(ocv_include_directories)
|
||||
include_directories(BEFORE ${__add_before})
|
||||
endfunction()
|
||||
|
||||
# adds include directories in such way that directories from the OpenCV source tree go first
|
||||
function(ocv_target_include_directories target)
|
||||
_ocv_fix_target(target)
|
||||
set(__params "")
|
||||
foreach(dir ${ARGN})
|
||||
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
|
||||
if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
|
||||
list(APPEND __params "${__abs_dir}")
|
||||
else()
|
||||
list(APPEND __params "${dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories(${__params})
|
||||
else()
|
||||
if(TARGET ${target})
|
||||
target_include_directories(${target} PRIVATE ${__params})
|
||||
else()
|
||||
set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
|
||||
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# clears all passed variables
|
||||
macro(ocv_clear_vars)
|
||||
foreach(_var ${ARGN})
|
||||
@@ -265,16 +304,19 @@ macro(CHECK_MODULE module_name define)
|
||||
set(${define} 1)
|
||||
foreach(P "${ALIAS_INCLUDE_DIRS}")
|
||||
if(${P})
|
||||
list(APPEND VIDEOIO_INCLUDE_DIRS ${${P}})
|
||||
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(P "${ALIAS_LIBRARY_DIRS}")
|
||||
if(${P})
|
||||
list(APPEND VIDEOIO_LIBRARY_DIRS ${${P}})
|
||||
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND VIDEOIO_LIBRARIES ${${ALIAS_LIBRARIES}})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
|
||||
endif()
|
||||
endif()
|
||||
@@ -292,8 +334,8 @@ endfunction()
|
||||
|
||||
macro(ocv_finalize_status)
|
||||
if(NOT OPENCV_SKIP_STATUS_FINALIZATION)
|
||||
if(TARGET opencv_core)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
|
||||
if(DEFINED OPENCV_MODULE_opencv_core_BINARY_DIR)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -467,6 +509,20 @@ macro(ocv_convert_to_full_paths VAR)
|
||||
endmacro()
|
||||
|
||||
|
||||
# convert list of paths to libraries names without lib prefix
|
||||
macro(ocv_convert_to_lib_name var)
|
||||
set(__tmp "")
|
||||
foreach(path ${ARGN})
|
||||
get_filename_component(__tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
|
||||
list(APPEND __tmp "${__tmp_name}")
|
||||
endforeach()
|
||||
set(${var} ${__tmp})
|
||||
unset(__tmp)
|
||||
unset(__tmp_name)
|
||||
endmacro()
|
||||
|
||||
|
||||
# add install command
|
||||
function(ocv_install_target)
|
||||
install(TARGETS ${ARGN})
|
||||
@@ -516,16 +572,20 @@ function(ocv_install_target)
|
||||
|
||||
# message(STATUS "Process ${__target} dst=${__dst}...")
|
||||
if(DEFINED __dst)
|
||||
get_target_property(fname ${__target} LOCATION_DEBUG)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug)
|
||||
endif()
|
||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||
get_target_property(fname ${__target} LOCATION_DEBUG)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug)
|
||||
endif()
|
||||
|
||||
get_target_property(fname ${__target} LOCATION_RELEASE)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release)
|
||||
get_target_property(fname ${__target} LOCATION_RELEASE)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release)
|
||||
endif()
|
||||
else()
|
||||
# CMake 2.8.12 brokes PDB support in STATIC libraries for MSVS
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -620,6 +680,9 @@ endmacro()
|
||||
################################################################################################
|
||||
# short command to setup source group
|
||||
function(ocv_source_group group)
|
||||
if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
|
||||
set(group "${the_module}\\${group}")
|
||||
endif()
|
||||
cmake_parse_arguments(SG "" "DIRBASE" "GLOB;GLOB_RECURSE;FILES" ${ARGN})
|
||||
set(files "")
|
||||
if(SG_FILES)
|
||||
@@ -652,3 +715,55 @@ function(ocv_source_group group)
|
||||
source_group(${group} FILES ${files})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(ocv_target_link_libraries target)
|
||||
_ocv_fix_target(target)
|
||||
set(LINK_DEPS ${ARGN})
|
||||
# process world
|
||||
if(BUILD_opencv_world)
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
|
||||
if(";${LINK_DEPS};" MATCHES ";${m};")
|
||||
list(REMOVE_ITEM LINK_DEPS ${m})
|
||||
if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;"))
|
||||
list(APPEND LINK_DEPS opencv_world)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
target_link_libraries(${target} ${LINK_DEPS})
|
||||
endfunction()
|
||||
|
||||
function(_ocv_append_target_includes target)
|
||||
if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target})
|
||||
target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
|
||||
unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_executable target)
|
||||
add_executable(${target} ${ARGN})
|
||||
_ocv_append_target_includes(${target})
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_library target)
|
||||
set(cuda_objs "")
|
||||
if(HAVE_CUDA)
|
||||
set(cuda_srcs "")
|
||||
|
||||
foreach(var ${ARGN})
|
||||
if(var MATCHES ".cu")
|
||||
list(APPEND cuda_srcs ${var})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(cuda_srcs)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(${target} ${ARGN} ${cuda_objs})
|
||||
_ocv_append_target_includes(${target})
|
||||
endfunction()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# helper file for Android samples build
|
||||
|
||||
file(GLOB_RECURSE LIBS RELATIVE ${SRC_DIR} "*.so")
|
||||
|
||||
foreach(l ${LIBS})
|
||||
message(STATUS " Copying: ${l} ...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_DIR}/${l} ${DST_DIR}/${l})
|
||||
endforeach()
|
||||
@@ -2,6 +2,13 @@
|
||||
# you might need to define NDK_USE_CYGPATH=1 before calling the ndk-build
|
||||
|
||||
USER_LOCAL_PATH:=$(LOCAL_PATH)
|
||||
|
||||
USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES)
|
||||
USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS)
|
||||
USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES)
|
||||
USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES)
|
||||
USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS)
|
||||
|
||||
LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
|
||||
|
||||
OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
|
||||
@@ -47,7 +54,7 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (${OPENCV_CAMERA_MODULES},on)
|
||||
ifeq ($(OPENCV_CAMERA_MODULES),on)
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_CONFIGCMAKE@
|
||||
endif
|
||||
@@ -113,6 +120,13 @@ ifeq ($(OPENCV_LOCAL_CFLAGS),)
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES)
|
||||
LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS)
|
||||
LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
|
||||
LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
|
||||
LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
|
||||
|
||||
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
|
||||
LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
#
|
||||
# Or you can search for specific OpenCV modules:
|
||||
#
|
||||
# find_package(OpenCV REQUIRED core highgui)
|
||||
# find_package(OpenCV REQUIRED core videoio)
|
||||
#
|
||||
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
|
||||
#
|
||||
# This file will define the following variables:
|
||||
# - OpenCV_LIBS : The list of all imported targets for OpenCV modules.
|
||||
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
|
||||
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
|
||||
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
|
||||
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability.
|
||||
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API.
|
||||
# - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@"
|
||||
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@"
|
||||
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@"
|
||||
@@ -28,25 +28,41 @@
|
||||
# - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@"
|
||||
#
|
||||
# Advanced variables:
|
||||
# - OpenCV_SHARED
|
||||
# - OpenCV_CONFIG_PATH
|
||||
# - OpenCV_INSTALL_PATH (not set on Windows)
|
||||
# - OpenCV_LIB_COMPONENTS
|
||||
# - OpenCV_USE_MANGLED_PATHS
|
||||
# - OpenCV_HAVE_ANDROID_CAMERA
|
||||
# - OpenCV_SHARED : Use OpenCV as shared library
|
||||
# - OpenCV_CONFIG_PATH : Path to this OpenCVConfig.cmake
|
||||
# - OpenCV_INSTALL_PATH : OpenCV location (not set on Windows)
|
||||
# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list
|
||||
# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag
|
||||
# - OpenCV_MODULES_SUFFIX : The suffix for OpenCVModules-XXX.cmake file
|
||||
# - OpenCV_HAVE_ANDROID_CAMERA : Presence of Android native camera wrappers
|
||||
#
|
||||
# Deprecated variables:
|
||||
# - OpenCV_VERSION_TWEAK : Always "0"
|
||||
#
|
||||
# ===================================================================================
|
||||
|
||||
set(modules_file_suffix "")
|
||||
if(ANDROID)
|
||||
string(REPLACE - _ modules_file_suffix "_${ANDROID_NDK_ABI_NAME}")
|
||||
if(NOT DEFINED OpenCV_MODULES_SUFFIX)
|
||||
if(ANDROID)
|
||||
string(REPLACE - _ OpenCV_MODULES_SUFFIX "_${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(OpenCV_MODULES_SUFFIX "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(@USE_IPPICV@) # value is defined by package builder
|
||||
if(NOT TARGET ippicv)
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PATH_RELATIVE_IPPICV@")
|
||||
add_library(ippicv STATIC IMPORTED)
|
||||
set_target_properties(ippicv PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ""
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PATH_RELATIVE_IPPICV@"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET opencv_core)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${modules_file_suffix}.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)
|
||||
endif()
|
||||
|
||||
# TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files)
|
||||
@@ -60,7 +76,11 @@ set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
|
||||
set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@)
|
||||
|
||||
# Android API level from which OpenCV has been compiled is remembered
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
|
||||
if(ANDROID)
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
|
||||
else()
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL 0)
|
||||
endif()
|
||||
|
||||
# Some additional settings are required if OpenCV is built as static libs
|
||||
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
|
||||
@@ -71,8 +91,8 @@ set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)
|
||||
# Extract the directory where *this* file has been installed (determined at cmake run-time)
|
||||
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
|
||||
|
||||
if(NOT WIN32 OR OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
|
||||
if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
|
||||
if(NOT WIN32 OR ANDROID)
|
||||
if(ANDROID)
|
||||
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../..")
|
||||
else()
|
||||
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../..")
|
||||
@@ -121,6 +141,7 @@ SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@")
|
||||
# ====================================================================
|
||||
|
||||
SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@)
|
||||
SET(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@)
|
||||
|
||||
# ==============================================================
|
||||
# Extra include directories, needed by OpenCV 2 new structure
|
||||
@@ -180,8 +201,8 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
|
||||
message(WARNING "${__cvcomponent} is required but was not found")
|
||||
endif()
|
||||
#indicate that module is NOT found
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponent)
|
||||
set(${__cvcomponent}_FOUND "${__cvcomponent}_FOUND-NOTFOUND")
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
|
||||
set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND")
|
||||
else()
|
||||
list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent})
|
||||
# Not using list(APPEND) here, because OpenCV_LIBS may not exist yet.
|
||||
@@ -189,8 +210,31 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
|
||||
# to find_package(OpenCV) with different component lists add up.
|
||||
set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}")
|
||||
#indicate that module is found
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponent)
|
||||
set(${__cvcomponent}_FOUND 1)
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
|
||||
set(${__cvcomponentUP}_FOUND 1)
|
||||
endif()
|
||||
if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent})
|
||||
get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG)
|
||||
get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE)
|
||||
get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG)
|
||||
get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE)
|
||||
add_library(${__cvcomponent} SHARED IMPORTED)
|
||||
if(__location_dbg)
|
||||
set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(${__cvcomponent} PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${__implib_dbg}"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG ""
|
||||
IMPORTED_LOCATION_DEBUG "${__location_dbg}"
|
||||
)
|
||||
endif()
|
||||
if(__location_release)
|
||||
set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(${__cvcomponent} PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${__implib_release}"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE ""
|
||||
IMPORTED_LOCATION_RELEASE "${__location_release}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
|
||||
@@ -209,7 +253,7 @@ foreach(__opttype OPT DBG)
|
||||
SET(OpenCV_EXTRA_LIBS_${__opttype} "")
|
||||
|
||||
# CUDA
|
||||
if(OpenCV_CUDA_VERSION AND (CMAKE_CROSSCOMPILING OR (WIN32 AND NOT OpenCV_SHARED)))
|
||||
if(OpenCV_CUDA_VERSION)
|
||||
if(NOT CUDA_FOUND)
|
||||
find_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
|
||||
else()
|
||||
@@ -218,32 +262,41 @@ foreach(__opttype OPT DBG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_LIBRARIES})
|
||||
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
|
||||
|
||||
if(${CUDA_VERSION} VERSION_LESS "5.5")
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_npp_LIBRARY})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
|
||||
else()
|
||||
find_cuda_helper_libs(nppc)
|
||||
find_cuda_helper_libs(nppi)
|
||||
find_cuda_helper_libs(npps)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUBLAS)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUBLAS_LIBRARIES})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUBLAS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_CUFFT)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUFFT_LIBRARIES})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUFFT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_NVCUVID)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvid_LIBRARIES})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvid_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvenc_LIBRARIES})
|
||||
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set(OpenCV_CUDA_LIBS_RELPATH "")
|
||||
foreach(l ${OpenCV_CUDA_LIBS_ABSPATH})
|
||||
get_filename_component(_tmp ${l} PATH)
|
||||
list(APPEND OpenCV_CUDA_LIBS_RELPATH ${_tmp})
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES OpenCV_CUDA_LIBS_RELPATH)
|
||||
link_directories(${OpenCV_CUDA_LIBS_RELPATH})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -292,6 +345,7 @@ macro(ocv_check_dependencies)
|
||||
set(OCV_DEPENDENCIES_FOUND TRUE)
|
||||
foreach(d ${ARGN})
|
||||
if(NOT TARGET ${d})
|
||||
message(WARNING "OpenCV: Can't resolve dependency: ${d}")
|
||||
set(OCV_DEPENDENCIES_FOUND FALSE)
|
||||
break()
|
||||
endif()
|
||||
@@ -317,6 +371,10 @@ macro(ocv_include_modules)
|
||||
include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}")
|
||||
endmacro()
|
||||
|
||||
macro(ocv_target_link_libraries)
|
||||
target_link_libraries(${ARGN})
|
||||
endmacro()
|
||||
|
||||
# remove all matching elements from the list
|
||||
macro(ocv_list_filterout lst regex)
|
||||
foreach(item ${${lst}})
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
/* ffmpeg in Gentoo */
|
||||
#cmakedefine HAVE_GENTOO_FFMPEG
|
||||
|
||||
/* Geospatial Data Abstraction Library */
|
||||
#cmakedefine HAVE_GDAL
|
||||
|
||||
/* GStreamer multimedia framework */
|
||||
#cmakedefine HAVE_GSTREAMER
|
||||
|
||||
@@ -93,6 +96,10 @@
|
||||
|
||||
/* Intel Integrated Performance Primitives */
|
||||
#cmakedefine HAVE_IPP
|
||||
#cmakedefine HAVE_IPP_ICV_ONLY
|
||||
|
||||
/* Intel IPP Async */
|
||||
#cmakedefine HAVE_IPP_A
|
||||
|
||||
/* JPEG-2000 codec */
|
||||
#cmakedefine HAVE_JASPER
|
||||
@@ -125,6 +132,9 @@
|
||||
/* OpenNI library */
|
||||
#cmakedefine HAVE_OPENNI
|
||||
|
||||
/* OpenNI library */
|
||||
#cmakedefine HAVE_OPENNI2
|
||||
|
||||
/* PNG codec */
|
||||
#cmakedefine HAVE_PNG
|
||||
|
||||
@@ -167,6 +177,6 @@
|
||||
/* Xine video library */
|
||||
#cmakedefine HAVE_XINE
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
/* Define if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user