├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── LICENSE ├── OpenTLDConfig.cmake.in ├── README.md ├── accuracy_test_instruction.md ├── installation.md ├── performance_report_objecttraker.pdf ├── sample └── benchmark │ ├── calc.py │ ├── cfg_gen.py │ └── deleteTest.py └── src ├── 3rdparty ├── cf_tracking │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ └── src │ │ ├── 3rdparty │ │ ├── cv_ext │ │ │ ├── init_box_selector.cpp │ │ │ ├── init_box_selector.hpp │ │ │ ├── math_spectrums.cpp │ │ │ ├── math_spectrums.hpp │ │ │ ├── psr.hpp │ │ │ ├── shift.cpp │ │ │ ├── shift.hpp │ │ │ ├── tracker_run.cpp │ │ │ └── tracker_run.hpp │ │ ├── piotr │ │ │ ├── README.md │ │ │ ├── gradientMex.hpp │ │ │ └── src │ │ │ │ ├── gradientMex.cpp │ │ │ │ ├── sse.hpp │ │ │ │ ├── sse_to_neon.hpp │ │ │ │ └── wrappers.hpp │ │ └── tclap │ │ │ ├── AUTHORS │ │ │ ├── COPYING │ │ │ ├── ChangeLog │ │ │ ├── INSTALL │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ └── tclap │ │ │ ├── Arg.h │ │ │ ├── ArgException.h │ │ │ ├── ArgTraits.h │ │ │ ├── CmdLine.h │ │ │ ├── CmdLineInterface.h │ │ │ ├── CmdLineOutput.h │ │ │ ├── Constraint.h │ │ │ ├── DocBookOutput.h │ │ │ ├── HelpVisitor.h │ │ │ ├── IgnoreRestVisitor.h │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── MultiArg.h │ │ │ ├── MultiSwitchArg.h │ │ │ ├── OptionalUnlabeledTracker.h │ │ │ ├── StandardTraits.h │ │ │ ├── StdOutput.h │ │ │ ├── SwitchArg.h │ │ │ ├── UnlabeledMultiArg.h │ │ │ ├── UnlabeledValueArg.h │ │ │ ├── ValueArg.h │ │ │ ├── ValuesConstraint.h │ │ │ ├── VersionVisitor.h │ │ │ ├── Visitor.h │ │ │ ├── XorHandler.h │ │ │ └── ZshCompletionOutput.h │ │ ├── cf_libs │ │ ├── common │ │ │ ├── cf_tracker.hpp │ │ │ ├── cv_ext.hpp │ │ │ ├── feature_channels.hpp │ │ │ ├── mat_consts.hpp │ │ │ ├── math_helper.cpp │ │ │ ├── math_helper.hpp │ │ │ ├── scale_estimator.hpp │ │ │ └── tracker_debug.hpp │ │ ├── dsst │ │ │ ├── dsst_debug.hpp │ │ │ └── dsst_tracker.hpp │ │ └── kcf │ │ │ ├── kcf_debug.hpp │ │ │ └── kcf_tracker.hpp │ │ └── main │ │ ├── image_acquisition.cpp │ │ ├── image_acquisition.hpp │ │ ├── main_dsst.cpp │ │ └── main_kcf.cpp └── libconfig │ ├── CMakeLists.txt │ ├── grammar.c │ ├── grammar.h │ ├── libconfig.c │ ├── libconfig.h │ ├── libconfig.h++ │ ├── libconfig.hh │ ├── libconfigcpp.c++ │ ├── libconfigcpp.cc │ ├── parsectx.h │ ├── scanctx.c │ ├── scanctx.h │ ├── scanner.c │ ├── scanner.h │ ├── strbuf.c │ ├── strbuf.h │ └── wincompat.h ├── libopentld ├── CMakeLists.txt ├── CMakeLists2.txt ├── imacq │ ├── ImAcq.cpp │ └── ImAcq.h └── tld │ ├── Clustering.cpp │ ├── Clustering.h │ ├── DetectionResult.cpp │ ├── DetectionResult.h │ ├── DetectorCascade.cpp │ ├── DetectorCascade.h │ ├── EnsembleClassifier.cpp │ ├── EnsembleClassifier.h │ ├── IntegralImage.h │ ├── NNClassifier.cpp │ ├── NNClassifier.h │ ├── NormalizedPatch.h │ ├── TLD.cpp │ ├── TLD.h │ ├── TLDUtil.cpp │ ├── TLDUtil.h │ ├── VarianceFilter.cpp │ └── VarianceFilter.h └── opentld ├── CMakeLists.txt ├── OpenTLD.cpp └── main ├── Config.cpp ├── Config.h ├── Gui.cpp ├── Gui.h ├── Main.cpp ├── Main.h ├── Settings.cpp ├── Settings.h ├── Trajectory.cpp ├── Trajectory.h ├── json.cpp ├── json ├── json-forwards.h └── json.h ├── log.h ├── perf.h ├── tools ├── jsoncpp.cpp ├── log.cpp └── perf.cpp └── trackerTld.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors 2 | ======= 3 | 4 | Georg Nebehay 5 | 6 | Contributors 7 | ============ 8 | 9 | Clemens Korner 10 | Bernd Lukatschek 11 | João Silva 12 | Lucas Doyle 13 | Lukas Oberhuber 14 | Michael Rennie 15 | Sebastian Borggrewe 16 | Jonathan Senecal 17 | Huang Xin 18 | Jason Catchpole 19 | Victor Daropoulos 20 | Klaus Haag 21 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Open The CMake GUI 2 | # specify the source directory and the binary directory 3 | # press configure. 4 | # 5 | # UNIX Makefile: 6 | # 1) go to the binary folder and type "make" to build the project 7 | # 8 | # Microsoft Visual C++: 9 | # 1) open the .sln file 10 | # 2) build the project "ALL_BUILD" to build the opentld project 11 | 12 | 13 | project(CF_TLD) 14 | cmake_minimum_required(VERSION 2.6) 15 | 16 | # add c++11 support 17 | if(CMAKE_COMPILER_IS_GNUCC) 18 | ADD_DEFINITIONS ( -std=c++11 ) 19 | endif(CMAKE_COMPILER_IS_GNUCC) 20 | 21 | set(OpenCV_DIR "/usr/local/AID/opencv3.3.0") 22 | #set(OpenCV_DIR "/home/firefly/opencv-3.3.0/build") 23 | 24 | #find_package(OpenCV REQUIRED highgui video videoio imgproc imgcodecs) 25 | 26 | # find_package(OpenCV) does not account for proper path setup 27 | # on windows; proper path setup requires path "OPENCV_DIR" 28 | # pointing to ie. \build_opencv_3\install\x64\vc12 29 | set(OPENCV_DIR_HINT "/usr/local/AID/opencv3.3.0") 30 | 31 | if(WIN32) 32 | get_filename_component(OPENCV_DIR_PLATFORM $ENV{OPENCV_DIR} DIRECTORY) 33 | get_filename_component(OPENCV_DIR_HINT ${OPENCV_DIR_PLATFORM} DIRECTORY) 34 | endif(WIN32) 35 | 36 | set(OpenCV_STATIC OFF) 37 | find_package(OpenCV REQUIRED HINTS ${OPENCV_DIR_HINT}) 38 | # OpenCV 3.0 does currently not include its' includes correctly 39 | include_directories(${OpenCV_DIR}/include) 40 | 41 | 42 | #------------------------------------------------------------------------------- 43 | #version 44 | set(TLD_VERSION_MAJOR 1) 45 | set(TLD_VERSION_MINOR 4) 46 | set(TLD_VERSION_PATCH 0) 47 | set(TLD_VERSION ${TLD_VERSION_MAJOR}.${TLD_VERSION_MINOR}.${TLD_VERSION_PATCH}) 48 | 49 | #------------------------------------------------------------------------------ 50 | #build type 51 | if(NOT CMAKE_BUILD_TYPE) 52 | set(CMAKE_BUILD_TYPE Release CACHE STRING 53 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 54 | FORCE) 55 | endif(NOT CMAKE_BUILD_TYPE) 56 | 57 | option(USE_SYSTEM_LIBS "Use the installed version of libconfig++." OFF) 58 | option(WITH_OPENMP "Use OpenMP." OFF) 59 | 60 | if(WITH_OPENMP) 61 | find_package(OpenMP REQUIRED) 62 | 63 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 64 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 65 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") 66 | endif(WITH_OPENMP) 67 | 68 | if(WIN32) 69 | add_definitions(-DLIBCONFIGXX_STATIC -DLIBCONFIG_STATIC) #Needed when linking libconfig statically 70 | endif(WIN32) 71 | 72 | if(APPLE) 73 | add_definitions(-DHAVE_XLOCALE_H) 74 | endif(APPLE) 75 | 76 | if(NOT MSVC) 77 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") 78 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 79 | endif(NOT MSVC) 80 | 81 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 82 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 83 | 84 | #------------------------------------------------------------------------------- 85 | #add subdirectories 86 | add_subdirectory(src/3rdparty/cf_tracking) 87 | 88 | if(NOT USE_SYSTEM_LIBS) 89 | add_subdirectory(src/3rdparty/libconfig) 90 | endif(NOT USE_SYSTEM_LIBS) 91 | 92 | add_subdirectory(src/libopentld) 93 | add_subdirectory(src/opentld) 94 | 95 | configure_file("${PROJECT_SOURCE_DIR}/OpenTLDConfig.cmake.in" "${PROJECT_BINARY_DIR}/OpenTLDConfig.cmake" @ONLY) 96 | -------------------------------------------------------------------------------- /OpenTLDConfig.cmake.in: -------------------------------------------------------------------------------- 1 | find_package(OpenCV) 2 | 3 | set(bin_dir "@PROJECT_BINARY_DIR@") 4 | set(src_dir "@PROJECT_SOURCE_DIR@") 5 | 6 | set(OPENTLD_INCLUDE_DIRS 7 | ${src_dir}/src/3rdparty/cvblobs 8 | ${src_dir}/src/3rdparty/libconfig 9 | ${src_dir}/src/libopentld/tld 10 | ${src_dir}/src/libopentld/mftracker 11 | ${src_dir}/src/libopentld/imacq 12 | ${src_dir}/src/opentld/main/json 13 | ${src_dir}/src/opentld/main) 14 | INCLUDE_DIRECTORIES(${OPENTLD_INCLUDE_DIRS}) 15 | 16 | SET(OPENTLD_LIB_DIRS ${LIBRARY_OUTPUT_PATH}) 17 | LINK_DIRECTORIES(${OPENTLD_LIB_DIRS}) 18 | 19 | set(OPENTLD_LIBS cvblobs libconfig libopentld) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ObjectTracker 2 | 3 | This is a fork of the [C++ implementation of OpenTLD](https://github.com/gnebehay/OpenTLD) called TrackTLD. 4 | OpenTLD was originally proposed in [1] and implemented by Georg Nebehay in C++. 5 | 6 | This fork uses C++ implementations of correlation filter based trackers as short-term trackers. Both short-term trackers are modified variants of the visual trackers proposed in [2,3]. 7 | The short-term trackers are extended with target loss detection capabilities as in [4] and use the C++ implementation [5] of the FHOG features proposed in [6]. The detection cascade is only used to suggest possible target locations to the short-term trackers for redetection purposes. It cannot reinitialize the short-term trackers. The short-term trackers decide whether a suggested patch actually contains the target. 8 | 9 | The system starts with the KCFcpp as default short-term tracker. 10 | 11 | # Usage 12 | If you have a webcam attached to your ROCK960, you can simply execute cftld in order to 13 | try it out. 14 | 15 | Press 'r' key, drag the mouse to draw the box to be tracked target. And press the Enter key to start tracking. 16 | 17 | ### Keyboard shortcuts 18 | * `r` select a target 19 | * `q` quit 20 | * `l` toggle learning 21 | * `a` toggle alternating mode (if true, detector is switched off when tracker is available) 22 | 23 | ### Documents 24 | * [Installation instructions](installation.md) 25 | * [Accuracy test instructions](accuracy_test_instruction.md) 26 | * [Performance Report PDF](performance_report_objecttraker.pdf) 27 | 28 | # Release History 29 | 30 | ### Version 0.1.3 - 2018-02-05 31 | * Add script to test accuracy. 32 | * Add 2xA72 and 4xA53 performance data. 33 | 34 | 35 | # Commercial Use (US) 36 | The code using linear correlation filters may be affected by a US patent. If you want to use this code commercially in the US please refer to http://www.cs.colostate.edu/~vision/ocof_toolset_2012/index.php for possible patent claims. 37 | 38 | # References 39 | If you reuse this code for a scientific publication, please cite the related publications (dependent on what parts of the code you reuse): 40 | 41 | [1] 42 | ``` 43 | @article{kalal2012TLD, 44 | title={Tracking-Learning-Detection}, 45 | author={Kalal, Zdenek and Mikolajczyk, Krystian and Matas, Jiri}, 46 | journal={Pattern Analysis and Machine Intelligence, IEEE Transactions on}, 47 | year={2012}} 48 | ``` 49 | 50 | [2] 51 | ``` 52 | @article{henriques2015tracking, 53 | title = {High-Speed Tracking with Kernelized Correlation Filters}, 54 | author = {Henriques, J. F. and Caseiro, R. and Martins, P. and Batista, J.}, 55 | journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, 56 | year = {2015} 57 | ``` 58 | 59 | 60 | [3] 61 | ``` 62 | @inproceedings{danelljan2014dsst, 63 | title={Accurate Scale Estimation for Robust Visual Tracking}, 64 | author={Danelljan, Martin and H{\"a}ger, Gustav and Khan, Fahad Shahbaz and Felsberg, Michael}, 65 | booktitle={Proceedings of the British Machine Vision Conference BMVC}, 66 | year={2014}} 67 | ``` 68 | 69 | [4] 70 | ``` 71 | @inproceedings{bolme2010mosse, 72 | author={Bolme, David S. and Beveridge, J. Ross and Draper, Bruce A. and Yui Man Lui}, 73 | title={Visual Object Tracking using Adaptive Correlation Filters}, 74 | booktitle={Conference on Computer Vision and Pattern Recognition (CVPR)}, 75 | year={2010}} 76 | ``` 77 | 78 | [5] 79 | ``` 80 | @misc{PMT, 81 | author = {Piotr Doll\'ar}, 82 | title = {{P}iotr's {C}omputer {V}ision {M}atlab {T}oolbox ({PMT})}, 83 | howpublished = {\url{http://vision.ucsd.edu/~pdollar/toolbox/doc/index.html}}} 84 | ``` 85 | 86 | [6] 87 | ``` 88 | @article{lsvm-pami, 89 | title = "Object Detection with Discriminatively Trained Part Based Models", 90 | author = "Felzenszwalb, P. F. and Girshick, R. B. and McAllester, D. and Ramanan, D.", 91 | journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence", 92 | year = "2010", volume = "32", number = "9", pages = "1627--1645"} 93 | ``` 94 | 95 | -------------------------------------------------------------------------------- /accuracy_test_instruction.md: -------------------------------------------------------------------------------- 1 | # Accuracy test instructions 2 | 3 | ## Install dependencies 4 | 5 | * Install OpenCV library for Python 6 | ``` 7 | sudo cp /usr/local/AID/opencv3.3.0/lib/python2.7/dist-packages/cv2.so /usr/local/lib/python2.7/dist-packages/cv2.so 8 | ``` 9 | 10 | * Install Matplotlib for Python 11 | ``` 12 | sudo apt-get install python-matplotlib 13 | ``` 14 | 15 | ## Get the average fps value 16 | Get the average fps value per 100 frames by using the "avfps" value in the window. 17 | 18 | ## Run accuracy test script 19 | 20 | ``` 21 | cp ~/ObjectTracker/build/bin/cftld ~/ObjectTracker/sample/benchmark 22 | cd ~/ObjectTracker/sample/benchmark 23 | wget -c ftp.openailab.net/dataset/ObjectTracker_Benchmark/test.tar --ftp-user=*** --ftp-password=*** --no-passive-ftp 24 | tar -xvf test.tar 25 | python cfg_gen.py 26 | sh RunTracker.sh 27 | python calc.py 28 | ``` 29 | You may need to contact to access the dataset. 30 | 31 | ## Add your own images to test dataset 32 | ``` 33 | 1) save your images to ObjectTracker/sample/benchmark/test/[folder name]/img. 34 | 2) save the grountruth_rect.txt to ObjectTracker/sample/benchmark/test/[folder name]. 35 | 3) run cfg_gen.py to generate the configuration file and RunTracker.sh. 36 | 4) run RunTracker.sh to start testing. 37 | 5) run calc.py to get the result. 38 | ``` 39 | -------------------------------------------------------------------------------- /installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ## Install dependencies 4 | 5 | * Install CMake: 6 | Skip this step if OpenCV3.3 has been installed 7 | ``` 8 | sudo apt-get install cmake 9 | ``` 10 | 11 | * Download OpenCV3.3 12 | ``` 13 | wget https://github.com/opencv/opencv/archive/3.3.0.zip --no-check-certificate 14 | unzip 3.3.0.zip 15 | ``` 16 | 17 | * Download "gen-pkg-config-pc" 18 | ``` 19 | wget ftp://ftp.openailab.net/tools/script/gen-pkg-config-pc.sh 20 | chmod +x ./gen-pkg-config-pc.sh 21 | ``` 22 | 23 | * Install OpenCV3.3 24 | ``` 25 | cd opencv-3.3.0 26 | mkdir build 27 | cd build 28 | cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/AID/opencv3.3.0 .. 29 | sudo make install 30 | ``` 31 | 32 | * Configure The Libraries 33 | ``` 34 | sudo ~/gen-pkg-config-pc.sh /usr/local/AID 35 | ``` 36 | 37 | ## ObjectTracker Compile 38 | 39 | ``` 40 | cd ObjectTracker 41 | mkdir build 42 | cd build 43 | cmake .. 44 | make 45 | ``` 46 | 47 | ## Camera live demo 48 | * Please ensure camera is connected 49 | 50 | ``` 51 | cd ObejectTracker/build/bin 52 | ./cftld 53 | ``` 54 | 55 | ## Command line options 56 | ### Synopsis 57 | `bin/cftld [option arguments] [Arguments]` 58 | 59 | ### option arguments 60 | * `[-x]` Use DSSTcpp instead of KCFcpp as short-term tracker. KCFcpp is the default short-term tracker. 61 | * `[-a ]` Video starts at the _startFrameNumber_. 62 | * `[-b ]` Initial bounding box. 63 | * `[-d ]` Selects input device: _device_=(_IMGS_|_CAM_|_VID_|_STREAM_) 64 | _IMGS_: Capture from images. 65 | _CAM_: Capture from connected camera. 66 | _VID_: Capture from a video. 67 | _STREAM_: Capture from RTSP stream. 68 | * `[-f]` Shows foreground. 69 | * `[-i ]` _path_ to the images or to the video. 70 | * `[-j ]` Shows trajectory for the last _number_ frames. 71 | * `[-h]` Shows help. 72 | * `[-n ]` Specifies the video device to use (defaults to 0). Useful to select a different camera when multiple cameras are connected. 73 | * `[-p path]` Prints results into the file _path_. 74 | * `[-s]` If set, user can select initial bounding box. 75 | * `[-t ]` Threshold for determining positive results. 76 | * `[-z ]` Video ends at the _lastFrameNumber_. 77 | If _lastFrameNumber_ is 0 or the option argument isn't specified means 78 | all frames are taken. 79 | 80 | ### Arguments 81 | `[CONFIG_FILE]` path to config file 82 | 83 | ## Config files 84 | Refer to the sample folder to see usage and config file examples. 85 | 86 | -------------------------------------------------------------------------------- /performance_report_objecttraker.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OAID/ObjectTracker/d76608c7a1d71ad3522c3b840f6edfcaa1ed3f19/performance_report_objecttraker.pdf -------------------------------------------------------------------------------- /sample/benchmark/cfg_gen.py: -------------------------------------------------------------------------------- 1 | import os 2 | import random 3 | 4 | path = './test' 5 | files = os.listdir(path) 6 | folder_list = [] 7 | random_count = 0 8 | for file in files: 9 | 10 | m = os.path.join(path,file) 11 | 12 | if (os.path.isdir(m)): 13 | h = os.path.split(m) 14 | # print h[1] 15 | folder_list.append(h[1]) 16 | # print folder_list 17 | random_count = len(folder_list) 18 | for i in range(len(folder_list)): 19 | ran_num = random.randint(0,len(folder_list)-1) 20 | folder_list[i],folder_list[ran_num] = folder_list[ran_num], folder_list[i] 21 | 22 | random_list = folder_list[0:random_count] 23 | print(random_list) 24 | 25 | if(~os.path.exists("config")): 26 | os.system("mkdir config") 27 | if(~os.path.exists("config/KCF")): 28 | os.system("mkdir config/KCF") 29 | if(~os.path.exists("config/DSST")): 30 | os.system("mkdir config/DSST") 31 | if(~os.path.exists("results")): 32 | os.system("mkdir results") 33 | if(~os.path.exists("results/KCF")): 34 | os.system("mkdir results/KCF") 35 | if(~os.path.exists("results/DSST")): 36 | os.system("mkdir results/DSST") 37 | 38 | shfile1 = open("RunTracker.sh","w") 39 | #shfile2 = open("KCFTracker.sh","w") 40 | for i in range(len(random_list)): 41 | if os.path.isfile("test/%s/groundtruth_rect.txt"%random_list[i]): 42 | truth_file = open("test/%s/groundtruth_rect.txt"%random_list[i]) 43 | else: 44 | truth_file = open("test/%s/groundtruth_rect.1.txt"%random_list[i]) 45 | line = truth_file.readline() 46 | line = line.strip('\n') 47 | truth_file.close() 48 | File = open("config/KCF/image_sequence_%s"%random_list[i]+".cfg", "w") 49 | File.write("seed = 0;" + "\n") 50 | if line.find(',')==-1: 51 | File.write("initialBoundingBox = [%s,%s,%s,%s];"%(line.split()[0],line.split()[1],line.split()[2],line.split()[3]) + "\n") 52 | else: 53 | File.write("initialBoundingBox = [%s];"%line + "\n") 54 | File.write("showNotConfident = true;" + "\n") 55 | File.write("saveOutput = true;" + "\n") 56 | File.write('saveDir = "%s";'%random_list[i] + "\n") 57 | File.write('printResults = "results/KCF/results_%s.txt";'%random_list[i] + "\n") 58 | File.write("showOutput = true;"+ "\n") 59 | File.write("# useDsstTracker = true;" + "\n\n") 60 | File.write("acq: {" + "\n") 61 | File.write(' method = "IMGS";' + "\n") 62 | File.write(' imgPath = "test/%s/img/%%.4d.jpg";'%random_list[i] + "\n") 63 | File.write("};" + "\n") 64 | File.close() 65 | File = open("config/DSST/image_sequence_%s"%random_list[i]+".cfg", "w") 66 | File.write("seed = 0;" + "\n") 67 | if line.find(',')==-1: 68 | File.write("initialBoundingBox = [%s,%s,%s,%s];"%(line.split()[0],line.split()[1],line.split()[2],line.split()[3]) + "\n") 69 | else: 70 | File.write("initialBoundingBox = [%s];"%line + "\n") 71 | File.write("showNotConfident = true;" + "\n") 72 | File.write("saveOutput = true;" + "\n") 73 | File.write('saveDir = "%s";'%random_list[i] + "\n") 74 | File.write('printResults = "results/DSST/results_%s.txt";'%random_list[i] + "\n") 75 | File.write("showOutput = true;"+ "\n") 76 | File.write("# useDsstTracker = true;" + "\n\n") 77 | File.write("acq: {" + "\n") 78 | File.write(' method = "IMGS";' + "\n") 79 | File.write(' imgPath = "test/%s/img/%%.4d.jpg";'%random_list[i] + "\n") 80 | File.write("};" + "\n") 81 | File.close() 82 | shfile1.write("./cftld -x config/DSST/image_sequence_%s.cfg"%random_list[i] + "\n") 83 | shfile1.write("./cftld config/KCF/image_sequence_%s.cfg"%random_list[i] + "\n") 84 | shfile1.close() 85 | #shfile2.close() 86 | -------------------------------------------------------------------------------- /sample/benchmark/deleteTest.py: -------------------------------------------------------------------------------- 1 | import os 2 | import random 3 | 4 | path = './test' 5 | files = os.listdir(path) 6 | folder_list = [] 7 | truth_line_count = 0 8 | file_count = 0 9 | for file in files: 10 | # h = file.split('_',1) 11 | # temp = h[1].split('.',1) 12 | if file.find('.sh')<0: 13 | folder_list.append(file) 14 | print folder_list 15 | 16 | for i in range(len(folder_list)): 17 | if os.path.isfile("test/%s/groundtruth_rect.txt"%folder_list[i]): 18 | truth_file = open("test/%s/groundtruth_rect.txt"%folder_list[i]) 19 | else: 20 | truth_file = open("test/%s/groundtruth_rect.1.txt"%folder_list[i]) 21 | for truth_line in truth_file: 22 | truth_line_count += 1 23 | for filename in os.listdir("test/%s/img"%folder_list[i]): 24 | if filename.find('.jpg')>0: 25 | file_count = file_count + 1 26 | if truth_line_count != file_count: 27 | print ("%s error"%folder_list[i]) 28 | print truth_line_count 29 | print file_count 30 | os.system("sudo mv test/%s error"%folder_list[i]) 31 | truth_file.close() 32 | truth_line_count = 0 33 | file_count = 0 34 | 35 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CF_CV_EXT "src/3rdparty/cv_ext") 2 | set(CF_PIOTR_DIR "src/3rdparty/piotr/") 3 | 4 | set(CF_HEADER_DIRS 5 | ${CMAKE_CURRENT_SOURCE_DIR}/${CF_CV_EXT} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/${CF_PIOTR_DIR} 7 | ${CMAKE_CURRENT_SOURCE_DIR}/${CF_PIOTR_DIR}/src 8 | ${CMAKE_CURRENT_SOURCE_DIR}/src/cf_libs/kcf 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src/cf_libs/dsst 10 | ${CMAKE_CURRENT_SOURCE_DIR}/src/cf_libs/common 11 | PARENT_SCOPE) 12 | 13 | set(CF_PIOTR_SOURCES 14 | ${CF_PIOTR_DIR}/src/gradientMex.cpp 15 | ${CF_PIOTR_DIR}/gradientMex.hpp 16 | ${CF_PIOTR_DIR}/src/sse.hpp 17 | ${CF_PIOTR_DIR}/src/wrappers.hpp) 18 | 19 | set(CF_LIB_COMMON_SOURCES 20 | src/cf_libs/common/feature_channels.hpp 21 | src/cf_libs/common/mat_consts.hpp 22 | src/cf_libs/common/math_helper.hpp 23 | src/cf_libs/common/math_helper.cpp 24 | src/cf_libs/common/cf_tracker.hpp 25 | src/cf_libs/common/tracker_debug.hpp 26 | src/cf_libs/common/scale_estimator.hpp 27 | src/cf_libs/common/cv_ext.hpp 28 | ${CF_CV_EXT}/shift.cpp 29 | ${CF_CV_EXT}/shift.hpp 30 | ${CF_CV_EXT}/math_spectrums.cpp 31 | ${CF_CV_EXT}/math_spectrums.hpp 32 | ${CF_PIOTR_SOURCES}) 33 | 34 | set(CF_SOURCES_ 35 | src/cf_libs/dsst/dsst_debug.hpp 36 | src/cf_libs/dsst/dsst_tracker.hpp 37 | src/cf_libs/kcf/kcf_debug.hpp 38 | src/cf_libs/kcf/kcf_tracker.hpp 39 | ${CF_LIB_COMMON_SOURCES} 40 | ) 41 | 42 | function(PREFIX prefix list_) 43 | SET(tmp_list) 44 | 45 | foreach(SOURCE_FILE ${${list_}}) 46 | list(APPEND tmp_list "${prefix}${SOURCE_FILE}") 47 | endforeach(SOURCE_FILE) 48 | 49 | set(${list_} ${tmp_list} PARENT_SCOPE) 50 | endfunction(PREFIX) 51 | 52 | PREFIX("${CMAKE_CURRENT_SOURCE_DIR}/" "CF_SOURCES_") 53 | set(CF_SOURCES ${CF_SOURCES_} PARENT_SCOPE) 54 | # message(STATUS ${CF_SOURCES_}) 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | This repository provides C++ implementations for two correlation filter-based trackers. The code implements modified versions of the 4 | visual trackers proposed in [1] and [2]: 5 | * KCFcpp: This tracker is a C++ port of the Matlab implementation of the kernelized correlation filter (KCF) tracker proposed in [1]. Project webpage: http://home.isr.uc.pt/~henriques/circulant/ KCFcpp uses as default scale adaption the 1D scale filter proposed in [2]. In addition, a fixed template size, 6 | the subpixel/subcell response peak estimation, and the model update from [3] is used as in the KCF version used by Henriques et al. in the VOT challenge 2014 (http://votchallenge.net/vot2014/). The scale adaption used by Henriques et al. in the VOT challenge 2014 is available as option. 7 | * DSSTcpp: This tracker is a C++ port of the Matlab implementation of the discriminative scale space tracker (DSST) proposed in [2]. The default settings 8 | use a fixed template size and the subpixel/cell response peak estimation as in 9 | the KCF version. Project webpage: http://www.cvl.isy.liu.se/en/research/objrec/visualtracking/scalvistrack/index.html 10 | 11 | Both implementations use the FHOG features proposed in [4]. 12 | More specifically, the FHOG implementation from [5] is used. 13 | Both trackers offer the option to use the target 14 | loss detection proposed in [6]. 15 | 16 | 17 | 18 | 19 | # Build 20 | ### Dependencies 21 | * C++11 22 | * OpenCV 3.0 23 | * CMake 24 | * SSE2-capable CPU 25 | 26 | Compilation has been tested on Windows 7 with Visual Studio 2013 Ultimate, 27 | on Windows 8.1 with Visual Studio 2013 Community and on Ubuntu 14.04 with g++. 28 | 29 | ### Windows 7 30 | * Set environment variables according to [OpenCV Setup - Environment Variables](http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable) 31 | * Launch cmake-gui, create a build folder and configure. 32 | * Open CfTracking.sln in Visual Studio and compile the projects DSSTcpp and KCFcpp. 33 | 34 | ### Ubuntu 14.04 35 | * Install OpenCV 3.0 and CMake. 36 | * Configure and compile: 37 | ``` 38 | mkdir /build 39 | cd /build 40 | cmake ../ 41 | make -j 8 42 | ``` 43 | 44 | # Usage 45 | * To track images from a webcam, simply launch DSSTcpp(.exe) or KCFcpp(.exe) and 46 | mark an object with a rectangle. 47 | * To pass a predefined bounding box, use the `-b x,y,w,h` command line switch. Boxes 48 | are expected to use images starting at position 0,0. 49 | * To track an image sequence or video, copy the contents of `/sample/*` to your build/release folder and run the batch/sh file. 50 | The example launch scripts are brief and explain the trackers' usage. If you run the tracker from Windows cmd, use only one 51 | % sign to specify the naming convention of the image sequence. 52 | * To enable target loss detection, run the tracker with the `--para_enable_tracking_loss` command line switch. 53 | * To achieve tracking performance as close to the original Matlab implementations as possible, run the trackers with the `--original_version` command line switch. 54 | While the trackers are implemented closely to their original Matlab implementations, 55 | implementation differences do still exist (even with the `--original_version` switch) and the tracking performance of the C++ implementations 56 | may deviate from their original Matlab implementations. 57 | * To see a full list of available options, run the trackers with `--help` command line switch. 58 | 59 | 60 | # Commercial Use (US) 61 | The code using linear correlation filters may be affected by a US patent. If you want to use this code commercially in the US please refer to http://www.cs.colostate.edu/~vision/ocof_toolset_2012/index.php for possible patent claims. 62 | 63 | 64 | # Contributors 65 | Luka Cehovin: Equalize FHOG performance on AMD and Intel CPUs 66 | 67 | 68 | ## 3rdparty libraries used: 69 | * Piotr's Matlab Toolbox http://vision.ucsd.edu/~pdollar/toolbox/doc/ 70 | * OpenCV http://opencv.org/ 71 | * tclap http://tclap.sourceforge.net/ 72 | 73 | ## References 74 | If you reuse this code for a scientific publication, please cite the related publications (dependent on what parts of the code you reuse): 75 | 76 | [1] 77 | ``` 78 | @article{henriques2015tracking, 79 | title = {High-Speed Tracking with Kernelized Correlation Filters}, 80 | author = {Henriques, J. F. and Caseiro, R. and Martins, P. and Batista, J.}, 81 | journal = {Pattern Analysis and Machine Intelligence, IEEE Transactions on}, 82 | year = {2015} 83 | ``` 84 | 85 | 86 | [2] 87 | ``` 88 | @inproceedings{danelljan2014dsst, 89 | title={Accurate Scale Estimation for Robust Visual Tracking}, 90 | author={Danelljan, Martin and H{\"a}ger, Gustav and Khan, Fahad Shahbaz and Felsberg, Michael}, 91 | booktitle={Proceedings of the British Machine Vision Conference BMVC}, 92 | year={2014}} 93 | ``` 94 | 95 | [3] 96 | ``` 97 | @inproceedings{danelljan2014colorattributes, 98 | title={Adaptive Color Attributes for Real-Time Visual Tracking}, 99 | author={Danelljan, Martin and Khan, Fahad Shahbaz and Felsberg, Michael and Weijer, Joost van de}, 100 | booktitle={Conference on Computer Vision and Pattern Recognition (CVPR)}, 101 | year={2014}} 102 | ``` 103 | 104 | [4] 105 | ``` 106 | @article{lsvm-pami, 107 | title = "Object Detection with Discriminatively Trained Part Based Models", 108 | author = "Felzenszwalb, P. F. and Girshick, R. B. and McAllester, D. and Ramanan, D.", 109 | journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence", 110 | year = "2010", volume = "32", number = "9", pages = "1627--1645"} 111 | ``` 112 | 113 | [5] 114 | ``` 115 | @misc{PMT, 116 | author = {Piotr Doll\'ar}, 117 | title = {{P}iotr's {C}omputer {V}ision {M}atlab {T}oolbox ({PMT})}, 118 | howpublished = {\url{http://vision.ucsd.edu/~pdollar/toolbox/doc/index.html}}} 119 | ``` 120 | 121 | [6] 122 | ``` 123 | @inproceedings{bolme2010mosse, 124 | author={Bolme, David S. and Beveridge, J. Ross and Draper, Bruce A. and Yui Man Lui}, 125 | title={Visual Object Tracking using Adaptive Correlation Filters}, 126 | booktitle={Conference on Computer Vision and Pattern Recognition (CVPR)}, 127 | year={2010}} 128 | ``` 129 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/cv_ext/init_box_selector.cpp: -------------------------------------------------------------------------------- 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 | // License Agreement 10 | // For Open Source Computer Vision Library 11 | // (3-clause BSD License) 12 | // 13 | // Copyright (C) 2000-2015, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. 15 | // Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved. 16 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 17 | // Copyright (C) 2015, OpenCV Foundation, all rights reserved. 18 | // Copyright (C) 2015, Itseez Inc., all rights reserved. 19 | // Third party copyrights are property of their respective owners. 20 | // 21 | // Redistribution and use in source and binary forms, with or without modification, 22 | // are permitted provided that the following conditions are met: 23 | // 24 | // * Redistributions of source code must retain the above copyright notice, 25 | // this list of conditions and the following disclaimer. 26 | // 27 | // * Redistributions in binary form must reproduce the above copyright notice, 28 | // this list of conditions and the following disclaimer in the documentation 29 | // and/or other materials provided with the distribution. 30 | // 31 | // * Neither the names of the copyright holders nor the names of the contributors 32 | // may be used to endorse or promote products derived from this software 33 | // without specific prior written permission. 34 | // 35 | // This software is provided by the copyright holders and contributors "as is" and 36 | // any express or implied warranties, including, but not limited to, the implied 37 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 38 | // In no event shall copyright holders or contributors be liable for any direct, 39 | // indirect, incidental, special, exemplary, or consequential damages 40 | // (including, but not limited to, procurement of substitute goods or services; 41 | // loss of use, data, or profits; or business interruption) however caused 42 | // and on any theory of liability, whether in contract, strict liability, 43 | // or tort (including negligence or otherwise) arising in any way out of 44 | // the use of this software, even if advised of the possibility of such damage. 45 | //M*/ 46 | 47 | /* 48 | // Original file: https://github.com/Itseez/opencv_contrib/blob/292b8fa6aa403fb7ad6d2afadf4484e39d8ca2f1/modules/tracking/samples/tracker.cpp 49 | // + Author: Klaus Haag 50 | // * Refactor file: Move target selection to separate class/file 51 | */ 52 | 53 | #include "init_box_selector.hpp" 54 | 55 | void InitBoxSelector::onMouse(int event, int x, int y, int, void*) 56 | { 57 | if (!selectObject) 58 | { 59 | switch (event) 60 | { 61 | case cv::EVENT_LBUTTONDOWN: 62 | //set origin of the bounding box 63 | startSelection = true; 64 | initBox.x = x; 65 | initBox.y = y; 66 | break; 67 | case cv::EVENT_LBUTTONUP: 68 | //set width and height of the bounding box 69 | initBox.width = std::abs(x - initBox.x); 70 | initBox.height = std::abs(y - initBox.y); 71 | startSelection = false; 72 | selectObject = true; 73 | break; 74 | case cv::EVENT_MOUSEMOVE: 75 | if (startSelection && !selectObject) 76 | { 77 | //draw the bounding box 78 | cv::Mat currentFrame; 79 | image.copyTo(currentFrame); 80 | cv::rectangle(currentFrame, cv::Point((int)initBox.x, (int)initBox.y), cv::Point(x, y), cv::Scalar(255, 0, 0), 2, 1); 81 | cv::imshow(windowTitle.c_str(), currentFrame); 82 | } 83 | break; 84 | } 85 | } 86 | } 87 | 88 | bool InitBoxSelector::selectBox(cv::Mat& frame, cv::Rect& initBox) 89 | { 90 | frame.copyTo(image); 91 | startSelection = false; 92 | selectObject = false; 93 | cv::imshow(windowTitle.c_str(), image); 94 | cv::setMouseCallback(windowTitle.c_str(), onMouse, 0); 95 | 96 | while (selectObject == false) 97 | { 98 | char c = (char)cv::waitKey(10); 99 | 100 | if (c == 27) 101 | return false; 102 | } 103 | 104 | initBox = InitBoxSelector::initBox; 105 | cv::setMouseCallback(windowTitle.c_str(), 0, 0); 106 | cv::destroyWindow(windowTitle.c_str()); 107 | return true; 108 | } 109 | 110 | const std::string InitBoxSelector::windowTitle = "Draw Bounding Box"; 111 | bool InitBoxSelector::startSelection = false; 112 | bool InitBoxSelector::selectObject = false; 113 | cv::Mat InitBoxSelector::image; 114 | cv::Rect InitBoxSelector::initBox; 115 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/cv_ext/init_box_selector.hpp: -------------------------------------------------------------------------------- 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 | // License Agreement 10 | // For Open Source Computer Vision Library 11 | // (3-clause BSD License) 12 | // 13 | // Copyright (C) 2000-2015, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. 15 | // Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved. 16 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 17 | // Copyright (C) 2015, OpenCV Foundation, all rights reserved. 18 | // Copyright (C) 2015, Itseez Inc., all rights reserved. 19 | // Third party copyrights are property of their respective owners. 20 | // 21 | // Redistribution and use in source and binary forms, with or without modification, 22 | // are permitted provided that the following conditions are met: 23 | // 24 | // * Redistributions of source code must retain the above copyright notice, 25 | // this list of conditions and the following disclaimer. 26 | // 27 | // * Redistributions in binary form must reproduce the above copyright notice, 28 | // this list of conditions and the following disclaimer in the documentation 29 | // and/or other materials provided with the distribution. 30 | // 31 | // * Neither the names of the copyright holders nor the names of the contributors 32 | // may be used to endorse or promote products derived from this software 33 | // without specific prior written permission. 34 | // 35 | // This software is provided by the copyright holders and contributors "as is" and 36 | // any express or implied warranties, including, but not limited to, the implied 37 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 38 | // In no event shall copyright holders or contributors be liable for any direct, 39 | // indirect, incidental, special, exemplary, or consequential damages 40 | // (including, but not limited to, procurement of substitute goods or services; 41 | // loss of use, data, or profits; or business interruption) however caused 42 | // and on any theory of liability, whether in contract, strict liability, 43 | // or tort (including negligence or otherwise) arising in any way out of 44 | // the use of this software, even if advised of the possibility of such damage. 45 | //M*/ 46 | 47 | /* 48 | // Original file: https://github.com/Itseez/opencv_contrib/blob/292b8fa6aa403fb7ad6d2afadf4484e39d8ca2f1/modules/tracking/samples/tracker.cpp 49 | // + Author: Klaus Haag 50 | // * Refactor file: Move target selection to separate class/file 51 | */ 52 | 53 | #ifndef INIT_BOX_SELECTOR_HPP_ 54 | #define INIT_BOX_SELECTOR_HPP_ 55 | 56 | #include "opencv2/highgui/highgui.hpp" 57 | #include "opencv2/opencv.hpp" 58 | 59 | class InitBoxSelector 60 | { 61 | public: 62 | static bool selectBox(cv::Mat& frame, cv::Rect& initBox); 63 | 64 | private: 65 | static void onMouse(int event, int x, int y, int, void*); 66 | static bool startSelection; 67 | static bool selectObject; 68 | static cv::Rect initBox; 69 | static cv::Mat image; 70 | static const std::string windowTitle; 71 | }; 72 | 73 | #endif /* INIT_BOX_SELECTOR_H_ */ 74 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/cv_ext/psr.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OAID/ObjectTracker/d76608c7a1d71ad3522c3b840f6edfcaa1ed3f19/src/3rdparty/cf_tracking/src/3rdparty/cv_ext/psr.hpp -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/cv_ext/shift.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2012, Willow Garage, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of Willow Garage, Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * File: shift.hpp 35 | * Author: Hilton Bristow 36 | * Created: Aug 23, 2012 37 | * + Author: Klaus Haag (split into header/source file) 38 | */ 39 | 40 | #ifndef SHIFT_HPP_ 41 | #define SHIFT_HPP_ 42 | 43 | #include 44 | 45 | void shift(const cv::Mat& src, cv::Mat& dst, cv::Point2f delta, 46 | int fill = cv::BORDER_CONSTANT, 47 | cv::Scalar value = cv::Scalar(0, 0, 0, 0)); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/cv_ext/tracker_run.hpp: -------------------------------------------------------------------------------- 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 | // License Agreement 10 | // For Open Source Computer Vision Library 11 | // (3-clause BSD License) 12 | // 13 | // Copyright (C) 2000-2015, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. 15 | // Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved. 16 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 17 | // Copyright (C) 2015, OpenCV Foundation, all rights reserved. 18 | // Copyright (C) 2015, Itseez Inc., all rights reserved. 19 | // Third party copyrights are property of their respective owners. 20 | // 21 | // Redistribution and use in source and binary forms, with or without modification, 22 | // are permitted provided that the following conditions are met: 23 | // 24 | // * Redistributions of source code must retain the above copyright notice, 25 | // this list of conditions and the following disclaimer. 26 | // 27 | // * Redistributions in binary form must reproduce the above copyright notice, 28 | // this list of conditions and the following disclaimer in the documentation 29 | // and/or other materials provided with the distribution. 30 | // 31 | // * Neither the names of the copyright holders nor the names of the contributors 32 | // may be used to endorse or promote products derived from this software 33 | // without specific prior written permission. 34 | // 35 | // This software is provided by the copyright holders and contributors "as is" and 36 | // any express or implied warranties, including, but not limited to, the implied 37 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 38 | // In no event shall copyright holders or contributors be liable for any direct, 39 | // indirect, incidental, special, exemplary, or consequential damages 40 | // (including, but not limited to, procurement of substitute goods or services; 41 | // loss of use, data, or profits; or business interruption) however caused 42 | // and on any theory of liability, whether in contract, strict liability, 43 | // or tort (including negligence or otherwise) arising in any way out of 44 | // the use of this software, even if advised of the possibility of such damage. 45 | //M*/ 46 | 47 | /* 48 | // Original file: https://github.com/Itseez/opencv_contrib/blob/292b8fa6aa403fb7ad6d2afadf4484e39d8ca2f1/modules/tracking/samples/tracker.cpp 49 | // + Author: Klaus Haag 50 | // * Refactor file: Move target selection to separate class/file 51 | // * Replace command line argumnets 52 | // * Change tracker calling code 53 | // * Add a variety of additional features 54 | */ 55 | 56 | #ifndef TRACKER_RUN_HPP_ 57 | #define TRACKER_RUN_HPP_ 58 | 59 | #include 60 | #include 61 | #include 62 | #include "cf_tracker.hpp" 63 | #include "tracker_debug.hpp" 64 | #include "dsst_tracker.hpp" 65 | #include "image_acquisition.hpp" 66 | 67 | struct Parameters{ 68 | std::string sequencePath; 69 | std::string outputFilePath; 70 | std::string imgExportPath; 71 | std::string expansion; 72 | cv::Rect initBb; 73 | int device; 74 | int startFrame; 75 | bool showOutput; 76 | bool paused; 77 | bool repeat; 78 | bool isMockSequence; 79 | }; 80 | 81 | class TrackerRun 82 | { 83 | public: 84 | TrackerRun(std::string windowTitle); 85 | virtual ~TrackerRun(); 86 | bool start(int argc, const char** argv); 87 | void setTrackerDebug(cf_tracking::TrackerDebug* debug); 88 | 89 | private: 90 | Parameters parseCmdArgs(int argc, const char** argv); 91 | bool init(); 92 | bool run(); 93 | bool update(); 94 | void printResults(const cv::Rect_& boundingBox, bool isConfident, double fps); 95 | 96 | protected: 97 | virtual cf_tracking::CfTracker* parseTrackerParas(TCLAP::CmdLine& cmd, int argc, const char** argv) = 0; 98 | private: 99 | cv::Mat _image; 100 | cf_tracking::CfTracker* _tracker; 101 | std::string _windowTitle; 102 | Parameters _paras; 103 | cv::Rect_ _boundingBox; 104 | ImageAcquisition _cap; 105 | std::ofstream _resultsFile; 106 | TCLAP::CmdLine _cmd; 107 | cf_tracking::TrackerDebug* _debug; 108 | int _frameIdx; 109 | bool _isPaused = false; 110 | bool _isStep = false; 111 | bool _exit = false; 112 | bool _hasInitBox = false; 113 | bool _isTrackerInitialzed = false; 114 | bool _targetOnFrame = false; 115 | bool _updateAtPos = false; 116 | }; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/piotr/README.md: -------------------------------------------------------------------------------- 1 | This module provides the FHOG implementation from 2 | http://vision.ucsd.edu/~pdollar/toolbox/doc/ 3 | with an OpenCV integration. 4 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/piotr/src/sse.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Piotr Dollar 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are those 26 | of the authors and should not be interpreted as representing official policies, 27 | either expressed or implied, of the FreeBSD Project. 28 | */ 29 | 30 | /******************************************************************************* 31 | * Piotr's Computer Vision Matlab Toolbox Version 3.23 32 | * Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com] 33 | * Licensed under the Simplified BSD License [see above] 34 | * Project page: http://vision.ucsd.edu/~pdollar/toolbox/doc/ 35 | * Original file: https://github.com/pdollar/toolbox/blob/612f9a0451a6abbe2a64768c9e6654692929102e/channels/private/sse.hpp 36 | 37 | + author: Klaus Haag: Move external license into this source file 38 | + author: Luka Cehovin: Fix equal results on AMD and Intel CPUs 39 | *******************************************************************************/ 40 | #ifndef _SSE_HPP_ 41 | #define _SSE_HPP_ 42 | 43 | #define __ARM_NEON__ 44 | 45 | #ifdef __ARM_NEON__ 46 | #include "sse_to_neon.hpp" 47 | #else 48 | #include 49 | #endif 50 | 51 | #define RETf inline __m128 52 | #define RETi inline __m128i 53 | 54 | // set, load and store values 55 | RETf SET(const float& x) { return _mm_set1_ps(x); } 56 | RETf SET(float x, float y, float z, float w) { return _mm_set_ps(x, y, z, w); } 57 | RETi SET(const int& x) { return _mm_set1_epi32(x); } 58 | RETf LD(const float& x) { return _mm_load_ps(&x); } 59 | RETf LDu(const float& x) { return _mm_loadu_ps(&x); } 60 | RETf STR(float& x, const __m128 y) { _mm_store_ps(&x, y); return y; } 61 | RETf STR1(float& x, const __m128 y) { _mm_store_ss(&x, y); return y; } 62 | RETf STRu(float& x, const __m128 y) { _mm_storeu_ps(&x, y); return y; } 63 | RETf STR(float& x, const float y) { return STR(x, SET(y)); } 64 | 65 | // arithmetic operators 66 | RETi ADD(const __m128i x, const __m128i y) { return _mm_add_epi32(x, y); } 67 | RETf ADD(const __m128 x, const __m128 y) { return _mm_add_ps(x, y); } 68 | RETf ADD(const __m128 x, const __m128 y, const __m128 z) { 69 | return ADD(ADD(x, y), z); 70 | } 71 | RETf ADD(const __m128 a, const __m128 b, const __m128 c, const __m128& d) { 72 | return ADD(ADD(ADD(a, b), c), d); 73 | } 74 | RETf SUB(const __m128 x, const __m128 y) { return _mm_sub_ps(x, y); } 75 | RETf MUL(const __m128 x, const __m128 y) { return _mm_mul_ps(x, y); } 76 | RETf MUL(const __m128 x, const float y) { return MUL(x, SET(y)); } 77 | RETf MUL(const float x, const __m128 y) { return MUL(SET(x), y); } 78 | RETf INC(__m128& x, const __m128 y) { return x = ADD(x, y); } 79 | RETf INC(float& x, const __m128 y) { __m128 t = ADD(LD(x), y); return STR(x, t); } 80 | RETf DEC(__m128& x, const __m128 y) { return x = SUB(x, y); } 81 | RETf DEC(float& x, const __m128 y) { __m128 t = SUB(LD(x), y); return STR(x, t); } 82 | RETf MIN_SSE(const __m128 x, const __m128 y) { return _mm_min_ps(x, y); } 83 | RETf RCP(const __m128 x) { return _mm_rcp_ps(x); } 84 | 85 | RETf SQRT(const __m128 x) { return _mm_sqrt_ps(x); } 86 | RETf MAX_SSE(const __m128 x, const __m128 y) { return _mm_max_ps(x, y); } 87 | RETf DIV(const __m128 x, const __m128 y) { 88 | #ifdef __ARM_NEON__ // NEON doesn't seem to support this 89 | return x / y; 90 | #else 91 | return _mm_div_ps(x, y); 92 | #endif 93 | } 94 | RETf DIV(const __m128 x, const float y) { return DIV(x, SET(y)); } 95 | RETf DIV(const float x, const __m128 y) { return DIV(SET(x), y); } 96 | 97 | // logical operators 98 | RETf AND(const __m128 x, const __m128 y) { return _mm_and_ps(x, y); } 99 | RETi AND(const __m128i x, const __m128i y) { return _mm_and_si128(x, y); } 100 | RETf ANDNOT(const __m128 x, const __m128 y) { return _mm_andnot_ps(x, y); } 101 | RETf OR(const __m128 x, const __m128 y) { return _mm_or_ps(x, y); } 102 | RETf XOR(const __m128 x, const __m128 y) { return _mm_xor_ps(x, y); } 103 | 104 | // comparison operators 105 | RETf CMPGT(const __m128 x, const __m128 y) { return _mm_cmpgt_ps(x, y); } 106 | RETf CMPLT(const __m128 x, const __m128 y) { return _mm_cmplt_ps(x, y); } 107 | RETi CMPGT(const __m128i x, const __m128i y) { return _mm_cmpgt_epi32(x, y); } 108 | RETi CMPLT(const __m128i x, const __m128i y) { return _mm_cmplt_epi32(x, y); } 109 | 110 | // conversion operators 111 | RETf CVT(const __m128i x) { return _mm_cvtepi32_ps(x); } 112 | RETi CVT(const __m128 x) { return _mm_cvttps_epi32(x); } 113 | 114 | #undef RETf 115 | #undef RETi 116 | #endif 117 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/piotr/src/wrappers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Piotr Dollar 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are those 26 | of the authors and should not be interpreted as representing official policies, 27 | either expressed or implied, of the FreeBSD Project. 28 | */ 29 | 30 | /******************************************************************************* 31 | * Piotr's Computer Vision Matlab Toolbox Version 3.00 32 | * Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com] 33 | * Licensed under the Simplified BSD License [see above] 34 | * Project page: http://vision.ucsd.edu/~pdollar/toolbox/doc/ 35 | * Original file: https://github.com/pdollar/toolbox/blob/612f9a0451a6abbe2a64768c9e6654692929102e/channels/private/wrappers.hpp 36 | 37 | + author: Klaus Haag: Move external license into this source file 38 | *******************************************************************************/ 39 | #ifndef WRAPPERS_HPP_ 40 | #define WRAPPERS_HPP_ 41 | 42 | #ifdef MATLAB_MEX_FILE 43 | 44 | // wrapper functions if compiling from Matlab 45 | #include "mex.h" 46 | inline void wrError(const char *errormsg) { mexErrMsgTxt(errormsg); } 47 | inline void* wrCalloc(size_t num, size_t size) { return mxCalloc(num, size); } 48 | inline void* wrMalloc(size_t size) { return mxMalloc(size); } 49 | inline void wrFree(void * ptr) { mxFree(ptr); } 50 | 51 | #else 52 | 53 | #include 54 | // wrapper functions if compiling from C/C++ 55 | inline void wrError(const char *errormsg) { throw errormsg; } 56 | inline void* wrCalloc(size_t num, size_t size) { return calloc(num, size); } 57 | inline void* wrMalloc(size_t size) { return malloc(size); } 58 | inline void wrFree(void * ptr) { free(ptr); } 59 | 60 | #endif 61 | 62 | // platform independent aligned memory allocation (see also alFree) 63 | inline void* alMalloc(size_t size, int alignment) { 64 | const size_t pSize = sizeof(void*); 65 | const size_t a = alignment - 1; 66 | void *raw = wrMalloc(size + a + pSize); 67 | void *aligned = (void*)(((size_t)raw + pSize + a) & ~a); 68 | *(void**)((size_t)aligned - pSize) = raw; 69 | return aligned; 70 | } 71 | 72 | // platform independent alignned memory de-allocation (see also alMalloc) 73 | inline void alFree(void* aligned) { 74 | const size_t pSize = sizeof(void*); 75 | void* raw = *(void**)((char*)aligned - pSize); 76 | wrFree(raw); 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | original author: Michael E. Smoot 3 | invaluable contributions: Daniel Aarno 4 | more contributions: Erik Zeek 5 | more contributions: Fabien Carmagnac (Tinbergen-AM) 6 | outstanding editing: Carol Smoot 7 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2003 Michael E. Smoot 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = tclap 2 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/README: -------------------------------------------------------------------------------- 1 | 2 | TCLAP - Templatized Command Line Argument Parser 3 | 4 | This is a simple C++ library that facilitates parsing command line 5 | arguments in a type independent manner. It doesn't conform exactly 6 | to either the GNU or POSIX standards, although it is close. See 7 | docs/manual.html for descriptions of how things work or look at the 8 | simple examples in the examples dir. 9 | 10 | To find out what the latest changes are read the NEWS file in this directory. 11 | 12 | 13 | Any and all feedback is welcome to: Mike Smoot 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/ArgException.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgException.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_ARG_EXCEPTION_H 25 | #define TCLAP_ARG_EXCEPTION_H 26 | 27 | #include 28 | #include 29 | 30 | namespace TCLAP { 31 | 32 | /** 33 | * A simple class that defines and argument exception. Should be caught 34 | * whenever a CmdLine is created and parsed. 35 | */ 36 | class ArgException : public std::exception 37 | { 38 | public: 39 | 40 | /** 41 | * Constructor. 42 | * \param text - The text of the exception. 43 | * \param id - The text identifying the argument source. 44 | * \param td - Text describing the type of ArgException it is. 45 | * of the exception. 46 | */ 47 | ArgException( const std::string& text = "undefined exception", 48 | const std::string& id = "undefined", 49 | const std::string& td = "Generic ArgException") 50 | : std::exception(), 51 | _errorText(text), 52 | _argId( id ), 53 | _typeDescription(td) 54 | { } 55 | 56 | /** 57 | * Destructor. 58 | */ 59 | virtual ~ArgException() throw() { } 60 | 61 | /** 62 | * Returns the error text. 63 | */ 64 | std::string error() const { return ( _errorText ); } 65 | 66 | /** 67 | * Returns the argument id. 68 | */ 69 | std::string argId() const 70 | { 71 | if ( _argId == "undefined" ) 72 | return " "; 73 | else 74 | return ( "Argument: " + _argId ); 75 | } 76 | 77 | /** 78 | * Returns the arg id and error text. 79 | */ 80 | const char* what() const throw() 81 | { 82 | static std::string ex; 83 | ex = _argId + " -- " + _errorText; 84 | return ex.c_str(); 85 | } 86 | 87 | /** 88 | * Returns the type of the exception. Used to explain and distinguish 89 | * between different child exceptions. 90 | */ 91 | std::string typeDescription() const 92 | { 93 | return _typeDescription; 94 | } 95 | 96 | 97 | private: 98 | 99 | /** 100 | * The text of the exception message. 101 | */ 102 | std::string _errorText; 103 | 104 | /** 105 | * The argument related to this exception. 106 | */ 107 | std::string _argId; 108 | 109 | /** 110 | * Describes the type of the exception. Used to distinguish 111 | * between different child exceptions. 112 | */ 113 | std::string _typeDescription; 114 | 115 | }; 116 | 117 | /** 118 | * Thrown from within the child Arg classes when it fails to properly 119 | * parse the argument it has been passed. 120 | */ 121 | class ArgParseException : public ArgException 122 | { 123 | public: 124 | /** 125 | * Constructor. 126 | * \param text - The text of the exception. 127 | * \param id - The text identifying the argument source 128 | * of the exception. 129 | */ 130 | ArgParseException( const std::string& text = "undefined exception", 131 | const std::string& id = "undefined" ) 132 | : ArgException( text, 133 | id, 134 | std::string( "Exception found while parsing " ) + 135 | std::string( "the value the Arg has been passed." )) 136 | { } 137 | }; 138 | 139 | /** 140 | * Thrown from CmdLine when the arguments on the command line are not 141 | * properly specified, e.g. too many arguments, required argument missing, etc. 142 | */ 143 | class CmdLineParseException : public ArgException 144 | { 145 | public: 146 | /** 147 | * Constructor. 148 | * \param text - The text of the exception. 149 | * \param id - The text identifying the argument source 150 | * of the exception. 151 | */ 152 | CmdLineParseException( const std::string& text = "undefined exception", 153 | const std::string& id = "undefined" ) 154 | : ArgException( text, 155 | id, 156 | std::string( "Exception found when the values ") + 157 | std::string( "on the command line do not meet ") + 158 | std::string( "the requirements of the defined ") + 159 | std::string( "Args." )) 160 | { } 161 | }; 162 | 163 | /** 164 | * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. 165 | * same flag as another Arg, same name, etc. 166 | */ 167 | class SpecificationException : public ArgException 168 | { 169 | public: 170 | /** 171 | * Constructor. 172 | * \param text - The text of the exception. 173 | * \param id - The text identifying the argument source 174 | * of the exception. 175 | */ 176 | SpecificationException( const std::string& text = "undefined exception", 177 | const std::string& id = "undefined" ) 178 | : ArgException( text, 179 | id, 180 | std::string("Exception found when an Arg object ")+ 181 | std::string("is improperly defined by the ") + 182 | std::string("developer." )) 183 | { } 184 | 185 | }; 186 | 187 | class ExitException { 188 | public: 189 | ExitException(int estat) : _estat(estat) {} 190 | 191 | int getExitStatus() const { return _estat; } 192 | 193 | private: 194 | int _estat; 195 | }; 196 | 197 | } // namespace TCLAP 198 | 199 | #endif 200 | 201 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_ARGTRAITS_H 27 | #define TCLAP_ARGTRAITS_H 28 | 29 | namespace TCLAP { 30 | 31 | // We use two empty structs to get compile type specialization 32 | // function to work 33 | 34 | /** 35 | * A value like argument value type is a value that can be set using 36 | * operator>>. This is the default value type. 37 | */ 38 | struct ValueLike { 39 | typedef ValueLike ValueCategory; 40 | virtual ~ValueLike() {} 41 | }; 42 | 43 | /** 44 | * A string like argument value type is a value that can be set using 45 | * operator=(string). Usefull if the value type contains spaces which 46 | * will be broken up into individual tokens by operator>>. 47 | */ 48 | struct StringLike { 49 | virtual ~StringLike() {} 50 | }; 51 | 52 | /** 53 | * A class can inherit from this object to make it have string like 54 | * traits. This is a compile time thing and does not add any overhead 55 | * to the inherenting class. 56 | */ 57 | struct StringLikeTrait { 58 | typedef StringLike ValueCategory; 59 | virtual ~StringLikeTrait() {} 60 | }; 61 | 62 | /** 63 | * A class can inherit from this object to make it have value like 64 | * traits. This is a compile time thing and does not add any overhead 65 | * to the inherenting class. 66 | */ 67 | struct ValueLikeTrait { 68 | typedef ValueLike ValueCategory; 69 | virtual ~ValueLikeTrait() {} 70 | }; 71 | 72 | /** 73 | * Arg traits are used to get compile type specialization when parsing 74 | * argument values. Using an ArgTraits you can specify the way that 75 | * values gets assigned to any particular type during parsing. The two 76 | * supported types are StringLike and ValueLike. 77 | */ 78 | template 79 | struct ArgTraits { 80 | typedef typename T::ValueCategory ValueCategory; 81 | virtual ~ArgTraits() {} 82 | //typedef ValueLike ValueCategory; 83 | }; 84 | 85 | #endif 86 | 87 | } // namespace 88 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/CmdLineInterface.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: CmdLineInterface.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H 24 | #define TCLAP_COMMANDLINE_INTERFACE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | namespace TCLAP { 34 | 35 | class Arg; 36 | class CmdLineOutput; 37 | class XorHandler; 38 | 39 | /** 40 | * The base class that manages the command line definition and passes 41 | * along the parsing to the appropriate Arg classes. 42 | */ 43 | class CmdLineInterface 44 | { 45 | public: 46 | 47 | /** 48 | * Destructor 49 | */ 50 | virtual ~CmdLineInterface() {} 51 | 52 | /** 53 | * Adds an argument to the list of arguments to be parsed. 54 | * \param a - Argument to be added. 55 | */ 56 | virtual void add( Arg& a )=0; 57 | 58 | /** 59 | * An alternative add. Functionally identical. 60 | * \param a - Argument to be added. 61 | */ 62 | virtual void add( Arg* a )=0; 63 | 64 | /** 65 | * Add two Args that will be xor'd. 66 | * If this method is used, add does 67 | * not need to be called. 68 | * \param a - Argument to be added and xor'd. 69 | * \param b - Argument to be added and xor'd. 70 | */ 71 | virtual void xorAdd( Arg& a, Arg& b )=0; 72 | 73 | /** 74 | * Add a list of Args that will be xor'd. If this method is used, 75 | * add does not need to be called. 76 | * \param xors - List of Args to be added and xor'd. 77 | */ 78 | virtual void xorAdd( std::vector& xors )=0; 79 | 80 | /** 81 | * Parses the command line. 82 | * \param argc - Number of arguments. 83 | * \param argv - Array of arguments. 84 | */ 85 | virtual void parse(int argc, const char * const * argv)=0; 86 | 87 | /** 88 | * Parses the command line. 89 | * \param args - A vector of strings representing the args. 90 | * args[0] is still the program name. 91 | */ 92 | void parse(std::vector& args); 93 | 94 | /** 95 | * Returns the CmdLineOutput object. 96 | */ 97 | virtual CmdLineOutput* getOutput()=0; 98 | 99 | /** 100 | * \param co - CmdLineOutput object that we want to use instead. 101 | */ 102 | virtual void setOutput(CmdLineOutput* co)=0; 103 | 104 | /** 105 | * Returns the version string. 106 | */ 107 | virtual std::string& getVersion()=0; 108 | 109 | /** 110 | * Returns the program name string. 111 | */ 112 | virtual std::string& getProgramName()=0; 113 | 114 | /** 115 | * Returns the argList. 116 | */ 117 | virtual std::list& getArgList()=0; 118 | 119 | /** 120 | * Returns the XorHandler. 121 | */ 122 | virtual XorHandler& getXorHandler()=0; 123 | 124 | /** 125 | * Returns the delimiter string. 126 | */ 127 | virtual char getDelimiter()=0; 128 | 129 | /** 130 | * Returns the message string. 131 | */ 132 | virtual std::string& getMessage()=0; 133 | 134 | /** 135 | * Indicates whether or not the help and version switches were created 136 | * automatically. 137 | */ 138 | virtual bool hasHelpAndVersion()=0; 139 | 140 | /** 141 | * Resets the instance as if it had just been constructed so that the 142 | * instance can be reused. 143 | */ 144 | virtual void reset()=0; 145 | }; 146 | 147 | } //namespace 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: CmdLineOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_CMDLINEOUTPUT_H 24 | #define TCLAP_CMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | class CmdLineInterface; 36 | class ArgException; 37 | 38 | /** 39 | * The interface that any output object must implement. 40 | */ 41 | class CmdLineOutput 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Virtual destructor. 48 | */ 49 | virtual ~CmdLineOutput() {} 50 | 51 | /** 52 | * Generates some sort of output for the USAGE. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c)=0; 56 | 57 | /** 58 | * Generates some sort of output for the version. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void version(CmdLineInterface& c)=0; 62 | 63 | /** 64 | * Generates some sort of output for a failure. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure( CmdLineInterface& c, 69 | ArgException& e )=0; 70 | 71 | }; 72 | 73 | } //namespace TCLAP 74 | #endif 75 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Constraint.h 5 | * 6 | * Copyright (c) 2005, Michael E. Smoot 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_CONSTRAINT_H 23 | #define TCLAP_CONSTRAINT_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The interface that defines the interaction between the Arg and Constraint. 36 | */ 37 | template 38 | class Constraint 39 | { 40 | 41 | public: 42 | /** 43 | * Returns a description of the Constraint. 44 | */ 45 | virtual std::string description() const =0; 46 | 47 | /** 48 | * Returns the short ID for the Constraint. 49 | */ 50 | virtual std::string shortID() const =0; 51 | 52 | /** 53 | * The method used to verify that the value parsed from the command 54 | * line meets the constraint. 55 | * \param value - The value that will be checked. 56 | */ 57 | virtual bool check(const T& value) const =0; 58 | 59 | /** 60 | * Destructor. 61 | * Silences warnings about Constraint being a base class with virtual 62 | * functions but without a virtual destructor. 63 | */ 64 | virtual ~Constraint() { ; } 65 | }; 66 | 67 | } //namespace TCLAP 68 | #endif 69 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: HelpVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_HELP_VISITOR_H 23 | #define TCLAP_HELP_VISITOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor object that calls the usage method of the given CmdLineOutput 33 | * object for the specified CmdLine object. 34 | */ 35 | class HelpVisitor: public Visitor 36 | { 37 | private: 38 | /** 39 | * Prevent accidental copying. 40 | */ 41 | HelpVisitor(const HelpVisitor& rhs); 42 | HelpVisitor& operator=(const HelpVisitor& rhs); 43 | 44 | protected: 45 | 46 | /** 47 | * The CmdLine the output will be generated for. 48 | */ 49 | CmdLineInterface* _cmd; 50 | 51 | /** 52 | * The output object. 53 | */ 54 | CmdLineOutput** _out; 55 | 56 | public: 57 | 58 | /** 59 | * Constructor. 60 | * \param cmd - The CmdLine the output will be generated for. 61 | * \param out - The type of output. 62 | */ 63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 64 | : Visitor(), _cmd( cmd ), _out( out ) { } 65 | 66 | /** 67 | * Calls the usage method of the CmdLineOutput for the 68 | * specified CmdLine. 69 | */ 70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 71 | 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Vistor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | CmdLineInterface.h \ 6 | ArgException.h \ 7 | CmdLine.h \ 8 | XorHandler.h \ 9 | MultiArg.h \ 10 | UnlabeledMultiArg.h \ 11 | ValueArg.h \ 12 | UnlabeledValueArg.h \ 13 | Visitor.h Arg.h \ 14 | HelpVisitor.h \ 15 | SwitchArg.h \ 16 | MultiSwitchArg.h \ 17 | VersionVisitor.h \ 18 | IgnoreRestVisitor.h \ 19 | CmdLineOutput.h \ 20 | StdOutput.h \ 21 | DocBookOutput.h \ 22 | ZshCompletionOutput.h \ 23 | OptionalUnlabeledTracker.h \ 24 | Constraint.h \ 25 | ValuesConstraint.h \ 26 | ArgTraits.h \ 27 | StandardTraits.h 28 | 29 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: OptionalUnlabeledTracker.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 26 | 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | class OptionalUnlabeledTracker 32 | { 33 | 34 | public: 35 | 36 | static void check( bool req, const std::string& argName ); 37 | 38 | static void gotOptional() { alreadyOptionalRef() = true; } 39 | 40 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 41 | 42 | private: 43 | 44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 45 | }; 46 | 47 | 48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 49 | { 50 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 51 | throw( SpecificationException( 52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 53 | argName ) ); 54 | 55 | if ( !req ) 56 | OptionalUnlabeledTracker::gotOptional(); 57 | } 58 | 59 | 60 | } // namespace TCLAP 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/StandardTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StandardTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_STANDARD_TRAITS_H 27 | #define TCLAP_STANDARD_TRAITS_H 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include // To check for long long 31 | #endif 32 | 33 | // If Microsoft has already typedef'd wchar_t as an unsigned 34 | // short, then compiles will break because it's as if we're 35 | // creating ArgTraits twice for unsigned short. Thus... 36 | #ifdef _MSC_VER 37 | #ifndef _NATIVE_WCHAR_T_DEFINED 38 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 39 | #endif 40 | #endif 41 | 42 | namespace TCLAP { 43 | 44 | // ====================================================================== 45 | // Integer types 46 | // ====================================================================== 47 | 48 | /** 49 | * longs have value-like semantics. 50 | */ 51 | template<> 52 | struct ArgTraits { 53 | typedef ValueLike ValueCategory; 54 | }; 55 | 56 | /** 57 | * ints have value-like semantics. 58 | */ 59 | template<> 60 | struct ArgTraits { 61 | typedef ValueLike ValueCategory; 62 | }; 63 | 64 | /** 65 | * shorts have value-like semantics. 66 | */ 67 | template<> 68 | struct ArgTraits { 69 | typedef ValueLike ValueCategory; 70 | }; 71 | 72 | /** 73 | * chars have value-like semantics. 74 | */ 75 | template<> 76 | struct ArgTraits { 77 | typedef ValueLike ValueCategory; 78 | }; 79 | 80 | #ifdef HAVE_LONG_LONG 81 | /** 82 | * long longs have value-like semantics. 83 | */ 84 | template<> 85 | struct ArgTraits { 86 | typedef ValueLike ValueCategory; 87 | }; 88 | #endif 89 | 90 | // ====================================================================== 91 | // Unsigned integer types 92 | // ====================================================================== 93 | 94 | /** 95 | * unsigned longs have value-like semantics. 96 | */ 97 | template<> 98 | struct ArgTraits { 99 | typedef ValueLike ValueCategory; 100 | }; 101 | 102 | /** 103 | * unsigned ints have value-like semantics. 104 | */ 105 | template<> 106 | struct ArgTraits { 107 | typedef ValueLike ValueCategory; 108 | }; 109 | 110 | /** 111 | * unsigned shorts have value-like semantics. 112 | */ 113 | template<> 114 | struct ArgTraits { 115 | typedef ValueLike ValueCategory; 116 | }; 117 | 118 | /** 119 | * unsigned chars have value-like semantics. 120 | */ 121 | template<> 122 | struct ArgTraits { 123 | typedef ValueLike ValueCategory; 124 | }; 125 | 126 | // Microsoft implements size_t awkwardly. 127 | #if defined(_MSC_VER) && defined(_M_X64) 128 | /** 129 | * size_ts have value-like semantics. 130 | */ 131 | template<> 132 | struct ArgTraits { 133 | typedef ValueLike ValueCategory; 134 | }; 135 | #endif 136 | 137 | 138 | #ifdef HAVE_LONG_LONG 139 | /** 140 | * unsigned long longs have value-like semantics. 141 | */ 142 | template<> 143 | struct ArgTraits { 144 | typedef ValueLike ValueCategory; 145 | }; 146 | #endif 147 | 148 | // ====================================================================== 149 | // Float types 150 | // ====================================================================== 151 | 152 | /** 153 | * floats have value-like semantics. 154 | */ 155 | template<> 156 | struct ArgTraits { 157 | typedef ValueLike ValueCategory; 158 | }; 159 | 160 | /** 161 | * doubles have value-like semantics. 162 | */ 163 | template<> 164 | struct ArgTraits { 165 | typedef ValueLike ValueCategory; 166 | }; 167 | 168 | // ====================================================================== 169 | // Other types 170 | // ====================================================================== 171 | 172 | /** 173 | * bools have value-like semantics. 174 | */ 175 | template<> 176 | struct ArgTraits { 177 | typedef ValueLike ValueCategory; 178 | }; 179 | 180 | 181 | /** 182 | * wchar_ts have value-like semantics. 183 | */ 184 | #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 185 | template<> 186 | struct ArgTraits { 187 | typedef ValueLike ValueCategory; 188 | }; 189 | #endif 190 | 191 | /** 192 | * Strings have string like argument traits. 193 | */ 194 | template<> 195 | struct ArgTraits { 196 | typedef StringLike ValueCategory; 197 | }; 198 | 199 | template 200 | void SetString(T &dst, const std::string &src) 201 | { 202 | dst = src; 203 | } 204 | 205 | } // namespace 206 | 207 | #endif 208 | 209 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/ValuesConstraint.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ValuesConstraint.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_VALUESCONSTRAINT_H 24 | #define TCLAP_VALUESCONSTRAINT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include 32 | #else 33 | #define HAVE_SSTREAM 34 | #endif 35 | 36 | #if defined(HAVE_SSTREAM) 37 | #include 38 | #elif defined(HAVE_STRSTREAM) 39 | #include 40 | #else 41 | #error "Need a stringstream (sstream or strstream) to compile!" 42 | #endif 43 | 44 | namespace TCLAP { 45 | 46 | /** 47 | * A Constraint that constrains the Arg to only those values specified 48 | * in the constraint. 49 | */ 50 | template 51 | class ValuesConstraint : public Constraint 52 | { 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param allowed - vector of allowed values. 59 | */ 60 | ValuesConstraint(std::vector& allowed); 61 | 62 | /** 63 | * Virtual destructor. 64 | */ 65 | virtual ~ValuesConstraint() {} 66 | 67 | /** 68 | * Returns a description of the Constraint. 69 | */ 70 | virtual std::string description() const; 71 | 72 | /** 73 | * Returns the short ID for the Constraint. 74 | */ 75 | virtual std::string shortID() const; 76 | 77 | /** 78 | * The method used to verify that the value parsed from the command 79 | * line meets the constraint. 80 | * \param value - The value that will be checked. 81 | */ 82 | virtual bool check(const T& value) const; 83 | 84 | protected: 85 | 86 | /** 87 | * The list of valid values. 88 | */ 89 | std::vector _allowed; 90 | 91 | /** 92 | * The string used to describe the allowed values of this constraint. 93 | */ 94 | std::string _typeDesc; 95 | 96 | }; 97 | 98 | template 99 | ValuesConstraint::ValuesConstraint(std::vector& allowed) 100 | : _allowed(allowed), 101 | _typeDesc("") 102 | { 103 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 104 | { 105 | 106 | #if defined(HAVE_SSTREAM) 107 | std::ostringstream os; 108 | #elif defined(HAVE_STRSTREAM) 109 | std::ostrstream os; 110 | #else 111 | #error "Need a stringstream (sstream or strstream) to compile!" 112 | #endif 113 | 114 | os << _allowed[i]; 115 | 116 | std::string temp( os.str() ); 117 | 118 | if ( i > 0 ) 119 | _typeDesc += "|"; 120 | _typeDesc += temp; 121 | } 122 | } 123 | 124 | template 125 | bool ValuesConstraint::check( const T& val ) const 126 | { 127 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 128 | return false; 129 | else 130 | return true; 131 | } 132 | 133 | template 134 | std::string ValuesConstraint::shortID() const 135 | { 136 | return _typeDesc; 137 | } 138 | 139 | template 140 | std::string ValuesConstraint::description() const 141 | { 142 | return _typeDesc; 143 | } 144 | 145 | 146 | } //namespace TCLAP 147 | #endif 148 | 149 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Vistor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/3rdparty/tclap/tclap/XorHandler.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: XorHandler.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_XORHANDLER_H 24 | #define TCLAP_XORHANDLER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * This class handles lists of Arg's that are to be XOR'd on the command 36 | * line. This is used by CmdLine and you shouldn't ever use it. 37 | */ 38 | class XorHandler 39 | { 40 | protected: 41 | 42 | /** 43 | * The list of of lists of Arg's to be or'd together. 44 | */ 45 | std::vector< std::vector > _orList; 46 | 47 | public: 48 | 49 | /** 50 | * Constructor. Does nothing. 51 | */ 52 | XorHandler( ) : _orList(std::vector< std::vector >()) {} 53 | 54 | /** 55 | * Add a list of Arg*'s that will be orred together. 56 | * \param ors - list of Arg* that will be xor'd. 57 | */ 58 | void add( std::vector& ors ); 59 | 60 | /** 61 | * Checks whether the specified Arg is in one of the xor lists and 62 | * if it does match one, returns the size of the xor list that the 63 | * Arg matched. If the Arg matches, then it also sets the rest of 64 | * the Arg's in the list. You shouldn't use this. 65 | * \param a - The Arg to be checked. 66 | */ 67 | int check( const Arg* a ); 68 | 69 | /** 70 | * Returns the XOR specific short usage. 71 | */ 72 | std::string shortUsage(); 73 | 74 | /** 75 | * Prints the XOR specific long usage. 76 | * \param os - Stream to print to. 77 | */ 78 | void printLongUsage(std::ostream& os); 79 | 80 | /** 81 | * Simply checks whether the Arg is contained in one of the arg 82 | * lists. 83 | * \param a - The Arg to be checked. 84 | */ 85 | bool contains( const Arg* a ); 86 | 87 | std::vector< std::vector >& getXorList(); 88 | 89 | }; 90 | 91 | 92 | ////////////////////////////////////////////////////////////////////// 93 | //BEGIN XOR.cpp 94 | ////////////////////////////////////////////////////////////////////// 95 | inline void XorHandler::add( std::vector& ors ) 96 | { 97 | _orList.push_back( ors ); 98 | } 99 | 100 | inline int XorHandler::check( const Arg* a ) 101 | { 102 | // iterate over each XOR list 103 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 104 | { 105 | // if the XOR list contains the arg.. 106 | ArgVectorIterator ait = std::find( _orList[i].begin(), 107 | _orList[i].end(), a ); 108 | if ( ait != _orList[i].end() ) 109 | { 110 | // first check to see if a mutually exclusive switch 111 | // has not already been set 112 | for ( ArgVectorIterator it = _orList[i].begin(); 113 | it != _orList[i].end(); 114 | it++ ) 115 | if ( a != (*it) && (*it)->isSet() ) 116 | throw(CmdLineParseException( 117 | "Mutually exclusive argument already set!", 118 | (*it)->toString())); 119 | 120 | // go through and set each arg that is not a 121 | for ( ArgVectorIterator it = _orList[i].begin(); 122 | it != _orList[i].end(); 123 | it++ ) 124 | if ( a != (*it) ) 125 | (*it)->xorSet(); 126 | 127 | // return the number of required args that have now been set 128 | if ( (*ait)->allowMore() ) 129 | return 0; 130 | else 131 | return static_cast(_orList[i].size()); 132 | } 133 | } 134 | 135 | if ( a->isRequired() ) 136 | return 1; 137 | else 138 | return 0; 139 | } 140 | 141 | inline bool XorHandler::contains( const Arg* a ) 142 | { 143 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 144 | for ( ArgVectorIterator it = _orList[i].begin(); 145 | it != _orList[i].end(); 146 | it++ ) 147 | if ( a == (*it) ) 148 | return true; 149 | 150 | return false; 151 | } 152 | 153 | inline std::vector< std::vector >& XorHandler::getXorList() 154 | { 155 | return _orList; 156 | } 157 | 158 | 159 | 160 | ////////////////////////////////////////////////////////////////////// 161 | //END XOR.cpp 162 | ////////////////////////////////////////////////////////////////////// 163 | 164 | } //namespace TCLAP 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/common/cf_tracker.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef TRACKER_HPP_ 33 | #define TRACKER_HPP_ 34 | 35 | #include "opencv2/core/core.hpp" 36 | #include "tracker_debug.hpp" 37 | 38 | namespace cf_tracking 39 | { 40 | class CfTracker 41 | { 42 | public: 43 | virtual ~CfTracker() {}; 44 | 45 | virtual bool update(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 46 | virtual bool reinit(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 47 | virtual bool updateAt(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 48 | 49 | virtual bool update(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 50 | virtual bool reinit(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 51 | virtual bool updateAt(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 52 | 53 | virtual bool update(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 54 | virtual bool reinit(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 55 | virtual bool updateAt(const cv::Mat& image, cv::Rect_& boundingBox) = 0; 56 | 57 | virtual TrackerDebug* getTrackerDebug() = 0; 58 | virtual const std::string getId() = 0; 59 | }; 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/common/cv_ext.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef CV_EXT_HPP_ 33 | #define CV_EXT_HPP_ 34 | 35 | #include "math_spectrums.hpp" 36 | #include "shift.hpp" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/common/mat_consts.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef MAT_CONSTS_H_ 33 | #define MAT_CONSTS_H_ 34 | 35 | namespace mat_consts 36 | { 37 | template 38 | struct constants 39 | { 40 | const static T c0_5; 41 | const static T c2_0; 42 | }; 43 | 44 | template const T constants::c0_5 = static_cast(0.5); 45 | template const T constants::c2_0 = static_cast(2.0); 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/common/math_helper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #include "math_helper.hpp" 33 | #include 34 | 35 | namespace cf_tracking 36 | { 37 | int mod(int dividend, int divisor) 38 | { 39 | // http://stackoverflow.com/questions/12276675/modulus-with-negative-numbers-in-c 40 | return ((dividend % divisor) + divisor) % divisor; 41 | } 42 | 43 | void dftCcs(const cv::Mat& input, cv::Mat& out, int flags) 44 | { 45 | cv::dft(input, out, flags); 46 | } 47 | 48 | void dftNoCcs(const cv::Mat& input, cv::Mat& out, int flags) 49 | { 50 | flags = flags | cv::DFT_COMPLEX_OUTPUT; 51 | cv::dft(input, out, flags); 52 | } 53 | 54 | // use bi-linear interpolation on zoom, area otherwise 55 | // similar to mexResize.cpp of DSST 56 | // http://www.cvl.isy.liu.se/en/research/objrec/visualtracking/scalvistrack/index.html 57 | void depResize(const cv::Mat& source, cv::Mat& dst, const cv::Size& dsize) 58 | { 59 | int interpolationType = cv::INTER_AREA; 60 | 61 | if (dsize.width > source.cols 62 | || dsize.height > source.rows) 63 | interpolationType = cv::INTER_LINEAR; 64 | 65 | cv::resize(source, dst, dsize, 0, 0, interpolationType); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/common/tracker_debug.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef TRACKER_DEBUG_HPP_ 33 | #define TRACKER_DEBUG_HPP_ 34 | 35 | namespace cf_tracking 36 | { 37 | class TrackerDebug 38 | { 39 | public: 40 | virtual ~TrackerDebug(){} 41 | 42 | virtual void init(std::string outputFilePath) = 0; 43 | virtual void printOnImage(cv::Mat& image) = 0; 44 | virtual void printConsoleOutput() = 0; 45 | virtual void printToFile() = 0; 46 | }; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/dsst/dsst_debug.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef DSST_DEBUG_HPP_ 33 | #define DSST_DEBUG_HPP_ 34 | 35 | #include "opencv2/imgproc/imgproc.hpp" 36 | #include "opencv2/core/core.hpp" 37 | #include 38 | #include 39 | 40 | #include "tracker_debug.hpp" 41 | 42 | namespace cf_tracking 43 | { 44 | template 45 | class DsstDebug : public TrackerDebug 46 | { 47 | public: 48 | DsstDebug() : 49 | _maxResponse(0), 50 | _psrClamped(0), 51 | _targetSizeArea(0) 52 | {} 53 | 54 | virtual ~DsstDebug() 55 | { 56 | if (_outputFile.is_open()) 57 | _outputFile.close(); 58 | } 59 | 60 | virtual void init(std::string outputFilePath) 61 | { 62 | namedWindow(_SUB_WINDOW_TITLE, cv::WINDOW_NORMAL); 63 | namedWindow(_RESPONSE_TITLE, cv::WINDOW_NORMAL); 64 | _outputFile.open(outputFilePath.c_str()); 65 | } 66 | 67 | virtual void printOnImage(cv::Mat& image) 68 | { 69 | _ss.str(""); 70 | _ss.clear(); 71 | _ss << "Max Response: " << _maxResponse; 72 | putText(image, _ss.str(), cv::Point(20, 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 0, 0)); 73 | 74 | _ss.str(""); 75 | _ss.clear(); 76 | _ss << "PSR Clamped: " << _psrClamped; 77 | putText(image, _ss.str(), cv::Point(20, 80), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 0, 0)); 78 | 79 | _ss.str(""); 80 | _ss.clear(); 81 | _ss << "Area: " << _targetSizeArea; 82 | putText(image, _ss.str(), cv::Point(image.cols - 100, 80), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 0, 0)); 83 | } 84 | 85 | virtual void printConsoleOutput() 86 | { 87 | } 88 | 89 | virtual void printToFile() 90 | { 91 | _outputFile << _maxResponse << "," << _psrClamped << std::endl; 92 | } 93 | 94 | void showPatch(const cv::Mat& patchResized) 95 | { 96 | imshow(_SUB_WINDOW_TITLE, patchResized); 97 | } 98 | 99 | void setPsr(double psrClamped) 100 | { 101 | _psrClamped = psrClamped; 102 | } 103 | 104 | void showResponse(const cv::Mat& response, double maxResponse) 105 | { 106 | cv::Mat responseOutput = response.clone(); 107 | _maxResponse = maxResponse; 108 | imshow(_RESPONSE_TITLE, responseOutput); 109 | } 110 | 111 | void setTargetSizeArea(T targetSizeArea) 112 | { 113 | _targetSizeArea = targetSizeArea; 114 | } 115 | 116 | private: 117 | const std::string _SUB_WINDOW_TITLE = "Sub Window"; 118 | const std::string _RESPONSE_TITLE = "Response"; 119 | double _maxResponse; 120 | double _psrClamped; 121 | T _targetSizeArea; 122 | std::stringstream _ss; 123 | std::ofstream _outputFile; 124 | }; 125 | } 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/dsst/dsst_tracker.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OAID/ObjectTracker/d76608c7a1d71ad3522c3b840f6edfcaa1ed3f19/src/3rdparty/cf_tracking/src/cf_libs/dsst/dsst_tracker.hpp -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/kcf/kcf_debug.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef KCF_DEBUG_HPP_ 33 | #define KCF_DEBUG_HPP_ 34 | 35 | #include "opencv2/imgproc/imgproc.hpp" 36 | #include "opencv2/core/core.hpp" 37 | #include 38 | #include 39 | 40 | #include "tracker_debug.hpp" 41 | 42 | namespace cf_tracking 43 | { 44 | template 45 | class KcfDebug : public TrackerDebug 46 | { 47 | public: 48 | KcfDebug() : 49 | _maxResponse(0), 50 | _psrClamped(0) 51 | {} 52 | 53 | virtual ~KcfDebug() 54 | { 55 | if (_outputFile.is_open()) 56 | _outputFile.close(); 57 | } 58 | 59 | virtual void init(std::string outputFilePath) 60 | { 61 | namedWindow(_SUB_WINDOW_TITLE, cv::WINDOW_NORMAL); 62 | namedWindow(_RESPONSE_TITLE, cv::WINDOW_NORMAL); 63 | _outputFile.open(outputFilePath.c_str()); 64 | } 65 | 66 | virtual void printOnImage(cv::Mat& image) 67 | { 68 | _ss.str(""); 69 | _ss.clear(); 70 | _ss << "Max Response: " << _maxResponse; 71 | putText(image, _ss.str(), cv::Point(20, 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 0, 0)); 72 | 73 | _ss.str(""); 74 | _ss.clear(); 75 | _ss << "PSR Clamped: " << _psrClamped; 76 | putText(image, _ss.str(), cv::Point(20, 80), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 0, 0)); 77 | } 78 | 79 | virtual void printConsoleOutput() 80 | { 81 | } 82 | 83 | virtual void printToFile() 84 | { 85 | _outputFile << _maxResponse << "," << _psrClamped << std::endl; 86 | } 87 | 88 | void showPatch(const cv::Mat& patchResized) 89 | { 90 | imshow(_SUB_WINDOW_TITLE, patchResized); 91 | } 92 | 93 | void setPsr(T psrClamped) 94 | { 95 | _psrClamped = psrClamped; 96 | std::cout << "PSR: " << psrClamped << std::endl; 97 | } 98 | 99 | void showResponse(const cv::Mat& response, T maxResponse) 100 | { 101 | cv::Mat responseOutput = response.clone(); 102 | _maxResponse = maxResponse; 103 | imshow(_RESPONSE_TITLE, responseOutput); 104 | } 105 | 106 | private: 107 | const std::string _SUB_WINDOW_TITLE = "Sub Window"; 108 | const std::string _RESPONSE_TITLE = "Response"; 109 | T _maxResponse; 110 | T _psrClamped; 111 | std::stringstream _ss; 112 | std::ofstream _outputFile; 113 | }; 114 | } 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/cf_libs/kcf/kcf_tracker.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OAID/ObjectTracker/d76608c7a1d71ad3522c3b840f6edfcaa1ed3f19/src/3rdparty/cf_tracking/src/cf_libs/kcf/kcf_tracker.hpp -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/main/image_acquisition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #include "image_acquisition.hpp" 33 | 34 | ImageAcquisition::ImageAcquisition() 35 | { 36 | } 37 | 38 | ImageAcquisition& ImageAcquisition::operator>>(CV_OUT cv::Mat& image) 39 | { 40 | if (_paras.isMock) 41 | _mockCap >> image; 42 | else 43 | _cvCap >> image; 44 | 45 | return *this; 46 | } 47 | 48 | void ImageAcquisition::release() 49 | { 50 | if (!_paras.isMock) 51 | _cvCap.release(); 52 | } 53 | 54 | bool ImageAcquisition::isOpened() 55 | { 56 | if (_paras.isMock) 57 | return _mockCap.isOpened(); 58 | else 59 | return _cvCap.isOpened(); 60 | } 61 | 62 | void ImageAcquisition::set(int key, int value) 63 | { 64 | if (!_paras.isMock) 65 | _cvCap.set(key, value); 66 | } 67 | 68 | void ImageAcquisition::open(ImgAcqParas paras) 69 | { 70 | _paras = paras; 71 | 72 | if (_paras.isMock) 73 | { 74 | _mockCap.open(); 75 | } 76 | else 77 | { 78 | if (_paras.sequencePath.empty()) 79 | _cvCap.open(_paras.device); 80 | else 81 | { 82 | std::string sequenceExpansion = 83 | _paras.sequencePath + _paras.expansionStr; 84 | 85 | _cvCap.open(sequenceExpansion); 86 | } 87 | } 88 | } 89 | 90 | ImageAcquisition::~ImageAcquisition() 91 | { 92 | } 93 | 94 | double ImageAcquisition::get(int key) 95 | { 96 | if (!_paras.isMock) 97 | return _cvCap.get(key); 98 | 99 | return 0.0; 100 | } 101 | 102 | void VideoCaptureMock::release() 103 | { 104 | } 105 | 106 | bool VideoCaptureMock::isOpened() 107 | { 108 | return isOpen; 109 | } 110 | 111 | VideoCaptureMock& VideoCaptureMock::operator>>(CV_OUT cv::Mat& image) 112 | { 113 | image = _staticImage; 114 | return *this; 115 | } 116 | 117 | void VideoCaptureMock::open() 118 | { 119 | isOpen = true; 120 | } 121 | 122 | VideoCaptureMock::~VideoCaptureMock() 123 | { 124 | } 125 | 126 | VideoCaptureMock::VideoCaptureMock() : isOpen(false) 127 | { 128 | _staticImage = cv::Mat(360, 640, CV_8UC3); 129 | cv::randu(_staticImage, cv::Scalar::all(0), cv::Scalar::all(255)); 130 | } 131 | -------------------------------------------------------------------------------- /src/3rdparty/cf_tracking/src/main/image_acquisition.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | // License Agreement (3-clause BSD License) 3 | // Copyright (c) 2015, Klaus Haag, all rights reserved. 4 | // Third party copyrights and patents are property of their respective owners. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, 7 | // are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the names of the copyright holders nor the names of the contributors 17 | // may be used to endorse or promote products derived from this software 18 | // without specific prior written permission. 19 | // 20 | // This software is provided by the copyright holders and contributors "as is" and 21 | // any express or implied warranties, including, but not limited to, the implied 22 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 23 | // In no event shall copyright holders or contributors be liable for any direct, 24 | // indirect, incidental, special, exemplary, or consequential damages 25 | // (including, but not limited to, procurement of substitute goods or services; 26 | // loss of use, data, or profits; or business interruption) however caused 27 | // and on any theory of liability, whether in contract, strict liability, 28 | // or tort (including negligence or otherwise) arising in any way out of 29 | // the use of this software, even if advised of the possibility of such damage. 30 | */ 31 | 32 | #ifndef IMAGE_ACQUISITION_HPP_ 33 | #define IMAGE_ACQUISITION_HPP_ 34 | 35 | #include "opencv2/highgui/highgui.hpp" 36 | 37 | struct ImgAcqParas 38 | { 39 | bool isMock = false; 40 | int device = -1; 41 | std::string sequencePath = ""; 42 | std::string expansionStr = ""; 43 | }; 44 | 45 | class VideoCaptureMock 46 | { 47 | public: 48 | VideoCaptureMock(); 49 | 50 | virtual ~VideoCaptureMock(); 51 | 52 | void open(); 53 | 54 | VideoCaptureMock& operator >> (CV_OUT cv::Mat& image); 55 | 56 | bool isOpened(); 57 | 58 | void release(); 59 | 60 | private: 61 | bool isOpen; 62 | cv::Mat _staticImage; 63 | }; 64 | 65 | class ImageAcquisition 66 | { 67 | public: 68 | ImageAcquisition(); 69 | 70 | virtual ~ImageAcquisition(); 71 | 72 | void open(ImgAcqParas paras); 73 | 74 | void set(int key, int value); 75 | 76 | double get(int key); 77 | 78 | bool isOpened(); 79 | 80 | void release(); 81 | 82 | ImageAcquisition& operator >> (CV_OUT cv::Mat& image); 83 | 84 | private: 85 | cv::VideoCapture _cvCap; 86 | ImgAcqParas _paras; 87 | VideoCaptureMock _mockCap; 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #This are the defines for building a static libconfig for windows 2 | if(WIN32) 3 | add_definitions(-DLIBCONFIGXX_STATIC -DLIBCONFIG_STATIC -DYY_NO_UNISTD_H -DYY_USE_CONST -D_CRT_SECURE_NO_DEPRECATE -D_STDLIB_H) 4 | endif(WIN32) 5 | 6 | add_library(config++ 7 | grammar.c 8 | libconfig.c 9 | libconfigcpp.cc 10 | scanctx.c 11 | scanner.c 12 | strbuf.c 13 | grammar.h 14 | libconfig.h 15 | libconfig.hh 16 | parsectx.h 17 | scanctx.h 18 | scanner.h 19 | strbuf.h 20 | wincompat.h) 21 | 22 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/grammar.h: -------------------------------------------------------------------------------- 1 | 2 | /* A Bison parser, made by GNU Bison 2.4.1. */ 3 | 4 | /* Skeleton interface for Bison's Yacc-like parsers in C 5 | 6 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 7 | Free Software Foundation, Inc. 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . */ 21 | 22 | /* As a special exception, you may create a larger work that contains 23 | part or all of the Bison parser skeleton and distribute that work 24 | under terms of your choice, so long as that work isn't itself a 25 | parser generator using the skeleton or a modified version thereof 26 | as a parser skeleton. Alternatively, if you modify or redistribute 27 | the parser skeleton itself, you may (at your option) remove this 28 | special exception, which will cause the skeleton and the resulting 29 | Bison output files to be licensed under the GNU General Public 30 | License without this special exception. 31 | 32 | This special exception was added by the Free Software Foundation in 33 | version 2.2 of Bison. */ 34 | 35 | 36 | /* Tokens. */ 37 | #ifndef YYTOKENTYPE 38 | # define YYTOKENTYPE 39 | /* Put the tokens into the symbol table, so that GDB and other debuggers 40 | know about them. */ 41 | enum yytokentype { 42 | TOK_BOOLEAN = 258, 43 | TOK_INTEGER = 259, 44 | TOK_HEX = 260, 45 | TOK_INTEGER64 = 261, 46 | TOK_HEX64 = 262, 47 | TOK_FLOAT = 263, 48 | TOK_STRING = 264, 49 | TOK_NAME = 265, 50 | TOK_EQUALS = 266, 51 | TOK_NEWLINE = 267, 52 | TOK_ARRAY_START = 268, 53 | TOK_ARRAY_END = 269, 54 | TOK_LIST_START = 270, 55 | TOK_LIST_END = 271, 56 | TOK_COMMA = 272, 57 | TOK_GROUP_START = 273, 58 | TOK_GROUP_END = 274, 59 | TOK_SEMICOLON = 275, 60 | TOK_GARBAGE = 276, 61 | TOK_ERROR = 277 62 | }; 63 | #endif 64 | /* Tokens. */ 65 | #define TOK_BOOLEAN 258 66 | #define TOK_INTEGER 259 67 | #define TOK_HEX 260 68 | #define TOK_INTEGER64 261 69 | #define TOK_HEX64 262 70 | #define TOK_FLOAT 263 71 | #define TOK_STRING 264 72 | #define TOK_NAME 265 73 | #define TOK_EQUALS 266 74 | #define TOK_NEWLINE 267 75 | #define TOK_ARRAY_START 268 76 | #define TOK_ARRAY_END 269 77 | #define TOK_LIST_START 270 78 | #define TOK_LIST_END 271 79 | #define TOK_COMMA 272 80 | #define TOK_GROUP_START 273 81 | #define TOK_GROUP_END 274 82 | #define TOK_SEMICOLON 275 83 | #define TOK_GARBAGE 276 84 | #define TOK_ERROR 277 85 | 86 | 87 | 88 | 89 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 90 | typedef union YYSTYPE 91 | { 92 | 93 | /* Line 1676 of yacc.c */ 94 | #line 85 "grammar.y" 95 | 96 | int ival; 97 | long long llval; 98 | double fval; 99 | char *sval; 100 | 101 | 102 | 103 | /* Line 1676 of yacc.c */ 104 | #line 105 "grammar.h" 105 | } YYSTYPE; 106 | # define YYSTYPE_IS_TRIVIAL 1 107 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 108 | # define YYSTYPE_IS_DECLARED 1 109 | #endif 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/libconfig.hh: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A structured configuration file parsing library 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #include 24 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/libconfigcpp.cc: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A structured configuration file parsing library 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #include "libconfigcpp.c++" 24 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/parsectx.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #ifndef __libconfig_parsectx_h 24 | #define __libconfig_parsectx_h 25 | 26 | #include "libconfig.h" 27 | #include "strbuf.h" 28 | 29 | struct parse_context 30 | { 31 | config_t *config; 32 | config_setting_t *parent; 33 | config_setting_t *setting; 34 | char *name; 35 | strbuf_t string; 36 | }; 37 | 38 | #define parsectx_init(C) \ 39 | memset((C), 0, sizeof(struct parse_context)) 40 | #define parsectx_cleanup(C) \ 41 | free((void *)(strbuf_release(&((C)->string)))) 42 | 43 | #define parsectx_append_string(C, S) \ 44 | strbuf_append(&((C)->string), (S)) 45 | #define parsectx_take_string(C) \ 46 | strbuf_release(&((C)->string)) 47 | 48 | #endif /* __libconfig_parsectx_h */ 49 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/scanctx.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #include "scanctx.h" 24 | #include "wincompat.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #define STRING_BLOCK_SIZE 64 31 | #define CHUNK_SIZE 32 32 | 33 | /* ------------------------------------------------------------------------- */ 34 | 35 | static const char *err_bad_include = "cannot open include file"; 36 | static const char *err_include_too_deep = "include file nesting too deep"; 37 | 38 | /* ------------------------------------------------------------------------- */ 39 | 40 | static const char *__scanctx_add_filename(struct scan_context *ctx, 41 | const char *filename) 42 | { 43 | unsigned int count = ctx->num_filenames; 44 | const char **f; 45 | 46 | for(f = ctx->filenames; count > 0; ++f, --count) 47 | { 48 | if(!strcmp(*f, filename)) 49 | { 50 | free((void *)filename); 51 | return(*f); /* already in list */ 52 | } 53 | } 54 | 55 | if((ctx->num_filenames % CHUNK_SIZE) == 0) 56 | { 57 | ctx->filenames = (const char **)realloc( 58 | (void *)ctx->filenames, 59 | (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *)); 60 | } 61 | 62 | ctx->filenames[ctx->num_filenames] = filename; 63 | ++ctx->num_filenames; 64 | return(filename); 65 | } 66 | 67 | /* ------------------------------------------------------------------------- */ 68 | 69 | void scanctx_init(struct scan_context *ctx, const char *top_filename) 70 | { 71 | memset(ctx, 0, sizeof(struct scan_context)); 72 | if(top_filename) 73 | ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename)); 74 | } 75 | 76 | /* ------------------------------------------------------------------------- */ 77 | 78 | const char **scanctx_cleanup(struct scan_context *ctx, 79 | unsigned int *num_filenames) 80 | { 81 | int i; 82 | 83 | for(i = 0; i < ctx->depth; ++i) 84 | fclose(ctx->streams[i]); 85 | 86 | free((void *)(strbuf_release(&(ctx->string)))); 87 | 88 | *num_filenames = ctx->num_filenames; 89 | return(ctx->filenames); 90 | } 91 | 92 | /* ------------------------------------------------------------------------- */ 93 | 94 | FILE *scanctx_push_include(struct scan_context *ctx, void *buffer, 95 | const char **error) 96 | { 97 | FILE *fp = NULL; 98 | const char *file; 99 | char *full_file = NULL; 100 | 101 | *error = NULL; 102 | 103 | if(ctx->depth == MAX_INCLUDE_DEPTH) 104 | { 105 | *error = err_include_too_deep; 106 | return(NULL); 107 | } 108 | 109 | file = scanctx_take_string(ctx); 110 | if(ctx->config->include_dir) 111 | { 112 | full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) 113 | + 2); 114 | strcpy(full_file, ctx->config->include_dir); 115 | strcat(full_file, FILE_SEPARATOR); 116 | strcat(full_file, file); 117 | } 118 | 119 | fp = fopen(full_file ? full_file : file, "rt"); 120 | free((void *)full_file); 121 | 122 | if(fp) 123 | { 124 | ctx->streams[ctx->depth] = fp; 125 | ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file); 126 | ctx->buffers[ctx->depth] = buffer; 127 | ++(ctx->depth); 128 | } 129 | else 130 | { 131 | free((void *)file); 132 | *error = err_bad_include; 133 | } 134 | 135 | return(fp); 136 | } 137 | 138 | /* ------------------------------------------------------------------------- */ 139 | 140 | void *scanctx_pop_include(struct scan_context *ctx) 141 | { 142 | void *buffer; 143 | 144 | if(ctx->depth == 0) 145 | return(NULL); /* stack underflow */ 146 | 147 | --(ctx->depth); 148 | buffer = ctx->buffers[ctx->depth]; 149 | fclose(ctx->streams[ctx->depth]); 150 | 151 | return(buffer); 152 | } 153 | 154 | /* ------------------------------------------------------------------------- */ 155 | 156 | char *scanctx_take_string(struct scan_context *ctx) 157 | { 158 | char *r = strbuf_release(&(ctx->string)); 159 | 160 | return(r ? r : strdup("")); 161 | } 162 | 163 | /* ------------------------------------------------------------------------- */ 164 | 165 | const char *scanctx_current_filename(struct scan_context *ctx) 166 | { 167 | return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]); 168 | } 169 | 170 | /* ------------------------------------------------------------------------- */ 171 | /* eof */ 172 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/scanctx.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #ifndef __libconfig_scanctx_h 24 | #define __libconfig_scanctx_h 25 | 26 | #include "libconfig.h" 27 | #include "strbuf.h" 28 | 29 | #include 30 | #include 31 | 32 | #define MAX_INCLUDE_DEPTH 10 33 | 34 | struct scan_context 35 | { 36 | config_t *config; 37 | const char *top_filename; 38 | const char *files[MAX_INCLUDE_DEPTH]; 39 | void *buffers[MAX_INCLUDE_DEPTH]; 40 | FILE *streams[MAX_INCLUDE_DEPTH]; 41 | int depth; 42 | strbuf_t string; 43 | const char **filenames; 44 | unsigned int num_filenames; 45 | }; 46 | 47 | extern void scanctx_init(struct scan_context *ctx, const char *top_filename); 48 | extern const char **scanctx_cleanup(struct scan_context *ctx, 49 | unsigned int *num_filenames); 50 | 51 | extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer, 52 | const char **error); 53 | extern void *scanctx_pop_include(struct scan_context *ctx); 54 | 55 | #define scanctx_append_string(C, S) \ 56 | strbuf_append(&((C)->string), (S)) 57 | 58 | extern char *scanctx_take_string(struct scan_context *ctx); 59 | 60 | extern const char *scanctx_current_filename(struct scan_context *ctx); 61 | 62 | #endif /* __libconfig_scanctx_h */ 63 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/strbuf.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #include "strbuf.h" 24 | 25 | #include 26 | #include 27 | 28 | #define STRING_BLOCK_SIZE 64 29 | 30 | /* ------------------------------------------------------------------------- */ 31 | 32 | char *strbuf_release(strbuf_t *buf) 33 | { 34 | char *r = buf->string; 35 | memset(buf, 0, sizeof(strbuf_t)); 36 | return(r); 37 | } 38 | 39 | /* ------------------------------------------------------------------------- */ 40 | 41 | void strbuf_append(strbuf_t *buf, const char *text) 42 | { 43 | static const size_t mask = ~(STRING_BLOCK_SIZE - 1); 44 | size_t len = strlen(text); 45 | size_t newlen = buf->length + len + 1; /* add 1 for NUL */ 46 | 47 | if(newlen > buf->capacity) 48 | { 49 | buf->capacity = (newlen + (STRING_BLOCK_SIZE - 1)) & mask; 50 | buf->string = (char *)realloc(buf->string, buf->capacity); 51 | } 52 | 53 | strcpy(buf->string + buf->length, text); 54 | buf->length += len; 55 | } 56 | 57 | /* ------------------------------------------------------------------------- */ 58 | /* eof */ 59 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/strbuf.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #ifndef __libconfig_strbuf_h 24 | #define __libconfig_strbuf_h 25 | 26 | #include 27 | #include 28 | 29 | typedef struct 30 | { 31 | char *string; 32 | size_t length; 33 | size_t capacity; 34 | } strbuf_t; 35 | 36 | char *strbuf_release(strbuf_t *buf); 37 | 38 | void strbuf_append(strbuf_t *buf, const char *text); 39 | 40 | #endif /* __libconfig_strbuf_h */ 41 | -------------------------------------------------------------------------------- /src/3rdparty/libconfig/wincompat.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | libconfig - A library for processing structured configuration files 3 | Copyright (C) 2005-2010 Mark A Lindner 4 | 5 | This file is part of libconfig. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Library General Public 18 | License along with this library; if not, see 19 | . 20 | ---------------------------------------------------------------------------- 21 | */ 22 | 23 | #ifndef __wincompat_h 24 | #define __wincompat_h 25 | 26 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) 27 | 28 | #ifdef _MSC_VER 29 | #pragma warning (disable: 4996) 30 | #endif 31 | 32 | #define WIN32_LEAN_AND_MEAN 33 | #include 34 | 35 | #define snprintf _snprintf 36 | 37 | #ifndef __MINGW32__ 38 | #define atoll _atoi64 39 | #define strtoull _strtoui64 40 | #endif /* __MINGW32__ */ 41 | 42 | #endif 43 | 44 | #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ 45 | || defined(__MINGW32__)) 46 | 47 | /* Why does gcc on MinGW use the Visual C++ style format directives 48 | * for 64-bit integers? Inquiring minds want to know.... 49 | */ 50 | 51 | #define INT64_FMT "%I64d" 52 | #define UINT64_FMT "%I64u" 53 | 54 | #define INT64_HEX_FMT "%I64X" 55 | 56 | #define FILE_SEPARATOR "\\" 57 | 58 | #else /* defined(WIN32) || defined(__MINGW32__) */ 59 | 60 | #define INT64_FMT "%lld" 61 | #define UINT64_FMT "%llu" 62 | 63 | #define INT64_HEX_FMT "%llX" 64 | 65 | #define FILE_SEPARATOR "/" 66 | 67 | #endif /* defined(WIN32) || defined(__MINGW32__) */ 68 | 69 | #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ 70 | && ! defined(__MINGW32__) 71 | 72 | #define INT64_CONST(I) (I ## i64) 73 | #define UINT64_CONST(I) (I ## Ui64) 74 | 75 | #ifndef INT32_MAX 76 | #define INT32_MAX (2147483647) 77 | #endif 78 | 79 | #ifndef INT32_MIN 80 | #define INT32_MIN (-2147483647-1) 81 | #endif 82 | 83 | #else /* defined(WIN32) && ! defined(__MINGW32__) */ 84 | 85 | #define INT64_CONST(I) (I ## LL) 86 | #define UINT64_CONST(I) (I ## ULL) 87 | 88 | #endif /* defined(WIN32) && ! defined(__MINGW32__) */ 89 | 90 | #endif /* __wincompat_h */ 91 | -------------------------------------------------------------------------------- /src/libopentld/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(imacq 2 | tld 3 | ${CF_HEADER_DIRS} 4 | ${OpenCV_INCLUDE_DIRS}) 5 | 6 | link_directories(${OpenCV_LIB_DIR}) 7 | 8 | add_library(libopentld 9 | ${CF_SOURCES} 10 | imacq/ImAcq.cpp 11 | tld/Clustering.cpp 12 | tld/DetectionResult.cpp 13 | tld/DetectorCascade.cpp 14 | tld/EnsembleClassifier.cpp 15 | tld/NNClassifier.cpp 16 | tld/TLD.cpp 17 | tld/TLDUtil.cpp 18 | tld/VarianceFilter.cpp 19 | imacq/ImAcq.h 20 | tld/Clustering.h 21 | tld/DetectionResult.h 22 | tld/DetectorCascade.h 23 | tld/EnsembleClassifier.h 24 | tld/IntegralImage.h 25 | tld/NNClassifier.h 26 | tld/NormalizedPatch.h 27 | tld/TLD.h 28 | tld/TLDUtil.h 29 | tld/VarianceFilter.h) 30 | 31 | target_link_libraries(libopentld ${OpenCV_LIBS}) 32 | 33 | set_target_properties(libopentld PROPERTIES OUTPUT_NAME opentld) 34 | -------------------------------------------------------------------------------- /src/libopentld/CMakeLists2.txt: -------------------------------------------------------------------------------- 1 | include_directories(imacq 2 | tld 3 | ${CF_HEADER_DIRS} 4 | ${OpenCV_INCLUDE_DIRS}) 5 | 6 | link_directories(${OpenCV_LIB_DIR}) 7 | 8 | add_library(libopentld 9 | ${CF_SOURCES} 10 | tld/Clustering.cpp 11 | tld/DetectionResult.cpp 12 | tld/DetectorCascade.cpp 13 | tld/EnsembleClassifier.cpp 14 | tld/NNClassifier.cpp 15 | tld/TLD.cpp 16 | tld/TLDUtil.cpp 17 | tld/VarianceFilter.cpp 18 | tld/Clustering.h 19 | tld/DetectionResult.h 20 | tld/DetectorCascade.h 21 | tld/EnsembleClassifier.h 22 | tld/IntegralImage.h 23 | tld/NNClassifier.h 24 | tld/NormalizedPatch.h 25 | tld/TLD.h 26 | tld/TLDUtil.h 27 | tld/VarianceFilter.h) 28 | 29 | target_link_libraries(libopentld ${OpenCV_LIBS}) 30 | 31 | -------------------------------------------------------------------------------- /src/libopentld/imacq/ImAcq.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * imAcq.h 22 | * 23 | * Created on: 18 May 2011 24 | * Author: Georg Nebehaiy 25 | * Modified on: 26th May 2013 26 | * By: Jonathan Senecal 27 | */ 28 | 29 | #ifndef IMACQ_IMPL_H_ 30 | #define IMACQ_IMPL_H_ 31 | 32 | #include 33 | 34 | /** 35 | * Capturing method 36 | */ 37 | enum ImacqMethod 38 | { 39 | IMACQ_IMGS, //!< Images 40 | IMACQ_CAM, //!< Camera 41 | IMACQ_VID, //!< Video 42 | IMACQ_LIVESIM, //!< Livesim 43 | IMACQ_STREAM //!< Stream 44 | }; 45 | 46 | typedef struct 47 | { 48 | int method; 49 | const char *imgPath; 50 | CvCapture *capture; 51 | int lastFrame; 52 | int currentFrame; 53 | int startFrame; 54 | int camNo; 55 | int64 startTime; 56 | float fps; 57 | } ImAcq; 58 | 59 | ImAcq *imAcqAlloc(); 60 | 61 | void imAcqInit(ImAcq *imAcq); 62 | 63 | void imAcqRelease(ImAcq *imAcq); 64 | 65 | void imAcqVidSetNextFrameNumber(ImAcq *imAcq, int nFrame); 66 | int imAcqVidGetNextFrameNumber(ImAcq *imAcq); 67 | int imAcqVidGetNumberOfFrames(ImAcq *imAcq); 68 | int imAcqHasMoreFrames(ImAcq *imAcq); 69 | IplImage *imAcqGetImgAndAdvance(ImAcq *imAcq); 70 | IplImage *imAcqGetImg(ImAcq *imAcq); 71 | IplImage *imAcqGetImgByFrame(ImAcq *imAcq, int fNo); 72 | IplImage *imAcqGetImgByCurrentTime(ImAcq *imAcq); 73 | IplImage *imAcqLoadImg(ImAcq *imAcq, char *path); 74 | IplImage *imAcqLoadCurrentFrame(ImAcq *imAcq); 75 | IplImage *imAcqLoadVidFrame(CvCapture *capture); 76 | IplImage *imAcqGrab(CvCapture *capture); 77 | void imAcqAdvance(ImAcq *imAcq); 78 | void imAcqFree(ImAcq *); 79 | 80 | #endif /* IMACQ_H_ */ 81 | -------------------------------------------------------------------------------- /src/libopentld/tld/Clustering.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * Clustering.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef CLUSTERING_H_ 27 | #define CLUSTERING_H_ 28 | 29 | #include 30 | 31 | #include 32 | 33 | #include "DetectionResult.h" 34 | 35 | namespace tld 36 | { 37 | class Clustering 38 | { 39 | void calcMeanRect(std::vector * indices); 40 | void calcDistances(float *distances); 41 | void cluster(float *distances); 42 | public: 43 | int *windows; 44 | int numWindows; 45 | 46 | DetectionResult *detectionResult; 47 | 48 | //Configurable members 49 | float cutoff; 50 | 51 | Clustering(); 52 | virtual ~Clustering(); 53 | void release(); 54 | void clusterConfidentIndices(); 55 | }; 56 | } /* namespace tld */ 57 | #endif /* CLUSTERING_H_ */ 58 | -------------------------------------------------------------------------------- /src/libopentld/tld/DetectionResult.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * DetectionResult.cpp 22 | * 23 | * Created on: Nov 16, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #include "DetectionResult.h" 28 | 29 | #include "TLDUtil.h" 30 | 31 | using namespace cv; 32 | using namespace std; 33 | 34 | namespace tld 35 | { 36 | DetectionResult::DetectionResult() 37 | { 38 | containsValidData = false; 39 | fgList = new vector(); 40 | confidentIndices = new vector(); 41 | numClusters = 0; 42 | detectorBB = NULL; 43 | 44 | variances = NULL; 45 | posteriors = NULL; 46 | featureVectors = NULL; 47 | } 48 | 49 | DetectionResult::~DetectionResult() 50 | { 51 | release(); 52 | delete fgList; 53 | fgList = NULL; 54 | } 55 | 56 | void DetectionResult::init(int numWindows, int numTrees) 57 | { 58 | variances = new float[numWindows]; 59 | posteriors = new float[numWindows]; 60 | featureVectors = new int[numWindows * numTrees]{}; 61 | delete confidentIndices; 62 | confidentIndices = new vector(); 63 | } 64 | 65 | void DetectionResult::reset() 66 | { 67 | containsValidData = false; 68 | 69 | if (fgList != NULL) fgList->clear(); 70 | 71 | if (confidentIndices != NULL) confidentIndices->clear(); 72 | 73 | numClusters = 0; 74 | delete detectorBB; 75 | detectorBB = NULL; 76 | } 77 | 78 | void DetectionResult::release() 79 | { 80 | fgList->clear(); 81 | delete[] variances; 82 | variances = NULL; 83 | delete[] posteriors; 84 | posteriors = NULL; 85 | delete[] featureVectors; 86 | featureVectors = NULL; 87 | delete confidentIndices; 88 | confidentIndices = NULL; 89 | delete detectorBB; 90 | detectorBB = NULL; 91 | containsValidData = false; 92 | } 93 | } /* namespace tld */ 94 | -------------------------------------------------------------------------------- /src/libopentld/tld/DetectionResult.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * DetectionResult.h 22 | * 23 | * Created on: Nov 16, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #ifndef DETECTIONRESULT_H_ 28 | #define DETECTIONRESULT_H_ 29 | 30 | #include 31 | 32 | #include 33 | 34 | namespace tld 35 | { 36 | class DetectionResult 37 | { 38 | public: 39 | bool containsValidData; 40 | std::vector* fgList; 41 | float *posteriors; /* Contains the posteriors for each slding window. Is of size numWindows. Allocated by tldInitClassifier. */ 42 | std::vector* confidentIndices; 43 | int *featureVectors; 44 | float *variances; 45 | int numClusters; 46 | cv::Rect *detectorBB; //Contains a valid result only if numClusters = 1 47 | 48 | DetectionResult(); 49 | virtual ~DetectionResult(); 50 | 51 | void init(int numWindows, int numTrees); 52 | 53 | void reset(); 54 | void release(); 55 | }; 56 | } /* namespace tld */ 57 | #endif /* DETECTIONRESULT_H_ */ 58 | -------------------------------------------------------------------------------- /src/libopentld/tld/DetectorCascade.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * DetectorCascade.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef DETECTORCASCADE_H_ 27 | #define DETECTORCASCADE_H_ 28 | 29 | #include "DetectionResult.h" 30 | #include "VarianceFilter.h" 31 | #include "EnsembleClassifier.h" 32 | #include "Clustering.h" 33 | #include "NNClassifier.h" 34 | 35 | namespace tld 36 | { 37 | //Constants 38 | static const int TLD_WINDOW_SIZE = 5; 39 | static const int TLD_WINDOW_OFFSET_SIZE = 6; 40 | 41 | class DetectorCascade 42 | { 43 | //Working data 44 | int numScales; 45 | cv::Size *scales; 46 | public: 47 | //Configurable members 48 | int minScale; 49 | int maxScale; 50 | bool useShift; 51 | float shift; 52 | int minSize; 53 | int numFeatures; 54 | int numTrees; 55 | 56 | //Needed for init 57 | int imgWidth; 58 | int imgHeight; 59 | int imgWidthStep; 60 | int objWidth; 61 | int objHeight; 62 | 63 | int numWindows; 64 | int *windows; 65 | int *windowOffsets; 66 | 67 | //State data 68 | bool initialised; 69 | 70 | //Components of Detector Cascade 71 | VarianceFilter *varianceFilter; 72 | EnsembleClassifier *ensembleClassifier; 73 | Clustering *clustering; 74 | NNClassifier *nnClassifier; 75 | 76 | DetectionResult *detectionResult; 77 | 78 | void propagateMembers(); 79 | 80 | DetectorCascade(); 81 | ~DetectorCascade(); 82 | 83 | void init(std::shared_ptr rng); 84 | 85 | void initWindowOffsets(); 86 | void initWindowsAndScales(); 87 | 88 | void release(); 89 | void cleanPreviousData(); 90 | void detect(const cv::Mat &img); 91 | }; 92 | } /* namespace tld */ 93 | #endif /* DETECTORCASCADE_H_ */ 94 | -------------------------------------------------------------------------------- /src/libopentld/tld/EnsembleClassifier.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * EnsembleClassifier.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef ENSEMBLECLASSIFIER_H_ 27 | #define ENSEMBLECLASSIFIER_H_ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace tld 34 | { 35 | class EnsembleClassifier 36 | { 37 | const unsigned char *img; 38 | 39 | float calcConfidence(int *featureVector); 40 | int calcFernFeature(int windowIdx, int treeIdx); 41 | void calcFeatureVector(int windowIdx, int *featureVector); 42 | void updatePosteriors(int *featureVector, int positive, int amount); 43 | public: 44 | bool enabled; 45 | 46 | //Configurable members 47 | int numTrees; 48 | int numFeatures; 49 | 50 | int imgWidthStep; 51 | int numScales; 52 | cv::Size *scales; 53 | 54 | int *windowOffsets; 55 | int *featureOffsets; 56 | float *features; 57 | 58 | int numIndices; 59 | 60 | float *posteriors; 61 | int *positives; 62 | int *negatives; 63 | 64 | DetectionResult *detectionResult; 65 | 66 | EnsembleClassifier(); 67 | virtual ~EnsembleClassifier(); 68 | void init(std::shared_ptr rng); 69 | void initFeatureLocations(std::shared_ptr rng); 70 | void initFeatureOffsets(); 71 | void initPosteriors(); 72 | void release(); 73 | void nextIteration(const cv::Mat &img); 74 | void classifyWindow(int windowIdx); 75 | void updatePosterior(int treeIdx, int idx, int positive, int amount); 76 | void learn(int *boundary, int positive, int *featureVector); 77 | bool filter(int i); 78 | }; 79 | } /* namespace tld */ 80 | #endif /* ENSEMBLECLASSIFIER_H_ */ 81 | -------------------------------------------------------------------------------- /src/libopentld/tld/IntegralImage.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * IntegralImage.h 22 | * 23 | * Created on: Nov 16, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #ifndef INTEGRALIMAGE_H_ 28 | #define INTEGRALIMAGE_H_ 29 | 30 | #include 31 | 32 | namespace tld 33 | { 34 | template 35 | class IntegralImage 36 | { 37 | public: 38 | T *data; /* Array containg the entries for the integral image in row-first manner. Of size width*height. Allocated by tldAllocIntImg */ 39 | /* width, height: Dimensions of integral image.*/ 40 | int width; 41 | int height; 42 | 43 | IntegralImage(cv::Size size) 44 | { 45 | data = new T[size.width * size.height]; 46 | } 47 | 48 | virtual ~IntegralImage() 49 | { 50 | delete[] data; 51 | } 52 | 53 | void calcIntImg(const cv::Mat &img, bool squared = false) 54 | { 55 | const unsigned char *input = (const unsigned char *)(img.data); 56 | T *output = data; 57 | 58 | for (int i = 0; i < img.cols; i++) 59 | { 60 | for (int j = 0; j < img.rows; j++) 61 | { 62 | T A = (i > 0) ? output[img.cols * j + i - 1] : 0; 63 | T B = (j > 0) ? output[img.cols * (j - 1) + i] : 0; 64 | T C = (j > 0 && i > 0) ? output[img.cols * (j - 1) + i - 1] : 0; 65 | T value = input[img.step * j + i]; 66 | 67 | if (squared) 68 | { 69 | value = value * value; 70 | } 71 | 72 | output[img.cols * j + i] = A + B - C + value; 73 | } 74 | } 75 | } 76 | }; 77 | } /* namespace tld */ 78 | #endif /* INTEGRALIMAGE_H_ */ 79 | -------------------------------------------------------------------------------- /src/libopentld/tld/NNClassifier.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * NNClassifier.cpp 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #include "NNClassifier.h" 27 | #include "opencv2/imgproc/imgproc.hpp" 28 | #include "opencv2/highgui/highgui.hpp" 29 | #include "DetectorCascade.h" 30 | #include "TLDUtil.h" 31 | 32 | using namespace std; 33 | using namespace cv; 34 | 35 | namespace tld 36 | { 37 | NNClassifier::NNClassifier() 38 | { 39 | thetaFP = .5f; 40 | thetaTP = .55f; 41 | 42 | truePositives = new vector(); 43 | falsePositives = new vector(); 44 | } 45 | 46 | NNClassifier::~NNClassifier() 47 | { 48 | release(); 49 | 50 | delete truePositives; 51 | delete falsePositives; 52 | } 53 | 54 | void NNClassifier::release() 55 | { 56 | falsePositives->clear(); 57 | truePositives->clear(); 58 | } 59 | 60 | float NNClassifier::ncc(float *f1, float *f2) 61 | { 62 | double corr = 0; 63 | double norm1 = 0; 64 | double norm2 = 0; 65 | 66 | int size = TLD_PATCH_SIZE * TLD_PATCH_SIZE; 67 | 68 | for (int i = 0; i < size; i++) 69 | { 70 | corr += f1[i] * f2[i]; 71 | norm1 += f1[i] * f1[i]; 72 | norm2 += f2[i] * f2[i]; 73 | } 74 | 75 | // normalization to <0,1> 76 | 77 | return static_cast((corr / sqrt(norm1 * norm2) + 1) / 2.0); 78 | } 79 | 80 | float NNClassifier::classifyPatch(NormalizedPatch *patch) 81 | { 82 | if (truePositives->empty()) 83 | { 84 | return 0; 85 | } 86 | 87 | if (falsePositives->empty()) 88 | { 89 | return 1; 90 | } 91 | 92 | float ccorr_max_p = 0; 93 | 94 | //Compare patch to positive patches 95 | for (size_t i = 0; i < truePositives->size(); i++) 96 | { 97 | float ccorr = ncc(truePositives->at(i).values, patch->values); 98 | 99 | if (ccorr > ccorr_max_p) 100 | { 101 | ccorr_max_p = ccorr; 102 | } 103 | } 104 | 105 | float ccorr_max_n = 0; 106 | 107 | //Compare patch to negative patches 108 | for (size_t i = 0; i < falsePositives->size(); i++) 109 | { 110 | float ccorr = ncc(falsePositives->at(i).values, patch->values); 111 | 112 | if (ccorr > ccorr_max_n) 113 | { 114 | ccorr_max_n = ccorr; 115 | } 116 | } 117 | 118 | float dN = 1 - ccorr_max_n; 119 | float dP = 1 - ccorr_max_p; 120 | 121 | float distance = dN / (dN + dP); 122 | return distance; 123 | } 124 | 125 | float NNClassifier::classifyBB(const Mat &img, Rect *bb) 126 | { 127 | NormalizedPatch patch; 128 | 129 | tldExtractNormalizedPatchRect(img, bb, patch.values); 130 | return classifyPatch(&patch); 131 | } 132 | 133 | float NNClassifier::classifyWindow(const Mat &img, int windowIdx) 134 | { 135 | NormalizedPatch patch; 136 | 137 | int *bbox = &windows[TLD_WINDOW_SIZE * windowIdx]; 138 | tldExtractNormalizedPatchBB(img, bbox, patch.values); 139 | 140 | return classifyPatch(&patch); 141 | } 142 | 143 | void NNClassifier::showWindow(const Mat &img, int windowIdx) 144 | { 145 | NormalizedPatch patch; 146 | 147 | int *bbox = &windows[TLD_WINDOW_SIZE * windowIdx]; 148 | tldExtractNormalizedPatchBB(img, bbox, patch.values); 149 | Mat temp(TLD_PATCH_SIZE, TLD_PATCH_SIZE, CV_32F, patch.values); 150 | normalize(temp, temp, 0, 1, cv::NORM_MINMAX); 151 | resize(temp, temp, Size(0, 0), 5.0, 5.0); 152 | imshow("NN positive detection", temp); 153 | } 154 | 155 | bool NNClassifier::filter(const Mat &img, int windowIdx) 156 | { 157 | if (!enabled) return true; 158 | 159 | float conf = classifyWindow(img, windowIdx); 160 | 161 | if (conf < thetaTP) 162 | { 163 | return false; 164 | } 165 | //std::cout << "NN conf: " << conf << std::endl; 166 | //showWindow(img, windowIdx); 167 | return true; 168 | } 169 | 170 | void NNClassifier::learn(vector patches) 171 | { 172 | //TODO: Randomization might be a good idea here 173 | for (size_t i = 0; i < patches.size(); i++) 174 | { 175 | NormalizedPatch patch = patches[i]; 176 | 177 | float conf = classifyPatch(&patch); 178 | 179 | if (patch.positive && conf <= thetaTP) 180 | { 181 | truePositives->push_back(patch); 182 | } 183 | 184 | if (!patch.positive && conf >= thetaFP) 185 | { 186 | falsePositives->push_back(patch); 187 | } 188 | } 189 | } 190 | } /* namespace tld */ 191 | -------------------------------------------------------------------------------- /src/libopentld/tld/NNClassifier.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * NNClassifier.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef NNCLASSIFIER_H_ 27 | #define NNCLASSIFIER_H_ 28 | 29 | #include 30 | 31 | #include 32 | 33 | #include "NormalizedPatch.h" 34 | #include "DetectionResult.h" 35 | 36 | namespace tld 37 | { 38 | class NNClassifier 39 | { 40 | float ncc(float *f1, float *f2); 41 | void showWindow(const cv::Mat &img, int windowIdx); 42 | public: 43 | bool enabled; 44 | 45 | int *windows; 46 | float thetaFP; 47 | float thetaTP; 48 | DetectionResult *detectionResult; 49 | std::vector* falsePositives; 50 | std::vector* truePositives; 51 | 52 | NNClassifier(); 53 | virtual ~NNClassifier(); 54 | 55 | void release(); 56 | float classifyPatch(NormalizedPatch *patch); 57 | float classifyBB(const cv::Mat &img, cv::Rect *bb); 58 | float classifyWindow(const cv::Mat &img, int windowIdx); 59 | void learn(std::vector patches); 60 | bool filter(const cv::Mat &img, int windowIdx); 61 | }; 62 | } /* namespace tld */ 63 | #endif /* NNCLASSIFIER_H_ */ 64 | -------------------------------------------------------------------------------- /src/libopentld/tld/NormalizedPatch.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * NormalizedPatch.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef NORMALIZEDPATCH_H_ 27 | #define NORMALIZEDPATCH_H_ 28 | 29 | #define TLD_PATCH_SIZE 15 30 | 31 | namespace tld 32 | { 33 | class NormalizedPatch 34 | { 35 | public: 36 | float values[TLD_PATCH_SIZE *TLD_PATCH_SIZE]; 37 | bool positive; 38 | }; 39 | } /* namespace tld */ 40 | #endif /* NORMALIZEDPATCH_H_ */ 41 | -------------------------------------------------------------------------------- /src/libopentld/tld/TLD.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * TLD.h 22 | * 23 | * Created on: Nov 17, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #ifndef TLD_H_ 28 | #define TLD_H_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include "opencv2/core/core.hpp" 34 | #include "cf_tracker.hpp" 35 | #include "DetectorCascade.h" 36 | 37 | namespace tld 38 | { 39 | class TLD 40 | { 41 | private: 42 | void storeCurrentData(); 43 | void fuseHypotheses(const cv::Mat& colorImg); 44 | void learn(); 45 | void initialLearning(); 46 | void deleteCurrentBB(); 47 | std::shared_ptr tracker; 48 | public: 49 | DetectorCascade *detectorCascade; 50 | NNClassifier *nnClassifier; 51 | cv::Mat currImg; 52 | cv::Rect *currBB; 53 | cv::Rect trackerBB; 54 | bool valid; 55 | bool isTrackerValid; 56 | bool runTracker; 57 | float currConf; 58 | bool learning; 59 | 60 | bool hasImageDimensions; 61 | bool trackerEnabled; 62 | bool detectorEnabled; 63 | bool learningEnabled; 64 | bool alternating; 65 | std::shared_ptr rng; 66 | int seed; 67 | 68 | TLD(); 69 | virtual ~TLD(); 70 | void init(bool useDsstTracker); 71 | void release(); 72 | void selectObject(const cv::Mat &img, cv::Rect *bb); 73 | void processImage(cv::Mat &img); 74 | }; 75 | } /* namespace tld */ 76 | #endif /* TLD_H_ */ 77 | -------------------------------------------------------------------------------- /src/libopentld/tld/TLDUtil.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * util.h 22 | * 23 | * Created on: 30.05.2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #ifndef TLDUTIL_H_ 28 | #define TLDUTIL_H_ 29 | 30 | #include 31 | 32 | #include 33 | 34 | namespace tld 35 | { 36 | template 37 | void tldConvertBB(T1 *src, T2 *dest) 38 | { 39 | dest[0] = src[0]; 40 | dest[1] = src[1]; 41 | dest[2] = src[2]; 42 | dest[3] = src[3]; 43 | } 44 | 45 | template 46 | void tldCopyBB(T *src, T *dest) 47 | { 48 | tldConvertBB(src, dest); 49 | } 50 | 51 | template 52 | void tldCopyBoundaryToArray(T x, T y, T width, T height, T *array) 53 | { 54 | array[0] = x; 55 | array[1] = y; 56 | array[2] = width; 57 | array[3] = height; 58 | } 59 | 60 | template 61 | void tldExtractDimsFromArray(T *boundary, T *x, T *y, T *width, T *height) 62 | { 63 | *x = boundary[0]; 64 | *y = boundary[1]; 65 | *width = boundary[2]; 66 | *height = boundary[3]; 67 | } 68 | 69 | template 70 | void tldRectToArray(cv::Rect rect, T *boundary) 71 | { 72 | boundary[0] = rect.x; 73 | boundary[1] = rect.y; 74 | boundary[2] = rect.width; 75 | boundary[3] = rect.height; 76 | } 77 | 78 | template 79 | cv::Rect tldArrayToRect(T *boundary) 80 | { 81 | cv::Rect rect; 82 | rect.x = boundary[0]; 83 | rect.y = boundary[1]; 84 | rect.width = boundary[2]; 85 | rect.height = boundary[3]; 86 | 87 | return rect; 88 | } 89 | 90 | int tldIsInside(int *bb1, int *bb2); 91 | void tldRectToPoints(CvRect rect, CvPoint *p1, CvPoint *p2); 92 | void tldBoundingBoxToPoints(int *bb, CvPoint *p1, CvPoint *p2); 93 | 94 | void tldNormalizeImg(const cv::Mat &img, float *result, int size); 95 | 96 | void tldExtractNormalizedPatch(const cv::Mat &img, int x, int y, int w, int h, float *output); 97 | void tldExtractNormalizedPatchBB(const cv::Mat &img, int *boundary, float *output); 98 | void tldExtractNormalizedPatchRect(const cv::Mat &img, cv::Rect *rect, float *output); 99 | void tldExtractSubImage(const cv::Mat &img, cv::Mat &subImage, int *boundary); 100 | void tldExtractSubImage(const cv::Mat &img, cv::Mat &subImage, int x, int y, int w, int h); 101 | 102 | float tldCalcMean(float *value, int n); 103 | float tldCalcVariance(float *value, int n); 104 | 105 | bool tldSortByOverlapDesc(std::pair bb1, std::pair bb2); 106 | cv::Rect *tldCopyRect(cv::Rect *r); 107 | 108 | //TODO: Change function names 109 | float tldOverlapRectRect(cv::Rect r1, cv::Rect r2); 110 | void tldOverlapOne(int *windows, int index, std::vector * indices, float *overlap); 111 | void tldOverlap(int *windows, int numWindows, int *boundary, float *overlap); 112 | void tldOverlapRect(int *windows, int numWindows, cv::Rect *boundary, float *overlap); 113 | 114 | float tldCalcVariance(float *value, int n); 115 | 116 | #endif /* UTIL_H_ */ 117 | } /* End Namespace */ 118 | -------------------------------------------------------------------------------- /src/libopentld/tld/VarianceFilter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * VarianceFilter.cpp 22 | * 23 | * Created on: Nov 16, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #include "VarianceFilter.h" 28 | 29 | #include "IntegralImage.h" 30 | #include "DetectorCascade.h" 31 | 32 | using namespace cv; 33 | 34 | namespace tld 35 | { 36 | VarianceFilter::VarianceFilter() 37 | { 38 | enabled = true; 39 | minVar = 0; 40 | integralImg = NULL; 41 | integralImg_squared = NULL; 42 | } 43 | 44 | VarianceFilter::~VarianceFilter() 45 | { 46 | release(); 47 | } 48 | 49 | void VarianceFilter::release() 50 | { 51 | if (integralImg != NULL) delete integralImg; 52 | 53 | integralImg = NULL; 54 | 55 | if (integralImg_squared != NULL) delete integralImg_squared; 56 | 57 | integralImg_squared = NULL; 58 | } 59 | 60 | float VarianceFilter::calcVariance(int *off) 61 | { 62 | int *ii1 = integralImg->data; 63 | long long *ii2 = integralImg_squared->data; 64 | 65 | float mX = (ii1[off[3]] - ii1[off[2]] - ii1[off[1]] + ii1[off[0]]) / (float)off[5]; //Sum of Area divided by area 66 | float mX2 = (ii2[off[3]] - ii2[off[2]] - ii2[off[1]] + ii2[off[0]]) / (float)off[5]; 67 | return mX2 - mX * mX; 68 | } 69 | 70 | void VarianceFilter::nextIteration(const Mat &img) 71 | { 72 | if (!enabled) return; 73 | 74 | release(); 75 | 76 | integralImg = new IntegralImage(img.size()); 77 | integralImg->calcIntImg(img); 78 | 79 | integralImg_squared = new IntegralImage(img.size()); 80 | integralImg_squared->calcIntImg(img, true); 81 | } 82 | 83 | bool VarianceFilter::filter(int i) 84 | { 85 | if (!enabled) return true; 86 | 87 | float bboxvar = calcVariance(windowOffsets + TLD_WINDOW_OFFSET_SIZE * i); 88 | 89 | detectionResult->variances[i] = bboxvar; 90 | 91 | if (bboxvar < minVar) 92 | { 93 | return false; 94 | } 95 | 96 | return true; 97 | } 98 | } /* namespace tld */ 99 | -------------------------------------------------------------------------------- /src/libopentld/tld/VarianceFilter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | /* 20 | * VarianceFilter.h 21 | * 22 | * Created on: Nov 16, 2011 23 | * Author: Georg Nebehay 24 | */ 25 | 26 | #ifndef VARIANCEFILTER_H_ 27 | #define VARIANCEFILTER_H_ 28 | 29 | #include 30 | 31 | #include "IntegralImage.h" 32 | #include "DetectionResult.h" 33 | 34 | namespace tld 35 | { 36 | class VarianceFilter 37 | { 38 | IntegralImage* integralImg; 39 | IntegralImage* integralImg_squared; 40 | 41 | public: 42 | bool enabled; 43 | int *windowOffsets; 44 | 45 | DetectionResult *detectionResult; 46 | 47 | float minVar; 48 | 49 | VarianceFilter(); 50 | virtual ~VarianceFilter(); 51 | 52 | void release(); 53 | void nextIteration(const cv::Mat &img); 54 | bool filter(int idx); 55 | float calcVariance(int *off); 56 | }; 57 | } /* namespace tld */ 58 | #endif /* VARIANCEFILTER_H_ */ 59 | -------------------------------------------------------------------------------- /src/opentld/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_directories(${OpenCV_LIB_DIR}) 3 | 4 | include_directories(main 5 | ../libopentld/imacq 6 | ../libopentld/mftracker 7 | ../libopentld/tld 8 | ${CF_HEADER_DIRS} 9 | ${OpenCV_INCLUDE_DIRS}) 10 | 11 | if(NOT USE_SYSTEM_LIBS) 12 | include_directories(../3rdparty/libconfig) 13 | endif(NOT USE_SYSTEM_LIBS) 14 | 15 | #------------------------------------------------------------------------------- 16 | # main 17 | add_library(main 18 | main/Config.cpp 19 | main/Gui.cpp 20 | main/Main.cpp 21 | main/Settings.cpp 22 | main/Trajectory.cpp 23 | main/json.cpp 24 | main/Config.h 25 | main/Gui.h 26 | main/Main.h 27 | main/Settings.h 28 | main/Trajectory.h 29 | main/json/json.h 30 | main/json/json-forwards.h 31 | main/perf.h 32 | main/log.h 33 | main/tools/jsoncpp.cpp 34 | main/tools/log.cpp 35 | main/tools/perf.cpp 36 | ../3rdparty/cf_tracking/src/cf_libs/common/cf_tracker.hpp) 37 | 38 | target_link_libraries(main libopentld config++ ${OpenCV_LIBS}) 39 | 40 | #------------------------------------------------------------------------------- 41 | # opentld 42 | add_executable(cftld 43 | OpenTLD.cpp) 44 | 45 | target_link_libraries(cftld main libopentld config++ ${OpenCV_LIBS}) 46 | 47 | install(TARGETS cftld DESTINATION bin) 48 | 49 | #------------------------------------------------------------------------------- 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/opentld/OpenTLD.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /** 21 | * @author Georg Nebehay 22 | */ 23 | 24 | #include "Main.h" 25 | #include "Config.h" 26 | #include "ImAcq.h" 27 | #include "Gui.h" 28 | #include 29 | 30 | using tld::Config; 31 | using tld::Gui; 32 | using tld::Settings; 33 | 34 | int main(int argc, char **argv) 35 | { 36 | Main *main = new Main(); 37 | Config config; 38 | ImAcq *imAcq = imAcqAlloc(); 39 | Gui *gui = new Gui(); 40 | 41 | main->gui = gui; 42 | main->imAcq = imAcq; 43 | 44 | if (config.init(argc, argv) == PROGRAM_EXIT) 45 | { 46 | return EXIT_FAILURE; 47 | } 48 | 49 | config.configure(main); 50 | 51 | main->tld->seed = main->seed; 52 | imAcqInit(imAcq); 53 | 54 | if (main->showOutput) 55 | { 56 | gui->init(); 57 | } 58 | 59 | main->doWork(); 60 | 61 | delete main; 62 | main = NULL; 63 | delete gui; 64 | gui = NULL; 65 | 66 | return EXIT_SUCCESS; 67 | } 68 | -------------------------------------------------------------------------------- /src/opentld/main/Config.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #ifndef CONFIG_H 21 | #define CONFIG_H 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "ImAcq.h" 29 | #include "Settings.h" 30 | #include "Main.h" 31 | 32 | namespace tld 33 | { 34 | /** 35 | * Config is used to configure the program by cli and/or by a config file 36 | */ 37 | class Config 38 | { 39 | public: 40 | /** 41 | * Constructor 42 | */ 43 | Config(); 44 | 45 | Config(Settings &settings); 46 | 47 | /** 48 | * Destructor 49 | */ 50 | ~Config(); 51 | 52 | /** 53 | * Initializes the Config. 54 | * @param argc number of command line arguments 55 | * @param argv command line arguments 56 | * @return PROGRAM_EXIT when an error occurred, SUCCESS if not 57 | */ 58 | int init(int argc, char **argv); 59 | 60 | /** 61 | * Configures the CamNode, ImAcq and TldClassifier. 62 | * @param node 63 | * @param imAcq 64 | * @param classifier 65 | * @return SUCCESS 66 | */ 67 | int configure(Main *main); 68 | private: 69 | libconfig::Config m_cfg; //!< libconfig++ 70 | std::string m_configPath; //!< path to the config file 71 | Settings m_settings; //!< adjusted settings 72 | ///@{ 73 | /** 74 | * Flags if parameters were set by cli-arguments. 75 | * When the flags are set, the parameters couldn't be 76 | * overwritten by the options in the config file. 77 | * The cli-arguments have a higher priority than the options 78 | * in the config file. 79 | */ 80 | bool m_selectManuallySet; 81 | bool m_methodSet; 82 | bool m_startFrameSet; 83 | bool m_lastFrameSet; 84 | bool m_trajectorySet; 85 | bool m_showDetectionsSet; 86 | bool m_thetaSet; 87 | bool m_printResultsSet; 88 | bool m_camNoSet; 89 | bool m_imagePathSet; 90 | bool m_initialBBSet; 91 | bool m_showOutputSet; 92 | bool m_useDsstTrackerSet; 93 | ///@} 94 | }; 95 | 96 | /* 97 | POSIX getopt for Windows 98 | 99 | AT&T Public License 100 | 101 | Code given out at the 1985 UNIFORUM conference in Dallas. 102 | */ 103 | #ifdef __GNUC__ 104 | # include 105 | #endif 106 | 107 | #ifndef __GNUC__ 108 | extern int opterr; 109 | extern int optind; 110 | extern int optopt; 111 | extern char *optarg; 112 | extern int getopt(int argc, char **argv, char *opts); 113 | #endif /* __GNUC__ */ 114 | } /* End Namespace */ 115 | 116 | #endif /* CONFIG_H */ 117 | -------------------------------------------------------------------------------- /src/opentld/main/Gui.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * gui.cpp 22 | * 23 | * Created on: Oct 18, 2011 24 | * Author: clemensk 25 | */ 26 | 27 | #include "Gui.h" 28 | 29 | #include "Main.h" 30 | 31 | #include 32 | 33 | using std::string; 34 | 35 | namespace tld 36 | { 37 | Gui::Gui() : 38 | m_window_name("tld") 39 | { 40 | } 41 | 42 | Gui::~Gui() 43 | { 44 | } 45 | 46 | void Gui::init() 47 | { 48 | cvNamedWindow(m_window_name.c_str(), CV_WINDOW_AUTOSIZE); 49 | cvMoveWindow(m_window_name.c_str(), 100, 100); 50 | } 51 | 52 | void Gui::showImage(IplImage *image) 53 | { 54 | cvShowImage(m_window_name.c_str(), image); 55 | } 56 | 57 | char Gui::getKey() 58 | { 59 | return cvWaitKey(10); 60 | } 61 | 62 | std::string Gui::windowName() 63 | { 64 | return m_window_name; 65 | } 66 | 67 | static string window_name; 68 | static CvFont font; 69 | static IplImage *img0; 70 | static IplImage *img1; 71 | static CvPoint point; 72 | static CvRect *bb; 73 | static int drag = 0; 74 | 75 | static void mouseHandler(int event, int x, int y, int flags, void *param) 76 | { 77 | /* user press left button */ 78 | if (event == CV_EVENT_LBUTTONDOWN && !drag) 79 | { 80 | point = cvPoint(x, y); 81 | drag = 1; 82 | } 83 | 84 | /* user drag the mouse */ 85 | if (event == CV_EVENT_MOUSEMOVE && drag) 86 | { 87 | img1 = (IplImage *)cvClone(img0); 88 | 89 | cvRectangle(img1, point, cvPoint(x, y), CV_RGB(255, 0, 0), 1, 8, 0); 90 | 91 | cvShowImage(window_name.c_str(), img1); 92 | cvReleaseImage(&img1); 93 | } 94 | 95 | /* user release left button */ 96 | if (event == CV_EVENT_LBUTTONUP && drag) 97 | { 98 | *bb = cvRect(point.x, point.y, x - point.x, y - point.y); 99 | drag = 0; 100 | } 101 | } 102 | 103 | // TODO: member of Gui 104 | // --> problem: callback function mouseHandler as member! 105 | int getBBFromUser(IplImage *img, CvRect &rect, Gui *gui) 106 | { 107 | window_name = gui->windowName(); 108 | img0 = (IplImage *)cvClone(img); 109 | rect = cvRect(-1, -1, -1, -1); 110 | bb = ▭ 111 | bool correctBB = false; 112 | cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1, 8); 113 | 114 | cvSetMouseCallback(window_name.c_str(), mouseHandler, NULL); 115 | cvPutText(img0, "Draw a bounding box and press Enter", cvPoint(0, 60), 116 | &font, cvScalar(255, 255, 0)); 117 | cvShowImage(window_name.c_str(), img0); 118 | 119 | while (!correctBB) 120 | { 121 | char key = cvWaitKey(0); 122 | 123 | if (tolower(key) == 'q') 124 | { 125 | return PROGRAM_EXIT; 126 | } 127 | 128 | if (((key == '\n') || (key == '\r') || (key == '\r\n')) && (bb->x != -1) && (bb->y != -1)) 129 | { 130 | correctBB = true; 131 | } 132 | } 133 | 134 | if (rect.width < 0) 135 | { 136 | rect.x += rect.width; 137 | rect.width = abs(rect.width); 138 | } 139 | 140 | if (rect.height < 0) 141 | { 142 | rect.y += rect.height; 143 | rect.height = abs(rect.height); 144 | } 145 | 146 | cvSetMouseCallback(window_name.c_str(), NULL, NULL); 147 | 148 | cvReleaseImage(&img0); 149 | cvReleaseImage(&img1); 150 | 151 | return SUCCESS; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/opentld/main/Gui.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #ifndef GUI_H_ 21 | #define GUI_H_ 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace tld 28 | { 29 | class Gui 30 | { 31 | public: 32 | Gui(); 33 | ~Gui(); 34 | void init(); 35 | void showImage(IplImage *image); 36 | char getKey(); 37 | std::string windowName(); 38 | 39 | private: 40 | std::string m_window_name; 41 | }; 42 | 43 | /** 44 | * Get a bounding box from the user. 45 | * @param img image to display 46 | * @param rect CvRect containing the coordinates of the bounding box 47 | * @param gui initialized gui 48 | * @return PROGRAM_EXIT if 'q' or 'Q' pressed, SUCCESS if everything went right 49 | */ 50 | int getBBFromUser(IplImage *img, CvRect &rect, Gui *gui); 51 | } 52 | 53 | #endif /* GUI_H_ */ 54 | -------------------------------------------------------------------------------- /src/opentld/main/Main.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | /* 21 | * main.h 22 | * 23 | * Created on: Nov 18, 2011 24 | * Author: Georg Nebehay 25 | */ 26 | 27 | #ifndef MAIN_H_ 28 | #define MAIN_H_ 29 | 30 | #include "TLD.h" 31 | #include "ImAcq.h" 32 | #include "Gui.h" 33 | #include "cf_tracker.hpp" 34 | 35 | enum Retval 36 | { 37 | PROGRAM_EXIT = 0, 38 | SUCCESS = 1 39 | }; 40 | 41 | class Main 42 | { 43 | public: 44 | tld::TLD *tld; 45 | ImAcq *imAcq; 46 | tld::Gui *gui; 47 | bool showOutput; 48 | bool showTrajectory; 49 | int trajectoryLength; 50 | const char *printResults; 51 | const char *saveDir; 52 | double threshold; 53 | bool showForeground; 54 | bool showNotConfident; 55 | bool selectManually; 56 | int *initialBB; 57 | bool reinit; 58 | bool exportModelAfterRun; 59 | bool loadModel; 60 | const char *modelPath; 61 | const char *modelExportFile; 62 | int seed; 63 | 64 | Main() 65 | { 66 | tld = new tld::TLD(); 67 | showOutput = 1; 68 | printResults = NULL; 69 | saveDir = "."; 70 | threshold = 0.5; 71 | showForeground = 0; 72 | 73 | showTrajectory = false; 74 | trajectoryLength = 0; 75 | 76 | selectManually = 0; 77 | 78 | initialBB = NULL; 79 | showNotConfident = true; 80 | 81 | reinit = 0; 82 | 83 | loadModel = false; 84 | 85 | exportModelAfterRun = false; 86 | modelExportFile = "model"; 87 | seed = 0; 88 | 89 | gui = NULL; 90 | modelPath = NULL; 91 | imAcq = NULL; 92 | } 93 | 94 | ~Main() 95 | { 96 | delete tld; 97 | imAcqFree(imAcq); 98 | } 99 | 100 | void doWork(); 101 | }; 102 | 103 | #endif /* MAIN_H_ */ 104 | -------------------------------------------------------------------------------- /src/opentld/main/Settings.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #include "Settings.h" 21 | 22 | using namespace std; 23 | 24 | /** 25 | * @author Clemens Korner 26 | */ 27 | 28 | namespace tld 29 | { 30 | Settings::Settings() : 31 | m_useProportionalShift(true), 32 | m_varianceFilterEnabled(true), 33 | m_ensembleClassifierEnabled(true), 34 | m_nnClassifierEnabled(true), 35 | m_trackerEnabled(true), 36 | m_detectorEnabled(true), 37 | m_selectManually(false), 38 | m_learningEnabled(true), 39 | m_showOutput(true), 40 | m_showNotConfident(true), 41 | m_showColorImage(false), 42 | m_showDetections(false), 43 | m_saveOutput(false), 44 | m_alternating(false), 45 | m_useDsstTracker(false), 46 | m_trajectory(0), 47 | m_method(IMACQ_CAM), 48 | m_startFrame(1), 49 | m_lastFrame(0), 50 | m_minScale(-10), 51 | m_maxScale(10), 52 | m_numFeatures(13), 53 | m_numTrees(10), 54 | m_thetaP(0.55f), 55 | m_thetaN(0.5f), 56 | m_minSize(25), 57 | m_camNo(0), 58 | m_fps(24), 59 | m_seed(0), 60 | m_threshold(0.7f), 61 | m_proportionalShift(0.1f), 62 | m_initialBoundingBox(vector()) 63 | { 64 | } 65 | 66 | Settings::~Settings() 67 | { 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/opentld/main/Settings.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #ifndef SETTINGS_H 21 | #define SETTINGS_H 22 | 23 | #include 24 | 25 | #include "ImAcq.h" 26 | 27 | /** 28 | * @author Clemens Korner 29 | */ 30 | 31 | namespace tld 32 | { 33 | /** 34 | * In this class all settings are stored. 35 | */ 36 | class Settings 37 | { 38 | public: 39 | /** 40 | * Standard-Constructor 41 | */ 42 | Settings(); 43 | ~Settings(); 44 | bool m_trackerEnabled; 45 | bool m_detectorEnabled; 46 | bool m_varianceFilterEnabled; 47 | bool m_ensembleClassifierEnabled; 48 | bool m_nnClassifierEnabled; 49 | bool m_useProportionalShift; //!< sets scanwindows off by a percentage value of the window dimensions (specified in proportionalShift) rather than 1px. 50 | bool m_selectManually; //!< if true, user can select initial bounding box (which then overrides the setting "initialBoundingBox") 51 | bool m_learningEnabled; //!< enables learning while processing 52 | bool m_showOutput; //!< creates a window displaying results 53 | bool m_showNotConfident; //!< show bounding box also if confidence is low 54 | bool m_showColorImage; //!< shows color images instead of greyscale 55 | bool m_showDetections; //!< shows detections 56 | bool m_saveOutput; //!< specifies whether to save visual output 57 | bool m_alternating; //!< if set to true, detector is disabled while tracker is running. 58 | bool m_useDsstTracker; 59 | int m_trajectory; //!< specifies the number of the last frames which are considered by the trajectory; 0 disables the trajectory 60 | int m_method; //!< method of capturing: IMACQ_CAM, IMACQ_IMGS or IMACQ_VID 61 | int m_startFrame; //!< first frame of capturing 62 | int m_lastFrame; //!< last frame of caputing; 0 means take all frames 63 | int m_minScale; //!< number of scales smaller than initial object size 64 | int m_maxScale; //!< number of scales larger than initial object size 65 | int m_numFeatures; //!< number of features 66 | int m_numTrees; //!< number of trees 67 | float m_thetaP; 68 | float m_thetaN; 69 | int m_seed; 70 | int m_minSize; //!< minimum size of scanWindows 71 | int m_camNo; //!< Which camera to use 72 | float m_fps; //!< Frames per second 73 | float m_threshold; //!< threshold for determining positive results 74 | float m_proportionalShift; //!< proportional shift 75 | std::string m_imagePath; //!< path to the images or the video if m_method is IMACQ_VID or IMACQ_IMGS 76 | std::string m_outputDir; //!< required if saveOutput = true, no default 77 | std::string m_printResults; //!< path to the file were the results should be printed; NULL -> results will not be printed 78 | std::string m_printTiming; //!< path to the file were the timings should be printed; NULL -> results will not be printed 79 | std::vector m_initialBoundingBox; //!< Initial Bounding Box can be specified here 80 | }; 81 | } 82 | 83 | #endif /* SETTINGS_H */ 84 | -------------------------------------------------------------------------------- /src/opentld/main/Trajectory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #include "Trajectory.h" 21 | 22 | #include 23 | 24 | /** 25 | * @author Clemens Korner 26 | */ 27 | 28 | using namespace std; 29 | 30 | namespace tld 31 | { 32 | Trajectory::Trajectory() : 33 | m_length(0) 34 | { 35 | } 36 | 37 | Trajectory::~Trajectory() 38 | { 39 | } 40 | 41 | void Trajectory::init(std::size_t length) 42 | { 43 | m_length = length; 44 | m_track_positions = vector(); 45 | m_track_colors = vector(); 46 | } 47 | 48 | void Trajectory::addPoint(CvPoint point, CvScalar color) 49 | { 50 | size_t length = m_track_positions.size(); 51 | 52 | // vectors aren't full 53 | if (length < m_length) 54 | { 55 | m_track_positions.push_back(point); 56 | m_track_colors.push_back(color); 57 | } 58 | else 59 | { 60 | // push element to the end 61 | m_track_positions.push_back(point); 62 | m_track_colors.push_back(color); 63 | 64 | // drop first element 65 | m_track_positions.erase(m_track_positions.begin()); 66 | m_track_colors.erase(m_track_colors.begin()); 67 | } 68 | } 69 | 70 | void Trajectory::drawTrajectory(IplImage * image) 71 | { 72 | CvPoint tempPoint; 73 | bool needSecondPoint = false; 74 | 75 | for (size_t i = 0; i < m_track_positions.size(); i++) 76 | { 77 | // try to find 1. point of the line 78 | if ((!needSecondPoint) && (m_track_positions[i].x != -1)) { 79 | tempPoint = m_track_positions[i]; 80 | needSecondPoint = true; 81 | // try to find 2. point of the line 82 | } 83 | else if (needSecondPoint && (m_track_positions[i].x != -1)) 84 | { 85 | cvLine(image, tempPoint, m_track_positions[i], m_track_colors[i], 2); 86 | tempPoint = m_track_positions[i]; 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/opentld/main/Trajectory.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 AIT Austrian Institute of Technology 2 | * 3 | * This file is part of OpenTLD. 4 | * 5 | * OpenTLD is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OpenTLD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with OpenTLD. If not, see . 17 | * 18 | */ 19 | 20 | #ifndef TRAJECTORY_H_ 21 | #define TRAJECTORY_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** 27 | * @author Clemens Korner 28 | */ 29 | 30 | namespace tld 31 | { 32 | /** 33 | * Detection trajectory; a line which associates the last detections. 34 | * The data is stored in 2 "shift registers" 35 | */ 36 | class Trajectory 37 | { 38 | public: 39 | /** 40 | * Constructor; don't forget to call init(length) afterwards 41 | */ 42 | Trajectory(); 43 | 44 | /** 45 | * Destructor 46 | */ 47 | ~Trajectory(); 48 | 49 | /** 50 | * Initializes the trajectory. 51 | * @param length specifies the number of the last frames which are 52 | * considered by the trajectory 53 | */ 54 | void init(std::size_t length); 55 | 56 | /** 57 | * Adds a new point to the trajectory. 58 | * If you want to add a "place holder" point just add a cvPoint(-1, -1) 59 | * and cvScalar(-1 , -1, -1) 60 | * @param point point which specifies the location of the point 61 | * @param color defines the color (confidence) of the point 62 | */ 63 | void addPoint(CvPoint point, CvScalar color); 64 | 65 | /** 66 | * Draws the trajectory into an image. 67 | * @param image image to draw 68 | */ 69 | void drawTrajectory(IplImage * image); 70 | private: 71 | std::size_t m_length; ///< number of the last frames which are considered by the trajectory 72 | std::vector m_track_positions; ///< vector containing the locations of the points 73 | std::vector m_track_colors; ///< vector containing the colors of the points 74 | }; 75 | } 76 | 77 | #endif /* TRAJECTORY_H_ */ 78 | -------------------------------------------------------------------------------- /src/opentld/main/log.h: -------------------------------------------------------------------------------- 1 | #ifndef LOG_H__ 2 | #define LOG_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | #define BIT(_b) (1UL << (_b)) 12 | #define BIT64(_b) (1ULL << (_b)) 13 | #define BIT_MASK(_bw) ((1UL << (_bw)) - 1) 14 | #define BIT64_MASK(_bw) ((1ULL << (_bw)) - 1) 15 | 16 | #define BIT_GET(_raw, _b) (!!((_raw) & BIT(_b))) 17 | #define BIT64_GET(_raw, _b) (!!((_raw) & BIT64(_b))) 18 | #define BIT_SET(_raw, _b, _v) \ 19 | { \ 20 | uint8_t __v = _v; \ 21 | if (__v) (_raw) |= BIT(_b); \ 22 | else (_raw) &= (~(BIT(_b))); \ 23 | } 24 | 25 | #define BIT_RANGE_MASK(_bs, _bw) (BIT_MASK(_bw) << (_bs)) 26 | 27 | #define FIELD_GET(_raw, _bs, _bw, _val) \ 28 | _val = ((_raw) & BIT_RANGE_MASK(_bs, _bw)) >> (_bs) 29 | 30 | #define FIELD_SET(_raw, _bs, _bw, _val) \ 31 | _raw = ((_raw) & (~(BIT_RANGE_MASK(_bs, _bw)))) | (((_val) & BIT_MASK(_bw))<< (_bs)) 32 | 33 | #define BIT_NCOPY(src, dst, offs, n) FIELD_GET((src), (offs), (n), (dst)) 34 | 35 | /*This order of the enum mustn`t be changed*/ 36 | typedef enum 37 | { 38 | LOG_NULL = 0, 39 | LOG_VERB, 40 | LOG_STAT, 41 | LOG_INFO, 42 | LOG_DEBUG, 43 | LOG_CONFIG, 44 | LOG_EVENT, 45 | LOG_WARN, 46 | LOG_ALARM, 47 | LOG_ERROR, 48 | LOG_EMERG, 49 | LOG_PERFIX, //output the perfix info "__FUNCTION__" and "__LINE__" 50 | LOG_MAX 51 | } LOG_E; 52 | 53 | /*This order of the enum mustn`t be changed*/ 54 | extern char LOG_e_str[][30]; 55 | extern uint32_t g_LOG_config; 56 | extern void log_config_init(); 57 | extern void log_config_get(string &str); 58 | extern void log_config_set(string &str); 59 | 60 | 61 | #define aid_log(_type, _fmt, para...) \ 62 | { \ 63 | if (BIT_GET(g_LOG_config, _type)) \ 64 | { \ 65 | if(BIT_GET(g_LOG_config, LOG_PERFIX)) \ 66 | {\ 67 | char * str = LOG_e_str[_type]; \ 68 | fprintf(stderr, "[%7s] %s():%d - " _fmt, str+4, __FUNCTION__, __LINE__, ##para); \ 69 | }\ 70 | else \ 71 | fprintf(stderr, _fmt, ##para); \ 72 | } \ 73 | } 74 | 75 | #define log_emerg(_fmt, para...) aid_log(LOG_EMERG, _fmt, ##para) 76 | #define log_alarm(_fmt, para...) aid_log(LOG_ALARM, _fmt, ##para) 77 | #define log_config(_fmt, para...) aid_log(LOG_CONFIG, _fmt, ##para) 78 | #define log_error(_fmt, para...) aid_log(LOG_ERROR, _fmt, ##para) 79 | #define log_warn(_fmt, para...) aid_log(LOG_WARN, _fmt, ##para) 80 | #define log_event(_fmt, para...) aid_log(LOG_EVENT, _fmt, ##para) 81 | #define log_info(_fmt, para...) aid_log(LOG_INFO, _fmt, ##para) 82 | #define log_debug(_fmt, para...) aid_log(LOG_DEBUG, _fmt, ##para) 83 | #define log_verb(_fmt, para...) aid_log(LOG_VERB, _fmt, ##para) 84 | #define log_stat(_fmt, para...) aid_log(LOG_STAT, _fmt, ##para) 85 | #define log_printf(_fmt, para...) fprintf(stderr, _fmt, ##para); 86 | 87 | #endif /* !LOG_H__ */ 88 | -------------------------------------------------------------------------------- /src/opentld/main/perf.h: -------------------------------------------------------------------------------- 1 | #ifndef PERF_H__ 2 | #define PERF_H__ 3 | 4 | 5 | #include 6 | 7 | #define USECS_COUNT 1000000 8 | 9 | class perf 10 | { 11 | public: 12 | perf(); 13 | 14 | void start(); 15 | void stop(); 16 | // pause to counte time 17 | void pause(); 18 | // recovery to counte time 19 | void recovery(); 20 | 21 | // get the timeinterval(us), from start to now, 22 | // exclude the interval from pause to recovery 23 | double gettimegap(); 24 | 25 | private: 26 | struct timeval pretv; 27 | struct timeval sumtv; 28 | bool status; 29 | }; 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/opentld/main/tools/log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint32_t g_LOG_config = (BIT(LOG_EMERG)|BIT(LOG_ERROR)|BIT(LOG_ALARM)|BIT(LOG_PERFIX)); 5 | 6 | char LOG_e_str[][30] = 7 | { 8 | "LOG_NULL", 9 | "LOG_VERB", 10 | "LOG_STAT", 11 | "LOG_INFO", 12 | "LOG_DEBUG", 13 | "LOG_CONFIG", 14 | "LOG_EVENT", 15 | "LOG_WARN", 16 | "LOG_ALARM", 17 | "LOG_ERROR", 18 | "LOG_EMERG", 19 | "LOG_PERFIX", 20 | "LOG_MAX", 21 | "" 22 | }; 23 | 24 | 25 | void log_config_init() 26 | { 27 | char * temp = NULL; 28 | int len = 0, index = 0; 29 | char *log_config = NULL; 30 | 31 | if(BIT_GET(g_LOG_config, LOG_MAX)) 32 | return; 33 | g_LOG_config |= BIT(LOG_MAX); 34 | 35 | log_config = getenv("AID_LOG_CONFIG"); 36 | if(log_config == NULL) 37 | return; 38 | 39 | len = strlen(log_config); 40 | temp =(char *)malloc(len + 3); 41 | strcpy(temp, ":"); 42 | strcat(temp, log_config); 43 | strcat(temp, ":"); 44 | 45 | for(index=LOG_NULL; index 2 | #include "perf.h" 3 | 4 | 5 | perf::perf() 6 | { 7 | pretv.tv_sec = 0; 8 | pretv.tv_usec = 0; 9 | 10 | sumtv.tv_sec = 0; 11 | sumtv.tv_usec = 0; 12 | 13 | status = false; 14 | } 15 | 16 | void perf::start() 17 | { 18 | pretv.tv_sec = 0; 19 | pretv.tv_usec = 0; 20 | 21 | sumtv.tv_sec = 0; 22 | sumtv.tv_usec = 0; 23 | 24 | gettimeofday(&pretv, NULL); 25 | status = true; 26 | } 27 | void perf::stop() 28 | { 29 | pause(); 30 | } 31 | 32 | void perf::pause() 33 | { 34 | long scosts; 35 | long uscosts; 36 | struct timeval current_tv; 37 | 38 | if(status == false) 39 | return; 40 | 41 | gettimeofday(¤t_tv,NULL); 42 | 43 | scosts = current_tv.tv_sec - pretv.tv_sec + sumtv.tv_sec - 1; 44 | uscosts = current_tv.tv_usec - pretv.tv_usec + sumtv.tv_usec + USECS_COUNT; 45 | 46 | if(uscosts >= USECS_COUNT) 47 | { 48 | scosts += (uscosts / USECS_COUNT); 49 | uscosts = uscosts % USECS_COUNT; 50 | } 51 | 52 | sumtv.tv_sec = scosts; 53 | sumtv.tv_usec = uscosts; 54 | 55 | status = false; 56 | } 57 | 58 | void perf::recovery() 59 | { 60 | if(status == true) 61 | return; 62 | 63 | gettimeofday(&pretv, NULL); 64 | status = true; 65 | } 66 | 67 | double perf::gettimegap() 68 | { 69 | long scosts = 0; 70 | long uscosts = 0; 71 | double timegap = 0; 72 | struct timeval current_tv; 73 | 74 | if(status == false) 75 | { 76 | timegap = sumtv.tv_sec; 77 | timegap *= USECS_COUNT; 78 | timegap += sumtv.tv_usec; 79 | } 80 | else 81 | { 82 | gettimeofday(¤t_tv,NULL); 83 | 84 | scosts = current_tv.tv_sec - pretv.tv_sec + sumtv.tv_sec - 1; 85 | uscosts = current_tv.tv_usec - pretv.tv_usec + sumtv.tv_usec + USECS_COUNT; 86 | 87 | if(uscosts >= USECS_COUNT) 88 | { 89 | scosts += (uscosts / USECS_COUNT); 90 | uscosts = uscosts % USECS_COUNT; 91 | } 92 | 93 | timegap = scosts; 94 | timegap *= USECS_COUNT; 95 | timegap += uscosts; 96 | } 97 | 98 | return timegap; 99 | 100 | } 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/opentld/main/trackerTld.json: -------------------------------------------------------------------------------- 1 | { 2 | "learningEnabled": true, 3 | "alternating": false, 4 | "showOutput": true, 5 | "threshold": 0.5, 6 | "seed": 0, 7 | "camNo": 0, 8 | "useDsstTracker": false 9 | } 10 | --------------------------------------------------------------------------------