test_trackers.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // * Redistribution's in binary form must reproduce the above copyright notice,
  23. // this list of conditions and the following disclaimer in the documentation
  24. // and/or other materials provided with the distribution.
  25. //
  26. // * The name of the copyright holders may not be used to endorse or promote products
  27. // derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41. #include "test_precomp.hpp"
  42. #define TEST_LEGACY
  43. #include <opencv2/tracking/tracking_legacy.hpp>
  44. //#define DEBUG_TEST
  45. #ifdef DEBUG_TEST
  46. #include <opencv2/highgui.hpp>
  47. #endif
  48. namespace opencv_test { namespace {
  49. //using namespace cv::tracking;
  50. #define TESTSET_NAMES testing::Values("david","dudek","faceocc2")
  51. const string TRACKING_DIR = "tracking";
  52. const string FOLDER_IMG = "data";
  53. const string FOLDER_OMIT_INIT = "initOmit";
  54. // Check used "cmake" version in case of errors
  55. // Check compiler command line options for <opencv>/modules include
  56. #include "video/test/test_trackers.impl.hpp"
  57. /****************************************************************************************\
  58. * Tests registrations *
  59. \****************************************************************************************/
  60. //[TESTDATA]
  61. PARAM_TEST_CASE(DistanceAndOverlap, string)
  62. {
  63. string dataset;
  64. virtual void SetUp()
  65. {
  66. dataset = GET_PARAM(0);
  67. }
  68. };
  69. TEST_P(DistanceAndOverlap, MedianFlow)
  70. {
  71. TrackerTest<legacy::Tracker> test(legacy::TrackerMedianFlow::create(), dataset, 35, .5f, NoTransform, 1, 1);
  72. test.run();
  73. }
  74. TEST_P(DistanceAndOverlap, Boosting)
  75. {
  76. TrackerTest<legacy::Tracker> test(legacy::TrackerBoosting::create(), dataset, 70, .7f, NoTransform);
  77. test.run();
  78. }
  79. TEST_P(DistanceAndOverlap, KCF)
  80. {
  81. TrackerTest<Tracker, Rect> test(TrackerKCF::create(), dataset, 20, .35f, NoTransform, 5);
  82. test.run();
  83. }
  84. #ifdef TEST_LEGACY
  85. TEST_P(DistanceAndOverlap, KCF_legacy)
  86. {
  87. TrackerTest<legacy::Tracker> test(legacy::TrackerKCF::create(), dataset, 20, .35f, NoTransform, 5);
  88. test.run();
  89. }
  90. #endif
  91. TEST_P(DistanceAndOverlap, TLD)
  92. {
  93. TrackerTest<legacy::Tracker> test(legacy::TrackerTLD::create(), dataset, 40, .45f, NoTransform);
  94. test.run();
  95. }
  96. TEST_P(DistanceAndOverlap, MOSSE)
  97. {
  98. TrackerTest<legacy::Tracker> test(legacy::TrackerMOSSE::create(), dataset, 22, .7f, NoTransform);
  99. test.run();
  100. }
  101. TEST_P(DistanceAndOverlap, CSRT)
  102. {
  103. TrackerTest<Tracker, Rect> test(TrackerCSRT::create(), dataset, 22, .7f, NoTransform);
  104. test.run();
  105. }
  106. #ifdef TEST_LEGACY
  107. TEST_P(DistanceAndOverlap, CSRT_legacy)
  108. {
  109. TrackerTest<legacy::Tracker> test(legacy::TrackerCSRT::create(), dataset, 22, .7f, NoTransform);
  110. test.run();
  111. }
  112. #endif
  113. /***************************************************************************************/
  114. //Tests with shifted initial window
  115. TEST_P(DistanceAndOverlap, Shifted_Data_MedianFlow)
  116. {
  117. TrackerTest<legacy::Tracker> test(legacy::TrackerMedianFlow::create(), dataset, 80, .2f, CenterShiftLeft, 1, 1);
  118. test.run();
  119. }
  120. TEST_P(DistanceAndOverlap, Shifted_Data_Boosting)
  121. {
  122. TrackerTest<legacy::Tracker> test(legacy::TrackerBoosting::create(), dataset, 80, .65f, CenterShiftLeft);
  123. test.run();
  124. }
  125. TEST_P(DistanceAndOverlap, Shifted_Data_KCF)
  126. {
  127. TrackerTest<Tracker, Rect> test(TrackerKCF::create(), dataset, 20, .4f, CenterShiftLeft, 5);
  128. test.run();
  129. }
  130. #ifdef TEST_LEGACY
  131. TEST_P(DistanceAndOverlap, Shifted_Data_KCF_legacy)
  132. {
  133. TrackerTest<legacy::Tracker> test(legacy::TrackerKCF::create(), dataset, 20, .4f, CenterShiftLeft, 5);
  134. test.run();
  135. }
  136. #endif
  137. TEST_P(DistanceAndOverlap, Shifted_Data_TLD)
  138. {
  139. TrackerTest<legacy::Tracker> test(legacy::TrackerTLD::create(), dataset, 30, .35f, CenterShiftLeft);
  140. test.run();
  141. }
  142. TEST_P(DistanceAndOverlap, Shifted_Data_MOSSE)
  143. {
  144. TrackerTest<legacy::Tracker> test(legacy::TrackerMOSSE::create(), dataset, 13, .69f, CenterShiftLeft);
  145. test.run();
  146. }
  147. TEST_P(DistanceAndOverlap, Shifted_Data_CSRT)
  148. {
  149. TrackerTest<Tracker, Rect> test(TrackerCSRT::create(), dataset, 13, .69f, CenterShiftLeft);
  150. test.run();
  151. }
  152. #ifdef TEST_LEGACY
  153. TEST_P(DistanceAndOverlap, Shifted_Data_CSRT_legacy)
  154. {
  155. TrackerTest<legacy::Tracker> test(legacy::TrackerCSRT::create(), dataset, 13, .69f, CenterShiftLeft);
  156. test.run();
  157. }
  158. #endif
  159. /***************************************************************************************/
  160. //Tests with scaled initial window
  161. TEST_P(DistanceAndOverlap, Scaled_Data_MedianFlow)
  162. {
  163. TrackerTest<legacy::Tracker> test(legacy::TrackerMedianFlow::create(), dataset, 25, .5f, Scale_1_1, 1, 1);
  164. test.run();
  165. }
  166. TEST_P(DistanceAndOverlap, Scaled_Data_Boosting)
  167. {
  168. TrackerTest<legacy::Tracker> test(legacy::TrackerBoosting::create(), dataset, 80, .7f, Scale_1_1);
  169. test.run();
  170. }
  171. TEST_P(DistanceAndOverlap, Scaled_Data_KCF)
  172. {
  173. TrackerTest<Tracker, Rect> test(TrackerKCF::create(), dataset, 20, .4f, Scale_1_1, 5);
  174. test.run();
  175. }
  176. #ifdef TEST_LEGACY
  177. TEST_P(DistanceAndOverlap, Scaled_Data_KCF_legacy)
  178. {
  179. TrackerTest<legacy::Tracker> test(legacy::TrackerKCF::create(), dataset, 20, .4f, Scale_1_1, 5);
  180. test.run();
  181. }
  182. #endif
  183. TEST_P(DistanceAndOverlap, Scaled_Data_TLD)
  184. {
  185. TrackerTest<legacy::Tracker> test(legacy::TrackerTLD::create(), dataset, 30, .45f, Scale_1_1);
  186. test.run();
  187. }
  188. TEST_P(DistanceAndOverlap, Scaled_Data_MOSSE)
  189. {
  190. TrackerTest<legacy::Tracker> test(legacy::TrackerMOSSE::create(), dataset, 22, 0.69f, Scale_1_1, 1);
  191. test.run();
  192. }
  193. TEST_P(DistanceAndOverlap, Scaled_Data_CSRT)
  194. {
  195. TrackerTest<Tracker, Rect> test(TrackerCSRT::create(), dataset, 22, 0.69f, Scale_1_1, 1);
  196. test.run();
  197. }
  198. #ifdef TEST_LEGACY
  199. TEST_P(DistanceAndOverlap, Scaled_Data_CSRT_legacy)
  200. {
  201. TrackerTest<Tracker, Rect> test(TrackerCSRT::create(), dataset, 22, 0.69f, Scale_1_1, 1);
  202. test.run();
  203. }
  204. #endif
  205. INSTANTIATE_TEST_CASE_P(Tracking, DistanceAndOverlap, TESTSET_NAMES);
  206. }} // namespace