├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── VOT_integration ├── benchmark_wrapper │ ├── benchmark_tracker_wrapper.m │ ├── setup_tracker_paths.m │ └── vot.m └── configuration_file │ └── tracker_ECO.m ├── demo_ECO.m ├── demo_ECO_HC.m ├── demo_ECO_gpu.m ├── external_libs ├── mexResize │ ├── MxArray.cpp │ ├── MxArray.hpp │ ├── compile.m │ ├── libopencv_core.a │ ├── libopencv_core.so │ ├── libopencv_imgproc.a │ ├── libopencv_imgproc.so │ ├── mexResize.cpp │ ├── mexResize.mexa64 │ ├── mexResize.mexw64 │ ├── opencv2 │ │ ├── core │ │ │ ├── core.hpp │ │ │ ├── core_c.h │ │ │ ├── devmem2d.hpp │ │ │ ├── eigen.hpp │ │ │ ├── gpumat.hpp │ │ │ ├── internal.hpp │ │ │ ├── mat.hpp │ │ │ ├── opengl_interop.hpp │ │ │ ├── operations.hpp │ │ │ ├── types_c.h │ │ │ ├── version.hpp │ │ │ └── wimage.hpp │ │ ├── features2d │ │ │ └── features2d.hpp │ │ ├── flann │ │ │ ├── all_indices.h │ │ │ ├── allocator.h │ │ │ ├── any.h │ │ │ ├── autotuned_index.h │ │ │ ├── composite_index.h │ │ │ ├── config.h │ │ │ ├── defines.h │ │ │ ├── dist.h │ │ │ ├── dummy.h │ │ │ ├── dynamic_bitset.h │ │ │ ├── flann.hpp │ │ │ ├── flann_base.hpp │ │ │ ├── general.h │ │ │ ├── ground_truth.h │ │ │ ├── hdf5.h │ │ │ ├── heap.h │ │ │ ├── hierarchical_clustering_index.h │ │ │ ├── index_testing.h │ │ │ ├── kdtree_index.h │ │ │ ├── kdtree_single_index.h │ │ │ ├── kmeans_index.h │ │ │ ├── linear_index.h │ │ │ ├── logger.h │ │ │ ├── lsh_index.h │ │ │ ├── lsh_table.h │ │ │ ├── matrix.h │ │ │ ├── miniflann.hpp │ │ │ ├── nn_index.h │ │ │ ├── object_factory.h │ │ │ ├── params.h │ │ │ ├── random.h │ │ │ ├── result_set.h │ │ │ ├── sampling.h │ │ │ ├── saving.h │ │ │ ├── simplex_downhill.h │ │ │ └── timer.h │ │ ├── imgproc │ │ │ ├── imgproc.hpp │ │ │ ├── imgproc_c.h │ │ │ └── types_c.h │ │ ├── opencv.hpp │ │ └── opencv_modules.hpp │ ├── opencv_core242.dll │ ├── opencv_core242.lib │ ├── opencv_imgproc242.dll │ └── opencv_imgproc242.lib └── mtimesx │ ├── license.txt │ ├── mtimesx.c │ ├── mtimesx.m │ ├── mtimesx_RealTimesReal.c │ ├── mtimesx_build.m │ ├── mtimesx_sparse.m │ ├── mtimesx_test_ddequal.m │ ├── mtimesx_test_ddspeed.m │ ├── mtimesx_test_dsequal.m │ ├── mtimesx_test_dsspeed.m │ ├── mtimesx_test_nd.m │ ├── mtimesx_test_sdequal.m │ ├── mtimesx_test_sdspeed.m │ ├── mtimesx_test_ssequal.m │ └── mtimesx_test_ssspeed.m ├── feature_extraction ├── average_feature_region.m ├── extract_features.m ├── get_cnn_layers.m ├── get_colorspace.m ├── get_feature_extract_info.m ├── get_fhog.m ├── get_table_feature.m ├── init_features.m ├── integralVecImage.m ├── load_cnn.m ├── lookup_tables │ ├── CNnorm.mat │ ├── intensityChannelNorm11.mat │ ├── intensityChannelNorm16.mat │ └── intensityChannelNorm6.mat ├── sample_patch.m ├── set_cnn_input_size.m └── table_lookup.m ├── implementation ├── dim_reduction │ ├── init_projection_matrix.m │ └── project_sample.m ├── fourier_tools │ ├── cfft2.m │ ├── cifft2.m │ ├── compact_fourier_coeff.m │ ├── cubic_spline_fourier.m │ ├── full_fourier_coeff.m │ ├── interpolate_dft.m │ ├── resizeDFT.m │ ├── sample_fs.m │ ├── shift_sample.m │ └── symmetrize_filter.m ├── initialization │ ├── get_interp_fourier.m │ ├── get_reg_filter.m │ ├── init_default_params.m │ └── init_feature_params.m ├── localization │ └── optimize_scores.m ├── sample_space_model │ ├── find_gram_vector.m │ ├── find_gram_vector_gpu.m │ ├── merge_samples.m │ ├── update_distance_matrix.m │ ├── update_prior_weights.m │ ├── update_sample_space_model.m │ └── update_sample_space_model_gpu.m ├── scale_filter │ ├── extract_scale_sample.m │ ├── feature_projection_scale.m │ ├── init_scale_filter.m │ ├── scale_filter_track.m │ └── scale_filter_update.m ├── tracker.m └── training │ ├── diag_precond.m │ ├── inner_product_filter.m │ ├── inner_product_joint.m │ ├── lhs_operation.m │ ├── lhs_operation_gpu.m │ ├── lhs_operation_joint.m │ ├── lhs_operation_joint_gpu.m │ ├── pcg_ccot.m │ ├── train_filter.m │ ├── train_filter_gpu.m │ ├── train_joint.m │ └── train_joint_gpu.m ├── install.m ├── result_plots ├── OTB-2015_succsess_plot.pdf └── OTB-2015_succsess_plot.png ├── runfiles ├── OTB_DEEP_settings.m ├── OTB_HC_settings.m ├── SRDCF_settings.m ├── VOT2016_DEEP_settings.m ├── VOT2016_HC_settings.m ├── testing_ECO.m ├── testing_ECO_HC.m └── testing_ECO_gpu.m ├── sequences └── Crossing │ ├── groundtruth_rect.txt │ └── img │ ├── 0001.jpg │ ├── 0002.jpg │ ├── 0003.jpg │ ├── 0004.jpg │ ├── 0005.jpg │ ├── 0006.jpg │ ├── 0007.jpg │ ├── 0008.jpg │ ├── 0009.jpg │ ├── 0010.jpg │ ├── 0011.jpg │ ├── 0012.jpg │ ├── 0013.jpg │ ├── 0014.jpg │ ├── 0015.jpg │ ├── 0016.jpg │ ├── 0017.jpg │ ├── 0018.jpg │ ├── 0019.jpg │ ├── 0020.jpg │ ├── 0021.jpg │ ├── 0022.jpg │ ├── 0023.jpg │ ├── 0024.jpg │ ├── 0025.jpg │ ├── 0026.jpg │ ├── 0027.jpg │ ├── 0028.jpg │ ├── 0029.jpg │ ├── 0030.jpg │ ├── 0031.jpg │ ├── 0032.jpg │ ├── 0033.jpg │ ├── 0034.jpg │ ├── 0035.jpg │ ├── 0036.jpg │ ├── 0037.jpg │ ├── 0038.jpg │ ├── 0039.jpg │ ├── 0040.jpg │ ├── 0041.jpg │ ├── 0042.jpg │ ├── 0043.jpg │ ├── 0044.jpg │ ├── 0045.jpg │ ├── 0046.jpg │ ├── 0047.jpg │ ├── 0048.jpg │ ├── 0049.jpg │ ├── 0050.jpg │ ├── 0051.jpg │ ├── 0052.jpg │ ├── 0053.jpg │ ├── 0054.jpg │ ├── 0055.jpg │ ├── 0056.jpg │ ├── 0057.jpg │ ├── 0058.jpg │ ├── 0059.jpg │ ├── 0060.jpg │ ├── 0061.jpg │ ├── 0062.jpg │ ├── 0063.jpg │ ├── 0064.jpg │ ├── 0065.jpg │ ├── 0066.jpg │ ├── 0067.jpg │ ├── 0068.jpg │ ├── 0069.jpg │ ├── 0070.jpg │ ├── 0071.jpg │ ├── 0072.jpg │ ├── 0073.jpg │ ├── 0074.jpg │ ├── 0075.jpg │ ├── 0076.jpg │ ├── 0077.jpg │ ├── 0078.jpg │ ├── 0079.jpg │ ├── 0080.jpg │ ├── 0081.jpg │ ├── 0082.jpg │ ├── 0083.jpg │ ├── 0084.jpg │ ├── 0085.jpg │ ├── 0086.jpg │ ├── 0087.jpg │ ├── 0088.jpg │ ├── 0089.jpg │ ├── 0090.jpg │ ├── 0091.jpg │ ├── 0092.jpg │ ├── 0093.jpg │ ├── 0094.jpg │ ├── 0095.jpg │ ├── 0096.jpg │ ├── 0097.jpg │ ├── 0098.jpg │ ├── 0099.jpg │ ├── 0100.jpg │ ├── 0101.jpg │ ├── 0102.jpg │ ├── 0103.jpg │ ├── 0104.jpg │ ├── 0105.jpg │ ├── 0106.jpg │ ├── 0107.jpg │ ├── 0108.jpg │ ├── 0109.jpg │ ├── 0110.jpg │ ├── 0111.jpg │ ├── 0112.jpg │ ├── 0113.jpg │ ├── 0114.jpg │ ├── 0115.jpg │ ├── 0116.jpg │ ├── 0117.jpg │ ├── 0118.jpg │ ├── 0119.jpg │ └── 0120.jpg ├── setup_paths.m └── utils ├── get_sequence_frame.m ├── get_sequence_info.m ├── get_sequence_results.m ├── load_video_info.m └── report_tracking_result.m /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.asv 3 | external_libs/matconvnet/*.mexw* 4 | external_libs/matconvnet/*.mexa* 5 | external_libs/pdollar_toolbox/*.mexw* 6 | external_libs/pdollar_toolbox/*.mexa* 7 | external_libs/mtimesx/*.mexw* 8 | external_libs/mtimesx/*.mexa* 9 | feature_extraction/networks 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external_libs/matconvnet"] 2 | path = external_libs/matconvnet 3 | url = git@github.com:vlfeat/matconvnet.git 4 | ignore = dirty 5 | [submodule "external_libs/pdollar_toolbox"] 6 | path = external_libs/pdollar_toolbox 7 | url = git@github.com:pdollar/toolbox.git 8 | ignore = dirty 9 | -------------------------------------------------------------------------------- /VOT_integration/benchmark_wrapper/benchmark_tracker_wrapper.m: -------------------------------------------------------------------------------- 1 | function benchmark_tracker_wrapper(tracker_name, runfile_name, do_cleanup) 2 | 3 | if nargin < 3 4 | do_cleanup = true; 5 | end 6 | 7 | % ************************************************************* 8 | % VOT: Always call exit command at the end to terminate Matlab! 9 | % ************************************************************* 10 | if do_cleanup 11 | cleanup = onCleanup(@() exit() ); 12 | else 13 | [pathstr, ~, ~] = fileparts(mfilename('fullpath')); 14 | cd_ind = strfind(pathstr, filesep()); 15 | pathstr = pathstr(1:cd_ind(end)-1); 16 | cleanup = onCleanup(@() cd(pathstr)); 17 | end 18 | 19 | try 20 | 21 | % ************************************************************* 22 | % VOT: Set random seed to a different value every time. 23 | % ************************************************************* 24 | RandStream.setGlobalStream(RandStream('mt19937ar', 'Seed', sum(clock))); 25 | 26 | seq.format = 'vot'; 27 | 28 | setup_tracker_paths(tracker_name); 29 | 30 | disp([runfile_name '(seq, [], []);']); 31 | res = eval([runfile_name '(seq, [], []);']); 32 | 33 | catch err 34 | [wrapper_pathstr, ~, ~] = fileparts(mfilename('fullpath')); 35 | cd_ind = strfind(wrapper_pathstr, filesep()); 36 | VOT_path = wrapper_pathstr(1:cd_ind(end)); 37 | 38 | error_report_path = [VOT_path 'error_reports/']; 39 | if ~exist(error_report_path, 'dir') 40 | mkdir(error_report_path); 41 | end 42 | 43 | report_file_name = [error_report_path tracker_name '_' runfile_name datestr(now,'_yymmdd_HHMM') '.mat']; 44 | 45 | save(report_file_name, 'err') 46 | 47 | rethrow(err); 48 | end 49 | -------------------------------------------------------------------------------- /VOT_integration/benchmark_wrapper/setup_tracker_paths.m: -------------------------------------------------------------------------------- 1 | function setup_tracker_paths(tracker_name) 2 | 3 | [wrapper_path, name, ext] = fileparts(mfilename('fullpath')); 4 | 5 | addpath(wrapper_path) 6 | 7 | cd_ind = strfind(wrapper_path, filesep()); 8 | repo_path = wrapper_path(1:cd_ind(end-1)-1); 9 | 10 | addpath(repo_path); 11 | setup_paths(); -------------------------------------------------------------------------------- /VOT_integration/benchmark_wrapper/vot.m: -------------------------------------------------------------------------------- 1 | function [handle, image, region] = vot(format) 2 | % vot Initialize communication and obtain communication structure 3 | % 4 | % This function is used to initialize communication with the toolkit. 5 | % 6 | % The resulting handle is a structure provides several functions for 7 | % further interaction: 8 | % - frame(handle): Get new frame from the sequence. 9 | % - report(handle, region): Report region for current frame and advance. 10 | % - quit(handle): Closes the communication and saves the data. 11 | % 12 | % Input: 13 | % - format (string): Desired region input format. 14 | % 15 | % Output: 16 | % - handle (structure): Updated communication handle structure. 17 | % - image (string): Path to the first image file. 18 | % - region (vector): Initial region encoded as a rectangle or as a polygon. 19 | 20 | if nargin < 1 21 | format = 'rectangle'; 22 | end 23 | 24 | [handle, image, region] = tracker_initialize(format); 25 | handle.frame = @tracker_frame; 26 | handle.report = @tracker_report; 27 | handle.quit = @tracker_quit; 28 | 29 | end 30 | 31 | function [handle, image, region] = tracker_initialize(format) 32 | % tracker_initialize Initialize communication structure 33 | % 34 | % This function is used to initialize communication with the toolkit. 35 | % 36 | % Input: 37 | % - format (string): Desired region input format. 38 | % 39 | % Output: 40 | % - handle (structure): Updated communication handle structure. 41 | % - image (string): Path to the first image file. 42 | % - region (vector): Initial region encoded as a rectangle or as a polygon. 43 | 44 | if ~ismember(format, {'rectangle', 'polygon'}) 45 | error('VOT: Illegal region format.'); 46 | end; 47 | 48 | if ~isempty(getenv('TRAX_MEX')) 49 | addpath(getenv('TRAX_MEX')); 50 | end; 51 | traxserver('setup', format, 'path'); 52 | 53 | [image, region] = traxserver('wait'); 54 | 55 | handle = struct('trax', true); 56 | 57 | if isempty(image) || isempty(region) 58 | tracker_quit(handle); 59 | return; 60 | end; 61 | 62 | handle.initialization = region; 63 | 64 | end 65 | 66 | function [handle, image] = tracker_frame(handle) 67 | % tracker_frame Get new frame from the sequence 68 | % 69 | % This function is used to get new frame from the current sequence 70 | % 71 | % Input: 72 | % - handle (structure): Communication handle structure. 73 | % 74 | % Output: 75 | % - handle (structure): Updated communication handle structure. 76 | % - image (string): Path to image file. 77 | 78 | if ~isstruct(handle) 79 | error('VOT: Handle should be a structure.'); 80 | end; 81 | 82 | if ~isempty(handle.initialization) 83 | traxserver('status', handle.initialization); 84 | handle.initialization = []; 85 | end; 86 | 87 | [image, region] = traxserver('wait'); 88 | 89 | if isempty(image) || ~isempty(region) 90 | handle.quit(handle); 91 | end; 92 | 93 | end 94 | 95 | function handle = tracker_report(handle, region) 96 | % tracker_report Report region for current frame and advance 97 | % 98 | % This function stores the region for the current frame and advances 99 | % the internal counter to the next frame. 100 | % 101 | % Input: 102 | % - handle (structure): Communication handle structure. 103 | % - region (vector): Predicted region as a rectangle or a polygon. 104 | % 105 | % Output: 106 | % - handle (structure): Updated communication handle structure. 107 | 108 | if isempty(region) 109 | region = 0; 110 | end; 111 | 112 | if ~isstruct(handle) 113 | error('VOT: Handle should be a structure.'); 114 | end; 115 | 116 | if ~isempty(handle.initialization) 117 | handle.initialization = []; 118 | end; 119 | 120 | traxserver('status', region); 121 | 122 | end 123 | 124 | 125 | function tracker_quit(handle) 126 | % tracker_quit Closes the communication and saves the data 127 | % 128 | % This function closes the communication with the toolkit and 129 | % saves the remaining data. 130 | % 131 | % Input: 132 | % - handle (structure): Communication handle structure. 133 | % 134 | 135 | if ~isstruct(handle) 136 | error('VOT: Handle should be a structure.'); 137 | end; 138 | 139 | traxserver('quit'); 140 | 141 | end 142 | -------------------------------------------------------------------------------- /VOT_integration/configuration_file/tracker_ECO.m: -------------------------------------------------------------------------------- 1 | % Copy this template configuration file to your VOT workspace. 2 | % Enter the full path to the ECO repository root folder. 3 | 4 | ECO_repo_path = ######## 5 | 6 | tracker_label = 'ECO'; 7 | tracker_command = generate_matlab_command('benchmark_tracker_wrapper(''ECO'', ''VOT2016_DEEP_settings'', true)', {[ECO_repo_path '/VOT_integration/benchmark_wrapper']}); 8 | tracker_interpreter = 'matlab'; -------------------------------------------------------------------------------- /demo_ECO.m: -------------------------------------------------------------------------------- 1 | 2 | % This demo script runs the ECO tracker with deep features on the 3 | % included "Crossing" video. 4 | 5 | % Add paths 6 | setup_paths(); 7 | 8 | % Load video information 9 | video_path = 'sequences/Crossing'; 10 | [seq, ground_truth] = load_video_info(video_path); 11 | 12 | % Run ECO 13 | results = testing_ECO(seq); -------------------------------------------------------------------------------- /demo_ECO_HC.m: -------------------------------------------------------------------------------- 1 | 2 | % This demo script runs the ECO tracker with hand-crafted features on the 3 | % included "Crossing" video. 4 | 5 | % Add paths 6 | setup_paths(); 7 | 8 | % Load video information 9 | video_path = 'sequences/Crossing'; 10 | [seq, ground_truth] = load_video_info(video_path); 11 | 12 | % Run ECO 13 | results = testing_ECO_HC(seq); -------------------------------------------------------------------------------- /demo_ECO_gpu.m: -------------------------------------------------------------------------------- 1 | 2 | % This demo script runs the ECO tracker with deep features on the 3 | % included "Crossing" video. 4 | 5 | % Add paths 6 | setup_paths(); 7 | 8 | % Load video information 9 | video_path = 'sequences/Crossing'; 10 | [seq, ground_truth] = load_video_info(video_path); 11 | 12 | % Run ECO 13 | results = testing_ECO_gpu(seq); -------------------------------------------------------------------------------- /external_libs/mexResize/compile.m: -------------------------------------------------------------------------------- 1 | 2 | % Compiles the mexResize function. 3 | 4 | % Try to use the included mex files first. If they do not work, you can try 5 | % to compile it yourself with this script. If the bellow mex command does 6 | % not work, try to link to your own OpenCV installation. 7 | 8 | if ispc 9 | mex -lopencv_core242 -lopencv_imgproc242 -L./ -I./ mexResize.cpp MxArray.cpp 10 | else 11 | mex -lopencv_core -lopencv_imgproc -L./ -I./ mexResize.cpp MxArray.cpp 12 | end -------------------------------------------------------------------------------- /external_libs/mexResize/libopencv_core.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/libopencv_core.a -------------------------------------------------------------------------------- /external_libs/mexResize/libopencv_core.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/libopencv_core.so -------------------------------------------------------------------------------- /external_libs/mexResize/libopencv_imgproc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/libopencv_imgproc.a -------------------------------------------------------------------------------- /external_libs/mexResize/libopencv_imgproc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/libopencv_imgproc.so -------------------------------------------------------------------------------- /external_libs/mexResize/mexResize.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "mex.h" 5 | #include "MxArray.hpp" 6 | #include 7 | 8 | #include 9 | 10 | using namespace std; 11 | using namespace cv; 12 | 13 | /* 14 | * Use opencv function to resample image quickly 15 | */ 16 | 17 | // matlab entry point 18 | // dst = resize(src, scale) 19 | // image should be color with double values 20 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 21 | if (nrhs < 2){ 22 | mexErrMsgTxt("Wrong number of inputs"); 23 | } 24 | if (nlhs != 1){ 25 | mexErrMsgTxt("Wrong number of outputs"); 26 | } 27 | 28 | vector rhs(prhs,prhs+nrhs); 29 | 30 | //convert input data to opencv matrix 31 | Mat img = rhs[0].toMat(); 32 | Mat imgr; 33 | Size s = rhs[1].toSize(); 34 | Size newSize = Size(s.height,s.width); 35 | Size oldSize = img.size(); 36 | //interpolation method 37 | int interpolation = INTER_LINEAR; 38 | 39 | //if interpolation method provided set it 40 | if(nrhs == 3){ 41 | string interp = rhs[2].toString(); 42 | if(interp.compare("antialias") == 0){ 43 | interpolation = INTER_AREA; 44 | }else if(interp.compare("linear") == 0){ 45 | interpolation = INTER_LINEAR; 46 | }else if(interp.compare("auto") == 0){ //if we are zooming, use linear else use area interpolation 47 | //old array has width and height swapped, newArray does not 48 | if(newSize.width > oldSize.height){ 49 | interpolation = INTER_LINEAR; 50 | }else{ 51 | interpolation = INTER_AREA; 52 | } 53 | }else{ 54 | mexErrMsgTxt("Invalid interpolation provided, valid is linear (default), antialias, auto"); 55 | } 56 | } 57 | 58 | //use opencv resize function 59 | resize(img,imgr,newSize,0,0,interpolation); 60 | //convert back to matlab representation 61 | plhs[0] = MxArray(imgr); 62 | } 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /external_libs/mexResize/mexResize.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/mexResize.mexa64 -------------------------------------------------------------------------------- /external_libs/mexResize/mexResize.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/mexResize.mexw64 -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/core/version.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 | // 10 | // Intel License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright( C) 2000, Intel Corporation, all rights reserved. 14 | // Third party copyrights are property of their respective owners. 15 | // 16 | // Redistribution and use in source and binary forms, with or without modification, 17 | // are permitted provided that the following conditions are met: 18 | // 19 | // * Redistribution's of source code must retain the above copyright notice, 20 | // this list of conditions and the following disclaimer. 21 | // 22 | // * Redistribution's in binary form must reproduce the above copyright notice, 23 | // this list of conditions and the following disclaimer in the documentation 24 | // and/or other materials provided with the distribution. 25 | // 26 | // * The name of Intel Corporation may not be used to endorse or promote products 27 | // derived from this software without specific prior written permission. 28 | // 29 | // This software is provided by the copyright holders and contributors "as is" and 30 | // any express or implied warranties, including, but not limited to, the implied 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 | // In no event shall the Intel Corporation or contributors be liable for any direct, 33 | // indirect, incidental, special, exemplary, or consequential damages 34 | //(including, but not limited to, procurement of substitute goods or services; 35 | // loss of use, data, or profits; or business interruption) however caused 36 | // and on any theory of liability, whether in contract, strict liability, 37 | // or tort(including negligence or otherwise) arising in any way out of 38 | // the use of this software, even if advised of the possibility of such damage. 39 | // 40 | //M*/ 41 | 42 | /* 43 | definition of the current version of OpenCV 44 | Usefull to test in user programs 45 | */ 46 | 47 | #ifndef __OPENCV_VERSION_HPP__ 48 | #define __OPENCV_VERSION_HPP__ 49 | 50 | #define CV_MAJOR_VERSION 2 51 | #define CV_MINOR_VERSION 4 52 | #define CV_SUBMINOR_VERSION 2 53 | 54 | #define CVAUX_STR_EXP(__A) #__A 55 | #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) 56 | #define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/all_indices.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_ALL_INDICES_H_ 31 | #define OPENCV_FLANN_ALL_INDICES_H_ 32 | 33 | #include "general.h" 34 | 35 | #include "nn_index.h" 36 | #include "kdtree_index.h" 37 | #include "kdtree_single_index.h" 38 | #include "kmeans_index.h" 39 | #include "composite_index.h" 40 | #include "linear_index.h" 41 | #include "hierarchical_clustering_index.h" 42 | #include "lsh_index.h" 43 | #include "autotuned_index.h" 44 | 45 | 46 | namespace cvflann 47 | { 48 | 49 | template 50 | struct index_creator 51 | { 52 | static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) 53 | { 54 | flann_algorithm_t index_type = get_param(params, "algorithm"); 55 | 56 | NNIndex* nnIndex; 57 | switch (index_type) { 58 | case FLANN_INDEX_LINEAR: 59 | nnIndex = new LinearIndex(dataset, params, distance); 60 | break; 61 | case FLANN_INDEX_KDTREE_SINGLE: 62 | nnIndex = new KDTreeSingleIndex(dataset, params, distance); 63 | break; 64 | case FLANN_INDEX_KDTREE: 65 | nnIndex = new KDTreeIndex(dataset, params, distance); 66 | break; 67 | case FLANN_INDEX_KMEANS: 68 | nnIndex = new KMeansIndex(dataset, params, distance); 69 | break; 70 | case FLANN_INDEX_COMPOSITE: 71 | nnIndex = new CompositeIndex(dataset, params, distance); 72 | break; 73 | case FLANN_INDEX_AUTOTUNED: 74 | nnIndex = new AutotunedIndex(dataset, params, distance); 75 | break; 76 | case FLANN_INDEX_HIERARCHICAL: 77 | nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); 78 | break; 79 | case FLANN_INDEX_LSH: 80 | nnIndex = new LshIndex(dataset, params, distance); 81 | break; 82 | default: 83 | throw FLANNException("Unknown index type"); 84 | } 85 | 86 | return nnIndex; 87 | } 88 | }; 89 | 90 | template 91 | struct index_creator 92 | { 93 | static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) 94 | { 95 | flann_algorithm_t index_type = get_param(params, "algorithm"); 96 | 97 | NNIndex* nnIndex; 98 | switch (index_type) { 99 | case FLANN_INDEX_LINEAR: 100 | nnIndex = new LinearIndex(dataset, params, distance); 101 | break; 102 | case FLANN_INDEX_KMEANS: 103 | nnIndex = new KMeansIndex(dataset, params, distance); 104 | break; 105 | case FLANN_INDEX_HIERARCHICAL: 106 | nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); 107 | break; 108 | case FLANN_INDEX_LSH: 109 | nnIndex = new LshIndex(dataset, params, distance); 110 | break; 111 | default: 112 | throw FLANNException("Unknown index type"); 113 | } 114 | 115 | return nnIndex; 116 | } 117 | }; 118 | 119 | template 120 | struct index_creator 121 | { 122 | static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) 123 | { 124 | flann_algorithm_t index_type = get_param(params, "algorithm"); 125 | 126 | NNIndex* nnIndex; 127 | switch (index_type) { 128 | case FLANN_INDEX_LINEAR: 129 | nnIndex = new LinearIndex(dataset, params, distance); 130 | break; 131 | case FLANN_INDEX_HIERARCHICAL: 132 | nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); 133 | break; 134 | case FLANN_INDEX_LSH: 135 | nnIndex = new LshIndex(dataset, params, distance); 136 | break; 137 | default: 138 | throw FLANNException("Unknown index type"); 139 | } 140 | 141 | return nnIndex; 142 | } 143 | }; 144 | 145 | template 146 | NNIndex* create_index_by_type(const Matrix& dataset, const IndexParams& params, const Distance& distance) 147 | { 148 | return index_creator::create(dataset, params,distance); 151 | } 152 | 153 | } 154 | 155 | #endif /* OPENCV_FLANN_ALL_INDICES_H_ */ 156 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_CONFIG_H_ 31 | #define OPENCV_FLANN_CONFIG_H_ 32 | 33 | #ifdef FLANN_VERSION_ 34 | #undef FLANN_VERSION_ 35 | #endif 36 | #define FLANN_VERSION_ "1.6.10" 37 | 38 | #endif /* OPENCV_FLANN_CONFIG_H_ */ 39 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/defines.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_DEFINES_H_ 31 | #define OPENCV_FLANN_DEFINES_H_ 32 | 33 | #include "config.h" 34 | 35 | #ifdef FLANN_EXPORT 36 | #undef FLANN_EXPORT 37 | #endif 38 | #ifdef WIN32 39 | /* win32 dll export/import directives */ 40 | #ifdef FLANN_EXPORTS 41 | #define FLANN_EXPORT __declspec(dllexport) 42 | #elif defined(FLANN_STATIC) 43 | #define FLANN_EXPORT 44 | #else 45 | #define FLANN_EXPORT __declspec(dllimport) 46 | #endif 47 | #else 48 | /* unix needs nothing */ 49 | #define FLANN_EXPORT 50 | #endif 51 | 52 | 53 | #ifdef FLANN_DEPRECATED 54 | #undef FLANN_DEPRECATED 55 | #endif 56 | #ifdef __GNUC__ 57 | #define FLANN_DEPRECATED __attribute__ ((deprecated)) 58 | #elif defined(_MSC_VER) 59 | #define FLANN_DEPRECATED __declspec(deprecated) 60 | #else 61 | #pragma message("WARNING: You need to implement FLANN_DEPRECATED for this compiler") 62 | #define FLANN_DEPRECATED 63 | #endif 64 | 65 | 66 | #undef FLANN_PLATFORM_32_BIT 67 | #undef FLANN_PLATFORM_64_BIT 68 | #if defined __amd64__ || defined __x86_64__ || defined _WIN64 || defined _M_X64 69 | #define FLANN_PLATFORM_64_BIT 70 | #else 71 | #define FLANN_PLATFORM_32_BIT 72 | #endif 73 | 74 | 75 | #undef FLANN_ARRAY_LEN 76 | #define FLANN_ARRAY_LEN(a) (sizeof(a)/sizeof(a[0])) 77 | 78 | namespace cvflann { 79 | 80 | /* Nearest neighbour index algorithms */ 81 | enum flann_algorithm_t 82 | { 83 | FLANN_INDEX_LINEAR = 0, 84 | FLANN_INDEX_KDTREE = 1, 85 | FLANN_INDEX_KMEANS = 2, 86 | FLANN_INDEX_COMPOSITE = 3, 87 | FLANN_INDEX_KDTREE_SINGLE = 4, 88 | FLANN_INDEX_HIERARCHICAL = 5, 89 | FLANN_INDEX_LSH = 6, 90 | FLANN_INDEX_SAVED = 254, 91 | FLANN_INDEX_AUTOTUNED = 255, 92 | 93 | // deprecated constants, should use the FLANN_INDEX_* ones instead 94 | LINEAR = 0, 95 | KDTREE = 1, 96 | KMEANS = 2, 97 | COMPOSITE = 3, 98 | KDTREE_SINGLE = 4, 99 | SAVED = 254, 100 | AUTOTUNED = 255 101 | }; 102 | 103 | 104 | 105 | enum flann_centers_init_t 106 | { 107 | FLANN_CENTERS_RANDOM = 0, 108 | FLANN_CENTERS_GONZALES = 1, 109 | FLANN_CENTERS_KMEANSPP = 2, 110 | 111 | // deprecated constants, should use the FLANN_CENTERS_* ones instead 112 | CENTERS_RANDOM = 0, 113 | CENTERS_GONZALES = 1, 114 | CENTERS_KMEANSPP = 2 115 | }; 116 | 117 | enum flann_log_level_t 118 | { 119 | FLANN_LOG_NONE = 0, 120 | FLANN_LOG_FATAL = 1, 121 | FLANN_LOG_ERROR = 2, 122 | FLANN_LOG_WARN = 3, 123 | FLANN_LOG_INFO = 4 124 | }; 125 | 126 | enum flann_distance_t 127 | { 128 | FLANN_DIST_EUCLIDEAN = 1, 129 | FLANN_DIST_L2 = 1, 130 | FLANN_DIST_MANHATTAN = 2, 131 | FLANN_DIST_L1 = 2, 132 | FLANN_DIST_MINKOWSKI = 3, 133 | FLANN_DIST_MAX = 4, 134 | FLANN_DIST_HIST_INTERSECT = 5, 135 | FLANN_DIST_HELLINGER = 6, 136 | FLANN_DIST_CHI_SQUARE = 7, 137 | FLANN_DIST_CS = 7, 138 | FLANN_DIST_KULLBACK_LEIBLER = 8, 139 | FLANN_DIST_KL = 8, 140 | 141 | // deprecated constants, should use the FLANN_DIST_* ones instead 142 | EUCLIDEAN = 1, 143 | MANHATTAN = 2, 144 | MINKOWSKI = 3, 145 | MAX_DIST = 4, 146 | HIST_INTERSECT = 5, 147 | HELLINGER = 6, 148 | CS = 7, 149 | KL = 8, 150 | KULLBACK_LEIBLER = 8 151 | }; 152 | 153 | enum flann_datatype_t 154 | { 155 | FLANN_INT8 = 0, 156 | FLANN_INT16 = 1, 157 | FLANN_INT32 = 2, 158 | FLANN_INT64 = 3, 159 | FLANN_UINT8 = 4, 160 | FLANN_UINT16 = 5, 161 | FLANN_UINT32 = 6, 162 | FLANN_UINT64 = 7, 163 | FLANN_FLOAT32 = 8, 164 | FLANN_FLOAT64 = 9 165 | }; 166 | 167 | enum 168 | { 169 | FLANN_CHECKS_UNLIMITED = -1, 170 | FLANN_CHECKS_AUTOTUNED = -2 171 | }; 172 | 173 | } 174 | 175 | #endif /* OPENCV_FLANN_DEFINES_H_ */ 176 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/dummy.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef OPENCV_FLANN_DUMMY_H_ 3 | #define OPENCV_FLANN_DUMMY_H_ 4 | 5 | namespace cvflann 6 | { 7 | 8 | #if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS 9 | __declspec(dllexport) 10 | #endif 11 | void dummyfunc(); 12 | 13 | } 14 | 15 | 16 | #endif /* OPENCV_FLANN_DUMMY_H_ */ 17 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/dynamic_bitset.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | /*********************************************************************** 32 | * Author: Vincent Rabaud 33 | *************************************************************************/ 34 | 35 | #ifndef OPENCV_FLANN_DYNAMIC_BITSET_H_ 36 | #define OPENCV_FLANN_DYNAMIC_BITSET_H_ 37 | 38 | #ifndef FLANN_USE_BOOST 39 | # define FLANN_USE_BOOST 0 40 | #endif 41 | //#define FLANN_USE_BOOST 1 42 | #if FLANN_USE_BOOST 43 | #include 44 | typedef boost::dynamic_bitset<> DynamicBitset; 45 | #else 46 | 47 | #include 48 | 49 | #include "dist.h" 50 | 51 | namespace cvflann { 52 | 53 | /** Class re-implementing the boost version of it 54 | * This helps not depending on boost, it also does not do the bound checks 55 | * and has a way to reset a block for speed 56 | */ 57 | class DynamicBitset 58 | { 59 | public: 60 | /** @param default constructor 61 | */ 62 | DynamicBitset() 63 | { 64 | } 65 | 66 | /** @param only constructor we use in our code 67 | * @param the size of the bitset (in bits) 68 | */ 69 | DynamicBitset(size_t sz) 70 | { 71 | resize(sz); 72 | reset(); 73 | } 74 | 75 | /** Sets all the bits to 0 76 | */ 77 | void clear() 78 | { 79 | std::fill(bitset_.begin(), bitset_.end(), 0); 80 | } 81 | 82 | /** @brief checks if the bitset is empty 83 | * @return true if the bitset is empty 84 | */ 85 | bool empty() const 86 | { 87 | return bitset_.empty(); 88 | } 89 | 90 | /** @param set all the bits to 0 91 | */ 92 | void reset() 93 | { 94 | std::fill(bitset_.begin(), bitset_.end(), 0); 95 | } 96 | 97 | /** @brief set one bit to 0 98 | * @param 99 | */ 100 | void reset(size_t index) 101 | { 102 | bitset_[index / cell_bit_size_] &= ~(size_t(1) << (index % cell_bit_size_)); 103 | } 104 | 105 | /** @brief sets a specific bit to 0, and more bits too 106 | * This function is useful when resetting a given set of bits so that the 107 | * whole bitset ends up being 0: if that's the case, we don't care about setting 108 | * other bits to 0 109 | * @param 110 | */ 111 | void reset_block(size_t index) 112 | { 113 | bitset_[index / cell_bit_size_] = 0; 114 | } 115 | 116 | /** @param resize the bitset so that it contains at least size bits 117 | * @param size 118 | */ 119 | void resize(size_t sz) 120 | { 121 | size_ = sz; 122 | bitset_.resize(sz / cell_bit_size_ + 1); 123 | } 124 | 125 | /** @param set a bit to true 126 | * @param index the index of the bit to set to 1 127 | */ 128 | void set(size_t index) 129 | { 130 | bitset_[index / cell_bit_size_] |= size_t(1) << (index % cell_bit_size_); 131 | } 132 | 133 | /** @param gives the number of contained bits 134 | */ 135 | size_t size() const 136 | { 137 | return size_; 138 | } 139 | 140 | /** @param check if a bit is set 141 | * @param index the index of the bit to check 142 | * @return true if the bit is set 143 | */ 144 | bool test(size_t index) const 145 | { 146 | return (bitset_[index / cell_bit_size_] & (size_t(1) << (index % cell_bit_size_))) != 0; 147 | } 148 | 149 | private: 150 | std::vector bitset_; 151 | size_t size_; 152 | static const unsigned int cell_bit_size_ = CHAR_BIT * sizeof(size_t); 153 | }; 154 | 155 | } // namespace cvflann 156 | 157 | #endif 158 | 159 | #endif // OPENCV_FLANN_DYNAMIC_BITSET_H_ 160 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/general.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_GENERAL_H_ 32 | #define OPENCV_FLANN_GENERAL_H_ 33 | 34 | #include "defines.h" 35 | #include 36 | #include 37 | 38 | namespace cvflann 39 | { 40 | 41 | class FLANNException : public std::runtime_error 42 | { 43 | public: 44 | FLANNException(const char* message) : std::runtime_error(message) { } 45 | 46 | FLANNException(const std::string& message) : std::runtime_error(message) { } 47 | }; 48 | 49 | } 50 | 51 | 52 | #endif /* OPENCV_FLANN_GENERAL_H_ */ 53 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/ground_truth.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_GROUND_TRUTH_H_ 32 | #define OPENCV_FLANN_GROUND_TRUTH_H_ 33 | 34 | #include "dist.h" 35 | #include "matrix.h" 36 | 37 | 38 | namespace cvflann 39 | { 40 | 41 | template 42 | void find_nearest(const Matrix& dataset, typename Distance::ElementType* query, int* matches, int nn, 43 | int skip = 0, Distance distance = Distance()) 44 | { 45 | typedef typename Distance::ElementType ElementType; 46 | typedef typename Distance::ResultType DistanceType; 47 | int n = nn + skip; 48 | 49 | std::vector match(n); 50 | std::vector dists(n); 51 | 52 | dists[0] = distance(dataset[0], query, dataset.cols); 53 | match[0] = 0; 54 | int dcnt = 1; 55 | 56 | for (size_t i=1; i=1 && dists[j] 84 | void compute_ground_truth(const Matrix& dataset, const Matrix& testset, Matrix& matches, 85 | int skip=0, Distance d = Distance()) 86 | { 87 | for (size_t i=0; i(dataset, testset[i], matches[i], (int)matches.cols, skip, d); 89 | } 90 | } 91 | 92 | 93 | } 94 | 95 | #endif //OPENCV_FLANN_GROUND_TRUTH_H_ 96 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/heap.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_HEAP_H_ 32 | #define OPENCV_FLANN_HEAP_H_ 33 | 34 | #include 35 | #include 36 | 37 | namespace cvflann 38 | { 39 | 40 | /** 41 | * Priority Queue Implementation 42 | * 43 | * The priority queue is implemented with a heap. A heap is a complete 44 | * (full) binary tree in which each parent is less than both of its 45 | * children, but the order of the children is unspecified. 46 | */ 47 | template 48 | class Heap 49 | { 50 | 51 | /** 52 | * Storage array for the heap. 53 | * Type T must be comparable. 54 | */ 55 | std::vector heap; 56 | int length; 57 | 58 | /** 59 | * Number of element in the heap 60 | */ 61 | int count; 62 | 63 | 64 | 65 | public: 66 | /** 67 | * Constructor. 68 | * 69 | * Params: 70 | * sz = heap size 71 | */ 72 | 73 | Heap(int sz) 74 | { 75 | length = sz; 76 | heap.reserve(length); 77 | count = 0; 78 | } 79 | 80 | /** 81 | * 82 | * Returns: heap size 83 | */ 84 | int size() 85 | { 86 | return count; 87 | } 88 | 89 | /** 90 | * Tests if the heap is empty 91 | * 92 | * Returns: true is heap empty, false otherwise 93 | */ 94 | bool empty() 95 | { 96 | return size()==0; 97 | } 98 | 99 | /** 100 | * Clears the heap. 101 | */ 102 | void clear() 103 | { 104 | heap.clear(); 105 | count = 0; 106 | } 107 | 108 | struct CompareT 109 | { 110 | bool operator()(const T& t_1, const T& t_2) const 111 | { 112 | return t_2 < t_1; 113 | } 114 | }; 115 | 116 | /** 117 | * Insert a new element in the heap. 118 | * 119 | * We select the next empty leaf node, and then keep moving any larger 120 | * parents down until the right location is found to store this element. 121 | * 122 | * Params: 123 | * value = the new element to be inserted in the heap 124 | */ 125 | void insert(T value) 126 | { 127 | /* If heap is full, then return without adding this element. */ 128 | if (count == length) { 129 | return; 130 | } 131 | 132 | heap.push_back(value); 133 | static CompareT compareT; 134 | std::push_heap(heap.begin(), heap.end(), compareT); 135 | ++count; 136 | } 137 | 138 | 139 | 140 | /** 141 | * Returns the node of minimum value from the heap (top of the heap). 142 | * 143 | * Params: 144 | * value = out parameter used to return the min element 145 | * Returns: false if heap empty 146 | */ 147 | bool popMin(T& value) 148 | { 149 | if (count == 0) { 150 | return false; 151 | } 152 | 153 | value = heap[0]; 154 | static CompareT compareT; 155 | std::pop_heap(heap.begin(), heap.end(), compareT); 156 | heap.pop_back(); 157 | --count; 158 | 159 | return true; /* Return old last node. */ 160 | } 161 | }; 162 | 163 | } 164 | 165 | #endif //OPENCV_FLANN_HEAP_H_ 166 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/linear_index.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_LINEAR_INDEX_H_ 32 | #define OPENCV_FLANN_LINEAR_INDEX_H_ 33 | 34 | #include "general.h" 35 | #include "nn_index.h" 36 | 37 | namespace cvflann 38 | { 39 | 40 | struct LinearIndexParams : public IndexParams 41 | { 42 | LinearIndexParams() 43 | { 44 | (* this)["algorithm"] = FLANN_INDEX_LINEAR; 45 | } 46 | }; 47 | 48 | template 49 | class LinearIndex : public NNIndex 50 | { 51 | public: 52 | 53 | typedef typename Distance::ElementType ElementType; 54 | typedef typename Distance::ResultType DistanceType; 55 | 56 | 57 | LinearIndex(const Matrix& inputData, const IndexParams& params = LinearIndexParams(), 58 | Distance d = Distance()) : 59 | dataset_(inputData), index_params_(params), distance_(d) 60 | { 61 | } 62 | 63 | LinearIndex(const LinearIndex&); 64 | LinearIndex& operator=(const LinearIndex&); 65 | 66 | flann_algorithm_t getType() const 67 | { 68 | return FLANN_INDEX_LINEAR; 69 | } 70 | 71 | 72 | size_t size() const 73 | { 74 | return dataset_.rows; 75 | } 76 | 77 | size_t veclen() const 78 | { 79 | return dataset_.cols; 80 | } 81 | 82 | 83 | int usedMemory() const 84 | { 85 | return 0; 86 | } 87 | 88 | void buildIndex() 89 | { 90 | /* nothing to do here for linear search */ 91 | } 92 | 93 | void saveIndex(FILE*) 94 | { 95 | /* nothing to do here for linear search */ 96 | } 97 | 98 | 99 | void loadIndex(FILE*) 100 | { 101 | /* nothing to do here for linear search */ 102 | 103 | index_params_["algorithm"] = getType(); 104 | } 105 | 106 | void findNeighbors(ResultSet& resultSet, const ElementType* vec, const SearchParams& /*searchParams*/) 107 | { 108 | ElementType* data = dataset_.data; 109 | for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) { 110 | DistanceType dist = distance_(data, vec, dataset_.cols); 111 | resultSet.addPoint(dist, (int)i); 112 | } 113 | } 114 | 115 | IndexParams getParameters() const 116 | { 117 | return index_params_; 118 | } 119 | 120 | private: 121 | /** The dataset */ 122 | const Matrix dataset_; 123 | /** Index parameters */ 124 | IndexParams index_params_; 125 | /** Index distance */ 126 | Distance distance_; 127 | 128 | }; 129 | 130 | } 131 | 132 | #endif // OPENCV_FLANN_LINEAR_INDEX_H_ 133 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/logger.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_LOGGER_H 32 | #define OPENCV_FLANN_LOGGER_H 33 | 34 | #include 35 | #include 36 | 37 | #include "defines.h" 38 | 39 | 40 | namespace cvflann 41 | { 42 | 43 | class Logger 44 | { 45 | Logger() : stream(stdout), logLevel(FLANN_LOG_WARN) {} 46 | 47 | ~Logger() 48 | { 49 | if ((stream!=NULL)&&(stream!=stdout)) { 50 | fclose(stream); 51 | } 52 | } 53 | 54 | static Logger& instance() 55 | { 56 | static Logger logger; 57 | return logger; 58 | } 59 | 60 | void _setDestination(const char* name) 61 | { 62 | if (name==NULL) { 63 | stream = stdout; 64 | } 65 | else { 66 | stream = fopen(name,"w"); 67 | if (stream == NULL) { 68 | stream = stdout; 69 | } 70 | } 71 | } 72 | 73 | int _log(int level, const char* fmt, va_list arglist) 74 | { 75 | if (level > logLevel ) return -1; 76 | int ret = vfprintf(stream, fmt, arglist); 77 | return ret; 78 | } 79 | 80 | public: 81 | /** 82 | * Sets the logging level. All messages with lower priority will be ignored. 83 | * @param level Logging level 84 | */ 85 | static void setLevel(int level) { instance().logLevel = level; } 86 | 87 | /** 88 | * Sets the logging destination 89 | * @param name Filename or NULL for console 90 | */ 91 | static void setDestination(const char* name) { instance()._setDestination(name); } 92 | 93 | /** 94 | * Print log message 95 | * @param level Log level 96 | * @param fmt Message format 97 | * @return 98 | */ 99 | static int log(int level, const char* fmt, ...) 100 | { 101 | va_list arglist; 102 | va_start(arglist, fmt); 103 | int ret = instance()._log(level,fmt,arglist); 104 | va_end(arglist); 105 | return ret; 106 | } 107 | 108 | #define LOG_METHOD(NAME,LEVEL) \ 109 | static int NAME(const char* fmt, ...) \ 110 | { \ 111 | va_list ap; \ 112 | va_start(ap, fmt); \ 113 | int ret = instance()._log(LEVEL, fmt, ap); \ 114 | va_end(ap); \ 115 | return ret; \ 116 | } 117 | 118 | LOG_METHOD(fatal, FLANN_LOG_FATAL) 119 | LOG_METHOD(error, FLANN_LOG_ERROR) 120 | LOG_METHOD(warn, FLANN_LOG_WARN) 121 | LOG_METHOD(info, FLANN_LOG_INFO) 122 | 123 | private: 124 | FILE* stream; 125 | int logLevel; 126 | }; 127 | 128 | } 129 | 130 | #endif //OPENCV_FLANN_LOGGER_H 131 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/matrix.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_DATASET_H_ 32 | #define OPENCV_FLANN_DATASET_H_ 33 | 34 | #include 35 | 36 | #include "general.h" 37 | 38 | namespace cvflann 39 | { 40 | 41 | /** 42 | * Class that implements a simple rectangular matrix stored in a memory buffer and 43 | * provides convenient matrix-like access using the [] operators. 44 | */ 45 | template 46 | class Matrix 47 | { 48 | public: 49 | typedef T type; 50 | 51 | size_t rows; 52 | size_t cols; 53 | size_t stride; 54 | T* data; 55 | 56 | Matrix() : rows(0), cols(0), stride(0), data(NULL) 57 | { 58 | } 59 | 60 | Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) : 61 | rows(rows_), cols(cols_), stride(stride_), data(data_) 62 | { 63 | if (stride==0) stride = cols; 64 | } 65 | 66 | /** 67 | * Convenience function for deallocating the storage data. 68 | */ 69 | FLANN_DEPRECATED void free() 70 | { 71 | fprintf(stderr, "The cvflann::Matrix::free() method is deprecated " 72 | "and it does not do any memory deallocation any more. You are" 73 | "responsible for deallocating the matrix memory (by doing" 74 | "'delete[] matrix.data' for example)"); 75 | } 76 | 77 | /** 78 | * Operator that return a (pointer to a) row of the data. 79 | */ 80 | T* operator[](size_t index) const 81 | { 82 | return data+index*stride; 83 | } 84 | }; 85 | 86 | 87 | class UntypedMatrix 88 | { 89 | public: 90 | size_t rows; 91 | size_t cols; 92 | void* data; 93 | flann_datatype_t type; 94 | 95 | UntypedMatrix(void* data_, long rows_, long cols_) : 96 | rows(rows_), cols(cols_), data(data_) 97 | { 98 | } 99 | 100 | ~UntypedMatrix() 101 | { 102 | } 103 | 104 | 105 | template 106 | Matrix as() 107 | { 108 | return Matrix((T*)data, rows, cols); 109 | } 110 | }; 111 | 112 | 113 | 114 | } 115 | 116 | #endif //OPENCV_FLANN_DATASET_H_ 117 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/miniflann.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 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 15 | // Third party copyrights are property of their respective owners. 16 | // 17 | // Redistribution and use in source and binary forms, with or without modification, 18 | // are permitted provided that the following conditions are met: 19 | // 20 | // * Redistribution's of source code must retain the above copyright notice, 21 | // this list of conditions and the following disclaimer. 22 | // 23 | // * Redistribution's in binary form must reproduce the above copyright notice, 24 | // this list of conditions and the following disclaimer in the documentation 25 | // and/or other materials provided with the distribution. 26 | // 27 | // * The name of the copyright holders may not be used to endorse or promote products 28 | // derived from this software without specific prior written permission. 29 | // 30 | // This software is provided by the copyright holders and contributors "as is" and 31 | // any express or implied warranties, including, but not limited to, the implied 32 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 33 | // In no event shall the Intel Corporation or contributors be liable for any direct, 34 | // indirect, incidental, special, exemplary, or consequential damages 35 | // (including, but not limited to, procurement of substitute goods or services; 36 | // loss of use, data, or profits; or business interruption) however caused 37 | // and on any theory of liability, whether in contract, strict liability, 38 | // or tort (including negligence or otherwise) arising in any way out of 39 | // the use of this software, even if advised of the possibility of such damage. 40 | // 41 | //M*/ 42 | 43 | #ifndef _OPENCV_MINIFLANN_HPP_ 44 | #define _OPENCV_MINIFLANN_HPP_ 45 | 46 | #ifdef __cplusplus 47 | 48 | #include "opencv2/core/core.hpp" 49 | #include "opencv2/flann/defines.h" 50 | 51 | namespace cv 52 | { 53 | 54 | namespace flann 55 | { 56 | 57 | struct CV_EXPORTS IndexParams 58 | { 59 | IndexParams(); 60 | ~IndexParams(); 61 | 62 | std::string getString(const std::string& key, const std::string& defaultVal=std::string()) const; 63 | int getInt(const std::string& key, int defaultVal=-1) const; 64 | double getDouble(const std::string& key, double defaultVal=-1) const; 65 | 66 | void setString(const std::string& key, const std::string& value); 67 | void setInt(const std::string& key, int value); 68 | void setDouble(const std::string& key, double value); 69 | void setFloat(const std::string& key, float value); 70 | void setBool(const std::string& key, bool value); 71 | void setAlgorithm(int value); 72 | 73 | void getAll(std::vector& names, 74 | std::vector& types, 75 | std::vector& strValues, 76 | std::vector& numValues) const; 77 | 78 | void* params; 79 | }; 80 | 81 | struct CV_EXPORTS KDTreeIndexParams : public IndexParams 82 | { 83 | KDTreeIndexParams(int trees=4); 84 | }; 85 | 86 | struct CV_EXPORTS LinearIndexParams : public IndexParams 87 | { 88 | LinearIndexParams(); 89 | }; 90 | 91 | struct CV_EXPORTS CompositeIndexParams : public IndexParams 92 | { 93 | CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, 94 | cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2 ); 95 | }; 96 | 97 | struct CV_EXPORTS AutotunedIndexParams : public IndexParams 98 | { 99 | AutotunedIndexParams(float target_precision = 0.8, float build_weight = 0.01, 100 | float memory_weight = 0, float sample_fraction = 0.1); 101 | }; 102 | 103 | struct CV_EXPORTS KMeansIndexParams : public IndexParams 104 | { 105 | KMeansIndexParams(int branching = 32, int iterations = 11, 106 | cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2 ); 107 | }; 108 | 109 | struct CV_EXPORTS LshIndexParams : public IndexParams 110 | { 111 | LshIndexParams(int table_number, int key_size, int multi_probe_level); 112 | }; 113 | 114 | struct CV_EXPORTS SavedIndexParams : public IndexParams 115 | { 116 | SavedIndexParams(const std::string& filename); 117 | }; 118 | 119 | struct CV_EXPORTS SearchParams : public IndexParams 120 | { 121 | SearchParams( int checks = 32, float eps = 0, bool sorted = true ); 122 | }; 123 | 124 | class CV_EXPORTS_W Index 125 | { 126 | public: 127 | CV_WRAP Index(); 128 | CV_WRAP Index(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); 129 | virtual ~Index(); 130 | 131 | CV_WRAP virtual void build(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); 132 | CV_WRAP virtual void knnSearch(InputArray query, OutputArray indices, 133 | OutputArray dists, int knn, const SearchParams& params=SearchParams()); 134 | 135 | CV_WRAP virtual int radiusSearch(InputArray query, OutputArray indices, 136 | OutputArray dists, double radius, int maxResults, 137 | const SearchParams& params=SearchParams()); 138 | 139 | CV_WRAP virtual void save(const std::string& filename) const; 140 | CV_WRAP virtual bool load(InputArray features, const std::string& filename); 141 | CV_WRAP virtual void release(); 142 | CV_WRAP cvflann::flann_distance_t getDistance() const; 143 | CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const; 144 | 145 | protected: 146 | cvflann::flann_distance_t distType; 147 | cvflann::flann_algorithm_t algo; 148 | int featureType; 149 | void* index; 150 | }; 151 | 152 | } } // namespace cv::flann 153 | 154 | #endif // __cplusplus 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/object_factory.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_OBJECT_FACTORY_H_ 32 | #define OPENCV_FLANN_OBJECT_FACTORY_H_ 33 | 34 | #include 35 | 36 | namespace cvflann 37 | { 38 | 39 | class CreatorNotFound 40 | { 41 | }; 42 | 43 | template 46 | class ObjectFactory 47 | { 48 | typedef ObjectFactory ThisClass; 49 | typedef std::map ObjectRegistry; 50 | 51 | // singleton class, private constructor 52 | ObjectFactory() {} 53 | 54 | public: 55 | 56 | bool subscribe(UniqueIdType id, ObjectCreator creator) 57 | { 58 | if (object_registry.find(id) != object_registry.end()) return false; 59 | 60 | object_registry[id] = creator; 61 | return true; 62 | } 63 | 64 | bool unregister(UniqueIdType id) 65 | { 66 | return object_registry.erase(id) == 1; 67 | } 68 | 69 | ObjectCreator create(UniqueIdType id) 70 | { 71 | typename ObjectRegistry::const_iterator iter = object_registry.find(id); 72 | 73 | if (iter == object_registry.end()) { 74 | throw CreatorNotFound(); 75 | } 76 | 77 | return iter->second; 78 | } 79 | 80 | static ThisClass& instance() 81 | { 82 | static ThisClass the_factory; 83 | return the_factory; 84 | } 85 | private: 86 | ObjectRegistry object_registry; 87 | }; 88 | 89 | } 90 | 91 | #endif /* OPENCV_FLANN_OBJECT_FACTORY_H_ */ 92 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/params.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_PARAMS_H_ 31 | #define OPENCV_FLANN_PARAMS_H_ 32 | 33 | #include "any.h" 34 | #include "general.h" 35 | #include 36 | #include 37 | 38 | 39 | namespace cvflann 40 | { 41 | 42 | typedef std::map IndexParams; 43 | 44 | struct SearchParams : public IndexParams 45 | { 46 | SearchParams(int checks = 32, float eps = 0, bool sorted = true ) 47 | { 48 | // how many leafs to visit when searching for neighbours (-1 for unlimited) 49 | (*this)["checks"] = checks; 50 | // search for eps-approximate neighbours (default: 0) 51 | (*this)["eps"] = eps; 52 | // only for radius search, require neighbours sorted by distance (default: true) 53 | (*this)["sorted"] = sorted; 54 | } 55 | }; 56 | 57 | 58 | template 59 | T get_param(const IndexParams& params, std::string name, const T& default_value) 60 | { 61 | IndexParams::const_iterator it = params.find(name); 62 | if (it != params.end()) { 63 | return it->second.cast(); 64 | } 65 | else { 66 | return default_value; 67 | } 68 | } 69 | 70 | template 71 | T get_param(const IndexParams& params, std::string name) 72 | { 73 | IndexParams::const_iterator it = params.find(name); 74 | if (it != params.end()) { 75 | return it->second.cast(); 76 | } 77 | else { 78 | throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given")); 79 | } 80 | } 81 | 82 | inline void print_params(const IndexParams& params) 83 | { 84 | IndexParams::const_iterator it; 85 | 86 | for(it=params.begin(); it!=params.end(); ++it) { 87 | std::cout << it->first << " : " << it->second << std::endl; 88 | } 89 | } 90 | 91 | 92 | 93 | } 94 | 95 | 96 | #endif /* OPENCV_FLANN_PARAMS_H_ */ 97 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/random.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef OPENCV_FLANN_RANDOM_H 32 | #define OPENCV_FLANN_RANDOM_H 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "general.h" 39 | 40 | namespace cvflann 41 | { 42 | 43 | /** 44 | * Seeds the random number generator 45 | * @param seed Random seed 46 | */ 47 | inline void seed_random(unsigned int seed) 48 | { 49 | srand(seed); 50 | } 51 | 52 | /* 53 | * Generates a random double value. 54 | */ 55 | /** 56 | * Generates a random double value. 57 | * @param high Upper limit 58 | * @param low Lower limit 59 | * @return Random double value 60 | */ 61 | inline double rand_double(double high = 1.0, double low = 0) 62 | { 63 | return low + ((high-low) * (std::rand() / (RAND_MAX + 1.0))); 64 | } 65 | 66 | /** 67 | * Generates a random integer value. 68 | * @param high Upper limit 69 | * @param low Lower limit 70 | * @return Random integer value 71 | */ 72 | inline int rand_int(int high = RAND_MAX, int low = 0) 73 | { 74 | return low + (int) ( double(high-low) * (std::rand() / (RAND_MAX + 1.0))); 75 | } 76 | 77 | /** 78 | * Random number generator that returns a distinct number from 79 | * the [0,n) interval each time. 80 | */ 81 | class UniqueRandom 82 | { 83 | std::vector vals_; 84 | int size_; 85 | int counter_; 86 | 87 | public: 88 | /** 89 | * Constructor. 90 | * @param n Size of the interval from which to generate 91 | * @return 92 | */ 93 | UniqueRandom(int n) 94 | { 95 | init(n); 96 | } 97 | 98 | /** 99 | * Initializes the number generator. 100 | * @param n the size of the interval from which to generate random numbers. 101 | */ 102 | void init(int n) 103 | { 104 | // create and initialize an array of size n 105 | vals_.resize(n); 106 | size_ = n; 107 | for (int i = 0; i < size_; ++i) vals_[i] = i; 108 | 109 | // shuffle the elements in the array 110 | std::random_shuffle(vals_.begin(), vals_.end()); 111 | 112 | counter_ = 0; 113 | } 114 | 115 | /** 116 | * Return a distinct random integer in greater or equal to 0 and less 117 | * than 'n' on each call. It should be called maximum 'n' times. 118 | * Returns: a random integer 119 | */ 120 | int next() 121 | { 122 | if (counter_ == size_) { 123 | return -1; 124 | } 125 | else { 126 | return vals_[counter_++]; 127 | } 128 | } 129 | }; 130 | 131 | } 132 | 133 | #endif //OPENCV_FLANN_RANDOM_H 134 | 135 | 136 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/flann/sampling.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_SAMPLING_H_ 31 | #define OPENCV_FLANN_SAMPLING_H_ 32 | 33 | #include "matrix.h" 34 | #include "random.h" 35 | 36 | namespace cvflann 37 | { 38 | 39 | template 40 | Matrix random_sample(Matrix& srcMatrix, long size, bool remove = false) 41 | { 42 | Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); 43 | 44 | T* src,* dest; 45 | for (long i=0; i 63 | Matrix random_sample(const Matrix& srcMatrix, size_t size) 64 | { 65 | UniqueRandom rand((int)srcMatrix.rows); 66 | Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); 67 | 68 | T* src,* dest; 69 | for (size_t i=0; i 41 | void addValue(int pos, float val, float* vals, T* point, T* points, int n) 42 | { 43 | vals[pos] = val; 44 | for (int i=0; i0 && vals[j] 69 | float optimizeSimplexDownhill(T* points, int n, F func, float* vals = NULL ) 70 | { 71 | const int MAX_ITERATIONS = 10; 72 | 73 | assert(n>0); 74 | 75 | T* p_o = new T[n]; 76 | T* p_r = new T[n]; 77 | T* p_e = new T[n]; 78 | 79 | int alpha = 1; 80 | 81 | int iterations = 0; 82 | 83 | bool ownVals = false; 84 | if (vals == NULL) { 85 | ownVals = true; 86 | vals = new float[n+1]; 87 | for (int i=0; i MAX_ITERATIONS) break; 97 | 98 | // compute average of simplex points (except the highest point) 99 | for (int j=0; j=vals[0])&&(val_r=vals[n]) { 151 | for (int i=0; i 35 | 36 | 37 | namespace cvflann 38 | { 39 | 40 | /** 41 | * A start-stop timer class. 42 | * 43 | * Can be used to time portions of code. 44 | */ 45 | class StartStopTimer 46 | { 47 | clock_t startTime; 48 | 49 | public: 50 | /** 51 | * Value of the timer. 52 | */ 53 | double value; 54 | 55 | 56 | /** 57 | * Constructor. 58 | */ 59 | StartStopTimer() 60 | { 61 | reset(); 62 | } 63 | 64 | /** 65 | * Starts the timer. 66 | */ 67 | void start() 68 | { 69 | startTime = clock(); 70 | } 71 | 72 | /** 73 | * Stops the timer and updates timer value. 74 | */ 75 | void stop() 76 | { 77 | clock_t stopTime = clock(); 78 | value += ( (double)stopTime - startTime) / CLOCKS_PER_SEC; 79 | } 80 | 81 | /** 82 | * Resets the timer value to 0. 83 | */ 84 | void reset() 85 | { 86 | value = 0; 87 | } 88 | 89 | }; 90 | 91 | } 92 | 93 | #endif // FLANN_TIMER_H 94 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/opencv.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 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. 15 | // Third party copyrights are property of their respective owners. 16 | // 17 | // Redistribution and use in source and binary forms, with or without modification, 18 | // are permitted provided that the following conditions are met: 19 | // 20 | // * Redistribution's of source code must retain the above copyright notice, 21 | // this list of conditions and the following disclaimer. 22 | // 23 | // * Redistribution's in binary form must reproduce the above copyright notice, 24 | // this list of conditions and the following disclaimer in the documentation 25 | // and/or other materials provided with the distribution. 26 | // 27 | // * The name of the copyright holders may not be used to endorse or promote products 28 | // derived from this software without specific prior written permission. 29 | // 30 | // This software is provided by the copyright holders and contributors "as is" and 31 | // any express or implied warranties, including, but not limited to, the implied 32 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 33 | // In no event shall the Intel Corporation or contributors be liable for any direct, 34 | // indirect, incidental, special, exemplary, or consequential damages 35 | // (including, but not limited to, procurement of substitute goods or services; 36 | // loss of use, data, or profits; or business interruption) however caused 37 | // and on any theory of liability, whether in contract, strict liability, 38 | // or tort (including negligence or otherwise) arising in any way out of 39 | // the use of this software, even if advised of the possibility of such damage. 40 | // 41 | //M*/ 42 | 43 | #ifndef __OPENCV_ALL_HPP__ 44 | #define __OPENCV_ALL_HPP__ 45 | 46 | #include "opencv2/core/core_c.h" 47 | #include "opencv2/core/core.hpp" 48 | #include "opencv2/imgproc/imgproc_c.h" 49 | #include "opencv2/imgproc/imgproc.hpp" 50 | #include "opencv2/features2d/features2d.hpp" 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv2/opencv_modules.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ** File generated automatically, do not modify ** 3 | * 4 | * This file defines the list of modules available in current build configuration 5 | * 6 | * 7 | */ 8 | 9 | #define HAVE_OPENCV_CALIB3D 10 | #define HAVE_OPENCV_CONTRIB 11 | #define HAVE_OPENCV_CORE 12 | #define HAVE_OPENCV_FEATURES2D 13 | #define HAVE_OPENCV_FLANN 14 | #define HAVE_OPENCV_GPU 15 | #define HAVE_OPENCV_HIGHGUI 16 | #define HAVE_OPENCV_IMGPROC 17 | #define HAVE_OPENCV_LEGACY 18 | #define HAVE_OPENCV_ML 19 | #define HAVE_OPENCV_NONFREE 20 | #define HAVE_OPENCV_OBJDETECT 21 | #define HAVE_OPENCV_PHOTO 22 | #define HAVE_OPENCV_STITCHING 23 | #define HAVE_OPENCV_TS 24 | #define HAVE_OPENCV_VIDEO 25 | #define HAVE_OPENCV_VIDEOSTAB 26 | 27 | 28 | -------------------------------------------------------------------------------- /external_libs/mexResize/opencv_core242.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/opencv_core242.dll -------------------------------------------------------------------------------- /external_libs/mexResize/opencv_core242.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/opencv_core242.lib -------------------------------------------------------------------------------- /external_libs/mexResize/opencv_imgproc242.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/opencv_imgproc242.dll -------------------------------------------------------------------------------- /external_libs/mexResize/opencv_imgproc242.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mexResize/opencv_imgproc242.lib -------------------------------------------------------------------------------- /external_libs/mtimesx/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, James Tursa 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /external_libs/mtimesx/mtimesx.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mtimesx/mtimesx.c -------------------------------------------------------------------------------- /external_libs/mtimesx/mtimesx.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/external_libs/mtimesx/mtimesx.m -------------------------------------------------------------------------------- /external_libs/mtimesx/mtimesx_sparse.m: -------------------------------------------------------------------------------- 1 | % mtimesx_sparse does sparse matrix multiply of two inputs 2 | %****************************************************************************** 3 | % 4 | % MATLAB (R) is a trademark of The Mathworks (R) Corporation 5 | % 6 | % Function: mtimesx_sparse 7 | % Filename: mtimesx_sparse.m 8 | % Programmer: James Tursa 9 | % Version: 1.00 10 | % Date: September 27, 2009 11 | % Copyright: (c) 2009 by James Tursa, All Rights Reserved 12 | % 13 | % This code uses the BSD License: 14 | % 15 | % Redistribution and use in source and binary forms, with or without 16 | % modification, are permitted provided that the following conditions are 17 | % met: 18 | % 19 | % * Redistributions of source code must retain the above copyright 20 | % notice, this list of conditions and the following disclaimer. 21 | % * Redistributions in binary form must reproduce the above copyright 22 | % notice, this list of conditions and the following disclaimer in 23 | % the documentation and/or other materials provided with the distribution 24 | % 25 | % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | % ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | % LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | % POSSIBILITY OF SUCH DAMAGE. 36 | % 37 | %-- 38 | % 39 | % mtimesx_sparse is a helper function for mtimesx and is not intended to be called 40 | % directly by the user. 41 | % 42 | % --------------------------------------------------------------------------------------------------------------------------------- 43 | 44 | function result = mtimesx_sparse(a,transa,b,transb) 45 | if( transa == 'N' ) 46 | if( transb == 'N' ) 47 | result = a * b; 48 | elseif( transb == 'G' ) 49 | result = a * conj(b); 50 | elseif( transb == 'T' ) 51 | result = a * b.'; 52 | else 53 | result = a * b'; 54 | end 55 | elseif( transa == 'G' ) 56 | if( transb == 'N' ) 57 | result = conj(a) * b; 58 | elseif( transb == 'G' ) 59 | result = conj(a) * conj(b); 60 | elseif( transb == 'T' ) 61 | result = conj(a) * b.'; 62 | else 63 | result = conj(a) * b'; 64 | end 65 | elseif( transa == 'T' ) 66 | if( transb == 'N' ) 67 | result = a.' * b; 68 | elseif( transb == 'G' ) 69 | result = a.' * conj(b); 70 | elseif( transb == 'T' ) 71 | result = a.' * b.'; 72 | else 73 | result = a.' * b'; 74 | end 75 | else 76 | if( transb == 'N' ) 77 | result = a' * b; 78 | elseif( transb == 'G' ) 79 | result = a' * conj(b); 80 | elseif( transb == 'T' ) 81 | result = a' * b.'; 82 | else 83 | result = a' * b'; 84 | end 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /feature_extraction/average_feature_region.m: -------------------------------------------------------------------------------- 1 | function [ region_image ] = average_feature_region(im, region_size) 2 | % compute cell wise averages, where a cell is a region_size*region_sized 3 | % region in the image. Input can be uint8t, single or double matrices 4 | % of arbitrary dimension 5 | 6 | region_area = region_size.^2; 7 | 8 | if isa(im,'double') || isa(im,'single') || isa(im,'gpuArray') 9 | maxval = 1.0; 10 | elseif isa(im,'unit8') 11 | maxval = 255; 12 | end 13 | 14 | % compute the integral image 15 | iImage = integralVecImage(im); 16 | 17 | % region indices 18 | i1 = (region_size:region_size:size(im,1)) + 1; 19 | i2 = (region_size:region_size:size(im,2)) + 1; 20 | 21 | % sum over region, divided by number of elements, and normalize to [0,1] 22 | % range if integer image 23 | region_image = (iImage(i1,i2,:,:) - iImage(i1,i2-region_size,:,:) - iImage(i1-region_size,i2,:,:) + iImage(i1-region_size,i2-region_size,:,:)) ./ (region_area * maxval); 24 | 25 | end 26 | 27 | -------------------------------------------------------------------------------- /feature_extraction/extract_features.m: -------------------------------------------------------------------------------- 1 | function feature_map = extract_features(image, pos, scales, features, gparams, extract_info) 2 | 3 | % Sample image patches at given position and scales. Then extract features 4 | % from these patches. 5 | % Requires that cell size and image sample size is set for each feature. 6 | 7 | if ~iscell(features) 8 | error('Wrong input'); 9 | end 10 | 11 | if ~isfield(gparams, 'use_gpu') 12 | gparams.use_gpu = false; 13 | end 14 | if ~isfield(gparams, 'data_type') 15 | gparams.data_type = zeros(1, 'single'); 16 | end 17 | if nargin < 6 18 | % Find used image sample size 19 | extract_info = get_feature_extract_info(features); 20 | end 21 | 22 | num_features = length(features); 23 | num_scales = length(scales); 24 | num_sizes = length(extract_info.img_sample_sizes); 25 | 26 | % Extract image patches 27 | img_samples = cell(num_sizes,1); 28 | for sz_ind = 1:num_sizes 29 | img_sample_sz = extract_info.img_sample_sizes{sz_ind}; 30 | img_input_sz = extract_info.img_input_sizes{sz_ind}; 31 | img_samples{sz_ind} = zeros(img_input_sz(1), img_input_sz(2), size(image,3), num_scales, 'uint8'); 32 | for scale_ind = 1:num_scales 33 | img_samples{sz_ind}(:,:,:,scale_ind) = sample_patch(image, pos, img_sample_sz*scales(scale_ind), img_input_sz, gparams); 34 | end 35 | end 36 | 37 | % Find the number of feature blocks and total dimensionality 38 | num_feature_blocks = 0; 39 | total_dim = 0; 40 | for feat_ind = 1:num_features 41 | num_feature_blocks = num_feature_blocks + length(features{feat_ind}.fparams.nDim); 42 | total_dim = total_dim + sum(features{feat_ind}.fparams.nDim); 43 | end 44 | 45 | feature_map = cell(1, 1, num_feature_blocks); 46 | 47 | % Extract feature maps for each feature in the list 48 | ind = 1; 49 | for feat_ind = 1:num_features 50 | feat = features{feat_ind}; 51 | % gparams.cell_size = feat.fparams.cell_size; 52 | 53 | % get the image patch index 54 | img_sample_ind = cellfun(@(sz) isequal(feat.img_sample_sz, sz), extract_info.img_sample_sizes); 55 | 56 | % do feature computation 57 | if feat.is_cell 58 | num_blocks = length(feat.fparams.nDim); 59 | feature_map(ind:ind+num_blocks-1) = feat.getFeature(img_samples{img_sample_ind}, feat.fparams, gparams); 60 | else 61 | num_blocks = 1; 62 | feature_map{ind} = feat.getFeature(img_samples{img_sample_ind}, feat.fparams, gparams); 63 | end 64 | 65 | ind = ind + num_blocks; 66 | end 67 | 68 | % Do feature normalization 69 | if ~isempty(gparams.normalize_power) && gparams.normalize_power > 0 70 | if gparams.normalize_power == 2 71 | feature_map = cellfun(@(x) bsxfun(@times, x, ... 72 | sqrt((size(x,1)*size(x,2))^gparams.normalize_size * size(x,3)^gparams.normalize_dim ./ ... 73 | (sum(reshape(x, [], 1, 1, size(x,4)).^2, 1) + eps))), ... 74 | feature_map, 'uniformoutput', false); 75 | else 76 | feature_map = cellfun(@(x) bsxfun(@times, x, ... 77 | ((size(x,1)*size(x,2))^gparams.normalize_size * size(x,3)^gparams.normalize_dim ./ ... 78 | (sum(abs(reshape(x, [], 1, 1, size(x,4))).^gparams.normalize_power, 1) + eps)).^(1/gparams.normalize_power)), ... 79 | feature_map, 'uniformoutput', false); 80 | end 81 | end 82 | if gparams.square_root_normalization 83 | feature_map = cellfun(@(x) sign(x) .* sqrt(abs(x)), feature_map, 'uniformoutput', false); 84 | end 85 | 86 | end -------------------------------------------------------------------------------- /feature_extraction/get_cnn_layers.m: -------------------------------------------------------------------------------- 1 | function feature_map = get_cnn_layers(im, fparams, gparams) 2 | 3 | % Get layers from a cnn. 4 | 5 | if size(im,3) == 1 6 | im = repmat(im, [1 1 3]); 7 | end 8 | 9 | im_sample_size = size(im); 10 | 11 | %preprocess the image 12 | if ~isequal(im_sample_size(1:2), fparams.net.meta.normalization.imageSize(1:2)) 13 | im = imresize(single(im), fparams.net.meta.normalization.imageSize(1:2)); 14 | else 15 | im = single(im); 16 | end 17 | 18 | % Normalize with average image 19 | im = bsxfun(@minus, im, fparams.net.meta.normalization.averageImage); 20 | 21 | if gparams.use_gpu 22 | im = gpuArray(im); 23 | cnn_feat = vl_simplenn(fparams.net, im,[],[],'CuDNN',true, 'Mode', 'test'); 24 | else 25 | cnn_feat = vl_simplenn(fparams.net, im, [], [], 'Mode', 'test'); 26 | end 27 | 28 | feature_map = cell(1,1,length(fparams.output_layer)); 29 | 30 | for k = 1:length(fparams.output_layer) 31 | if fparams.downsample_factor(k) == 1 32 | feature_map{k} = cnn_feat(fparams.output_layer(k) + 1).x(fparams.start_ind(k,1):fparams.end_ind(k,1), fparams.start_ind(k,2):fparams.end_ind(k,2), :, :); 33 | else 34 | feature_map{k} = vl_nnpool(cnn_feat(fparams.output_layer(k) + 1).x(fparams.start_ind(k,1):fparams.end_ind(k,1), fparams.start_ind(k,2):fparams.end_ind(k,2), :, :), fparams.downsample_factor(k), 'stride', fparams.downsample_factor(k), 'method', 'avg'); 35 | end 36 | end 37 | 38 | -------------------------------------------------------------------------------- /feature_extraction/get_colorspace.m: -------------------------------------------------------------------------------- 1 | function [ feature_map ] = get_colorspace( im, fparam, gparam ) 2 | 3 | % Get a color space feature. Currently implements 'gray' and 'rgb'. 4 | 5 | if isfield(fparam, 'cell_size') 6 | cell_size = fparam.cell_size; 7 | else 8 | cell_size = gparam.cell_size; 9 | end 10 | 11 | [im_height, im_width, num_im_chan, num_images] = size(im); 12 | 13 | single_im = single(im)/255; 14 | 15 | if strcmpi(fparam.colorspace,'gray') 16 | if num_im_chan == 3 17 | if num_images == 1 18 | feature_map = rgb2gray(single_im) - 0.5; 19 | else 20 | feature_map = zeros(im_height, im_width, 1, num_images, 'single'); 21 | for k = 1:num_images 22 | feature_map(:,:,:,k) = rgb2gray(single_im(:,:,:,k)) - 0.5; 23 | end 24 | end 25 | elseif num_im_chan == 1 26 | feature_map = single_im - 0.5; 27 | else 28 | except = MException('get_colorspace','Invalid input data, must have 1 or 3 dimensions'); 29 | throw(except); 30 | end 31 | elseif strcmpi(fparam.colorspace,'rgb') 32 | if num_im_chan == 3 33 | feature_map = single_im - 0.5; 34 | else 35 | except = MException('get_colorspace','Invalid input data, must have 3 dimensions for rgb'); 36 | throw(except); 37 | end 38 | end 39 | 40 | if gparams.use_gpu 41 | feature_map = gpuArray(feature_map); 42 | end 43 | 44 | if cell_size > 1 45 | feature_map = average_feature_region(feature_map, cell_size); 46 | end 47 | end 48 | 49 | -------------------------------------------------------------------------------- /feature_extraction/get_feature_extract_info.m: -------------------------------------------------------------------------------- 1 | function extract_info = get_feature_extract_info(features) 2 | 3 | % Find used image sample size 4 | extract_info.img_sample_sizes = {}; 5 | extract_info.img_input_sizes = {}; 6 | for feat_ind = 1:length(features) 7 | % if not equals any previously stored size 8 | if ~any(cellfun(@(sz) isequal(features{feat_ind}.img_sample_sz, sz), extract_info.img_sample_sizes)) 9 | extract_info.img_sample_sizes{end+1} = features{feat_ind}.img_sample_sz; 10 | extract_info.img_input_sizes{end+1} = features{feat_ind}.img_input_sz; 11 | end 12 | end -------------------------------------------------------------------------------- /feature_extraction/get_fhog.m: -------------------------------------------------------------------------------- 1 | function [ feature_image ] = get_fhog( im, fparam, gparam ) 2 | 3 | % Extract FHOG features using pdollar toolbox. 4 | 5 | if ~isfield(fparam, 'nOrients') 6 | fparam.nOrients = 9; 7 | end 8 | if isfield(fparam, 'cell_size') 9 | cell_size = fparam.cell_size; 10 | else 11 | cell_size = gparam.cell_size; 12 | end 13 | 14 | [im_height, im_width, num_im_chan, num_images] = size(im); 15 | feature_image = zeros(floor(im_height/cell_size), floor(im_width/cell_size), fparam.nDim, num_images, 'like', gparam.data_type); 16 | 17 | for k = 1:num_images 18 | hog_image = fhog(single(im(:,:,:,k)), cell_size, fparam.nOrients); 19 | 20 | %the last dimension is all 0 so we can discard it 21 | feature_image(:,:,:,k) = hog_image(:,:,1:end-1); 22 | end 23 | end -------------------------------------------------------------------------------- /feature_extraction/get_table_feature.m: -------------------------------------------------------------------------------- 1 | function [ feature_map ] = get_table_feature( im, fparam, gparam) 2 | %get per-pixel features using a lookup table, if the gparam feature cell 3 | %size is set to something large than one, the resulting data will be 4 | %averaged in cells of the specified size. 5 | % 6 | %tables are loaded dynamically when needed from the lookup_tables folder, 7 | %and stored in a persistent variable 8 | 9 | persistent tables; 10 | 11 | if isempty(tables) 12 | tables = {}; 13 | end 14 | 15 | if isfield(fparam, 'cell_size') 16 | cell_size = fparam.cell_size; 17 | else 18 | cell_size = gparam.cell_size; 19 | end 20 | 21 | tab_ind = 0; 22 | for k = 1:length(tables) 23 | if isfield(tables{k}, fparam.tablename) 24 | tab_ind = k; 25 | break; 26 | end 27 | end 28 | 29 | if tab_ind == 0 30 | tables{end+1} = load(['lookup_tables/' fparam.tablename]); 31 | tab_ind = length(tables); 32 | end 33 | 34 | if strcmp(tables{tab_ind}.inputType,'color') 35 | if size(im,3) ~= 3 36 | except = MException('cannot get colorfeature from non color image'); 37 | raise(except); 38 | end 39 | elseif strcmp(tables{tab_ind}.inputType,'gray') 40 | if size(im,3) == 3 41 | im_gray = zeros(size(im,1),size(im,2),1,size(im,4),'uint8'); 42 | for k = 1:size(im,4) 43 | im_gray(:,:,:,k) = rgb2gray(im(:,:,:,k)); 44 | end 45 | im = im_gray; 46 | end 47 | end 48 | 49 | % Extract features from table 50 | if gparam.use_gpu 51 | feature_map = gpuArray(table_lookup(im,tables{tab_ind}.(fparam.tablename))); 52 | else 53 | feature_map = table_lookup(im,tables{tab_ind}.(fparam.tablename)); 54 | end 55 | 56 | if cell_size > 1 57 | feature_map = average_feature_region(feature_map, cell_size); 58 | end 59 | 60 | end 61 | 62 | -------------------------------------------------------------------------------- /feature_extraction/integralVecImage.m: -------------------------------------------------------------------------------- 1 | function intImage = integralVecImage(I) 2 | 3 | % Compute the integral image of I. 4 | 5 | if ~isempty(I) 6 | intImage = zeros(size(I,1)+1, size(I,2)+1, size(I,3), size(I,4), 'like', I); 7 | intImage(2:end, 2:end, :, :) = cumsum(cumsum(I,1),2); 8 | else 9 | intImage = []; 10 | end 11 | 12 | -------------------------------------------------------------------------------- /feature_extraction/load_cnn.m: -------------------------------------------------------------------------------- 1 | function net = load_cnn(fparams, im_size) 2 | 3 | net = load(['networks/' fparams.nn_name]); 4 | net = vl_simplenn_tidy(net); 5 | net.layers = net.layers(1:max(fparams.output_layer)); 6 | 7 | if strcmpi(fparams.input_size_mode, 'cnn_default') 8 | base_input_sz = net.meta.normalization.imageSize(1:2); 9 | elseif strcmpi(fparams.input_size_mode, 'adaptive') 10 | base_input_sz = im_size(1:2); 11 | else 12 | error('Unknown input_size_mode'); 13 | end 14 | 15 | net.meta.normalization.imageSize(1:2) = round(base_input_sz .* fparams.input_size_scale); 16 | net.meta.normalization.averageImageOrig = net.meta.normalization.averageImage; 17 | 18 | if isfield(net.meta,'inputSize') 19 | net.meta.inputSize = base_input_sz; 20 | end 21 | 22 | if size(net.meta.normalization.averageImage,1) > 1 || size(net.meta.normalization.averageImage,2) > 1 23 | net.meta.normalization.averageImage = imresize(single(net.meta.normalization.averageImage), net.meta.normalization.imageSize(1:2)); 24 | end 25 | 26 | net.info = vl_simplenn_display(net); 27 | end -------------------------------------------------------------------------------- /feature_extraction/lookup_tables/CNnorm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/feature_extraction/lookup_tables/CNnorm.mat -------------------------------------------------------------------------------- /feature_extraction/lookup_tables/intensityChannelNorm11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/feature_extraction/lookup_tables/intensityChannelNorm11.mat -------------------------------------------------------------------------------- /feature_extraction/lookup_tables/intensityChannelNorm16.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/feature_extraction/lookup_tables/intensityChannelNorm16.mat -------------------------------------------------------------------------------- /feature_extraction/lookup_tables/intensityChannelNorm6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/feature_extraction/lookup_tables/intensityChannelNorm6.mat -------------------------------------------------------------------------------- /feature_extraction/sample_patch.m: -------------------------------------------------------------------------------- 1 | function resized_patch = sample_patch(im, pos, sample_sz, output_sz, gparams) 2 | 3 | if nargin < 4 4 | output_sz = []; 5 | end 6 | if nargin < 5 || ~isfield(gparams, 'use_mexResize') 7 | gparams.use_mexResize = false; 8 | end 9 | 10 | % Pos should be integer when input, but floor in just in case. 11 | pos = floor(pos); 12 | 13 | % Downsample factor 14 | resize_factor = min(sample_sz ./ output_sz); 15 | df = max(floor(resize_factor - 0.1), 1); 16 | if df > 1 17 | % pos = 1 + of + df * (npos - 1) 18 | 19 | % compute offset and new center position 20 | os = mod(pos - 1, df); 21 | pos = (pos - 1 - os) / df + 1; 22 | 23 | % new sample size 24 | sample_sz = sample_sz / df; 25 | 26 | % donwsample image 27 | im = im(1+os(1):df:end, 1+os(2):df:end, :); 28 | end 29 | 30 | % make sure the size is not too small and round it 31 | sample_sz = max(round(sample_sz), 2); 32 | 33 | xs = pos(2) + (1:sample_sz(2)) - floor((sample_sz(2)+1)/2); 34 | ys = pos(1) + (1:sample_sz(1)) - floor((sample_sz(1)+1)/2); 35 | 36 | %check for out-of-bounds coordinates, and set them to the values at 37 | %the borders 38 | xs(xs < 1) = 1; 39 | ys(ys < 1) = 1; 40 | xs(xs > size(im,2)) = size(im,2); 41 | ys(ys > size(im,1)) = size(im,1); 42 | 43 | %extract image 44 | im_patch = im(ys, xs, :); 45 | 46 | if isempty(output_sz) || isequal(sample_sz(:), output_sz(:)) 47 | resized_patch = im_patch; 48 | else 49 | if gparams.use_mexResize 50 | resized_patch = mexResize(im_patch, output_sz, 'linear'); 51 | else 52 | resized_patch = imresize(im_patch, output_sz, 'bilinear', 'Antialiasing',false); 53 | end 54 | end 55 | 56 | end 57 | 58 | -------------------------------------------------------------------------------- /feature_extraction/set_cnn_input_size.m: -------------------------------------------------------------------------------- 1 | function net = set_cnn_input_size(net, im_size) 2 | 3 | net.meta.normalization.imageSize(1:2) = round(im_size(1:2)); 4 | net.meta.normalization.averageImage = imresize(single(net.meta.normalization.averageImageOrig), net.meta.normalization.imageSize(1:2)); 5 | 6 | net.info = vl_simplenn_display(net); 7 | end -------------------------------------------------------------------------------- /feature_extraction/table_lookup.m: -------------------------------------------------------------------------------- 1 | function out=table_lookup(im,table) 2 | 3 | if isa(im,'uint8') 4 | im = int32(im); 5 | end; 6 | 7 | [im_height, im_width, num_im_chan, num_images] = size(im); 8 | 9 | den = int32(8); 10 | fac = int32(32); 11 | offset = int32(1); 12 | 13 | if num_im_chan == 3 14 | RR=im(:,:,1,:);GG=im(:,:,2,:);BB=im(:,:,3,:); 15 | index_im = offset + idivide(RR,den) + fac*idivide(GG,den) + fac*fac*idivide(BB,den); 16 | out = permute(reshape(table(index_im(:),:), im_height, im_width, num_images, size(table,2)), [1 2 4 3]); 17 | else 18 | out = permute(reshape(table(im(:)+1,:), im_height, im_width, num_images, size(table,2)), [1 2 4 3]); 19 | end; 20 | -------------------------------------------------------------------------------- /implementation/dim_reduction/init_projection_matrix.m: -------------------------------------------------------------------------------- 1 | function projection_matrix = init_projection_matrix(init_sample, compressed_dim, params) 2 | 3 | % Initialize the projection matrix. 4 | 5 | % Convert the compressed dimensions to a cell 6 | compressed_dim_cell = permute(num2cell(compressed_dim), [2 3 1]); 7 | 8 | % Reshape the sample 9 | x = cellfun(@(x) reshape(x, [], size(x,3)), init_sample, 'uniformoutput', false); 10 | x = cellfun(@(x) bsxfun(@minus, x, mean(x, 1)), x, 'uniformoutput', false); 11 | 12 | if strcmpi(params.proj_init_method, 'pca') 13 | [projection_matrix, ~, ~] = cellfun(@(x) svd(x' * x), x, 'uniformoutput', false); 14 | projection_matrix = cellfun(@(P, dim) cast(P(:,1:dim), 'like', params.data_type), projection_matrix, compressed_dim_cell, 'uniformoutput', false); 15 | elseif strcmpi(params.proj_init_method, 'rand_uni') 16 | projection_matrix = cellfun(@(x, dim) randn(size(x,2), dim, 'like', params.data_type), x, compressed_dim_cell, 'uniformoutput', false); 17 | projection_matrix = cellfun(@(P) bsxfun(@rdivide, P, sqrt(sum(P.^2,1))), projection_matrix, 'uniformoutput', false); 18 | elseif strcmpi(params.proj_init_method, 'none') 19 | projection_matrix = []; 20 | else 21 | error('Unknown initialization method for the projection matrix: %s', params.proj_init_method); 22 | end -------------------------------------------------------------------------------- /implementation/dim_reduction/project_sample.m: -------------------------------------------------------------------------------- 1 | function x = project_sample(x, P) 2 | 3 | if isempty(P) 4 | return; 5 | end 6 | 7 | if isa(x{1}, 'gpuArray') 8 | for k = 1:length(x) 9 | x{k} = reshape(pagefun(@mtimes, reshape(x{k}, [], size(x{k},3), size(x{k},4)), P{k}), size(x{k},1), size(x{k},2), [], size(x{k},4)); 10 | end 11 | else 12 | for k = 1:length(x) 13 | x{k} = reshape(mtimesx(reshape(x{k}, [], size(x{k},3), size(x{k},4)), P{k}, 'speed'), size(x{k},1), size(x{k},2), [], size(x{k},4)); 14 | end 15 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/cfft2.m: -------------------------------------------------------------------------------- 1 | function xf = cfft2(x) 2 | 3 | % Find the data type 4 | data_type_complex = complex(zeros(1, 'like', x)); 5 | 6 | % calculate output size 7 | in_sz = size(x); 8 | 9 | % if both dimensions are odd 10 | if all(mod(in_sz(1:2), 2) == 1) 11 | xf = fftshift(fftshift(fft2(x), 1), 2); 12 | else 13 | out_sz = in_sz; 14 | out_sz(1:2) = out_sz(1:2) + mod(out_sz(1:2)+1,2); 15 | 16 | % allocate 17 | xf = zeros(out_sz, 'like', data_type_complex); 18 | 19 | xf(1:in_sz(1),1:in_sz(2),:,:) = fftshift(fftshift(fft2(x), 1), 2); 20 | 21 | if out_sz(1) ~= in_sz(1) 22 | xf(end,:,:,:) = conj(xf(1,end:-1:1,:,:)); 23 | end 24 | if out_sz(2) ~= in_sz(2) 25 | xf(:,end,:,:) = conj(xf(end:-1:1,1,:,:)); 26 | end 27 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/cifft2.m: -------------------------------------------------------------------------------- 1 | function x = cifft2(xf) 2 | 3 | if isa(xf, 'gpuArray') 4 | x = real(ifft2(ifftshift(ifftshift(xf, 1), 2))); 5 | else 6 | x = ifft2(ifftshift(ifftshift(xf, 1), 2), 'symmetric'); 7 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/compact_fourier_coeff.m: -------------------------------------------------------------------------------- 1 | function xf = compact_fourier_coeff(xf) 2 | 3 | % Creates a compact fourier series representation by removing the strict right 4 | % half plane. 5 | 6 | if iscell(xf) 7 | xf = cellfun(@(xf) xf(:,1:(size(xf,2)+1)/2,:), xf, 'uniformoutput', false); 8 | else 9 | xf = xf(:,1:(size(xf,2)+1)/2,:); 10 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/cubic_spline_fourier.m: -------------------------------------------------------------------------------- 1 | function bf = cubic_spline_fourier(f, a) 2 | 3 | % The continuous Fourier transform of a cubic spline kernel. 4 | 5 | bf = -(- 12*a + 12*exp(-pi*f*2i) + 12*exp(pi*f*2i) + 6*a*exp(-pi*f*4i) + ... 6 | 6*a*exp(pi*f*4i) + f.*(pi*exp(-pi*f*2i)*12i) - f.*(pi*exp(pi*f*2i)*12i) + ... 7 | a*f.*(pi*exp(-pi*f*2i)*16i) - a*f.*(pi*exp(pi*f*2i)*16i) + ... 8 | a*f.*(pi*exp(-pi*f*4i)*4i) - a*f.*(pi*exp(pi*f*4i)*4i) - 24)./(16*f.^4*pi^4); 9 | 10 | bf(f == 0) = 1; -------------------------------------------------------------------------------- /implementation/fourier_tools/full_fourier_coeff.m: -------------------------------------------------------------------------------- 1 | function xf = full_fourier_coeff(xf) 2 | 3 | % Reconstructs the full Fourier series coefficients. 4 | 5 | if iscell(xf) 6 | xf = cellfun(@(xf) cat(2, xf, conj(rot90(xf(:,1:end-1,:), 2))), xf, 'uniformoutput', false); 7 | else 8 | xf = cat(2, xf, conj(rot90(xf(:,1:end-1,:), 2))); 9 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/interpolate_dft.m: -------------------------------------------------------------------------------- 1 | function xf = interpolate_dft(xf, interp1_fs, interp2_fs) 2 | 3 | % Performs the implicit interpolation in the Fourier domain of a sample by 4 | % multiplying with the Fourier coefficients of the interpolation function. 5 | 6 | xf = cellfun(@(xf, interp1_fs, interp2_fs) bsxfun(@times, bsxfun(@times, xf, interp1_fs), interp2_fs), ... 7 | xf, interp1_fs, interp2_fs, 'uniformoutput', false); 8 | -------------------------------------------------------------------------------- /implementation/fourier_tools/resizeDFT.m: -------------------------------------------------------------------------------- 1 | function resizeddft = resizeDFT(inputdft, desiredLen) 2 | 3 | % Resizes a one-dimensional DFT to the desired length. 4 | 5 | len = length(inputdft); 6 | minsz = min(len, desiredLen); 7 | 8 | scaling = desiredLen/len; 9 | 10 | if size(inputdft, 1) > 1 11 | newSize = [desiredLen 1]; 12 | else 13 | newSize = [1 desiredLen]; 14 | end 15 | 16 | resizeddft = complex(zeros(newSize, 'single')); 17 | 18 | mids = ceil(minsz/2); 19 | mide = floor((minsz-1)/2) - 1; 20 | 21 | resizeddft(1:mids) = scaling * inputdft(1:mids); 22 | resizeddft(end - mide:end) = scaling * inputdft(end - mide:end); 23 | end -------------------------------------------------------------------------------- /implementation/fourier_tools/sample_fs.m: -------------------------------------------------------------------------------- 1 | function x = sample_fs(xf, grid_sz) 2 | 3 | % Samples the Fourier series 4 | 5 | sz = [size(xf,1) size(xf,2)]; 6 | 7 | if nargin < 2 || all(sz == grid_sz) 8 | x = prod(sz) * cifft2(xf); 9 | else 10 | if any(grid_sz < sz) 11 | error('The grid size must be larger than or equal to the signal size') 12 | end 13 | tot_pad = grid_sz - sz; 14 | pad_sz = ceil(tot_pad/2); 15 | xf_pad = padarray(xf, pad_sz); 16 | if any(mod(tot_pad,2) == 1) 17 | % Handle odd padding 18 | xf_pad = xf_pad(1:end-mod(tot_pad(1),2), 1:end-mod(tot_pad(2),2), :, :); 19 | end 20 | x = prod(grid_sz) * cifft2(xf_pad); 21 | end 22 | 23 | 24 | -------------------------------------------------------------------------------- /implementation/fourier_tools/shift_sample.m: -------------------------------------------------------------------------------- 1 | function xf = shift_sample(xf, shift, kx, ky) 2 | 3 | % Shift a sample in the Fourier domain. The shift should be normalized to 4 | % the range [-pi, pi]. 5 | 6 | shift_exp_y = cellfun(@(ky) exp((1i * shift(1)) * ky), ky, 'uniformoutput', false); 7 | shift_exp_x = cellfun(@(kx) exp((1i * shift(2)) * kx), kx, 'uniformoutput', false); 8 | xf = cellfun(@(xf, sy, sx) bsxfun(@times, bsxfun(@times, xf, sy), sx), xf, shift_exp_y, shift_exp_x, 'uniformoutput', false); -------------------------------------------------------------------------------- /implementation/fourier_tools/symmetrize_filter.m: -------------------------------------------------------------------------------- 1 | function hf = symmetrize_filter(hf) 2 | 3 | % Ensure hermetian symmetry. 4 | 5 | for k = 1:length(hf) 6 | dc_ind = (size(hf{k},1) + 1) / 2; 7 | hf{k}(dc_ind+1:end,end,:) = conj(flipud(hf{k}(1:dc_ind-1,end,:))); 8 | end -------------------------------------------------------------------------------- /implementation/initialization/get_interp_fourier.m: -------------------------------------------------------------------------------- 1 | function [interp1_fs, interp2_fs] = get_interp_fourier(sz, params) 2 | 3 | % Compute the Fourier series of the interpolation function (b_d in the 4 | % paper). The interpolation method is set using params.interpolation_method: 5 | % - 'ideal' performs ideal reconstruction, which corresponds to a periodic 6 | % summation of a sinc function b_d in the spatial domain. 7 | % - 'bicubic' uses a bicubic kernel b_d in the spatial domain. 8 | 9 | switch lower(params.interpolation_method) 10 | case 'none' 11 | % Do nothing 12 | interp1_fs = ones(sz(1),1); 13 | interp2_fs = ones(1,sz(2)); 14 | case 'ideal' 15 | % Ideal reconstruction (flat in the frequency domain) 16 | interp1_fs = ones(sz(1),1) / sz(1); 17 | interp2_fs = ones(1,sz(2)) / sz(2); 18 | case 'bicubic' 19 | % Take the truncated fourier series from the cubic spline 20 | a = params.interpolation_bicubic_a; 21 | interp1_fs = real(1/sz(1) * cubic_spline_fourier((-(sz(1)-1)/2:(sz(1)-1)/2)'/sz(1), a)); 22 | interp2_fs = real(1/sz(2) * cubic_spline_fourier((-(sz(2)-1)/2:(sz(2)-1)/2)/sz(2), a)); 23 | otherwise 24 | error('Unknown dft interpolation method'); 25 | end 26 | 27 | if params.interpolation_centering 28 | % Center the feature grids by shifting the interpolated features 29 | % Multiply Fourier coeff with e^(-i*pi*k/N) 30 | interp1_fs = interp1_fs .* exp(-1i*pi / sz(1) * (-(sz(1)-1)/2:(sz(1)-1)/2)'); 31 | interp2_fs = interp2_fs .* exp(-1i*pi / sz(2) * (-(sz(2)-1)/2:(sz(2)-1)/2)); 32 | end 33 | if params.interpolation_windowing 34 | % Window the Fourier series of the interpolation basis function 35 | win1 = hann(sz(1)+2); 36 | win2 = hann(sz(2)+2); 37 | interp1_fs = interp1_fs .* win1(2:end-1); 38 | interp2_fs = interp2_fs .* win2(2:end-1)'; 39 | end 40 | 41 | interp1_fs = cast(interp1_fs, 'like', params.data_type); 42 | interp2_fs = cast(interp2_fs, 'like', params.data_type); -------------------------------------------------------------------------------- /implementation/initialization/get_reg_filter.m: -------------------------------------------------------------------------------- 1 | function reg_filter = get_reg_filter(sz, target_sz, params, reg_window_edge) 2 | 3 | % Compute the spatial regularization function and derive the corresponding 4 | % filter operation used for the optimization 5 | 6 | if nargin < 3 || isempty(reg_window_edge) 7 | reg_window_edge = params.reg_window_edge; 8 | end 9 | 10 | if params.use_reg_window 11 | % create weight window 12 | reg_window_power = params.reg_window_power; 13 | 14 | % normalization factor 15 | reg_scale = 0.5 * target_sz; 16 | 17 | % construct grid 18 | wrg = -(sz(1)-1)/2:(sz(1)-1)/2; 19 | wcg = -(sz(2)-1)/2:(sz(2)-1)/2; 20 | [wrs, wcs] = ndgrid(wrg, wcg); 21 | 22 | % construct the regukarization window 23 | reg_window = (reg_window_edge - params.reg_window_min) * (abs(wrs/reg_scale(1)).^reg_window_power + abs(wcs/reg_scale(2)).^reg_window_power) + params.reg_window_min; 24 | 25 | % compute the DFT and enforce sparsity 26 | reg_window_dft = fft2(reg_window) / prod(sz); 27 | reg_window_dft(abs(reg_window_dft) < params.reg_sparsity_threshold * max(abs(reg_window_dft(:)))) = 0; 28 | 29 | % do the inverse transform, correct window minimum 30 | reg_window_sparse = real(ifft2(reg_window_dft)); 31 | reg_window_dft(1,1) = reg_window_dft(1,1) - prod(sz) * min(reg_window_sparse(:)) + params.reg_window_min; 32 | reg_window_dft = fftshift(reg_window_dft); 33 | 34 | % find the regularization filter by removing the zeros 35 | reg_filter = cast(real(reg_window_dft(~all(reg_window_dft==0,2), ~all(reg_window_dft==0,1))), 'like', params.data_type); 36 | else 37 | % else use a scaled identity matrix 38 | reg_filter = cast(params.reg_window_min, 'like', params.data_type); 39 | end -------------------------------------------------------------------------------- /implementation/initialization/init_default_params.m: -------------------------------------------------------------------------------- 1 | function params = init_default_params(params) 2 | 3 | % Initialize default parameters 4 | 5 | default_params.use_gpu = false; 6 | default_params.gpu_id = []; 7 | default_params.interpolation_method = 'none'; 8 | default_params.interpolation_centering = false; 9 | default_params.interpolation_windowing = false; 10 | default_params.clamp_position = false; 11 | default_params.update_projection_matrix = true; 12 | default_params.proj_init_method = 'pca'; 13 | default_params.use_detection_sample = true; 14 | default_params.use_projection_matrix = true; 15 | default_params.use_sample_merge = true; 16 | default_params.CG_use_FR = true; 17 | default_params.CG_standard_alpha = true; 18 | 19 | def_param_names = fieldnames(default_params); 20 | for k = 1:numel(def_param_names) 21 | param_name = def_param_names{k}; 22 | if ~isfield(params, param_name) 23 | params.(param_name) = default_params.(param_name); 24 | end 25 | end 26 | 27 | if params.use_projection_matrix == false 28 | params.proj_init_method = 'none'; 29 | params.update_projection_matrix = false; 30 | end 31 | 32 | params.visualization = params.visualization || params.debug; -------------------------------------------------------------------------------- /implementation/initialization/init_feature_params.m: -------------------------------------------------------------------------------- 1 | function feature_params = init_feature_params(features, feature_info) 2 | 3 | % Initialize some feature parameters. 4 | 5 | feature_dim = feature_info.dim; 6 | num_features = length(features); 7 | num_feature_blocks = length(feature_dim); 8 | 9 | feature_params.compressed_dim_block = cell(num_features, 1); 10 | 11 | for k = 1:num_features 12 | if ~isfield(features{k}.fparams, 'compressed_dim') 13 | features{k}.fparams.compressed_dim = features{k}.fparams.nDim; 14 | end 15 | 16 | feature_params.compressed_dim_block{k} = features{k}.fparams.compressed_dim(:); 17 | end 18 | 19 | feature_params.compressed_dim = cell2mat(feature_params.compressed_dim_block); -------------------------------------------------------------------------------- /implementation/localization/optimize_scores.m: -------------------------------------------------------------------------------- 1 | function [disp_row, disp_col, scale_ind] = optimize_scores(scores_fs, iterations) 2 | 3 | % Maximizes the continuous convolution response (classification scores). 4 | 5 | % Find the size of the output. 6 | [sz1, sz2, num_scales] = size(scores_fs); 7 | output_sz = [sz1 sz2]; 8 | 9 | % Do the grid search step by finding the maximum in the sampled response 10 | % for each scale. 11 | sampled_scores = sample_fs(scores_fs); 12 | [max_resp_row, max_row] = max(sampled_scores, [], 1); 13 | [init_max_score, max_col] = max(max_resp_row, [], 2); 14 | max_row_perm = permute(max_row, [2 3 1]); 15 | col = max_col(:)'; 16 | row = max_row_perm(sub2ind(size(max_row_perm), col, 1:size(sampled_scores,3))); 17 | 18 | % Shift and rescale the coordinate system to [-pi, pi] 19 | trans_row = mod(row - 1 + floor((output_sz(1)-1)/2), output_sz(1)) - floor((output_sz(1)-1)/2); 20 | trans_col = mod(col - 1 + floor((output_sz(2)-1)/2), output_sz(2)) - floor((output_sz(2)-1)/2); 21 | init_pos_y = permute(2*pi * trans_row / output_sz(1), [1 3 2]); 22 | init_pos_x = permute(2*pi * trans_col / output_sz(2), [1 3 2]); 23 | 24 | % Set the current maximum to the sampled one 25 | max_pos_y = init_pos_y; 26 | max_pos_x = init_pos_x; 27 | 28 | % construct grid 29 | ky = -ceil((output_sz(1) - 1)/2) : floor((output_sz(1) - 1)/2); 30 | kx = (-ceil((output_sz(2) - 1)/2) : floor((output_sz(2) - 1)/2))'; 31 | 32 | % pre-compute complex exponential 33 | exp_iky = exp(bsxfun(@times, 1i * ky, max_pos_y)); 34 | exp_ikx = exp(bsxfun(@times, 1i * kx, max_pos_x)); 35 | 36 | ky2 = ky.*ky; 37 | kx2 = kx.*kx; 38 | 39 | iter = 1; 40 | while iter <= iterations 41 | % Compute gradient 42 | ky_exp_ky = bsxfun(@times, ky, exp_iky); 43 | kx_exp_kx = bsxfun(@times, kx, exp_ikx); 44 | y_resp = mtimesx(exp_iky, scores_fs, 'speed'); 45 | resp_x = mtimesx(scores_fs, exp_ikx, 'speed'); 46 | grad_y = -imag(mtimesx(ky_exp_ky, resp_x, 'speed')); 47 | grad_x = -imag(mtimesx(y_resp, kx_exp_kx, 'speed')); 48 | 49 | % Compute Hessian 50 | ival = 1i * mtimesx(exp_iky, resp_x, 'speed'); 51 | H_yy = real(-mtimesx(bsxfun(@times, ky2, exp_iky), resp_x, 'speed') + ival); 52 | H_xx = real(-mtimesx(y_resp, bsxfun(@times, kx2, exp_ikx), 'speed') + ival); 53 | H_xy = real(-mtimesx(ky_exp_ky, mtimesx(scores_fs, kx_exp_kx, 'speed'), 'speed')); 54 | det_H = H_yy .* H_xx - H_xy .* H_xy; 55 | 56 | % Compute new position using newtons method 57 | max_pos_y = max_pos_y - (H_xx .* grad_y - H_xy .* grad_x) ./ det_H; 58 | max_pos_x = max_pos_x - (H_yy .* grad_x - H_xy .* grad_y) ./ det_H; 59 | 60 | % Evaluate maximum 61 | exp_iky = exp(bsxfun(@times, 1i * ky, max_pos_y)); 62 | exp_ikx = exp(bsxfun(@times, 1i * kx, max_pos_x)); 63 | 64 | iter = iter + 1; 65 | end 66 | 67 | % Evaluate the Fourier series at the estimated locations to find the 68 | % corresponding scores. 69 | max_score = real(mtimesx(mtimesx(exp_iky, scores_fs, 'speed'), exp_ikx, 'speed')); 70 | 71 | % check for scales that have not increased in score 72 | ind = max_score < init_max_score; 73 | max_score(ind) = init_max_score(ind); 74 | max_pos_y(ind) = init_pos_y(ind); 75 | max_pos_x(ind) = init_pos_x(ind); 76 | 77 | % Find the scale with the maximum response 78 | [max_scale_response, scale_ind] = max(max_score(:)); 79 | 80 | % Scale the coordinate system to output_sz 81 | disp_row = (mod(max_pos_y(1,1,scale_ind) + pi, 2*pi) - pi) / (2*pi) * output_sz(1); 82 | disp_col = (mod(max_pos_x(1,1,scale_ind) + pi, 2*pi) - pi) / (2*pi) * output_sz(2); 83 | end -------------------------------------------------------------------------------- /implementation/sample_space_model/find_gram_vector.m: -------------------------------------------------------------------------------- 1 | function gram_vector = find_gram_vector(samplesf, new_sample, num_training_samples, params) 2 | % Find the inner product of the new sample with the existing samples. TO be 3 | % used for distance calculation 4 | 5 | % Note: Since getting the 'exact' distance between the samples is not important, 6 | % the inner product computation is done by using only the half spectrum for 7 | % efficiency. In practice the error incurred by this is negligible. Also 8 | % since we wannt to merge samples that are similar, and finding the best 9 | % match is not important, small error in the distance computation doesn't 10 | % matter 11 | 12 | gram_vector = inf(params.nSamples,1,'like', params.data_type); 13 | 14 | num_feature_blocks = numel(new_sample); 15 | 16 | if num_training_samples == params.nSamples 17 | % This if statement is only for speed 18 | ip = zeros(1,'like', params.data_type); 19 | for k = 1:num_feature_blocks 20 | ip_block = 2*reshape(samplesf{k}, num_training_samples, []) * conj(new_sample{k}(:)); 21 | ip = ip + real(ip_block); 22 | end 23 | 24 | gram_vector = ip; 25 | elseif num_training_samples > 0 26 | ip = zeros(1,'like', params.data_type); 27 | for k = 1:num_feature_blocks 28 | ip_block = 2*reshape(samplesf{k}(1:num_training_samples,:,:,:),num_training_samples, []) * conj(new_sample{k}(:)); 29 | ip = ip + real(ip_block); 30 | end 31 | 32 | gram_vector(1:num_training_samples) = ip; 33 | end 34 | end 35 | 36 | 37 | -------------------------------------------------------------------------------- /implementation/sample_space_model/find_gram_vector_gpu.m: -------------------------------------------------------------------------------- 1 | function gram_vector = find_gram_vector_gpu(samplesf, new_sample, num_training_samples, params) 2 | % Find the inner product of the new sample with the existing samples. TO be 3 | % used for distance calculation 4 | 5 | % Note: Since getting the 'exact' distance between the samples is not important, 6 | % the inner product computation is done by using only the half spectrum for 7 | % efficiency. In practice the error incurred by this is negligible. Also 8 | % since we wannt to merge samples that are similar, and finding the best 9 | % match is not important, small error in the distance computation doesn't 10 | % matter 11 | 12 | gram_vector = inf(params.nSamples,1,'single'); 13 | 14 | num_feature_blocks = numel(new_sample); 15 | 16 | if num_training_samples > 0 17 | ip = zeros(1,num_training_samples,'like', params.data_type_complex); 18 | for k = 1:num_feature_blocks 19 | ip = ip + 2 * (new_sample{k}(:)' * reshape(samplesf{k}(:,:,:,1:num_training_samples), [],num_training_samples)); 20 | end 21 | 22 | gram_vector(1:num_training_samples) = real(gather(ip)); 23 | end 24 | 25 | end 26 | 27 | 28 | -------------------------------------------------------------------------------- /implementation/sample_space_model/merge_samples.m: -------------------------------------------------------------------------------- 1 | function merged_sample = merge_samples(sample1, sample2, w1, w2, sample_merge_type) 2 | % Merge sample1 and sample2 using weights w1 and w2. The type of merging is 3 | % decided by sample_merge_type. 4 | % The sample_merge_type can be 5 | % 1) Merge: The output is the weighted sum of the input samples 6 | % 2) Replace: The output is the first sample. ie w2 is assumed to be 0 7 | 8 | 9 | % Normalise the weights so that they sum to one 10 | alpha1 = w1/(w1+w2); 11 | alpha2 = 1 - alpha1; 12 | 13 | % Build the merged sample 14 | if strcmpi(sample_merge_type, 'replace') 15 | merged_sample = sample1; 16 | elseif strcmpi(sample_merge_type, 'merge') 17 | num_feature_blocks = numel(sample1); 18 | 19 | merged_sample = cell(1, 1, num_feature_blocks); 20 | for k = 1:num_feature_blocks 21 | merged_sample{k} = alpha1*sample1{k} + alpha2*sample2{k}; 22 | end 23 | else 24 | error('Invalid sample merge type'); 25 | end 26 | -------------------------------------------------------------------------------- /implementation/sample_space_model/update_distance_matrix.m: -------------------------------------------------------------------------------- 1 | function [distance_matrix, gram_matrix]= update_distance_matrix(distance_matrix, gram_matrix, gram_vector, new_sample_norm, id1, id2, w1, w2) 2 | % Updates the distance matrix 3 | 4 | % Normalise the weights so that they sum to one 5 | alpha1 = w1/(w1+w2); 6 | alpha2 = 1 - alpha1; 7 | 8 | 9 | if id2 < 0 10 | norm_id1 = gram_matrix(id1, id1); 11 | 12 | % Update the gram matrix 13 | if alpha1 == 0 14 | % The new sample replaces an existing sample. 15 | gram_matrix(:,id1) = gram_vector; 16 | gram_matrix(id1,:) = gram_matrix(:,id1); 17 | gram_matrix(id1, id1) = new_sample_norm; 18 | elseif alpha2 == 0 19 | % The new sample is discared 20 | else 21 | % The new sample is merge with an existing sample 22 | gram_matrix(:,id1) = alpha1*gram_matrix(:,id1) + alpha2*gram_vector; 23 | gram_matrix(id1,:) = gram_matrix(:,id1); 24 | gram_matrix(id1, id1) = alpha1^2*norm_id1 + alpha2^2*new_sample_norm + 2*alpha1*alpha2*gram_vector(id1); 25 | end 26 | 27 | % Update distance matrix 28 | distance_matrix(:,id1) = max(gram_matrix(id1, id1) + diag(gram_matrix) - 2*gram_matrix(:,id1),0); 29 | distance_matrix(id1,:) = distance_matrix(:,id1) ; 30 | distance_matrix(id1,id1) = inf; 31 | else 32 | if alpha1 == 0 || alpha2 == 0 33 | error('Error!'); 34 | end 35 | 36 | % Two existing samples are merged and the new sample fills the empty 37 | % slot 38 | norm_id1 = gram_matrix(id1, id1); 39 | norm_id2 = gram_matrix(id2, id2); 40 | ip_id1_id2 = gram_matrix(id1,id2); 41 | 42 | % Handle the merge of existing samples 43 | gram_matrix(:,id1) = alpha1*gram_matrix(:,id1) + alpha2*gram_matrix(:,id2); 44 | gram_matrix(id1,:) = gram_matrix(:,id1); 45 | gram_matrix(id1, id1) = alpha1^2*norm_id1 + alpha2^2*norm_id2 + 2*alpha1*alpha2*ip_id1_id2; 46 | 47 | gram_vector(id1) = alpha1*gram_vector(id1) + alpha2*gram_vector(id2); 48 | 49 | % Handle the new sample 50 | gram_matrix(:,id2) = gram_vector; 51 | gram_matrix(id2,:) = gram_matrix(:,id2); 52 | gram_matrix(id2, id2) = new_sample_norm; 53 | 54 | % Update the distance matrix 55 | distance_matrix(:,id1) = max(gram_matrix(id1, id1) + diag(gram_matrix) - 2*gram_matrix(:,id1),0); 56 | distance_matrix(id1,:) = distance_matrix(:,id1) ; 57 | distance_matrix(id1,id1) = inf; 58 | 59 | distance_matrix(:,id2) = max(gram_matrix(id2, id2) + diag(gram_matrix) - 2*gram_matrix(:,id2),0); 60 | distance_matrix(id2,:) = distance_matrix(:,id2) ; 61 | distance_matrix(id2,id2) = inf; 62 | end 63 | 64 | 65 | -------------------------------------------------------------------------------- /implementation/sample_space_model/update_prior_weights.m: -------------------------------------------------------------------------------- 1 | function [prior_weights, replace_ind] = update_prior_weights(prior_weights, sample_weights, latest_ind, frame, params) 2 | 3 | % Update the training sample wights 4 | 5 | learning_rate = params.learning_rate; 6 | 7 | if frame == 1 8 | replace_ind = 1; 9 | % prior_weights = zeros(params.nSamples,1,'single'); 10 | prior_weights(replace_ind) = 1; 11 | else 12 | % Get which sample to replace. 13 | switch params.sample_replace_strategy 14 | case 'lowest_prior' 15 | [~, replace_ind] = min(prior_weights); 16 | case 'lowest_weight' 17 | [~,replace_ind] = min(sample_weights); 18 | case 'lowest_median_prior' 19 | median_prior = median(prior_weights); 20 | % add 1 to all the weights that has a prior weight larger 21 | % than the median, and then take the mininum 22 | [~,replace_ind] = min(sample_weights + (prior_weights > median_prior)); 23 | case 'constant_tail' 24 | [~,I] = sort(prior_weights,'ascend'); 25 | lt_index = I(1:params.lt_size); 26 | st_index = I(params.lt_size+1:end); 27 | 28 | dummy_w = sample_weights; 29 | dummy_w(st_index) = inf; 30 | [~, replace_ind] = min(dummy_w); 31 | end 32 | 33 | if frame == 2 34 | prior_weights(latest_ind) = 1 - learning_rate; 35 | prior_weights(replace_ind) = learning_rate; 36 | else 37 | % take the previous value and ensure a relative difference of 38 | % (1-learning_rate) 39 | prior_weights(replace_ind) = prior_weights(latest_ind) / (1 - learning_rate); 40 | end 41 | 42 | if params.lt_size > 0 43 | [~,I] = sort(prior_weights,'ascend'); 44 | lt_index = I(1:params.lt_size); 45 | st_index = I(params.lt_size+1:end); 46 | 47 | minw = min(prior_weights(st_index)); 48 | 49 | if minw ~= 0 50 | lt_mask = false(size(prior_weights)); 51 | lt_mask(lt_index) = true; 52 | lt_mask = lt_mask & (prior_weights > 0); 53 | prior_weights(lt_mask) = minw * (1 - learning_rate); 54 | end; 55 | end; 56 | 57 | prior_weights = prior_weights/sum(prior_weights); 58 | end -------------------------------------------------------------------------------- /implementation/scale_filter/extract_scale_sample.m: -------------------------------------------------------------------------------- 1 | function scale_sample = extract_scale_sample(im, pos, base_target_sz, scaleFactors, scale_model_sz, use_mexResize) 2 | 3 | % Get scale filter sample. 4 | 5 | if nargin < 6 6 | use_mexResize = true; 7 | end 8 | 9 | nScales = length(scaleFactors); 10 | 11 | % Downsample factor. 12 | df = floor(min(scaleFactors)); 13 | if df > 1 14 | im = im(1:df:end,1:df:end,:); 15 | pos = (pos - 1) / df + 1; 16 | scaleFactors = scaleFactors / df; 17 | end 18 | 19 | for s = 1:nScales 20 | patch_sz = floor(base_target_sz * scaleFactors(s)); 21 | 22 | xs = floor(pos(2)) + (1:patch_sz(2)) - floor(patch_sz(2)/2); 23 | ys = floor(pos(1)) + (1:patch_sz(1)) - floor(patch_sz(1)/2); 24 | 25 | %check for out-of-bounds coordinates, and set them to the values at 26 | %the borders 27 | xs(xs < 1) = 1; 28 | ys(ys < 1) = 1; 29 | xs(xs > size(im,2)) = size(im,2); 30 | ys(ys > size(im,1)) = size(im,1); 31 | 32 | %extract image 33 | im_patch = im(ys, xs, :); 34 | 35 | % resize image to model size 36 | if use_mexResize 37 | im_patch_resized = mexResize(im_patch, scale_model_sz, 'auto'); 38 | else 39 | im_patch_resized = imresize(im_patch, scale_model_sz, 'bilinear', 'Antialiasing',false); 40 | end 41 | 42 | % extract scale features 43 | temp_hog = fhog(single(im_patch_resized), 4); 44 | 45 | if s == 1 46 | dim_scale = size(temp_hog,1)*size(temp_hog,2)*31; 47 | scale_sample = zeros(dim_scale, nScales, 'single'); 48 | end 49 | 50 | scale_sample(:,s) = reshape(temp_hog(:,:,1:31), dim_scale, 1); 51 | end 52 | -------------------------------------------------------------------------------- /implementation/scale_filter/feature_projection_scale.m: -------------------------------------------------------------------------------- 1 | function z = feature_projection_scale(x, projection_matrix, cos_window) 2 | 3 | % do the windowing of the output 4 | z = bsxfun(@times, cos_window, projection_matrix * x); 5 | end -------------------------------------------------------------------------------- /implementation/scale_filter/init_scale_filter.m: -------------------------------------------------------------------------------- 1 | function [nScales, scale_step, scaleFactors, scale_filter, params] = init_scale_filter(params) 2 | 3 | % Initialize the scale filter parameters. Uses the fDSST scale filter. 4 | 5 | init_target_sz = params.init_sz(:)'; 6 | 7 | nScales = params.number_of_scales_filter; 8 | scale_step = params.scale_step_filter; 9 | 10 | scale_sigma = params.number_of_interp_scales * params.scale_sigma_factor; 11 | 12 | scale_exp = (-floor((nScales-1)/2):ceil((nScales-1)/2)) * params.number_of_interp_scales/nScales; 13 | scale_exp_shift = circshift(scale_exp, [0 -floor((nScales-1)/2)]); 14 | 15 | interp_scale_exp = -floor((params.number_of_interp_scales-1)/2):ceil((params.number_of_interp_scales-1)/2); 16 | interp_scale_exp_shift = circshift(interp_scale_exp, [0 -floor((params.number_of_interp_scales-1)/2)]); 17 | 18 | scale_filter.scaleSizeFactors = scale_step .^ scale_exp; 19 | scale_filter.interpScaleFactors = scale_step .^ interp_scale_exp_shift; 20 | 21 | ys = exp(-0.5 * (scale_exp_shift.^2) /scale_sigma^2); 22 | scale_filter.yf = single(fft(ys)); 23 | scale_filter.window = single(hann(size(ys,2)))'; 24 | 25 | %make sure the scale model is not to large, to save computation time 26 | if params.scale_model_factor^2 * prod(init_target_sz) > params.scale_model_max_area 27 | params.scale_model_factor = sqrt(params.scale_model_max_area/prod(init_target_sz)); 28 | end 29 | 30 | %set the scale model size 31 | params.scale_model_sz = max(floor(init_target_sz * params.scale_model_factor), [8 8]); 32 | 33 | scale_filter.max_scale_dim = strcmp(params.s_num_compressed_dim,'MAX'); 34 | if scale_filter.max_scale_dim 35 | params.s_num_compressed_dim = length(scale_filter.scaleSizeFactors); 36 | end 37 | 38 | % Scale factor for the translation filter 39 | scaleFactors = 1; 40 | -------------------------------------------------------------------------------- /implementation/scale_filter/scale_filter_track.m: -------------------------------------------------------------------------------- 1 | function scale_change_factor = scale_filter_track(im, pos, base_target_sz, currentScaleFactor, scale_filter, params) 2 | 3 | % Track the scale using the scale filter. 4 | 5 | % Get scale filter features 6 | scales = currentScaleFactor*scale_filter.scaleSizeFactors; 7 | xs = extract_scale_sample(im, pos, base_target_sz, scales, params.scale_model_sz, params.use_mexResize); 8 | 9 | % Project 10 | xs = feature_projection_scale(xs, scale_filter.basis, scale_filter.window); 11 | 12 | % Get scores 13 | xsf = fft(xs, [], 2); 14 | scale_responsef = sum(scale_filter.sf_num .* xsf, 1) ./ (scale_filter.sf_den + params.lambda); 15 | interp_scale_response = ifft(resizeDFT(scale_responsef, params.number_of_interp_scales), 'symmetric'); 16 | 17 | recovered_scale_index = find(interp_scale_response == max(interp_scale_response(:)), 1); 18 | 19 | if params.do_poly_interp 20 | % Fit a quadratic polynomial to get a refined scale 21 | % estimate. 22 | id1 = mod(recovered_scale_index -1 -1,params.number_of_interp_scales)+1; 23 | id2 = mod(recovered_scale_index +1 -1,params.number_of_interp_scales)+1; 24 | 25 | poly_x = [scale_filter.interpScaleFactors(id1), scale_filter.interpScaleFactors(recovered_scale_index), scale_filter.interpScaleFactors(id2)]; 26 | poly_y = [interp_scale_response(id1), interp_scale_response(recovered_scale_index), interp_scale_response(id2)]; 27 | 28 | poly_A_mat = [poly_x(1)^2, poly_x(1), 1;... 29 | poly_x(2)^2, poly_x(2), 1;... 30 | poly_x(3)^2, poly_x(3), 1 ]; 31 | 32 | poly = poly_A_mat\poly_y'; 33 | 34 | scale_change_factor = -poly(2)/(2*poly(1)); 35 | else 36 | scale_change_factor = scale_filter.interpScaleFactors(recovered_scale_index); 37 | end 38 | -------------------------------------------------------------------------------- /implementation/scale_filter/scale_filter_update.m: -------------------------------------------------------------------------------- 1 | function scale_filter = scale_filter_update(im, pos, base_target_sz, currentScaleFactor, scale_filter, params) 2 | 3 | % Update the scale filter. 4 | 5 | % Get scale filter features 6 | scales = currentScaleFactor*scale_filter.scaleSizeFactors; 7 | xs = extract_scale_sample(im, pos, base_target_sz, scales, params.scale_model_sz, params.use_mexResize); 8 | 9 | is_first_frame = ~isfield(scale_filter, 's_num'); 10 | 11 | if is_first_frame 12 | scale_filter.s_num = xs; 13 | else 14 | scale_filter.s_num = (1 - params.scale_learning_rate) * scale_filter.s_num + params.scale_learning_rate * xs; 15 | end 16 | 17 | % Compute projection basis 18 | bigY = scale_filter.s_num; 19 | bigY_den = xs; 20 | if scale_filter.max_scale_dim 21 | [scale_filter.basis, ~] = qr(bigY, 0); 22 | [scale_basis_den, ~] = qr(bigY_den, 0); 23 | else 24 | [U,~,~] = svd(bigY,'econ'); 25 | scale_filter.basis = U(:,1:params.s_num_compressed_dim); 26 | end 27 | scale_filter.basis = scale_filter.basis'; 28 | 29 | % Compute numerator 30 | sf_proj = fft(feature_projection_scale(scale_filter.s_num, scale_filter.basis, scale_filter.window), [], 2); 31 | scale_filter.sf_num = bsxfun(@times, scale_filter.yf, conj(sf_proj)); 32 | 33 | % Update denominator 34 | xs = feature_projection_scale(xs, scale_basis_den', scale_filter.window); 35 | xsf = fft(xs,[],2); 36 | new_sf_den = sum(xsf .* conj(xsf),1); 37 | if is_first_frame 38 | scale_filter.sf_den = new_sf_den; 39 | else 40 | scale_filter.sf_den = (1 - params.scale_learning_rate) * scale_filter.sf_den + params.scale_learning_rate * new_sf_den; 41 | end 42 | -------------------------------------------------------------------------------- /implementation/training/diag_precond.m: -------------------------------------------------------------------------------- 1 | function hf_out = diag_precond(hf, M_diag) 2 | 3 | % This is the preconditioner operation in Conjugate Gradient 4 | 5 | hf_out = cellfun(@rdivide, hf, M_diag, 'uniformoutput',false); 6 | 7 | end -------------------------------------------------------------------------------- /implementation/training/inner_product_filter.m: -------------------------------------------------------------------------------- 1 | function ip = inner_product_filter(xf, yf) 2 | 3 | % Computes the inner product between two filters. 4 | 5 | ip = 0; 6 | for k = 1:length(xf) 7 | ip = ip + 2*gather(xf{k}(:)' * yf{k}(:)) - gather(reshape(xf{k}(:,end,:), [], 1, 1)' * reshape(yf{k}(:,end,:), [], 1, 1)); 8 | end 9 | ip = real(ip); 10 | -------------------------------------------------------------------------------- /implementation/training/inner_product_joint.m: -------------------------------------------------------------------------------- 1 | function ip = inner_product_joint(xf, yf) 2 | 3 | % Computes the joint inner product between two filters and projection matrices. 4 | 5 | ip = 0; 6 | for k = 1:size(xf,3) 7 | % Filter part 8 | ip = ip + 2*gather(xf{1,1,k}(:)' * yf{1,1,k}(:)) - gather(reshape(xf{1,1,k}(:,end,:), [], 1, 1)' * reshape(yf{1,1,k}(:,end,:), [], 1, 1)); 9 | 10 | % Projection matrix part 11 | ip = ip + gather(xf{2,1,k}(:)' * yf{2,1,k}(:)); 12 | end 13 | ip = real(ip); -------------------------------------------------------------------------------- /implementation/training/lhs_operation.m: -------------------------------------------------------------------------------- 1 | function hf_out = lhs_operation(hf, samplesf, reg_filter, sample_weights) 2 | 3 | % This is the left-hand-side operation in Conjugate Gradient 4 | 5 | % Get sizes 6 | num_features = length(hf); 7 | filter_sz = zeros(num_features,2); 8 | for k = 1:num_features 9 | filter_sz(k,:) = [size(hf{k},1), size(hf{k},2)]; 10 | end 11 | [~, k1] = max(filter_sz(:,1)); % Index for the feature block with the largest spatial size 12 | block_inds = 1:num_features; 13 | block_inds(k1) = []; 14 | output_sz = [size(hf{k1},1), 2*size(hf{k1},2)-1]; 15 | 16 | % Compute the operation corresponding to the data term in the optimization 17 | % (blockwise matrix multiplications) 18 | %implements: A' diag(sample_weights) A f 19 | 20 | % sum over all features and feature blocks 21 | sh = mtimesx(samplesf{k1}, permute(hf{k1}, [3 4 1 2]), 'speed'); % assumes the feature with the highest resolution is first 22 | pad_sz = cell(1,1,num_features); 23 | for k = block_inds 24 | pad_sz{k} = (output_sz - [size(hf{k},1), 2*size(hf{k},2)-1]) / 2; 25 | 26 | sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ... 27 | sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + mtimesx(samplesf{k}, permute(hf{k}, [3 4 1 2]), 'speed'); 28 | end 29 | 30 | % weight all the samples 31 | sh = bsxfun(@times,sample_weights,sh); 32 | 33 | % multiply with the transpose 34 | hf_out = cell(1,1,num_features); 35 | hf_out{k1} = permute(conj(mtimesx(sh, 'C', samplesf{k1}, 'speed')), [3 4 2 1]); 36 | for k = block_inds 37 | hf_out{k} = permute(conj(mtimesx(sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), 'C', samplesf{k}, 'speed')), [3 4 2 1]); 38 | end 39 | 40 | % compute the operation corresponding to the regularization term (convolve 41 | % each feature dimension with the DFT of w, and the tramsposed operation) 42 | % add the regularization part 43 | % hf_conv = cell(1,1,num_features); 44 | for k = 1:num_features 45 | reg_pad = min(size(reg_filter{k},2)-1, size(hf{k},2)-1); 46 | 47 | % add part needed for convolution 48 | hf_conv = cat(2, hf{k}, conj(rot90(hf{k}(:, end-reg_pad:end-1, :), 2))); 49 | 50 | % do first convolution 51 | hf_conv = convn(hf_conv, reg_filter{k}); 52 | 53 | % do final convolution and put toghether result 54 | hf_out{k} = hf_out{k} + convn(hf_conv(:,1:end-reg_pad,:), reg_filter{k}, 'valid'); 55 | end 56 | 57 | end -------------------------------------------------------------------------------- /implementation/training/lhs_operation_gpu.m: -------------------------------------------------------------------------------- 1 | function hf_out = lhs_operation_gpu(hf, samplesf, reg_filter, sample_weights) 2 | 3 | % This is the left-hand-side operation in Conjugate Gradient 4 | 5 | % Get sizes 6 | num_features = length(hf); 7 | filter_sz = zeros(num_features,2); 8 | for k = 1:num_features 9 | filter_sz(k,:) = [size(hf{k},1), size(hf{k},2)]; 10 | end 11 | [~, k1] = max(filter_sz(:,1)); % Index for the feature block with the largest spatial size 12 | block_inds = 1:num_features; 13 | block_inds(k1) = []; 14 | output_sz = [size(hf{k1},1), 2*size(hf{k1},2)-1]; 15 | 16 | % Compute the operation corresponding to the data term in the optimization 17 | % (blockwise matrix multiplications) 18 | %implements: A' diag(sample_weights) A f 19 | 20 | % sum over all features and feature blocks 21 | sh = sum(bsxfun(@times, samplesf{k1}, hf{k1}), 3); % assumes the feature with the highest resolution is first 22 | pad_sz = cell(1,1,num_features); 23 | for k = block_inds 24 | pad_sz{k} = (output_sz - [size(hf{k},1), 2*size(hf{k},2)-1]) / 2; 25 | 26 | sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,:) = ... 27 | sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,:) + sum(bsxfun(@times, samplesf{k}, hf{k}), 3); 28 | end 29 | 30 | % weight all the samples and take conjugate 31 | sh = conj(bsxfun(@times,sample_weights,sh)); 32 | 33 | % multiply with the transpose 34 | hf_out = cell(1,1,num_features); 35 | hf_out{k1} = conj(sum(bsxfun(@times, sh, samplesf{k1}), 4)); 36 | for k = block_inds 37 | hf_out{k} = conj(sum(bsxfun(@times, sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,:), samplesf{k}), 4)); 38 | end 39 | 40 | % compute the operation corresponding to the regularization term (convolve 41 | % each feature dimension with the DFT of w, and the tramsposed operation) 42 | % add the regularization part 43 | % hf_conv = cell(1,1,num_features); 44 | for k = 1:num_features 45 | reg_pad = min(size(reg_filter{k},2)-1, size(hf{k},2)-1); 46 | 47 | % add part needed for convolution 48 | hf_conv = cat(2, hf{k}, conj(rot90(hf{k}(:, end-reg_pad:end-1, :), 2))); 49 | 50 | % do first convolution 51 | hf_conv = convn(hf_conv, reg_filter{k}); 52 | 53 | % do final convolution and put toghether result 54 | hf_out{k} = hf_out{k} + convn(hf_conv(:,1:end-reg_pad,:), reg_filter{k}, 'valid'); 55 | end 56 | 57 | end -------------------------------------------------------------------------------- /implementation/training/lhs_operation_joint.m: -------------------------------------------------------------------------------- 1 | function hf_out = lhs_operation_joint(hf, samplesf, reg_filter, init_samplef, XH, init_hf, proj_reg) 2 | 3 | % This is the left-hand-side operation in Conjugate Gradient 4 | 5 | hf_out = cell(size(hf)); 6 | 7 | % Extract projection matrix and filter separately 8 | P = cellfun(@real, hf(2,1,:), 'uniformoutput',false); 9 | hf = hf(1,1,:); 10 | 11 | % Get sizes 12 | num_features = length(hf); 13 | filter_sz = zeros(num_features,2); 14 | for k = 1:num_features 15 | filter_sz(k,:) = [size(hf{k},1), size(hf{k},2)]; 16 | end 17 | [~, k1] = max(filter_sz(:,1)); % Index for the feature block with the largest spatial size 18 | block_inds = 1:num_features; 19 | block_inds(k1) = []; 20 | output_sz = [size(hf{k1},1), 2*size(hf{k1},2)-1]; 21 | 22 | 23 | % Compute the operation corresponding to the data term in the optimization 24 | % (blockwise matrix multiplications) 25 | %implements: A' diag(sample_weights) A f 26 | 27 | % sum over all features and feature blocks 28 | pad_sz = cell(1,1,num_features); 29 | sh = mtimesx(samplesf{k1}, permute(hf{k1}, [3 4 1 2]), 'speed'); % assumes the feature with the highest resolution is first 30 | for k = block_inds 31 | pad_sz{k} = (output_sz - [filter_sz(k,1), 2*filter_sz(k,2)-1]) / 2; 32 | 33 | sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ... 34 | sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + mtimesx(samplesf{k}, permute(hf{k}, [3 4 1 2]), 'speed'); 35 | end 36 | 37 | % weight all the samples 38 | % sh = bsxfun(@times,sample_weights,sh); 39 | 40 | % multiply with the transpose 41 | hf_out1 = cell(1,1,num_features); 42 | hf_out1{k1} = permute(conj(mtimesx(sh, 'C', samplesf{k1}, 'speed')), [3 4 2 1]); 43 | for k = block_inds 44 | hf_out1{k} = permute(conj(mtimesx(sh(:,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), 'C', samplesf{k}, 'speed')), [3 4 2 1]); 45 | end 46 | 47 | % compute the operation corresponding to the regularization term (convolve 48 | % each feature dimension with the DFT of w, and the tramsposed operation) 49 | % add the regularization part 50 | % hf_conv = cell(1,1,num_features); 51 | for k = 1:num_features 52 | reg_pad = min(size(reg_filter{k},2)-1, size(hf{k},2)-1); 53 | 54 | % add part needed for convolution 55 | hf_conv = cat(2, hf{k}, conj(rot90(hf{k}(:, end-reg_pad:end-1, :), 2))); 56 | 57 | % do first convolution 58 | hf_conv = convn(hf_conv, reg_filter{k}); 59 | 60 | % do final convolution and put toghether result 61 | hf_out1{k} = hf_out1{k} + convn(hf_conv(:,1:end-reg_pad,:), reg_filter{k}, 'valid'); 62 | end 63 | 64 | % Stuff related to the projection matrix 65 | 66 | % B * P 67 | BP_cell = cell(1,1,num_features); 68 | for k = 1:num_features 69 | BP_cell{k} = mtimesx(mtimesx(init_samplef{k}, P{k}, 'speed'), init_hf{k}, 'speed'); 70 | end 71 | 72 | BP = BP_cell{k1}; 73 | for k = block_inds 74 | BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ... 75 | BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + BP_cell{k}; 76 | end 77 | 78 | % multiply with the transpose: A^H * BP 79 | hf_out{1,1,k1} = hf_out1{k1} + permute(bsxfun(@times, BP, conj(samplesf{k1})), [3 4 2 1]); 80 | 81 | % B^H * BP 82 | fBP = cell(1,1,num_features); 83 | fBP{k1} = reshape(bsxfun(@times, conj(init_hf{k1}), BP), size(init_hf{k1},1), []).'; 84 | 85 | % Compute proj matrix part: B^H * A_m * f 86 | shBP = cell(1,1,num_features); 87 | shBP{k1} = reshape(bsxfun(@times, conj(init_hf{k1}), sh), size(init_hf{k1},1), []).'; 88 | 89 | for k = block_inds 90 | % multiply with the transpose: A^H * BP 91 | hf_out{1,1,k} = hf_out1{k} + permute(bsxfun(@times, BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), conj(samplesf{k})), [3 4 2 1]); 92 | 93 | % B^H * BP 94 | fBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), BP(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), size(init_hf{k},1), []).'; 95 | 96 | % Compute proj matrix part: B^H * A_m * f 97 | shBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), sh(1,1,1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), size(init_hf{k},1), []).'; 98 | end 99 | 100 | % hf_out2 = cell(1,1,num_features); 101 | for k = 1:num_features 102 | fi = size(hf{k},1) * (size(hf{k},2)-1) + 1; % index where the last frequency column starts 103 | 104 | % B^H * BP 105 | hf_out2 = 2*real(XH{k} * fBP{k} - XH{k}(:,fi:end) * fBP{k}(fi:end,:)) + proj_reg * P{k}; 106 | 107 | % Compute proj matrix part: B^H * A_m * f 108 | hf_out{2,1,k} = hf_out2 + (2*real(XH{k} * shBP{k} - XH{k}(:,fi:end) * shBP{k}(fi:end,:))); 109 | end 110 | end -------------------------------------------------------------------------------- /implementation/training/lhs_operation_joint_gpu.m: -------------------------------------------------------------------------------- 1 | function hf_out = lhs_operation_joint(hf, samplesf, reg_filter, init_samplef, XH, init_hf, proj_reg) 2 | 3 | % This is the left-hand-side operation in Conjugate Gradient 4 | 5 | hf_out = cell(size(hf)); 6 | 7 | % Extract projection matrix and filter separately 8 | P = cellfun(@real, hf(2,1,:), 'uniformoutput',false); 9 | hf = hf(1,1,:); 10 | 11 | % Get sizes 12 | num_features = length(hf); 13 | filter_sz = zeros(num_features,2); 14 | for k = 1:num_features 15 | filter_sz(k,:) = [size(hf{k},1), size(hf{k},2)]; 16 | end 17 | [~, k1] = max(filter_sz(:,1)); % Index for the feature block with the largest spatial size 18 | block_inds = 1:num_features; 19 | block_inds(k1) = []; 20 | output_sz = [size(hf{k1},1), 2*size(hf{k1},2)-1]; 21 | 22 | % Compute the operation corresponding to the data term in the optimization 23 | % (blockwise matrix multiplications) 24 | %implements: A' diag(sample_weights) A f 25 | 26 | % sum over all features and feature blocks 27 | sh = sum(bsxfun(@times, samplesf{k1}, hf{k1}), 3); % assumes the feature with the highest resolution is first 28 | pad_sz = cell(1,1,num_features); 29 | for k = block_inds 30 | pad_sz{k} = (output_sz - [size(hf{k},1), 2*size(hf{k},2)-1]) / 2; 31 | 32 | sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,:) = ... 33 | sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,:) + sum(bsxfun(@times, samplesf{k}, hf{k}), 3); 34 | end 35 | 36 | % weight all the samples and take conjugate 37 | % sh = bsxfun(@times,sample_weights,sh); 38 | sh = conj(sh); 39 | 40 | % multiply with the transpose 41 | hf_out1 = cell(1,1,num_features); 42 | hf_out1{k1} = conj(sum(bsxfun(@times, sh, samplesf{k1}), 4)); 43 | for k = block_inds 44 | hf_out1{k} = conj(sum(bsxfun(@times, sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end,1,1,:), samplesf{k}), 4)); 45 | end 46 | 47 | % compute the operation corresponding to the regularization term (convolve 48 | % each feature dimension with the DFT of w, and the tramsposed operation) 49 | % add the regularization part 50 | % hf_conv = cell(1,1,num_features); 51 | for k = 1:num_features 52 | reg_pad = min(size(reg_filter{k},2)-1, size(hf{k},2)-1); 53 | 54 | % add part needed for convolution 55 | hf_conv = cat(2, hf{k}, conj(rot90(hf{k}(:, end-reg_pad:end-1, :), 2))); 56 | 57 | % do first convolution 58 | hf_conv = convn(hf_conv, reg_filter{k}); 59 | 60 | % do final convolution and put toghether result 61 | hf_out1{k} = hf_out1{k} + convn(hf_conv(:,1:end-reg_pad,:), reg_filter{k}, 'valid'); 62 | end 63 | 64 | % Stuff related to the projection matrix 65 | 66 | % B * P 67 | BP_cell = cell(1,1,num_features); 68 | for k = 1:num_features 69 | BP_cell{k} = sum(bsxfun(@times, reshape(reshape(init_samplef{k}, [], size(init_samplef{k},3)) * P{k}, size(init_samplef{k},1), size(init_samplef{k},2), []), init_hf{k}), 3); 70 | end 71 | 72 | BP = BP_cell{k1}; 73 | for k = block_inds 74 | BP(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) = ... 75 | BP(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end) + BP_cell{k}; 76 | end 77 | 78 | % multiply with the transpose: A^H * BP 79 | hf_out{1,1,k1} = hf_out1{k1} + bsxfun(@times, BP, conj(samplesf{k1})); 80 | 81 | % B^H * BP 82 | fBP = cell(1,1,num_features); 83 | fBP{k1} = reshape(bsxfun(@times, conj(init_hf{k1}), BP), [], size(init_hf{k1},3)); 84 | 85 | % Compute proj matrix part: B^H * A_m * f 86 | shBP = cell(1,1,num_features); 87 | shBP{k1} = reshape(bsxfun(@times, conj(init_hf{k1}), sh), [], size(init_hf{k1},3)); 88 | 89 | for k = block_inds 90 | % multiply with the transpose: A^H * BP 91 | hf_out{1,1,k} = hf_out1{k} + bsxfun(@times, BP(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end), conj(samplesf{k})); 92 | 93 | % B^H * BP 94 | fBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), BP(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), [], size(init_hf{k},3)); 95 | 96 | % Compute proj matrix part: B^H * A_m * f 97 | shBP{k} = reshape(bsxfun(@times, conj(init_hf{k}), sh(1+pad_sz{k}(1):end-pad_sz{k}(1), 1+pad_sz{k}(2):end)), [], size(init_hf{k},3)); 98 | end 99 | 100 | % hf_out2 = cell(1,1,num_features); 101 | for k = 1:num_features 102 | fi = size(hf{k},1) * (size(hf{k},2)-1) + 1; % index where the last frequency column starts 103 | 104 | % B^H * BP 105 | hf_out2 = 2*real(XH{k} * fBP{k} - XH{k}(:,fi:end) * fBP{k}(fi:end,:)) + proj_reg * P{k}; 106 | 107 | % Compute proj matrix part: B^H * A_m * f 108 | hf_out{2,1,k} = hf_out2 + (2*real(XH{k} * shBP{k} - XH{k}(:,fi:end) * shBP{k}(fi:end,:))); 109 | end 110 | end -------------------------------------------------------------------------------- /implementation/training/pcg_ccot.m: -------------------------------------------------------------------------------- 1 | function [x,resvec,state] = pcg_ccot(A,b,opts,M1,M2,ip,x0,state) 2 | 3 | % This is a modified version of Matlab's pcg function, that performs 4 | % preconditioned conjugate gradient. 5 | 6 | 7 | % tol = opts.tol; 8 | maxit = opts.maxit; 9 | 10 | if ~isfield(opts, 'init_forget_factor') 11 | opts.init_forget_factor = 1; 12 | end 13 | 14 | if opts.debug 15 | n2b = sqrt(ip(b,b)); % Norm of rhs vector, b 16 | end 17 | 18 | existM1 = ((nargin >= 4) && ~isempty(M1)); 19 | existM2 = ((nargin >= 5) && ~isempty(M2)); 20 | 21 | x = x0; 22 | 23 | % Load the CG state 24 | p = []; 25 | rho = 1; 26 | r_prev = []; 27 | load_state = nargin > 7 && ~isempty(state) && opts.init_forget_factor > 0; 28 | if load_state 29 | if isfield(state, 'p') 30 | p = state.p; 31 | end 32 | if isfield(state, 'rho') && ~isempty(state.rho) 33 | rho = state.rho / opts.init_forget_factor; 34 | end 35 | if isfield(state, 'r_prev') && ~opts.CG_use_FR 36 | r_prev = state.r_prev; 37 | end 38 | end 39 | 40 | % Set up for the method 41 | state.flag = 1; 42 | 43 | % r = cellfun(@minus, b, iterapp('mtimes',afun,atype,afcnstr,x,varargin{:}), 'uniformoutput', false); 44 | r = cellfun(@minus, b, A(x), 'uniformoutput', false); 45 | 46 | if opts.debug 47 | normr = sqrt(ip(r,r)); % Norm of residual 48 | normr_act = normr; 49 | end 50 | 51 | 52 | if opts.debug 53 | resvec = zeros(maxit+1,1); % Preallocate vector for norm of residuals 54 | resvec(1,:) = normr; % resvec(1) = norm(b-A*x0) 55 | else 56 | resvec = []; 57 | relres = []; 58 | end 59 | 60 | % loop over maxit iterations (unless convergence or failure) 61 | 62 | for ii = 1 : maxit 63 | if existM1 64 | y = M1(r); 65 | else % no preconditioner 66 | y = r; 67 | end 68 | 69 | if existM2 70 | z = M2(y); 71 | else % no preconditioner 72 | z = y; 73 | end 74 | 75 | rho1 = rho; 76 | rho = ip(r, z); 77 | if ((rho == 0) || isinf(rho)) 78 | state.flag = 4; 79 | break 80 | end 81 | 82 | if (ii == 1 && isempty(p)) 83 | p = z; 84 | else 85 | if opts.CG_use_FR 86 | % Use Fletcher-Reeves 87 | beta = rho / rho1; 88 | else 89 | % Use Polak-Ribiere 90 | rho2 = ip(r_prev, z); 91 | beta = (rho - rho2) / rho1; 92 | end 93 | if ((beta == 0) || isinf(beta)) 94 | state.flag = 4; 95 | break 96 | end 97 | beta = max(0, beta); 98 | p = cellfun(@(z,p) z + beta * p, z, p, 'uniformoutput', false); 99 | end 100 | 101 | q = A(p); 102 | pq = ip(p, q); 103 | if ((pq <= 0) || isinf(pq)) 104 | state.flag = 4; 105 | break 106 | else 107 | if opts.CG_standard_alpha 108 | alpha = rho / pq; 109 | else 110 | alpha = ip(p, r) / pq; 111 | end 112 | end 113 | if isinf(alpha) 114 | state.flag = 4; 115 | break 116 | end 117 | 118 | % Save old r if not using FR formula for beta 119 | if ~opts.CG_use_FR 120 | r_prev = r; 121 | end 122 | 123 | % form new iterate 124 | x = cellfun(@(x,p) x + alpha * p, x, p, 'uniformoutput', false); 125 | 126 | if ii < maxit || opts.debug 127 | r = cellfun(@(r,q) r - alpha * q, r, q, 'uniformoutput', false); 128 | end 129 | 130 | if opts.debug 131 | normr = sqrt(ip(r,r)); 132 | normr_act = normr; 133 | resvec(ii+1,1) = normr; 134 | end 135 | end 136 | 137 | iter = ii; 138 | if opts.debug 139 | relres = normr_act / n2b; 140 | end 141 | 142 | % truncate the zeros from resvec 143 | if opts.debug 144 | if ((state.flag <= 1) || (state.flag == 3)) 145 | resvec = resvec(1:ii+1,:); 146 | else 147 | resvec = resvec(1:ii,:); 148 | end 149 | end 150 | 151 | % Save the state 152 | if nargout > 2 153 | state.p = p; 154 | state.rho = rho; 155 | if ~opts.CG_use_FR 156 | state.r_prev = r_prev; 157 | end 158 | end -------------------------------------------------------------------------------- /implementation/training/train_filter.m: -------------------------------------------------------------------------------- 1 | function [hf, res_norms, CG_state] = train_filter(hf, samplesf, yf, reg_filter, sample_weights, sample_energy, reg_energy, params, CG_opts, CG_state) 2 | 3 | % Do Conjugate gradient optimization of the filter. 4 | 5 | % Construct the right hand side vector 6 | rhs_samplef = cellfun(@(xf) permute(mtimesx(sample_weights, 'T', xf, 'speed'), [3 4 2 1]), samplesf, 'uniformoutput', false); 7 | rhs_samplef = cellfun(@(xf, yf) bsxfun(@times, conj(xf), yf), rhs_samplef, yf, 'uniformoutput', false); 8 | 9 | % Construct preconditioner 10 | diag_M = cellfun(@(m, reg_energy) (1-params.precond_reg_param) * bsxfun(@plus, params.precond_data_param * m, (1-params.precond_data_param) * mean(m,3)) + params.precond_reg_param*reg_energy, sample_energy, reg_energy, 'uniformoutput',false); 11 | 12 | % do conjugate gradient 13 | [hf, res_norms, CG_state] = pcg_ccot(... 14 | @(x) lhs_operation(x, samplesf, reg_filter, sample_weights),... 15 | rhs_samplef, CG_opts, ... 16 | @(x) diag_precond(x, diag_M), ... 17 | [], @inner_product_filter, ... 18 | hf, CG_state); 19 | 20 | res_norms = res_norms/sqrt(inner_product_filter(rhs_samplef,rhs_samplef)); -------------------------------------------------------------------------------- /implementation/training/train_filter_gpu.m: -------------------------------------------------------------------------------- 1 | function [hf, res_norms, CG_state] = train_filter_gpu(hf, samplesf, yf, reg_filter, sample_weights, sample_energy, reg_energy, params, CG_opts, CG_state) 2 | 3 | % Do Conjugate gradient optimization of the filter. 4 | 5 | sample_weights = permute(sample_weights, [2 3 4 1]); 6 | 7 | % Construct the right hand side vector 8 | rhs_samplef = cellfun(@(xf) sum(bsxfun(@times, sample_weights, xf), 4), samplesf, 'uniformoutput', false); 9 | rhs_samplef = cellfun(@(xf, yf) bsxfun(@times, conj(xf), yf), rhs_samplef, yf, 'uniformoutput', false); 10 | 11 | % Construct preconditioner 12 | diag_M = cellfun(@(m, reg_energy) (1-params.precond_reg_param) * bsxfun(@plus, params.precond_data_param * m, (1-params.precond_data_param) * mean(m,3)) + params.precond_reg_param*reg_energy, sample_energy, reg_energy, 'uniformoutput',false); 13 | 14 | % do conjugate gradient 15 | [hf, res_norms, CG_state] = pcg_ccot(... 16 | @(x) lhs_operation_gpu(x, samplesf, reg_filter, sample_weights),... 17 | rhs_samplef, CG_opts, ... 18 | @(x) diag_precond(x, diag_M), ... 19 | [], @inner_product_filter, ... 20 | hf, CG_state); 21 | 22 | res_norms = res_norms/sqrt(inner_product_filter(rhs_samplef,rhs_samplef)); -------------------------------------------------------------------------------- /implementation/training/train_joint.m: -------------------------------------------------------------------------------- 1 | function [hf, projection_matrix, res_norms] = train_joint(hf, projection_matrix, xlf, yf, reg_filter, sample_energy, reg_energy, proj_energy, params, init_CG_opts) 2 | 3 | % Initial Gauss-Newton optimization of the filter and 4 | % projection matrix. 5 | 6 | % Index for the start of the last column of frequencies 7 | lf_ind = cellfun(@(hf) size(hf,1) * (size(hf,2)-1) + 1, hf(1,1,:), 'uniformoutput', false); 8 | 9 | % Construct stuff for the proj matrix part 10 | init_samplef = cellfun(@(x) permute(x, [4 3 1 2]), xlf, 'uniformoutput', false); 11 | init_samplef_H = cellfun(@(X) conj(reshape(X, size(X,2), [])), init_samplef, 'uniformoutput', false); 12 | 13 | % Construct preconditioner 14 | diag_M = cell(size(hf)); 15 | diag_M(1,1,:) = cellfun(@(m, reg_energy) (1-params.precond_reg_param) * bsxfun(@plus, params.precond_data_param * m, (1-params.precond_data_param) * mean(m,3)) + params.precond_reg_param*reg_energy, sample_energy, reg_energy, 'uniformoutput',false); 16 | diag_M(2,1,:) = cellfun(@(m) params.precond_proj_param * (m + params.projection_reg), proj_energy, 'uniformoutput',false); 17 | 18 | % Allocate 19 | rhs_samplef = cell(size(hf)); 20 | res_norms = []; 21 | 22 | for iter = 1:params.init_GN_iter 23 | % Project sample with new matrix 24 | init_samplef_proj = cellfun(@(x,P) mtimesx(x, P, 'speed'), init_samplef, projection_matrix, 'uniformoutput', false); 25 | init_hf = cellfun(@(x) permute(x, [3 4 1 2]), hf(1,1,:), 'uniformoutput', false); 26 | 27 | % Construct the right hand side vector for the filter part 28 | rhs_samplef(1,1,:) = cellfun(@(xf, yf) bsxfun(@times, conj(permute(xf, [3 4 2 1])), yf), init_samplef_proj, yf, 'uniformoutput', false); 29 | 30 | % Construct the right hand side vector for the projection matrix part 31 | fyf = cellfun(@(f, yf) reshape(bsxfun(@times, conj(f), yf), [], size(f,3)), hf(1,1,:), yf, 'uniformoutput', false); 32 | rhs_samplef(2,1,:) = cellfun(@(P, XH, fyf, fi) (2*real(XH * fyf - XH(:,fi:end) * fyf(fi:end,:)) - params.projection_reg * P), ... 33 | projection_matrix, init_samplef_H, fyf, lf_ind, 'uniformoutput', false); 34 | 35 | % Initialize the projection matrix increment to zero 36 | hf(2,1,:) = cellfun(@(P) zeros(size(P), 'single'), projection_matrix, 'uniformoutput', false); 37 | 38 | % do conjugate gradient 39 | [hf, res_norms_temp] = pcg_ccot(... 40 | @(x) lhs_operation_joint(x, init_samplef_proj, reg_filter, init_samplef, init_samplef_H, init_hf, params.projection_reg),... 41 | rhs_samplef, init_CG_opts, ... 42 | @(x) diag_precond(x, diag_M), ... 43 | [], @inner_product_joint, hf); 44 | 45 | % Make the filter symmetric (avoid roundoff errors) 46 | hf(1,1,:) = symmetrize_filter(hf(1,1,:)); 47 | 48 | % Add to the projection matrix 49 | projection_matrix = cellfun(@plus, projection_matrix, hf(2,1,:), 'uniformoutput', false); 50 | 51 | res_norms = [res_norms; res_norms_temp]; 52 | end 53 | 54 | % Extract filter 55 | hf = hf(1,1,:); 56 | 57 | res_norms = res_norms/sqrt(inner_product_joint(rhs_samplef,rhs_samplef)); -------------------------------------------------------------------------------- /implementation/training/train_joint_gpu.m: -------------------------------------------------------------------------------- 1 | function [hf, projection_matrix, res_norms] = train_joint_gpu(hf, projection_matrix, init_samplef, yf, reg_filter, sample_energy, reg_energy, proj_energy, params, init_CG_opts) 2 | 3 | % Initial Gauss-Newton optimization of the filter and 4 | % projection matrix. 5 | 6 | % Index for the start of the last column of frequencies 7 | lf_ind = cellfun(@(hf) size(hf,1) * (size(hf,2)-1) + 1, hf(1,1,:), 'uniformoutput', false); 8 | 9 | % Construct stuff for the proj matrix part 10 | % init_samplef = cellfun(@(x) permute(x, [4 3 1 2]), init_samplef, 'uniformoutput', false); 11 | init_samplef_H = cellfun(@(X) reshape(X, [], size(X,3))', init_samplef, 'uniformoutput', false); 12 | 13 | % Construct preconditioner 14 | diag_M = cell(size(hf)); 15 | diag_M(1,1,:) = cellfun(@(m, reg_energy) (1-params.precond_reg_param) * bsxfun(@plus, params.precond_data_param * m, (1-params.precond_data_param) * mean(m,3)) + params.precond_reg_param*reg_energy, sample_energy, reg_energy, 'uniformoutput',false); 16 | diag_M(2,1,:) = cellfun(@(m) params.precond_proj_param * (m + params.projection_reg), proj_energy, 'uniformoutput',false); 17 | 18 | % Allocate 19 | rhs_samplef = cell(size(hf)); 20 | res_norms = []; 21 | 22 | for iter = 1:params.init_GN_iter 23 | % Project sample with new matrix 24 | init_samplef_proj = project_sample(init_samplef, projection_matrix); 25 | init_hf = hf(1,1,:); 26 | 27 | % Construct the right hand side vector for the filter part 28 | rhs_samplef(1,1,:) = cellfun(@(xf, yf) bsxfun(@times, conj(xf), yf), init_samplef_proj, yf, 'uniformoutput', false); 29 | 30 | % Construct the right hand side vector for the projection matrix part 31 | fyf = cellfun(@(f, yf) reshape(bsxfun(@times, conj(f), yf), [], size(f,3)), hf(1,1,:), yf, 'uniformoutput', false); 32 | rhs_samplef(2,1,:) = cellfun(@(P, XH, fyf, fi) (2*real(XH * fyf - XH(:,fi:end) * fyf(fi:end,:)) - params.projection_reg * P), ... 33 | projection_matrix, init_samplef_H, fyf, lf_ind, 'uniformoutput', false); 34 | 35 | % Initialize the projection matrix increment to zero 36 | hf(2,1,:) = cellfun(@(P) zeros(size(P), 'like', params.data_type), projection_matrix, 'uniformoutput', false); 37 | 38 | % do conjugate gradient 39 | [hf, res_norms_temp] = pcg_ccot(... 40 | @(x) lhs_operation_joint_gpu(x, init_samplef_proj, reg_filter, init_samplef, init_samplef_H, init_hf, params.projection_reg),... 41 | rhs_samplef, init_CG_opts, ... 42 | @(x) diag_precond(x, diag_M), ... 43 | [], @inner_product_joint, hf); 44 | 45 | % Make the filter symmetric (avoid roundoff errors) 46 | hf(1,1,:) = symmetrize_filter(hf(1,1,:)); 47 | 48 | % Add to the projection matrix 49 | projection_matrix = cellfun(@plus, projection_matrix, hf(2,1,:), 'uniformoutput', false); 50 | 51 | res_norms = [res_norms; res_norms_temp]; 52 | end 53 | 54 | res_norms = res_norms/sqrt(inner_product_joint(rhs_samplef,rhs_samplef)); 55 | 56 | % Extract filter 57 | hf = hf(1,1,:); -------------------------------------------------------------------------------- /install.m: -------------------------------------------------------------------------------- 1 | % Compile libraries and download network 2 | 3 | [home_dir, name, ext] = fileparts(mfilename('fullpath')); 4 | 5 | warning('ON', 'ECO:install') 6 | 7 | % mtimesx 8 | if exist('external_libs/mtimesx', 'dir') == 7 9 | cd external_libs/mtimesx 10 | mtimesx_build; 11 | cd(home_dir) 12 | else 13 | error('ECO:install', 'Mtimesx not found.') 14 | end 15 | 16 | % PDollar toolbox 17 | if exist('external_libs/pdollar_toolbox/external', 'dir') == 7 18 | cd external_libs/pdollar_toolbox/external 19 | toolboxCompile; 20 | cd(home_dir) 21 | else 22 | warning('ECO:install', 'PDollars toolbox not found. Clone this submodule if you want to use HOG features. Skipping for now.') 23 | end 24 | 25 | % matconvnet 26 | if exist('external_libs/matconvnet/matlab', 'dir') == 7 27 | cd external_libs/matconvnet/matlab 28 | try 29 | disp('Trying to compile MatConvNet with GPU support') 30 | vl_compilenn('enableGpu', true) 31 | catch err 32 | warning('ECO:install', 'Could not compile MatConvNet with GPU support. Compiling for only CPU instead.\nVisit http://www.vlfeat.org/matconvnet/install/ for instructions of how to compile MatConvNet.\nNote: remember to move the mex-files after re-compiling.'); 33 | vl_compilenn; 34 | end 35 | status = movefile('mex/vl_*.mex*'); 36 | cd(home_dir) 37 | 38 | % donwload network 39 | cd feature_extraction 40 | mkdir networks 41 | cd networks 42 | if ~(exist('imagenet-vgg-m-2048.mat', 'file') == 2) 43 | disp('Downloading the network "imagenet-vgg-m-2048.mat" from "http://www.vlfeat.org/matconvnet/models/imagenet-vgg-m-2048.mat"...') 44 | urlwrite('http://www.vlfeat.org/matconvnet/models/imagenet-vgg-m-2048.mat', 'imagenet-vgg-m-2048.mat') 45 | disp('Done!') 46 | end 47 | cd(home_dir) 48 | else 49 | warning('ECO:install', 'Matconvnet not found. Clone this submodule if you want to use CNN features. Skipping for now.') 50 | end -------------------------------------------------------------------------------- /result_plots/OTB-2015_succsess_plot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/result_plots/OTB-2015_succsess_plot.pdf -------------------------------------------------------------------------------- /result_plots/OTB-2015_succsess_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/result_plots/OTB-2015_succsess_plot.png -------------------------------------------------------------------------------- /sequences/Crossing/groundtruth_rect.txt: -------------------------------------------------------------------------------- 1 | 205 151 17 50 2 | 202 150 19 49 3 | 201 150 18 49 4 | 199 150 18 47 5 | 196 149 20 49 6 | 199 150 17 46 7 | 195 149 19 47 8 | 193 147 19 50 9 | 191 148 20 46 10 | 191 147 20 48 11 | 190 145 19 49 12 | 190 145 17 48 13 | 188 145 17 48 14 | 187 143 19 49 15 | 185 144 16 49 16 | 183 143 18 50 17 | 183 143 20 50 18 | 182 142 18 50 19 | 182 141 17 51 20 | 181 141 17 48 21 | 180 139 17 49 22 | 178 139 16 47 23 | 177 138 16 45 24 | 176 138 16 46 25 | 175 138 18 46 26 | 174 138 17 45 27 | 172 139 19 47 28 | 170 137 19 47 29 | 171 134 19 49 30 | 168 133 20 49 31 | 168 132 19 49 32 | 167 133 19 47 33 | 167 131 20 49 34 | 167 131 19 49 35 | 164 132 20 47 36 | 165 128 19 53 37 | 164 129 20 49 38 | 164 130 20 49 39 | 162 128 20 50 40 | 161 128 22 50 41 | 163 129 20 45 42 | 161 127 21 44 43 | 161 126 19 44 44 | 160 126 19 45 45 | 158 124 21 48 46 | 160 125 17 45 47 | 159 127 17 45 48 | 158 127 18 43 49 | 156 125 18 41 50 | 157 124 14 42 51 | 155 123 16 44 52 | 154 122 15 46 53 | 151 122 17 43 54 | 150 120 16 46 55 | 149 122 17 44 56 | 149 121 16 41 57 | 148 121 15 45 58 | 147 122 14 41 59 | 146 121 16 41 60 | 143 122 16 40 61 | 141 122 16 41 62 | 139 120 16 42 63 | 138 119 14 43 64 | 136 119 15 42 65 | 134 119 15 41 66 | 134 118 15 42 67 | 132 118 17 42 68 | 131 118 17 43 69 | 128 117 17 40 70 | 126 115 16 40 71 | 125 114 16 40 72 | 123 113 18 40 73 | 122 112 17 43 74 | 122 112 16 42 75 | 120 112 17 42 76 | 120 112 17 42 77 | 118 111 16 42 78 | 117 110 18 45 79 | 116 110 16 42 80 | 114 110 17 41 81 | 113 109 16 41 82 | 112 107 14 40 83 | 112 108 15 41 84 | 109 108 16 38 85 | 108 108 16 35 86 | 105 108 15 35 87 | 104 108 15 35 88 | 103 107 15 35 89 | 102 105 15 37 90 | 101 104 15 36 91 | 98 104 16 37 92 | 97 103 16 38 93 | 94 103 17 38 94 | 92 103 16 38 95 | 91 103 15 38 96 | 90 103 16 34 97 | 88 103 16 35 98 | 88 102 15 37 99 | 84 99 16 37 100 | 83 101 16 37 101 | 80 99 16 37 102 | 79 99 16 36 103 | 79 100 17 33 104 | 78 99 14 33 105 | 77 100 14 33 106 | 75 100 14 34 107 | 74 99 14 33 108 | 72 98 13 34 109 | 71 97 14 35 110 | 69 97 13 34 111 | 68 98 14 34 112 | 67 97 15 35 113 | 65 98 15 34 114 | 65 99 15 31 115 | 63 97 15 32 116 | 61 96 13 32 117 | 60 95 14 33 118 | 58 94 14 34 119 | 58 95 13 31 120 | 56 93 14 36 121 | -------------------------------------------------------------------------------- /sequences/Crossing/img/0001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0001.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0002.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0003.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0003.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0004.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0005.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0006.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0007.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0008.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0009.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0010.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0011.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0012.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0013.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0013.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0014.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0014.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0015.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0015.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0016.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0016.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0017.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0017.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0018.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0018.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0019.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0019.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0020.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0020.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0021.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0022.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0022.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0023.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0023.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0024.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0024.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0025.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0026.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0026.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0027.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0027.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0028.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0028.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0029.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0030.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0030.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0031.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0031.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0032.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0032.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0033.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0034.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0034.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0035.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0035.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0036.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0036.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0037.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0037.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0038.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0038.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0039.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0039.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0040.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0040.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0041.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0042.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0042.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0043.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0043.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0044.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0044.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0045.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0045.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0046.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0046.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0047.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0047.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0048.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0048.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0049.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0049.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0050.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0050.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0051.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0051.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0052.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0052.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0053.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0053.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0054.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0054.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0055.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0055.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0056.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0056.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0057.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0057.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0058.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0058.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0059.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0059.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0060.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0060.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0061.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0062.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0062.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0063.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0063.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0064.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0064.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0065.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0065.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0066.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0066.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0067.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0067.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0068.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0068.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0069.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0069.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0070.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0070.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0071.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0071.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0072.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0072.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0073.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0073.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0074.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0074.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0075.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0075.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0076.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0076.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0077.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0077.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0078.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0078.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0079.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0079.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0080.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0080.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0081.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0081.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0082.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0082.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0083.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0083.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0084.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0084.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0085.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0085.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0086.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0086.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0087.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0087.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0088.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0088.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0089.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0089.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0090.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0090.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0091.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0091.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0092.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0092.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0093.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0093.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0094.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0094.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0095.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0095.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0096.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0096.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0097.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0097.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0098.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0098.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0099.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0099.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0100.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0101.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0102.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0102.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0103.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0103.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0104.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0104.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0105.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0106.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0106.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0107.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0107.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0108.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0108.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0109.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0109.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0110.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0111.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0111.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0112.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0112.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0113.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0113.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0114.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0114.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0115.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0115.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0116.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0116.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0117.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0117.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0118.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0118.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0119.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0119.jpg -------------------------------------------------------------------------------- /sequences/Crossing/img/0120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-danelljan/ECO/27e8ae565cd63ec14bafcaad8b5b993bec8f3e69/sequences/Crossing/img/0120.jpg -------------------------------------------------------------------------------- /setup_paths.m: -------------------------------------------------------------------------------- 1 | function setup_paths() 2 | 3 | % Add the neccesary paths 4 | 5 | [pathstr, name, ext] = fileparts(mfilename('fullpath')); 6 | 7 | % Tracker implementation 8 | addpath(genpath([pathstr '/implementation/'])); 9 | 10 | % Runfiles 11 | addpath([pathstr '/runfiles/']); 12 | 13 | % Utilities 14 | addpath([pathstr '/utils/']); 15 | 16 | % The feature extraction 17 | addpath(genpath([pathstr '/feature_extraction/'])); 18 | 19 | % Matconvnet 20 | addpath([pathstr '/external_libs/matconvnet/matlab']); 21 | addpath([pathstr '/external_libs/matconvnet/matlab/mex/']); 22 | addpath([pathstr '/external_libs/matconvnet/matlab/simplenn']); 23 | 24 | % PDollar toolbox 25 | addpath(genpath([pathstr '/external_libs/pdollar_toolbox/channels'])); 26 | 27 | % Mtimesx 28 | addpath([pathstr '/external_libs/mtimesx/']); 29 | 30 | % mexResize 31 | addpath([pathstr '/external_libs/mexResize/']); 32 | -------------------------------------------------------------------------------- /utils/get_sequence_frame.m: -------------------------------------------------------------------------------- 1 | function [seq, im] = get_sequence_frame(seq) 2 | 3 | seq.frame = seq.frame + 1; 4 | 5 | if strcmpi(seq.format, 'otb') 6 | if seq.frame > seq.num_frames 7 | im = []; 8 | else 9 | im = imread(seq.image_files{seq.frame}); 10 | end 11 | elseif strcmpi(seq.format, 'vot') 12 | [seq.handle, image_file] = seq.handle.frame(seq.handle); 13 | if isempty(image_file) 14 | im = []; 15 | else 16 | im = imread(image_file); 17 | end 18 | else 19 | error('Uknown sequence format'); 20 | end -------------------------------------------------------------------------------- /utils/get_sequence_info.m: -------------------------------------------------------------------------------- 1 | function [seq, init_image] = get_sequence_info(seq) 2 | 3 | if ~isfield(seq, 'format') || isempty(seq.format) 4 | if isempty(seq) 5 | seq.format = 'vot'; 6 | else 7 | seq.format = 'otb'; 8 | end 9 | end 10 | 11 | seq.frame = 0; 12 | 13 | if strcmpi(seq.format, 'otb') 14 | seq.image_files = seq.s_frames; 15 | seq = rmfield(seq, 's_frames'); 16 | seq.init_sz = [seq.init_rect(1,4), seq.init_rect(1,3)]; 17 | seq.init_pos = [seq.init_rect(1,2), seq.init_rect(1,1)] + (seq.init_sz - 1)/2; 18 | seq.num_frames = numel(seq.image_files); 19 | seq.rect_position = zeros(seq.num_frames, 4); 20 | init_image = imread(seq.image_files{1}); 21 | elseif strcmpi(seq.format, 'vot') 22 | [seq.handle, init_image_file, init_region] = vot('polygon'); 23 | 24 | if isempty(init_image_file) 25 | init_image = []; 26 | return; 27 | end 28 | 29 | init_image = imread(init_image_file); 30 | 31 | bb_scale = 1; 32 | 33 | % If the provided region is a polygon ... 34 | if numel(init_region) > 4 35 | % Init with an axis aligned bounding box with correct area and center 36 | % coordinate 37 | cx = mean(init_region(1:2:end)); 38 | cy = mean(init_region(2:2:end)); 39 | x1 = min(init_region(1:2:end)); 40 | x2 = max(init_region(1:2:end)); 41 | y1 = min(init_region(2:2:end)); 42 | y2 = max(init_region(2:2:end)); 43 | A1 = norm(init_region(1:2) - init_region(3:4)) * norm(init_region(3:4) - init_region(5:6)); 44 | A2 = (x2 - x1) * (y2 - y1); 45 | s = sqrt(A1/A2); 46 | w = s * (x2 - x1) + 1; 47 | h = s * (y2 - y1) + 1; 48 | else 49 | cx = init_region(1) + (init_region(3) - 1)/2; 50 | cy = init_region(2) + (init_region(4) - 1)/2; 51 | w = init_region(3); 52 | h = init_region(4); 53 | end 54 | 55 | init_c = [cy cx]; 56 | init_sz = bb_scale * [h w]; 57 | 58 | im_size = size(init_image); 59 | 60 | seq.init_pos = init_c; 61 | seq.init_sz = min(max(round(init_sz), [1 1]), im_size(1:2)); 62 | seq.num_frames = Inf; 63 | seq.region = init_region; 64 | else 65 | error('Uknown sequence format'); 66 | end -------------------------------------------------------------------------------- /utils/get_sequence_results.m: -------------------------------------------------------------------------------- 1 | function [seq, results] = get_sequence_results(seq) 2 | 3 | if strcmpi(seq.format, 'otb') 4 | results.type = 'rect'; 5 | results.res = seq.rect_position; 6 | elseif strcmpi(seq.format, 'vot') 7 | seq.handle.quit(seq.handle); 8 | else 9 | error('Uknown sequence format'); 10 | end 11 | 12 | if isfield(seq, 'time') 13 | results.fps = seq.num_frames / seq.time; 14 | else 15 | results.fps = NaN; 16 | end -------------------------------------------------------------------------------- /utils/load_video_info.m: -------------------------------------------------------------------------------- 1 | function [seq, ground_truth] = load_video_info(video_path) 2 | 3 | ground_truth = dlmread([video_path '/groundtruth_rect.txt']); 4 | 5 | seq.format = 'otb'; 6 | seq.len = size(ground_truth, 1); 7 | seq.init_rect = ground_truth(1,:); 8 | 9 | img_path = [video_path '/img/']; 10 | 11 | if exist([img_path num2str(1, '%04i.png')], 'file'), 12 | img_files = num2str((1:seq.len)', [img_path '%04i.png']); 13 | elseif exist([img_path num2str(1, '%04i.jpg')], 'file'), 14 | img_files = num2str((1:seq.len)', [img_path '%04i.jpg']); 15 | elseif exist([img_path num2str(1, '%04i.bmp')], 'file'), 16 | img_files = num2str((1:seq.len)', [img_path '%04i.bmp']); 17 | else 18 | error('No image files to load.') 19 | end 20 | 21 | seq.s_frames = cellstr(img_files); 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /utils/report_tracking_result.m: -------------------------------------------------------------------------------- 1 | function seq = report_tracking_result(seq, result) 2 | 3 | if strcmpi(seq.format, 'otb') 4 | seq.rect_position(seq.frame,:) = round([result.center_pos([2,1]) - (result.target_size([2,1]) - 1)/2, result.target_size([2,1])]); 5 | elseif strcmpi(seq.format, 'vot') 6 | if seq.frame > 1 7 | bb_scale = 1; 8 | sz = result.target_size / bb_scale; 9 | tl = result.center_pos - (sz - 1)/2; 10 | br = result.center_pos + (sz - 1)/2; 11 | x1 = tl(2); y1 = tl(1); 12 | x2 = br(2); y2 = br(1); 13 | result_box = round(double([x1 y1 x2 y1 x2 y2 x1 y2])); 14 | if any(isnan(result_box) | isinf(result_box)) 15 | error('Illegal values in the result.') 16 | end 17 | % if any(result_box < 0) 18 | % error('Negative values') 19 | % end 20 | seq.handle = seq.handle.report(seq.handle, result_box); 21 | end 22 | else 23 | error('Uknown sequence format'); 24 | end --------------------------------------------------------------------------------