├── .gitignore ├── README.md ├── compile.m ├── cvpr_2019_test.rar ├── demo.m ├── demo_evalAIC19.m ├── get_opts.m ├── get_opts_aic.m ├── get_opts_mot.m ├── setup.m ├── src ├── AIC │ ├── L1 │ │ ├── aic_L1_motion_score.m │ │ ├── compute_L1_tracklets_aic.m │ │ ├── getAICValidDetections.m │ │ └── iou_score.m │ ├── L2 │ │ ├── aic_SmoothnessMatrix.m │ │ ├── aic_VelocityTimeMatrix.m │ │ ├── compute_L2_trajectories_aic.m │ │ ├── createTrajectories_aic.m │ │ ├── getGpsSpeed.m │ │ └── solveInGroups_aic.m │ ├── L3 │ │ ├── aic_L3_motion_score.m │ │ ├── aic_L3_motion_score_new.m │ │ ├── compute_L3_identities_aic.m │ │ ├── findIdentitiesInWindowInSubScene.m │ │ ├── linkIdentities_aic.m │ │ ├── linkIdentities_subscene.m │ │ └── solveInGroupsIdentities_aic.m │ ├── utils │ │ ├── C05_Mapping.mat │ │ ├── C35_Mapping.mat │ │ ├── add_gps.m │ │ ├── bbox_regression.m │ │ ├── create_testMat.m │ │ ├── extractHSVHistogram.m │ │ ├── get_frame_offset.m │ │ ├── get_projection_param.m │ │ ├── gps2image.m │ │ ├── hierarchical_cluster.m │ │ ├── image2gps.m │ │ ├── prepareMOTChallengeSubmission_aic.m │ │ ├── removeOverlapping.m │ │ └── unique_det_in_frame.m │ └── visualization │ │ ├── MyVideoReader_aic.m │ │ ├── ROI.m │ │ ├── render_results_aic.m │ │ └── show_gt_gps_pos.m ├── L1-tracklets │ ├── createTracklets.m │ ├── estimateVelocities.m │ ├── getAppearanceSubMatrix.m │ ├── getValidDetections.m │ ├── motionAffinity.m │ ├── smoothTracklets.m │ ├── trackletsVisualizePart1.m │ ├── trackletsVisualizePart2.m │ ├── trackletsVisualizePart3.m │ └── trackletsVisualizePart4.m ├── L2-trajectories │ ├── createTrajectories.m │ ├── fft_tracklet_feat.m │ ├── fillTrajectories.m │ ├── findTrackletsInWindow.m │ ├── findTrajectoriesInWindow.m │ ├── getAppearanceMatrix.m │ ├── getHeadTailSpeed.m │ ├── getHyperScore.m │ ├── getMotionFeat.m │ ├── getSpaceTimeAffinity.m │ ├── getTrackletFeatures.m │ ├── mergeResults.m │ ├── postProcess.m │ ├── recomputeTrajectories.m │ ├── removeShortTracks.m │ ├── solveInGroups.m │ ├── trackletsToTrajectories.m │ ├── trajectoriesToTop.m │ ├── trajectoriesVisualizePart1.m │ ├── trajectoriesVisualizePart2.m │ ├── trajectoriesVisualizePart2_5.m │ └── trajectoriesVisualizePart3.m ├── L3-identities │ ├── getSpaceTimeAffinityID.m │ ├── linkIdentities.m │ ├── loadL2trajectories.m │ ├── remedyIdentities.m │ ├── solveInGroupsIdentities.m │ └── trajectoriesToIdentities.m ├── MOT │ ├── compute_L1_tracklets_mot.m │ └── compute_L2_trajectories_mot.m ├── compute_L0_features.m ├── compute_L1_tracklets.m ├── compute_L2_trajectories.m ├── compute_L3_identities.m ├── correlation_clustering │ ├── BIPCC │ │ ├── BIPCC.m │ │ ├── createBIP.m │ │ ├── graphPartitioning.m │ │ └── labelsFromAdjacency.m │ └── external │ │ ├── AL-ICM │ │ ├── AL_ICM.m │ │ ├── LICENSE.txt │ │ ├── README.txt │ │ ├── VERSION.txt │ │ └── pure_potts_icm_iter_mex.cpp │ │ └── KL │ │ ├── KernighanLin.m │ │ ├── LICENSE.txt │ │ ├── Multicut_KL_MEX.cpp │ │ └── andres │ │ ├── graph │ │ ├── adjacency.hxx │ │ ├── complete-graph.hxx │ │ ├── detail │ │ │ └── graph.hxx │ │ ├── graph.hxx │ │ ├── multicut │ │ │ └── kernighan-lin.hxx │ │ ├── subgraph.hxx │ │ └── visitor.hxx │ │ └── random-access-set.hxx ├── duke │ ├── DukeFrameReader.m │ ├── DukeVideoReader.m │ ├── MyVideoReader.m │ ├── downloadDukeMTMC.m │ ├── getROIs.m │ ├── global2local.m │ ├── image2world.m │ ├── local2global.m │ ├── prepareMOTChallengeSubmission.m │ └── world2map.m ├── evaluate.m ├── external │ ├── DukeMTMC-reID_evaluation │ │ ├── CITATION_DukeMTMC-reID.txt │ │ ├── CITATION_DukeMTMC.txt │ │ ├── Data_Distribution.jpg │ │ ├── DukeMTMC-reID_mosaic.jpg │ │ ├── LICENSE_DukeMTMC-reID.txt │ │ ├── LICENSE_DukeMTMC.txt │ │ ├── README.md │ │ ├── State-of-the-art │ │ │ └── README.md │ │ ├── col_sum.m │ │ ├── compute_AP.m │ │ ├── duke_rank.jpg │ │ ├── evaluation_res_duke_fast.m │ │ ├── file.png │ │ ├── generate_train_list_caffe.m │ │ ├── sqdist.m │ │ └── train_list.txt │ ├── addborder │ │ ├── addborder.m │ │ └── license.txt │ ├── combinator │ │ ├── combinator.m │ │ ├── cumsumall.cpp │ │ ├── cumsumall.m │ │ └── license.txt │ ├── distinguishable_colors │ │ ├── distinguishable_colors.m │ │ └── license.txt │ ├── export-fig │ │ ├── .gitignore │ │ ├── ImageSelection.class │ │ ├── ImageSelection.java │ │ ├── LICENSE │ │ ├── README.md │ │ ├── append_pdfs.m │ │ ├── copyfig.m │ │ ├── crop_borders.m │ │ ├── eps2pdf.m │ │ ├── export_fig.m │ │ ├── fix_lines.m │ │ ├── ghostscript.m │ │ ├── im2gif.m │ │ ├── isolate_axes.m │ │ ├── pdf2eps.m │ │ ├── pdftops.m │ │ ├── print2array.m │ │ ├── print2eps.m │ │ ├── read_write_entire_textfile.m │ │ ├── user_string.m │ │ └── using_hg2.m │ ├── motchallenge-devkit │ │ ├── .hg_archival.txt │ │ ├── .hgignore │ │ ├── README.md │ │ ├── compile.m │ │ ├── evaluateDetection.m │ │ ├── evaluateTracking.m │ │ ├── seqmaps │ │ │ ├── AIC19-train.txt │ │ │ ├── AIC19-trainval.txt │ │ │ ├── AIC19-val.txt │ │ │ ├── DukeMTMCT-test-easy.txt │ │ │ ├── DukeMTMCT-test-hard.txt │ │ │ ├── DukeMTMCT-trainval-mini.txt │ │ │ ├── DukeMTMCT-trainval.txt │ │ │ ├── DukeMTMCT-val.txt │ │ │ └── MOT16-train.txt │ │ └── utils │ │ │ ├── CLEAR_MOD_HUN.m │ │ │ ├── CLEAR_MOT_HUN.m │ │ │ ├── Hungarian.m │ │ │ ├── IDmeasures.m │ │ │ ├── MinCostMatching.cpp │ │ │ ├── boxIntersect.m │ │ │ ├── boxUnion.m │ │ │ ├── boxiou.m │ │ │ ├── camera │ │ │ ├── README.md │ │ │ ├── calib_towncentre.m │ │ │ ├── distortedToUndistortedImageCoord.m │ │ │ ├── distortedToUndistortedSensorCoord.m │ │ │ ├── getRotTrans.m │ │ │ ├── imageToWorld.m │ │ │ ├── parseCameraParameters.m │ │ │ ├── undistortedToDistortedImageCoord.m │ │ │ ├── undistortedToDistortedSensorCoord.m │ │ │ └── worldToImage.m │ │ │ ├── classIDToString.m │ │ │ ├── classStringToID.m │ │ │ ├── cleanRequired.m │ │ │ ├── clearMOTLoopMatlab.m │ │ │ ├── clearMOTMex.cpp │ │ │ ├── convertMatToStruct.m │ │ │ ├── convertTXTToStruct.m │ │ │ ├── costBlockMex.cpp │ │ │ ├── costFunction.m │ │ │ ├── evaluateBenchmark.m │ │ │ ├── evaluateMultiCam.m │ │ │ ├── external │ │ │ ├── PrintTable.m │ │ │ ├── dollar │ │ │ │ └── toolbox │ │ │ │ │ └── detector │ │ │ │ │ ├── Contents.m │ │ │ │ │ ├── acfDemoCal.m │ │ │ │ │ ├── acfDemoInria.m │ │ │ │ │ ├── acfDetect.m │ │ │ │ │ ├── acfModify.m │ │ │ │ │ ├── acfTest.m │ │ │ │ │ ├── acfTrain.m │ │ │ │ │ ├── bbApply.m │ │ │ │ │ ├── bbGt.m │ │ │ │ │ ├── bbLabeler.m │ │ │ │ │ ├── bbNms.m │ │ │ │ │ ├── detectPeople.m │ │ │ │ │ ├── evalDetections.m │ │ │ │ │ ├── models │ │ │ │ │ ├── AcfCaltechDetector.mat │ │ │ │ │ ├── AcfCaltechLog.txt │ │ │ │ │ ├── AcfCaltechRoc.png │ │ │ │ │ ├── AcfInriaDetector.mat │ │ │ │ │ ├── AcfInriaLog.txt │ │ │ │ │ └── AcfInriaRoc.png │ │ │ │ │ ├── private │ │ │ │ │ └── acfDetect1.cpp │ │ │ │ │ └── writeDets.m │ │ │ └── iniconfig │ │ │ │ ├── IniConfig.m │ │ │ │ └── license.txt │ │ │ ├── getClassLabels.m │ │ │ ├── getImgExt.m │ │ │ ├── getROIs.m │ │ │ ├── getSeqInfoFromFile.m │ │ │ ├── ismember_mex.c │ │ │ ├── parseSequences2.m │ │ │ ├── preprocessResult.m │ │ │ ├── printMetrics.m │ │ │ ├── printMetricsDet.m │ │ │ ├── printMetricsExt.m │ │ │ ├── removeObjsSingleCam.m │ │ │ └── removeOutliersROI.m │ ├── nestedSortStruct │ │ ├── license.txt │ │ ├── nestedSortStruct.m │ │ ├── nestedSortStruct2.m │ │ ├── sortStruct.m │ │ └── sortStruct2.m │ └── tSNE │ │ ├── d2p.m │ │ ├── tsne.m │ │ ├── tsne_d.m │ │ ├── tsne_p.m │ │ └── x2p.m ├── hyper_score │ ├── DET_L1_processing.m │ ├── DET_L1_tracklets.m │ ├── GT_L1_processing.m │ ├── GT_L1_tracklets.m │ ├── GT_L2_fft.m │ ├── GT_L2_motion.m │ ├── GT_L2_trajectories.m │ ├── GT_L3_motion.m │ ├── README.md │ ├── Utils.py │ ├── dataset.py │ ├── dataset_AB.py │ ├── main.py │ ├── models.py │ ├── new_GT_L3_motion.m │ ├── new_GT_feat.m │ ├── new_GT_feat_aic.m │ ├── regress_AM.m │ ├── sampler.py │ ├── train_L2.sh │ └── train_L3.sh ├── prepare_bbox │ ├── gen_det_function.m │ ├── gen_gt_function.m │ ├── get_ALL_det_bbox.m │ └── get_ALL_gt_bbox.m ├── test_tracker.m ├── util │ ├── create_experiment_dir.m │ ├── error_types.m │ ├── feetPosition.m │ ├── getBoundingBoxCenters.m │ ├── getSpatialGroupIDs.m │ ├── get_bb.m │ ├── identities2mat.m │ ├── intervalSearch.m │ ├── matching_errors.m │ ├── pose2bb.m │ ├── renderPoses.m │ └── scale_bb.m └── visualization │ ├── data │ ├── duke_easy_scores.txt │ ├── duke_hard_scores.txt │ └── map.jpg │ ├── file_list.csv │ ├── find_consecute_iCam_part1.m │ ├── find_consecute_iCam_part2.m │ ├── render_results.m │ ├── render_state_of_the_art.m │ ├── render_trajectories_side.m │ ├── render_trajectories_top.m │ ├── show_bbox.m │ ├── show_detections.m │ ├── view_MCT_metirc_hist.m │ ├── view_SCT_metirc_hist.m │ ├── view_consecutive_score.m │ ├── view_distance_distribution.m │ ├── view_distance_distribution_separate_icam.m │ ├── view_ingroup_score.m │ ├── view_tsne.m │ ├── view_tsne_2.m │ └── view_tsne_2_function.m ├── test_aic_zju_ensemble.m ├── train_mot_full.m ├── train_mot_og.m ├── val_aic_ensemble.m ├── val_aic_tc_ssd.m ├── val_aic_zju.m ├── val_duke_L2.m ├── val_duke_og.m └── view_appear_score.m /.gitignore: -------------------------------------------------------------------------------- 1 | experiments/ 2 | src/external/mexopencv/ 3 | src/hyper_score/.idea/* 4 | src/hyper_score/logs/* 5 | src/external/motchallenge-devkit/seqmaps/AIC19-test* 6 | script/ 7 | *.mex* 8 | *.asv 9 | *.pyc 10 | *.tar 11 | *.jpg 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DeepCC-local 2 | 3 | This repo is based on Ergys Ristani's DeepCC \[[code](https://github.com/ergysr/DeepCC), [paper](http://openaccess.thecvf.com/content_cvpr_2018/papers/Ristani_Features_for_Multi-Target_CVPR_2018_paper.pdf)\]. This tracker is based on *MATLAB*. 4 | 5 | We added multiple functions for performance and utilities, including our *locality-aware* setting reported in our CVPR 2019 workshop paper (to be released). 6 | 7 | Besides, other dataset support are also added including MOT-16 and AI-City 2019. 8 | 9 | # AI-City 2019 update 10 | 11 | ### Setup 12 | For AI-City setup, please download the folder from [google drive](https://drive.google.com/drive/folders/1BklU8afXHoLu3xmmOcSFqniD3ZUJqqfJ?usp=sharing). Note that the official AI-City 2019 track-1 dataset also has to be downloaded. This folder only act as a incremental package. 13 | 14 | The folder we provide contains the re-ID features for demo usage. 15 | 16 | Before running, please check that the dataset position in `get_opts_aic.m` is changed as your setting. 17 | ``` 18 | opts.dataset_path = '~/Data/AIC19'; 19 | ``` 20 | 21 | After that, open up *MATLAB* at the code root directory, first run `get_opts_aic.m` to finish the setup. Then, type to run `add_gps.m` to add gps position to the detections. 22 | 23 | 24 | ### Running Demo 25 | To run the demo, please open up *MATLAB* and run `val_aic_ensemble.m`. This should give you about 79.7 SCT IDF1 and 78.1 MCT IDF1 on the `train` set. 26 | 27 | For the `test` set, please run `test_aic_ensemble.m`. However, the test set result must be uploaded to the AI-City server for online test. To do that, please run `prepareMOTChallengeSubmission_aic.m`. 28 | 29 | ### Train your own re-ID model and run the tracker 30 | If you want to train your own re-ID model, please check our other repo [open-reid-tracking](https://github.com/hou-yz/open-reid-tracking). 31 | 32 | After training the re-ID model and computing the re-ID features for detection bounding boxes (pre-requisite of tracking), please run the `view_appear_score.m` file to get your own threshold/norm parameters. 33 | NOthe that the experiment directory in `view_appear_score.m` must be changed accordingly before running. 34 | ``` 35 | opts.net.experiment_root = 'experiments/zju_lr001_colorjitter_256_gt_val'; 36 | ``` 37 | 38 | After that, you can replace the old parameters. Remember to change the new feature saving directory in `val_aic_ensemble.m` or `test_aic_ensemble.m`, and you should be good to go. 39 | -------------------------------------------------------------------------------- /compile.m: -------------------------------------------------------------------------------- 1 | cur_dir = pwd; 2 | 3 | % KL 4 | cd src/correlation_clustering/external/KL 5 | mex -O -largeArrayDims Multicut_KL_MEX.cpp 6 | cd(cur_dir) 7 | 8 | % AL-ICM 9 | cd src/correlation_clustering/external/AL-ICM 10 | mex -O -largeArrayDims pure_potts_icm_iter_mex.cpp 11 | cd(cur_dir) 12 | 13 | % Combinator 14 | cd src/external/combinator 15 | mex -O -largeArrayDims cumsumall.cpp 16 | cd(cur_dir) 17 | 18 | cd src/external/motchallenge-devkit 19 | mex utils/MinCostMatching.cpp -outdir utils CXXFLAGS="$CXXFLAGS --std=c++11" 20 | mex utils/clearMOTMex.cpp -outdir utils CXXFLAGS="$CXXFLAGS --std=c++11" 21 | mex utils/costBlockMex.cpp -outdir utils COMPFLAGS="/openmp $COMPFLAGS" CXXFLAGS="$CXXFLAGS --std=c++11" 22 | cd(cur_dir) 23 | -------------------------------------------------------------------------------- /cvpr_2019_test.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/cvpr_2019_test.rar -------------------------------------------------------------------------------- /demo.m: -------------------------------------------------------------------------------- 1 | %% Options 2 | opts = get_opts(); 3 | create_experiment_dir(opts); 4 | 5 | %% Setup Gurobi 6 | if ~exist('setup_done','var') 7 | setup; 8 | setup_done = true; 9 | end 10 | 11 | %% Run Tracker 12 | 13 | % opts.visualize = true; 14 | opts.sequence = 2; % trainval-mini 15 | 16 | % Tracklets 17 | opts.optimization = 'KL'; 18 | compute_L1_tracklets(opts); 19 | 20 | % Single-camera trajectories 21 | opts.optimization = 'BIPCC'; 22 | opts.trajectories.appearance_groups = 1; 23 | compute_L2_trajectories(opts); 24 | opts.eval_dir = 'L2-trajectories'; 25 | evaluate(opts); 26 | 27 | % Multi-camera identities 28 | opts.identities.appearance_groups = 0; 29 | compute_L3_identities(opts); 30 | opts.eval_dir = 'L3-identities'; 31 | evaluate(opts); 32 | 33 | -------------------------------------------------------------------------------- /demo_evalAIC19.m: -------------------------------------------------------------------------------- 1 | %% Fetching data 2 | opts = get_opts_aic; 3 | if ~exist(fullfile(opts.dataset_path,'ground_truth/train.mat'),'file') 4 | fprintf('Downloading ground truth...\n'); 5 | url = 'https://drive.google.com/uc?export=download&id=1_fWMD3kMawp9hOaHnkpCKIYgpt9vufsQ'; 6 | if ~exist(fullfile(opts.dataset_path,'ground_truth'),'dir'), mkdir(fullfile(opts.dataset_path,'ground_truth')); end 7 | filename = fullfile(opts.dataset_path,'ground_truth/train.mat'); 8 | if exist('websave','builtin') 9 | outfilename = websave(filename,url); % exists from MATLAB 2014b 10 | else 11 | outfilename = urlwrite(url, filename); 12 | end 13 | end 14 | if ~exist('experiments/aic_demo','dir') || ~exist('experiments/aic_demo/train.txt','file') %|| ~exist('experiments/aic_demo/test.txt','file') 15 | fprintf('Downloading baseline tracker output...\n'); 16 | url = 'https://drive.google.com/uc?export=download&id=1qQ1PJXyrdKb8kU0NWlZtAlWfB4oFv__O'; 17 | if ~exist('experiments/aic_demo','dir'), mkdir('experiments/aic_demo'); end 18 | filename = 'experiments/aic_demo/baseline.zip'; 19 | if exist('websave','builtin') 20 | outfilename = websave(filename,url); % exists from MATLAB 2014b 21 | else 22 | outfilename = urlwrite(url, filename); 23 | end 24 | unzip(outfilename,'experiments/aic_demo/'); 25 | delete(filename); 26 | % Convert to motchallenge format: Frame, ID, left, top, right, bottom, 27 | % worldX, worldY 28 | output_train = dlmread('experiments/aic_demo/train.txt'); 29 | %output_test = dlmread('experiments/aic_demo/test.txt'); 30 | 31 | for cam = 1:40 32 | filter_train = output_train(:,1) == cam; 33 | data_train = output_train(filter_train,:); 34 | data_train = data_train(:,2:end); 35 | data_train(:,[1 2]) = data_train(:,[2 1]); 36 | if ~isempty(data_train) 37 | dlmwrite(sprintf('experiments/aic_demo/c%03d_train.txt', cam), data_train, 'delimiter', ',', 'precision', 6); 38 | end 39 | 40 | % filter_test = output_test(:,1) == cam; 41 | % data_test = output_test(filter_test,:); 42 | % data_test = data_test(:,2:end); 43 | % data_test(:,[1 2]) = data_test(:,[2 1]); 44 | % if ~isempty(data_test) 45 | % dlmwrite(sprintf('experiments/aic_demo/c%03d_test.txt', cam), data_test, 'delimiter', ',', 'precision', 6); 46 | % end 47 | end 48 | end 49 | 50 | %% Evaluation 51 | [allMets, metsBenchmark, metsMultiCam] = evaluateTracking('AIC19-train.txt', 'experiments/aic_demo/', 'gt/AIC19', 'AIC19',opts.dataset_path); 52 | -------------------------------------------------------------------------------- /get_opts_mot.m: -------------------------------------------------------------------------------- 1 | function opts = get_opts_mot() 2 | 3 | addpath(genpath('src')) 4 | 5 | opts = []; 6 | opts.dataset = 1;%0 for duke, 1 for mot, 2 for aic 7 | opts.feature_dir = 'D:/Data/MOT16/det_feat/og512/'; 8 | opts.dataset_path = 'D:/Data/MOT16/'; 9 | opts.gurobi_path = 'C:/Utils/gurobi801/win64/matlab'; 10 | opts.experiment_root = 'experiments'; 11 | opts.experiment_name = 'demo'; 12 | 13 | 14 | % General settings 15 | opts.eval_dir = 'L2-trajectories'; 16 | opts.visualize = false; 17 | opts.image_width = 1920; 18 | opts.image_height = 1080; 19 | opts.current_camera = -1; 20 | opts.minimum_trajectory_length = 50; 21 | opts.optimization = 'KL'; 22 | opts.sequence = 7; 23 | opts.sequence_names = {'trainval', 'trainval_mini', 'test_easy', 'test_hard', 'trainval_nano','test_all','train','val'}; 24 | opts.seqs = [2,4,5,9,10,11,13]; 25 | opts.render_threshold = -10; 26 | opts.load_tracklets = 1; 27 | opts.load_trajectories = 1; 28 | opts.appear_model_name = 'MOT/og512/model_param_L2_15.mat'; 29 | opts.soft = 0.1; 30 | 31 | % Tracklets 32 | tracklets = []; 33 | tracklets.spatial_groups = 1; 34 | tracklets.window_width = 50; 35 | tracklets.min_length = 5; 36 | tracklets.alpha = 1; 37 | tracklets.beta = 0.02; 38 | tracklets.cluster_coeff = 0.75; 39 | tracklets.nearest_neighbors = 8; 40 | tracklets.speed_limit = 20; 41 | tracklets.threshold = 8; 42 | tracklets.diff_p = 0; 43 | tracklets.diff_n = 0; 44 | tracklets.step = false; 45 | tracklets.og_appear_score = true; 46 | tracklets.og_motion_score = true; 47 | 48 | 49 | % Trajectories 50 | trajectories = []; 51 | trajectories.appearance_groups = 0; % determined automatically when zero 52 | trajectories.alpha = 1; 53 | trajectories.beta = 0.01; 54 | trajectories.window_width = 300; 55 | trajectories.speed_limit = 30; 56 | trajectories.indifference_time = 100; 57 | trajectories.threshold = 8; 58 | trajectories.diff_p = 0; 59 | trajectories.diff_n = 0; 60 | trajectories.step = false; 61 | trajectories.og_appear_score = true; 62 | trajectories.og_motion_score = true; 63 | trajectories.use_indiff = true; 64 | 65 | opts.tracklets = tracklets; 66 | opts.trajectories = trajectories; 67 | end 68 | 69 | -------------------------------------------------------------------------------- /setup.m: -------------------------------------------------------------------------------- 1 | % Checks for a valid installation of the Gurobi optimizer. 2 | % Without Gurobi you can still run the tracker with the AL-ICM or KL optimizer 3 | try 4 | % Change this path accordingly 5 | run(fullfile(opts.gurobi_path, 'gurobi_setup.m')); 6 | catch 7 | fprintf('\nWARNING!\n\nGurobi optimizer not found.\nYou can still run the tracker with AL-ICM or KL optimization.\n'); 8 | end -------------------------------------------------------------------------------- /src/AIC/L1/aic_L1_motion_score.m: -------------------------------------------------------------------------------- 1 | function [stAffinity, impossibilityMatrix] = aic_L1_motion_score(bboxs, world_pos, frames, speedLimit, beta) 2 | centers = world_pos; 3 | 4 | ious = bboxOverlapRatio(bboxs,bboxs); 5 | iou_min = bboxOverlapRatio(bboxs,bboxs,'min'); 6 | 7 | frameDifference = repmat(frames,1,numel(frames)) - repmat(frames',numel(frames),1); 8 | overlapping = frameDifference == 0; 9 | centersDistance = pdist2(centers,centers); 10 | merging = overlapping & (iou_min > 0); 11 | % merging = false; 12 | velocity = centersDistance./(abs(frameDifference)+10^-12)*10; 13 | violators = velocity > speedLimit; 14 | 15 | % build impossibility matrix 16 | impossibilityMatrix = zeros(numel(frames)); 17 | impossibilityMatrix(violators > 0 & merging ~=1) = 1; 18 | impossibilityMatrix(overlapping == 1 & merging ~=1) = 1; 19 | 20 | 21 | % compute space-time affinities 22 | stAffinity = ious-0.1*centersDistance; 23 | end 24 | 25 | -------------------------------------------------------------------------------- /src/AIC/L1/getAICValidDetections.m: -------------------------------------------------------------------------------- 1 | function valid = getAICValidDetections(iCam, detections, imageROI) 2 | % if ismember(iCam, [1:9,16,22,25,26,27,34:36,50]) 3 | % ignore_size = [100,80]; 4 | % elseif ismember(iCam, 10:15) 5 | % ignore_size = [120,100]; 6 | % else 7 | % ignore_size = [100,80]; 8 | % end 9 | % ignore_size = ignore_size - 40; 10 | frames = unique(detections(:,1)); 11 | % Flags valid OpenPose detections 12 | valid = true(size(detections,1),1); 13 | 14 | for i = 1:length(frames) 15 | frame = frames(i); 16 | line_ids = find(detections(:,1) == frame); 17 | bboxs = detections(line_ids, [3, 4, 5, 6]); 18 | feet_pos = feetPosition(bboxs); 19 | %% NMS 20 | % ious = bboxOverlapRatio(bboxs,bboxs); 21 | % ious_min = bboxOverlapRatio(bboxs,bboxs,'Min'); 22 | % merging = ious>0.9 & ious_min>0.95; 23 | % [rows,columns] = find(triu(merging,1)); 24 | % valid(columns) = false; 25 | %% ROI 26 | inds = sub2ind( size(imageROI), uint64(feet_pos(:,2)), uint64(feet_pos(:,1))); 27 | valid(line_ids(imageROI(inds) == 0)) = false; 28 | valid(line_ids(bboxs(:,3) .* bboxs(:,4) < 1000)) = false; 29 | end 30 | end -------------------------------------------------------------------------------- /src/AIC/L1/iou_score.m: -------------------------------------------------------------------------------- 1 | function [ious] = iou_score(bboxs) 2 | %iou_score Summary of this function goes here 3 | % Detailed explanation goes here 4 | ious = bboxOverlapRatio(bboxs,bboxs); 5 | ious(ious == 0) = -1; 6 | ious = ious/2; 7 | % ious(ious>0) = ious(ious>0)/0.8; 8 | % ious(ious<=0) = ious(ious<=0)/0.2; 9 | end 10 | 11 | -------------------------------------------------------------------------------- /src/AIC/L2/getGpsSpeed.m: -------------------------------------------------------------------------------- 1 | function [ startpoint, endpoint, velocity,intervals] = getGpsSpeed( trackletData) 2 | 3 | numTracklets = length(trackletData); 4 | 5 | % calculate velocity, direction, for each tracklet 6 | 7 | velocity = zeros(numTracklets,2); 8 | startpoint = zeros(numTracklets,2); 9 | endpoint = zeros(numTracklets,2); 10 | duration = zeros(numTracklets,1); 11 | intervals = zeros(numTracklets,2); 12 | 13 | 14 | for ind = 1:numTracklets 15 | intervals(ind,:) = [trackletData{ind}(1,1), trackletData{ind}(end,1)]; 16 | startpoint(ind,:) = [trackletData{ind}(1,7), trackletData{ind}(1,8)]; 17 | endpoint(ind,:) = [trackletData{ind}(end,7), trackletData{ind}(end,8)]; 18 | duration(ind) = intervals(ind,2) - intervals(ind,1); 19 | direction = endpoint(ind,:) - startpoint(ind,:); 20 | velocity(ind,:) = direction./duration(ind)*10; 21 | end 22 | end 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/AIC/L3/findIdentitiesInWindowInSubScene.m: -------------------------------------------------------------------------------- 1 | function trajectoriesInWindow = findIdentitiesInWindowInSubScene(ids, startTime, endTime, cams_in_subscene) 2 | trajectoriesInWindow = []; 3 | 4 | if isempty(ids), return; end 5 | 6 | in_subscene = zeros(1,length(ids)); 7 | for i = 1:length(ids) 8 | in_subscene(i) = sum(ismember(ids(i).iCams,cams_in_subscene)); 9 | end 10 | 11 | trajectoryStartFrame = [ids.startFrame]; %cell2mat({trajectories.startFrame}); 12 | trajectoryEndFrame = [ids.endFrame]; % cell2mat({trajectories.endFrame}); 13 | trajectoriesInWindow = find( (trajectoryEndFrame >= startTime) .* (trajectoryStartFrame <= endTime) .* in_subscene ); 14 | 15 | end -------------------------------------------------------------------------------- /src/AIC/utils/C05_Mapping.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/AIC/utils/C05_Mapping.mat -------------------------------------------------------------------------------- /src/AIC/utils/C35_Mapping.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/AIC/utils/C35_Mapping.mat -------------------------------------------------------------------------------- /src/AIC/utils/add_gps.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | opts = get_opts_aic(); 5 | for scene = 1:5 6 | gt = 0; 7 | 8 | cam_pool = opts.cams_in_scene{scene}; 9 | all_detections = cell(1,length(cam_pool)); 10 | 11 | for i = length(cam_pool):-1:1 12 | iCam = cam_pool(i); 13 | opts.current_camera = iCam; 14 | % Load OpenPose detections for current camera 15 | if gt 16 | data = load(sprintf('%s/%s/S%02d/c%03d/gt/gt.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam)); 17 | else 18 | data = load(sprintf('%s/%s/S%02d/c%03d/det/det_%s.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam, opts.detections)); 19 | end 20 | bboxs = data(:,3:6); 21 | % feet pos 22 | feet_pos = feetPosition(bboxs); 23 | 24 | % Show window detections 25 | if opts.visualize 26 | startFrame = 100; 27 | detectionCenters = feet_pos((data(:,1) >= startFrame) & (data(:,1) <= (startFrame+opts.tracklets.window_width)),:); 28 | spatialGroupIDs = ones(length(detectionCenters),1); 29 | trackletsVisualizePart1; 30 | end 31 | 32 | % image2gps 33 | gps_pos = image2gps(opts,feet_pos,scene,iCam); 34 | re_image_pos = gps2image(opts,gps_pos,scene,iCam); 35 | max(max(feet_pos-re_image_pos)) 36 | 37 | % global time 38 | frame_offset = opts.frame_offset{scene} .* opts.fps; 39 | global_frame = local2global(frame_offset(iCam),data(:,1)); 40 | 41 | data(:,8) = ones(size(global_frame))*iCam; 42 | data(:,9) = global_frame; 43 | data(:,10:11) = gps_pos; 44 | all_detections{iCam} = data; 45 | if gt 46 | dlmwrite(sprintf('%s/%s/S%02d/c%03d/gt/gt_gps.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam),data,'precision',10); 47 | else 48 | dlmwrite(sprintf('%s/%s/S%02d/c%03d/det/det_%s_gps.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam, opts.detections),data,'precision',10); 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /src/AIC/utils/bbox_regression.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | opts = get_opts_aic(); 4 | 5 | w_det = []; h_det = []; 6 | w_gt = []; h_gt = []; 7 | min_gt_w = zeros(1,40); min_gt_h = zeros(1,40); 8 | for scene = opts.seqs{opts.sequence} 9 | for iCam = opts.cams_in_scene{scene} 10 | gt = load(sprintf('%s/%s/S%02d/c%03d/gt/gt.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam)); 11 | det = load(sprintf('%s/%s/labeled/c%03d_det_ssd512_labeled.txt', opts.dataset_path, opts.folder_by_scene{scene}, iCam)); 12 | min_gt_w(iCam) = min(gt(:,5)); min_gt_h(iCam) = min(gt(:,6)); 13 | det(det(:,2)==-1,:) = []; 14 | gt = sortrows(gt,[2,1]); 15 | det = sortrows(det,[2,1]); 16 | [C,ia] = setdiff(gt(:,1:2),det(:,1:2),'rows'); 17 | gt(ia,:) = []; 18 | w_det = [w_det;det(:,5)]; h_det = [h_det;det(:,6)]; 19 | w_gt = [w_gt;gt(:,5)]; h_gt = [h_gt;gt(:,6)]; 20 | 21 | end 22 | end 23 | 24 | w_model = polyfit(w_det,w_gt,1); 25 | w_pred = polyval(w_model, w_det); 26 | h_model = polyfit(h_det,h_gt,1); 27 | h_pred = polyval(h_model, h_det); -------------------------------------------------------------------------------- /src/AIC/utils/create_testMat.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | 4 | opts = get_opts_aic(); 5 | opts.experiment_name = 'aic_util'; 6 | opts.sequence = 2; 7 | 8 | % removeOverlapping(opts); 9 | 10 | 11 | testData = []; 12 | 13 | scene = 6; 14 | 15 | cams = [6:9,22:28,33:35] 16 | for i = 1:length(cams) 17 | iCam = cams(i); 18 | resdata = dlmread(sprintf('%s/%s/L3-identities/cam%d_%s.txt',opts.experiment_root, opts.experiment_name, iCam,opts.folder_by_seq{opts.sequence})); 19 | resdata = round(resdata); 20 | resdata(:,[1,2]) = resdata(:,[2,1]); 21 | resdata(:,[7:end]) = []; 22 | resdata = [ones(size(resdata,1),1)*iCam,resdata]; 23 | testData = [testData;resdata]; 24 | end 25 | 26 | testData = [testData,ones(size(testData,1),4)*-1]; 27 | testData = sortrows(testData,[1,3]); 28 | % s02 = load(fullfile(opts.dataset_path,'ground_truth', 'test_easy.mat')); 29 | % max_id = max(s02.testData(:,2)); 30 | % s05 = load(fullfile(opts.dataset_path,'ground_truth', 'test_mini.mat')); 31 | % s05.testData(:,2) = s05.testData(:,2) + max_id; 32 | % testData = [s02.testData;s05.testData]; 33 | 34 | save(fullfile(opts.dataset_path,'ground_truth', 'test.mat'),'testData'); 35 | -------------------------------------------------------------------------------- /src/AIC/utils/extractHSVHistogram.m: -------------------------------------------------------------------------------- 1 | function [ feature ] = extractHSVHistogram( image ) 2 | 3 | binsH = 16; 4 | binsS = 16; 5 | binsV = 4; 6 | 7 | img = rgb2hsv(image); 8 | 9 | h = img(:,:,1); 10 | s = img(:,:,2); 11 | v = img(:,:,3); 12 | 13 | histH = hist(h(:),binsH); 14 | histS = hist(s(:),binsS); 15 | histV = hist(v(:),binsV); 16 | 17 | feature = [histH, histS, histV]; 18 | feature = feature/(eps+sum(feature)); -------------------------------------------------------------------------------- /src/AIC/utils/get_frame_offset.m: -------------------------------------------------------------------------------- 1 | function frame_offset = get_frame_offset(opts) 2 | frame_offset = cell(1,6); 3 | for scene = 1:5 4 | fpath = fullfile(opts.dataset_path,'cam_timestamp',sprintf('S%02d.txt',scene)); 5 | fileID = fopen(fpath,'r'); 6 | line1 = textscan(fileID, '%s%f\r\n'); 7 | time_offsets = zeros(1,40); 8 | time_offsets(opts.cams_in_scene{scene}) = line1{2}; 9 | frame_offsets = round(time_offsets * opts.fps); 10 | frame_offset{scene} = frame_offsets; 11 | end 12 | frame_offset{6} = frame_offset{5}; 13 | fclose('all'); 14 | end 15 | 16 | -------------------------------------------------------------------------------- /src/AIC/utils/get_projection_param.m: -------------------------------------------------------------------------------- 1 | function [projection,camera_pos_mapping] = get_projection_param(opts) 2 | projection = cell(1,40); 3 | for iCam = 1:40 4 | param = struct('homography',[],'error',[],'intrinsic',[],'distortion',[]); 5 | fpath = fullfile(opts.dataset_path,'calibration',sprintf('c%03d',iCam),'calibration.txt'); 6 | fileID = fopen(fpath,'r'); 7 | tline = fgetl(fileID); 8 | while tline ~= -1 9 | if contains(tline,'Homography matrix') 10 | tline = erase(tline,'Homography matrix: '); 11 | format long 12 | param.homography = str2num(tline); 13 | elseif contains(tline,'Reprojection error') 14 | tline = erase(tline,'Reprojection error: '); 15 | format long 16 | param.error = str2num(tline); 17 | elseif contains(tline,'Intrinsic parameter matrix') 18 | tline = erase(tline,'Intrinsic parameter matrix: '); 19 | format long 20 | param.intrinsic = str2num(tline); 21 | elseif contains(tline,'Distortion coefficients') 22 | tline = erase(tline,'Distortion coefficients: '); 23 | format long 24 | param.distortion = str2num(tline); 25 | end 26 | tline = fgetl(fileID); 27 | end 28 | projection{iCam} = param; 29 | end 30 | 31 | fclose('all'); 32 | 33 | 34 | camera_pos_mapping = cell(1,40); 35 | 36 | format long 37 | for iCam = [5,35] 38 | load(fullfile('src/AIC/utils',sprintf('C%02d_Mapping.mat',iCam))) 39 | camera_pos_mapping{1,iCam} = struct('undistort2pix_x',x','undistort2pix_y',y'); 40 | end 41 | end 42 | 43 | -------------------------------------------------------------------------------- /src/AIC/utils/gps2image.m: -------------------------------------------------------------------------------- 1 | function image_points = gps2image(opts, gps_points, scene, iCam) 2 | %GPS2IMAGE Summary of this function goes here 3 | % Detailed explanation goes here 4 | param = opts.projection{iCam}; 5 | format long 6 | gps_points = gps_points(:,[2,1]); 7 | gps_points = gps_points / opts.world_scale + opts.world_center{scene}; 8 | gps_points = [gps_points,ones(size(gps_points,1),1)]'; 9 | 10 | if isempty(param.intrinsic) 11 | camera_points = param.homography * gps_points; 12 | image_points = camera_points(1:2,:)./camera_points(3,:); 13 | image_points = image_points'; 14 | else 15 | % image_points = intrinsic * camera_points = intrinsic * homography * world_points 16 | % without distortion 17 | camera_points = param.homography * gps_points; 18 | camera_points = round(camera_points(1:2,:)./camera_points(3,:)); 19 | camera_points = camera_points'; 20 | 21 | pix_x = opts.fisheye_mapping{iCam}.undistort2pix_x; 22 | pix_y = opts.fisheye_mapping{iCam}.undistort2pix_y; 23 | linear_idx = sub2ind(size(pix_x),camera_points(:,1),camera_points(:,2)); 24 | image_points = [pix_x(linear_idx), pix_y(linear_idx)]; 25 | 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /src/AIC/utils/hierarchical_cluster.m: -------------------------------------------------------------------------------- 1 | function labels = hierarchical_cluster(correlationMatrix,num_cluster) 2 | %HIERACHICAL_CLUSTER Summary of this function goes here 3 | % Detailed explanation goes here 4 | Z = linkage(correlationMatrix); 5 | labels = cluster(Z,'maxclust',num_cluster); 6 | end 7 | 8 | -------------------------------------------------------------------------------- /src/AIC/utils/image2gps.m: -------------------------------------------------------------------------------- 1 | function gps_points = image2gps(opts, image_points, scene, iCam) 2 | %IMAGE2GPS Summary of this function goes here 3 | % Detailed explanation goes here 4 | param = opts.projection{iCam}; 5 | format long 6 | if isempty(param.intrinsic) 7 | camera_points = [image_points,ones(size(image_points,1),1)]'; 8 | gps_points = param.homography \ camera_points; 9 | gps_points = (gps_points(1:2,:)./gps_points(3,:))'; 10 | else 11 | % image_points = intrinsic * camera_points = intrinsic * homography * world_points 12 | 13 | pix_x = opts.fisheye_mapping{iCam}.undistort2pix_x; 14 | pix_y = opts.fisheye_mapping{iCam}.undistort2pix_y; 15 | 16 | undistorted_x = 1:size(pix_x,1);undistorted_y = 1:size(pix_x,2); 17 | [undistorted_x,undistorted_y] = meshgrid(undistorted_x,undistorted_y); 18 | undistorted_x = undistorted_x'; undistorted_y = undistorted_y'; 19 | 20 | pix_x = reshape(pix_x,[],1); 21 | pix_y = reshape(pix_y,[],1); 22 | undistorted_x = reshape(undistorted_x,[],1); 23 | undistorted_y = reshape(undistorted_y,[],1); 24 | 25 | camera_points = zeros(size(image_points)); 26 | 27 | for i = 1:100:length(image_points) 28 | line_ids = i:min(i+99,length(image_points)); 29 | dist = pdist2(image_points(line_ids,1),pix_x) + pdist2(image_points(line_ids,2),pix_y); 30 | [~,index] = min(dist,[],2); 31 | camera_points(line_ids,:) = [undistorted_x(index),undistorted_y(index)]; 32 | end 33 | 34 | camera_points = [camera_points,ones(size(image_points,1),1)]'; 35 | 36 | gps_points = param.homography \ camera_points; 37 | gps_points = (gps_points(1:2,:)./gps_points(3,:))'; 38 | end 39 | gps_points = (gps_points - opts.world_center{scene}) * opts.world_scale; 40 | gps_points = gps_points(:,[2,1]); 41 | end 42 | -------------------------------------------------------------------------------- /src/AIC/utils/prepareMOTChallengeSubmission_aic.m: -------------------------------------------------------------------------------- 1 | function prepareMOTChallengeSubmission_aic(opts) 2 | % Prepare submission file duke.txt 3 | 4 | submission_data = []; 5 | for scene = opts.seqs{opts.sequence} 6 | for iCam = opts.cams_in_scene{scene} 7 | filename = sprintf('%s/%s/L3-identities/cam%d_%s.txt', opts.experiment_root, opts.experiment_name, iCam, opts.folder_by_seq{opts.sequence}); 8 | data = dlmread(filename); 9 | data(:,[1 2]) = data(:,[2 1]); 10 | data = [iCam*ones(size(data,1),1), data]; 11 | data = data(:,[1:7]); 12 | submission_data = [submission_data; data]; 13 | end 14 | end 15 | 16 | too_big = abs(submission_data)>10^4; 17 | too_big = find(sum(too_big,2)); 18 | submission_data(too_big,:) = []; 19 | 20 | % Write duke.txt 21 | dlmwrite(sprintf('%s/%s/aic19.txt',opts.experiment_root, opts.experiment_name), int32(submission_data), 'delimiter', ' ','precision',6); 22 | end 23 | -------------------------------------------------------------------------------- /src/AIC/utils/unique_det_in_frame.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | 4 | opts = get_opts_aic(); 5 | opts.experiment_name = 'aic_util'; 6 | opts.sequence = 6; 7 | scene = 5; 8 | cams = 22:27%[27,28,33,34,35]; 9 | for i = 1:length(cams)%1:length(opts.cams_in_scene{scene}) 10 | iCam = cams(i)%opts.cams_in_scene{scene}(i); 11 | resdata = dlmread(sprintf('%s/%s/L3-identities/cam%d_%s.txt',opts.experiment_root, opts.experiment_name, iCam,opts.folder_by_seq{opts.sequence})); 12 | %% det bboxs to og size 13 | % bboxs = resdata(:,3:6); 14 | % og_wh = bboxs(:,3:4)/1.4; 15 | % bboxs(:,1:2) = bboxs(:,1:2)+0.2*og_wh; 16 | % bboxs(:,3:4) = og_wh; 17 | % %% det bboxs to gt size 18 | % bboxs(:,1:2) = bboxs(:,1:2) - 20; 19 | % bboxs(:,3:4) = bboxs(:,3:4) + 40; 20 | % resdata(:,3:6) = bboxs; 21 | %% unique bbox for each id in each frame 22 | unique_ids = unique(resdata(:,2)); 23 | to_remove = []; 24 | for i = 1:length(unique_ids) 25 | id = unique_ids(i); 26 | line_idx = find(resdata(:,2)==id); 27 | detections = resdata(line_idx,:); 28 | frames = detections(:,1); 29 | [unique_frames, I] = unique(frames, 'first'); 30 | dup_idx = 1:length(frames); 31 | dup_idx(I) = []; 32 | duplicate_frames = frames(dup_idx); 33 | if isempty(duplicate_frames) 34 | continue 35 | end 36 | for j = 1:length(duplicate_frames) 37 | frame = duplicate_frames(j); 38 | dup_line_ids = find(frames==frame); 39 | resdata(line_idx(dup_line_ids(1)),:) = mean(detections(dup_line_ids,:),1); 40 | end 41 | to_remove = [to_remove;line_idx(dup_idx)]; 42 | end 43 | resdata(to_remove,:) = []; 44 | dlmwrite(sprintf('%s/%s/L3-identities/cam%d_%s.txt',opts.experiment_root, opts.experiment_name, iCam,opts.folder_by_seq{opts.sequence}),... 45 | resdata, 'delimiter', ' ', 'precision', 6); 46 | end -------------------------------------------------------------------------------- /src/AIC/visualization/MyVideoReader_aic.m: -------------------------------------------------------------------------------- 1 | classdef MyVideoReader_aic < handle 2 | % Example use 3 | % 4 | % reader = DukeVideoReader('F:/datasets/DukeMTMC/'); 5 | % camera = 2; 6 | % frame = 360720; 7 | % figure, imshow(reader.getFrame(camera, frame)); 8 | 9 | properties 10 | DatasetPath = ''; 11 | CurrentCamera = 1; 12 | PrevCamera = -1; 13 | PrevFrame = 0; 14 | Video = []; 15 | CurrentScene = 1; 16 | train_test = {'train','test','train','train','test'}; 17 | end 18 | methods 19 | function obj = MyVideoReader_aic(datasetPath) 20 | obj.DatasetPath = datasetPath; 21 | obj.Video = VideoReader(fullfile(sprintf('%s/%s/S%02d/c%03d', obj.DatasetPath, obj.train_test{obj.CurrentScene}, obj.CurrentScene, obj.CurrentCamera), 'vdo.avi')); 22 | end 23 | 24 | function img = getFrame(obj, scene, iCam, iFrame) 25 | % DukeMTMC frames are 1-indexed 26 | 27 | if iCam ~= obj.CurrentCamera || scene ~= obj.CurrentScene 28 | obj.CurrentScene = scene; 29 | obj.CurrentCamera = iCam; 30 | obj.PrevFrame = -1; 31 | obj.Video = VideoReader(fullfile(sprintf('%s/%s/S%02d/c%03d', obj.DatasetPath, obj.train_test{obj.CurrentScene}, obj.CurrentScene, obj.CurrentCamera), 'vdo.avi')); 32 | end 33 | 34 | if iFrame ~= obj.PrevFrame + 1 35 | obj.Video.CurrentTime = iFrame / obj.Video.FrameRate; 36 | end 37 | 38 | if abs(obj.Video.CurrentTime*obj.Video.FrameRate - iFrame) >= 2 39 | obj.Video.CurrentTime = iFrame / obj.Video.FrameRate; 40 | end 41 | 42 | img = readFrame(obj.Video); 43 | 44 | % Keep track of last read 45 | obj.PrevFrame = iFrame; 46 | obj.PrevCamera = iCam; 47 | end 48 | 49 | end 50 | end 51 | 52 | -------------------------------------------------------------------------------- /src/AIC/visualization/ROI.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | 4 | opts = get_opts_aic(); 5 | opts.experiment_name = 'aic_zju_ensemble'; 6 | opts.sequence = 6; 7 | all_colors = distinguishable_colors(5000)*255; 8 | 9 | %% print background 10 | % for scene = 5%1:5 11 | % mkdir(sprintf('%s/aic_util/background/S%02d', opts.experiment_root, scene)); 12 | % for iCam = 29%opts.cams_in_scene{scene} 13 | % %% load image background 14 | % imageROI = opts.reader.getFrame(scene,iCam,1); 15 | % 16 | % %% load gt 17 | % if scene~=2 && scene~=5 18 | % gt = load(sprintf('%s/%s/S%02d/c%03d/gt/gt.txt', opts.dataset_path, opts.folder_by_scene{scene}, scene, iCam)); 19 | % else 20 | % gt = load(sprintf('%s/%s/L3-identities/cam%d_%s.txt',opts.experiment_root, opts.experiment_name, iCam,opts.folder_by_seq{opts.sequence})); 21 | % bboxs = gt(:,3:6); 22 | % % gt2det bbox 23 | % bboxs(:,1:2) = bboxs(:,1:2)+20; bboxs(:,3:4) = bboxs(:,3:4)-40; 24 | % feet_pos = feetPosition(bboxs); 25 | % feet_pos(:,3) = 3; 26 | % colors = all_colors(gt(:,2),:); 27 | % imageROI = insertShape(imageROI,'FilledCircle',feet_pos,'Color', colors); 28 | % end 29 | % imwrite(imageROI, fullfile(sprintf('%s/aic_util/background/S%02d', opts.experiment_root, scene),sprintf('c%02d.png',iCam))) 30 | % end 31 | % end 32 | 33 | 34 | %% color to binary 35 | for scene = 5 36 | mkdir(sprintf('%s/ROIs/background/S%02d', opts.dataset_path, scene)); 37 | for iCam = opts.cams_in_scene{scene} 38 | imageROI = imread(fullfile(sprintf('%s/aic_util/background/S%02d', opts.experiment_root, scene),sprintf('c%02d.png',iCam))); 39 | imageROI = rgb2gray(imageROI); 40 | imageROI = ~imbinarize(imageROI,1-10^-12); 41 | imwrite(imageROI,sprintf('%s/ROIs/background/S%02d/c%02d.png', opts.dataset_path, scene, iCam)); 42 | end 43 | end -------------------------------------------------------------------------------- /src/AIC/visualization/show_gt_gps_pos.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | opts = get_opts_aic(); 5 | scene = 1; 6 | all_gt = []; 7 | 8 | for iCam = opts.cams_in_scene{scene} 9 | data = load(sprintf('%s/train/S%02d/c%03d/gt/gt_gps.txt', opts.dataset_path, scene, iCam)); 10 | all_gt = [all_gt;data]; 11 | end 12 | 13 | all_gt = sortrows(all_gt, [2,9,8]); 14 | 15 | pids = unique(all_gt(:,2)); 16 | 17 | for i = 1:length(pids) 18 | figure(1) 19 | clf('reset'); 20 | daspect([1 1 1]) 21 | hold on; 22 | pid = pids(i); 23 | lines = all_gt(all_gt(:,2) == pid,:); 24 | cams = unique(lines(:,8)); 25 | legend_str = []; 26 | for j = 1:length(cams) 27 | iCam = cams(j); 28 | icam_pos = lines(lines(:,8)==iCam,10:11); 29 | if isempty(icam_pos) 30 | continue 31 | end 32 | scatter(icam_pos(:,1),icam_pos(:,2),'filled') 33 | legend_str = [legend_str,{"iCam: "+num2str(iCam)}]; 34 | end 35 | legend(legend_str) 36 | pause(1) 37 | end 38 | -------------------------------------------------------------------------------- /src/L1-tracklets/getAppearanceSubMatrix.m: -------------------------------------------------------------------------------- 1 | function [ correlation ] = getAppearanceSubMatrix(observations, featureVectors, threshold, diff_p,diff_n ,step) 2 | 3 | features = cell2mat(featureVectors.appearance(observations)); 4 | dist = pdist2(features, features); 5 | if diff_p==0 6 | diff_p=threshold; 7 | diff_n=threshold; 8 | end 9 | correlation = (threshold - dist); 10 | correlation_p = correlation/diff_p; 11 | correlation_n = correlation/diff_n; 12 | if step 13 | correlation(correlation>0) = 1; 14 | correlation(correlation<0) = -1; 15 | correlation(correlation==0) = 0; 16 | else 17 | correlation(correlation>=0) = correlation_p(correlation_p>=0); 18 | correlation(correlation<0) = correlation_n(correlation_n<0); 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /src/L1-tracklets/getValidDetections.m: -------------------------------------------------------------------------------- 1 | function [valid, detections_in_interval] = getValidDetections(detections_in_interval, detections_conf, num_visible, opts, iCam) 2 | 3 | % Flags valid OpenPose detections 4 | valid = true(size(detections_in_interval,1),1); 5 | for k = 1:size(detections_in_interval,1) 6 | pose = detections_in_interval(k,3:end); 7 | bb = pose2bb(pose, opts.render_threshold); 8 | [newbb, newpose] = scale_bb(bb, pose,1.25); 9 | feet = feetPosition(newbb); 10 | detections_in_interval(k,[3 4 5 6]) = newbb; 11 | 12 | % Drop small and large detections 13 | if newbb(3) < 20 || newbb(4) < 20 || newbb(4) > 450 14 | valid(k) = 0; 15 | continue; 16 | end 17 | 18 | % Check detection confidence 19 | if num_visible(k) < 5 || detections_conf(k) < 4 20 | valid(k) = 0; 21 | continue; 22 | end 23 | 24 | % Filter feet outside of ROI 25 | if ~inpolygon(feet(:,1),feet(:,2),opts.ROIs{iCam}(:,1),opts.ROIs{iCam}(:,2)) 26 | valid(k) = 0; 27 | continue; 28 | end 29 | 30 | end 31 | 32 | -------------------------------------------------------------------------------- /src/L1-tracklets/motionAffinity.m: -------------------------------------------------------------------------------- 1 | function [motionScores, impossibilityMatrix] = motionAffinity(detectionCenters,detectionFrames,estimatedVelocity, speedLimit, beta) 2 | % This function computes the motion affinities given a set of detections. 3 | % A simple motion prediction is performed from a source detection to 4 | % a target detection to compute the prediction error. 5 | 6 | numDetections = size(detectionCenters,1); 7 | impossibilityMatrix = zeros(length(detectionFrames)); 8 | 9 | frameDifference = pdist2(detectionFrames, detectionFrames); 10 | velocityX = repmat(estimatedVelocity(:,1), 1, numDetections ); 11 | velocityY = repmat(estimatedVelocity(:,2), 1, numDetections ); 12 | centerX = repmat(detectionCenters(:,1), 1, numDetections ); 13 | centerY = repmat(detectionCenters(:,2), 1, numDetections ); 14 | 15 | errorXForward = centerX + velocityX.*frameDifference - centerX'; 16 | errorYForward = centerY + velocityY.*frameDifference - centerY'; 17 | 18 | errorXBackward = centerX' + velocityX' .* -frameDifference' - centerX; 19 | errorYBackward = centerY' + velocityY' .* -frameDifference' - centerY; 20 | 21 | errorForward = sqrt( errorXForward.^2 + errorYForward.^2); 22 | errorBackward = sqrt( errorXBackward.^2 + errorYBackward.^2); 23 | 24 | % Only upper triangular part is valid 25 | predictionError = min(errorForward, errorBackward); 26 | predictionError = triu(predictionError) + triu(predictionError)'; 27 | 28 | % Check if speed limit is violated 29 | xDiff = centerX - centerX'; 30 | yDiff = centerY - centerY'; 31 | distanceMatrix = sqrt(xDiff.^2 + yDiff.^2); 32 | 33 | maxRequiredSpeedMatrix = distanceMatrix ./ abs(frameDifference); 34 | predictionError(maxRequiredSpeedMatrix > speedLimit) = inf; 35 | impossibilityMatrix(maxRequiredSpeedMatrix > speedLimit) = 1; 36 | 37 | motionScores = 1 - beta*predictionError; 38 | 39 | -------------------------------------------------------------------------------- /src/L1-tracklets/trackletsVisualizePart1.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % SHOW DETECTIONS IN WINDOW 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | h = figure(2); 6 | clf('reset'); 7 | if opts.dataset ~=2 8 | imshow(opts.reader.getFrame(opts.current_camera,startFrame)); 9 | else 10 | imshow(opts.reader.getFrame(opts.current_scene, opts.current_camera,startFrame)); 11 | end 12 | pause(1); 13 | hold on; 14 | scatter(detectionCenters(:,1),detectionCenters(:,2),[],spatialGroupIDs); 15 | 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L1-tracklets/trackletsVisualizePart2.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % SHOW SPATIAL GROUPING AND CORRELATIONS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | rows = find(spatialGroupIDs == spatialGroupID); 6 | 7 | figure(2); 8 | 9 | % draw bounding box 10 | minx = min(detectionCenters(rows,1)); 11 | maxx = max(detectionCenters(rows,1)); 12 | miny = min(detectionCenters(rows,2)); 13 | maxy = max(detectionCenters(rows,2)); 14 | 15 | x = minx - 40; 16 | y = miny - 40; 17 | w = maxx - minx + 80; 18 | h = maxy - miny + 80; 19 | 20 | rectangle('Position',[x,y,w,h],'EdgeColor','green','LineWidth',2); 21 | 22 | labels = originalDetections(spatialGroupObservations,1); 23 | 24 | % for kk = min(labels):min(labels) 25 | % 26 | % rrows = rows; 27 | % 28 | % if isempty(rrows) 29 | % continue; 30 | % end 31 | % 32 | % pairs = combnk([1:length(rrows)],2); 33 | % 34 | % pairs_i = pairs(:,1); 35 | % pairs_j = pairs(:,2); 36 | % 37 | % points1 = detectionCenters(rrows(pairs_i),:); 38 | % points2 = detectionCenters(rrows(pairs_j),:); 39 | % 40 | % points1top = detectionCenters(rrows(pairs_i),:); 41 | % points2top = detectionCenters(rrows(pairs_j),:); 42 | % 43 | % myColorMap = distinguishable_colors(1024); 44 | % 45 | % if size(pairs,1) >2 46 | % for p = 1 : length(pairs) 47 | % 48 | % pts = [ points1(p,:); points2(p,:) ]; 49 | % ptstop = [ points1top(p,:); points2top(p,:) ]; 50 | % correlation = correlationMatrix(pairs_i(p),pairs_j(p)); 51 | % colorindex = int32( 1 + (1 + correlation) * 63 ); 52 | % 53 | % 54 | % if correlation<-1 55 | % linecolor = [0 0 0]; 56 | % else 57 | % linecolor = myColorMap(colorindex,:); 58 | % end 59 | % 60 | % line(pts(:,1),pts(:,2),'color',linecolor); 61 | % hold on; 62 | % end 63 | % end 64 | % 65 | % pause(0.5); 66 | % end 67 | 68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L1-tracklets/trackletsVisualizePart3.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % SHOW CLUSTERED DETECTIONS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | ids = unique(identities); 5 | 6 | for kkk = 1:length(ids); 7 | 8 | id = ids(kkk); 9 | 10 | mask = identities == id; 11 | mask2 = ismember(currentDetectionsIDX,spatialGroupObservations.*mask); 12 | rows = find(currentDetectionsIDX .* mask2); 13 | 14 | figure(2); 15 | scatter(detectionCenters(rows,1), detectionCenters(rows,2), 'fill'); 16 | hold on; 17 | 18 | end 19 | 20 | pause(0.5); 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L1-tracklets/trackletsVisualizePart4.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % SHOW GENERATED TRACKLETS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | figure(3); 6 | clf('reset') 7 | if opts.dataset ~=2 8 | imshow(opts.reader.getFrame(opts.current_camera,startFrame)); 9 | else 10 | imshow(opts.reader.getFrame(opts.current_scene, opts.current_camera,startFrame)); 11 | end 12 | hold on; 13 | 14 | for k = 1:length(ids) 15 | if isempty(smoothedTracklets), break; end 16 | 17 | data = smoothedTracklets(k).data; 18 | centers = getBoundingBoxCenters(data(:, 3 : 6)); 19 | 20 | scatter(centers(:,1),centers(:,2),'filled'); 21 | hold on; 22 | end 23 | hold off; 24 | drawnow; 25 | 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L2-trajectories/fft_tracklet_feat.m: -------------------------------------------------------------------------------- 1 | function tracklets = fft_tracklet_feat(opts, tracklets) 2 | for ind = 1:length(tracklets) 3 | % FFT features 4 | tracked_frames = tracklets(ind).realdata(:,1); 5 | all_frames = tracklets(ind).data(:,1); 6 | feats = cell2mat(tracklets(ind).features); 7 | % duplicate indices 8 | [missed_frames,insert_pos] = setdiff(all_frames,tracked_frames); 9 | for j = 1:length(insert_pos) 10 | pos = insert_pos(j); 11 | feats = [feats(1:pos-1,:);zeros(1,256);feats(pos:end,:)]; 12 | end 13 | fft_feats = abs(fft(feats,opts.tracklets.window_width,1))/length(tracked_frames); 14 | fft_feats = reshape(fft_feats(1:4,:),1,1024); 15 | % Add to tracklet list 16 | if opts.fft 17 | tracklets(ind).feature = fft_feats; 18 | end 19 | end 20 | 21 | end 22 | 23 | -------------------------------------------------------------------------------- /src/L2-trajectories/fillTrajectories.m: -------------------------------------------------------------------------------- 1 | function [ detectionsUpdated ] = fillTrajectories( detections ) 2 | % This function adds points by interpolation to the resulting trajectories, 3 | % so that trajectories are complete and results are less influenced by 4 | % false negative detections 5 | 6 | detections = sortrows(detections,[1 3 4 5 6]); 7 | 8 | 9 | detectionsUpdated = detections; 10 | 11 | personIDs = unique(detections(:,2)); 12 | 13 | count = 0; 14 | 15 | for i = 1 : length(personIDs) 16 | 17 | personID = personIDs( i ); 18 | 19 | relevantDetections = detections( detections(:,2) == personID, : ); 20 | 21 | startFrame = min( relevantDetections(:,1)); 22 | endFrame = max( relevantDetections(:,1) ); 23 | 24 | missingFrames = setdiff( [startFrame:endFrame]', relevantDetections(:,1) ); 25 | 26 | if isempty(missingFrames) 27 | 28 | continue; 29 | 30 | end 31 | 32 | frameDiff = diff(missingFrames') > 1; 33 | 34 | startInd = [1, frameDiff]; 35 | endInd = [frameDiff, 1]; 36 | 37 | startInd = find(startInd); 38 | endInd = find(endInd); 39 | 40 | 41 | 42 | for k = 1:length(startInd) 43 | 44 | interpolatedDetections = zeros( missingFrames(endInd(k)) - missingFrames(startInd(k)) + 1 , size(detections,2) ); 45 | 46 | interpolatedDetections(:,2) = personID; 47 | interpolatedDetections(:,1) = [ missingFrames(startInd(k)):missingFrames(endInd(k)) ]'; 48 | 49 | preDetection = detections( (detections(:,2) == personID) .* detections(:,1) == missingFrames(startInd(k)) - 1, :); 50 | postDetection = detections( (detections(:,2) == personID) .* detections(:,1) == missingFrames(endInd(k)) + 1, :); 51 | 52 | 53 | for c = 3:size(detections,2) 54 | 55 | interpolatedDetections(:,c) = linspace(preDetection(c),postDetection(c),size(interpolatedDetections,1)); 56 | 57 | end 58 | 59 | detectionsUpdated = [ detectionsUpdated; interpolatedDetections ]; 60 | 61 | end 62 | 63 | count = count + length( missingFrames ); 64 | 65 | 66 | 67 | 68 | 69 | end 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/L2-trajectories/findTrackletsInWindow.m: -------------------------------------------------------------------------------- 1 | function trackletsInWindow = findTrackletsInWindow(trajectories, startTime, endTime) 2 | trackletsInWindow = []; 3 | 4 | if isempty(trajectories), return; end 5 | 6 | trackletStartFrame = cell2mat({trajectories.startFrame}); 7 | trackletEndFrame = cell2mat({trajectories.endFrame}); 8 | trackletsInWindow = find( (trackletEndFrame >= startTime) .* (trackletStartFrame <= endTime) ); 9 | 10 | -------------------------------------------------------------------------------- /src/L2-trajectories/findTrajectoriesInWindow.m: -------------------------------------------------------------------------------- 1 | function trajectoriesInWindow = findTrajectoriesInWindow(trajectories, startTime, endTime) 2 | trajectoriesInWindow = []; 3 | 4 | if isempty(trajectories), return; end 5 | 6 | trajectoryStartFrame = [trajectories.startFrame]; %cell2mat({trajectories.startFrame}); 7 | trajectoryEndFrame = [trajectories.endFrame]; % cell2mat({trajectories.endFrame}); 8 | trajectoriesInWindow = find( (trajectoryEndFrame >= startTime) .* (trajectoryStartFrame <= endTime) ); 9 | 10 | -------------------------------------------------------------------------------- /src/L2-trajectories/getAppearanceMatrix.m: -------------------------------------------------------------------------------- 1 | function [ appearanceMatrix ] = getAppearanceMatrix(source_feat_vectors,target_feat_vectors, threshold, diff_p,diff_n ,step) 2 | 3 | % Computes the appearance affinity matrix 4 | 5 | source_feats = double(cell2mat(source_feat_vectors')); 6 | target_feats = double(cell2mat(target_feat_vectors')); 7 | dist = pdist2(source_feats, target_feats); 8 | if diff_p==0 9 | diff_p=threshold; 10 | diff_n=threshold; 11 | end 12 | correlation = (threshold - dist); 13 | correlation_p = correlation/diff_p; 14 | correlation_n = correlation/diff_n; 15 | if step 16 | correlation(correlation>0) = 1; 17 | correlation(correlation<0) = -1; 18 | correlation(correlation==0) = 0; 19 | else 20 | correlation(correlation>=0) = correlation_p(correlation_p>=0); 21 | correlation(correlation<0) = correlation_n(correlation_n<0); 22 | end 23 | appearanceMatrix = correlation; 24 | end 25 | -------------------------------------------------------------------------------- /src/L2-trajectories/getHeadTailSpeed.m: -------------------------------------------------------------------------------- 1 | function [ centersWorld, centersView, startpoint, endpoint, intervals, duration, head_velocity,tail_velocity ] = getHeadTailSpeed( tracklets ) 2 | 3 | numTracklets = length(tracklets); 4 | 5 | % bounding box centers for each tracklet 6 | 7 | centersWorld = cell( numTracklets, 1 ); 8 | centersView = cell( numTracklets, 1 ); 9 | 10 | for i = 1 : numTracklets 11 | 12 | detections = cell2mat({tracklets(i).data}); 13 | 14 | % 2d points 15 | bb = detections( :, [3,4,5,6,1] ); 16 | x = 0.5*(bb(:,1) + bb(:,3)); 17 | y = 0.5*(bb(:,2) + bb(:,4)); 18 | t = bb(:,5); 19 | centersView{i} = [x,y,t]; 20 | 21 | % 3d points 22 | % worldcoords = detections(:, [7,8,2] ); 23 | % x = worldcoords(:,1); 24 | % y = worldcoords(:,2); 25 | % t = worldcoords(:,3); 26 | % centersWorld{i} = [x,y,t]; 27 | centersWorld{i} = centersView{i}; 28 | 29 | end 30 | 31 | % calculate velocity, direction, for each tracklet 32 | 33 | head_velocity = zeros(numTracklets,2); 34 | duration = zeros(numTracklets,1); 35 | intervals = zeros(numTracklets,2); 36 | startpoint = zeros(numTracklets,2); 37 | endpoint = zeros(numTracklets,2); 38 | 39 | for ind = 1:numTracklets 40 | 41 | 42 | intervals(ind,:) = [centersWorld{ind}(1,3), centersWorld{ind}(end,3)]; 43 | startpoint(ind,:) = [centersWorld{ind}(1,1), centersWorld{ind}(1,2)]; 44 | head_end = [centersWorld{ind}(5,1), centersWorld{ind}(5,2)]; 45 | tail_start = [centersWorld{ind}(end-5,1), centersWorld{ind}(end-5,2)]; 46 | endpoint(ind,:) = [centersWorld{ind}(end,1), centersWorld{ind}(end,2)]; 47 | 48 | duration(ind) = centersWorld{ind}(end,3)-centersWorld{ind}(1,3); 49 | head_direction = [head_end - startpoint(ind,:)]; 50 | head_velocity(ind,:) = head_direction./duration(ind); 51 | 52 | tail_direction = [endpoint(ind,:) - tail_start]; 53 | tail_velocity(ind,:) = tail_direction./duration(ind); 54 | 55 | 56 | end 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/L2-trajectories/getHyperScore.m: -------------------------------------------------------------------------------- 1 | function correlationMatrix = getHyperScore(features,model_param,soft,threshold, norm, motion) 2 | tic; 3 | if iscell(features) 4 | numFeatures = length(features); 5 | features = reshape(cell2mat(features)', numel(features{1}),[])'; 6 | else 7 | numFeatures = size(features,1); 8 | end 9 | 10 | if ~motion 11 | data = repmat(reshape(features,1,numFeatures,[]),numFeatures,1,1) - repmat(reshape(features,numFeatures,1,[]),1,numFeatures,1); 12 | data = abs(reshape(data,numFeatures*numFeatures,[])); 13 | else 14 | centerFrame = features(:,1); 15 | centers = features(:,[2,3]); 16 | velocity = features(:,[4,5]); 17 | 18 | feat1 = [centerFrame,-centers,zeros(size(centers)),-velocity,zeros(size(velocity))]; 19 | feat2 = [centerFrame,zeros(size(centers)),centers,zeros(size(velocity)),velocity]; 20 | data = repmat(reshape(feat2,1,numFeatures,[]),numFeatures,1,1) - repmat(reshape(feat1,numFeatures,1,[]),1,numFeatures,1); 21 | bad_lines = logical(tril(ones(length(centerFrame)),-1)); 22 | 23 | data = reshape(data,numFeatures*numFeatures,[]); 24 | data(:,6:9) = data(:,6:9).*data(:,1); 25 | data(:,1) = []; 26 | end 27 | 28 | correlationMatrix = hyper_score_net(data,model_param,soft); 29 | correlationMatrix = reshape(correlationMatrix,numFeatures,numFeatures); 30 | 31 | if motion 32 | transposeMatrix = correlationMatrix.'; 33 | correlationMatrix(bad_lines) = transposeMatrix(bad_lines); 34 | end 35 | 36 | t1=toc; 37 | fprintf('time elapsed: %d',t1) 38 | end 39 | 40 | function output = hyper_score_net(data,model_param,soft) 41 | feat = data; 42 | output = max(feat*double(model_param.fc1_w')+double(model_param.fc1_b),0); 43 | output = max(output*double(model_param.fc2_w')+double(model_param.fc2_b),0); 44 | output = max(output*double(model_param.fc3_w')+double(model_param.fc3_b),0); 45 | output = output*double(model_param.out_w')+double(model_param.out_b); 46 | output = softmax(soft*output')'; 47 | output = (output(:,2)-output(:,1))/soft; 48 | 49 | end 50 | -------------------------------------------------------------------------------- /src/L2-trajectories/getMotionFeat.m: -------------------------------------------------------------------------------- 1 | function feat = getMotionFeat(tracklets, iCam, opts) 2 | 3 | [~, ~, startpoint, endpoint, intervals, ~, ~] = getTrackletFeatures(tracklets); 4 | [startpoint, ~, ~] = image2world( startpoint, iCam ); 5 | [endpoint, ~, ~] = image2world( endpoint, iCam ); 6 | velocity = (endpoint-startpoint)./(intervals(:,2)-intervals(:,1)); 7 | intervals = local2global(opts.start_frames(iCam),intervals); 8 | centerFrame = round(mean(intervals,2)); 9 | centers = 0.5 * (endpoint + startpoint); 10 | 11 | feat = [centerFrame,centers,velocity]; 12 | 13 | end -------------------------------------------------------------------------------- /src/L2-trajectories/getTrackletFeatures.m: -------------------------------------------------------------------------------- 1 | function [ centersWorld, centersView, startpoint, endpoint, intervals, duration, velocity, bboxs ] = getTrackletFeatures( tracklets ) 2 | 3 | numTracklets = length(tracklets); 4 | 5 | % bounding box centers for each tracklet 6 | 7 | centersWorld = cell( numTracklets, 1 ); 8 | centersView = cell( numTracklets, 1 ); 9 | bboxs = zeros(numTracklets,4); 10 | 11 | for i = 1 : numTracklets 12 | 13 | detections = cell2mat({tracklets(i).data}); 14 | 15 | % 2d points 16 | bb = detections( :, [3,4,5,6,1] ); 17 | x = 0.5*(bb(:,1) + bb(:,3)); 18 | y = 0.5*(bb(:,2) + bb(:,4)); 19 | t = bb(:,5); 20 | centersView{i} = [x,y,t]; 21 | 22 | bb(:,[3,4]) = bb(:,[1,2])+bb(:,[3,4]); 23 | bb(:,5) = []; 24 | new_bb = zeros(1,4); 25 | new_bb(1:2) = min(bb(:,[1,2])); 26 | new_bb(3:4) = max(bb(:,[3,4]))-new_bb(1:2); 27 | bboxs(i,:) = new_bb; 28 | 29 | % 3d points 30 | % worldcoords = detections(:, [7,8,2] ); 31 | % x = worldcoords(:,1); 32 | % y = worldcoords(:,2); 33 | % t = worldcoords(:,3); 34 | % centersWorld{i} = [x,y,t]; 35 | centersWorld{i} = centersView{i}; 36 | 37 | end 38 | 39 | % calculate velocity, direction, for each tracklet 40 | 41 | velocity = zeros(numTracklets,2); 42 | duration = zeros(numTracklets,1); 43 | intervals = zeros(numTracklets,2); 44 | startpoint = zeros(numTracklets,2); 45 | endpoint = zeros(numTracklets,2); 46 | 47 | 48 | for ind = 1:numTracklets 49 | intervals(ind,:) = [centersWorld{ind}(1,3), centersWorld{ind}(end,3)]; 50 | startpoint(ind,:) = [centersWorld{ind}(1,1), centersWorld{ind}(1,2)]; 51 | endpoint(ind,:) = [centersWorld{ind}(end,1), centersWorld{ind}(end,2)]; 52 | duration(ind) = centersWorld{ind}(end,3)-centersWorld{ind}(1,3); 53 | direction = [endpoint(ind,:) - startpoint(ind,:)]; 54 | velocity(ind,:) = direction./duration(ind); 55 | 56 | end 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/L2-trajectories/mergeResults.m: -------------------------------------------------------------------------------- 1 | function [ mergedResult ] = mergeResults( result1, result2 ) 2 | % Merges the independent solutions for the two results 3 | 4 | maximumLabel = max(result1.labels); 5 | 6 | if isempty(maximumLabel) 7 | maximumLabel = 0; 8 | end 9 | 10 | mergedResult.labels = [result1.labels; maximumLabel + result2.labels]; 11 | mergedResult.observations = [result1.observations;result2.observations]; 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/L2-trajectories/postProcess.m: -------------------------------------------------------------------------------- 1 | function [trackerOutputFinal] = postProcess(dataset, extendedTracklets, trackerOutputFinal) 2 | if isempty(extendedTracklets), return; end 3 | 4 | lastID = 0; 5 | if ~isempty(trackerOutputFinal), lastID = max(trackerOutputFinal(:, 1)); end 6 | 7 | % collect tracker output 8 | trackerOutputRaw = []; 9 | for i = 1 : length(extendedTracklets) 10 | currentTrackletData = extendedTracklets(i).data; 11 | currentTrackletData(:, 1) = lastID + 1; 12 | lastID = lastID + 1; 13 | trackerOutputRaw = [trackerOutputRaw; currentTrackletData]; 14 | end 15 | 16 | % interpolate to recover missing observations 17 | trackerOutputFilled = fillTrajectories(trackerOutputRaw); 18 | 19 | % remove very short trajectories 20 | trackerOutputRemoved = removeShortTracks(trackerOutputFilled, dataset.minimumTrajectoryDuration); 21 | %[~, ~, ic] = unique(trackerOutputRemoved(:,1)); 22 | %trackerOutputRemoved(:,1) = ic; 23 | %trackerOutput = sortrows(trackerOutputRemoved,[2 1]); 24 | 25 | trackerOutputFinal = sortrows(vertcat(trackerOutputFinal, trackerOutputRemoved), [2 1]); 26 | -------------------------------------------------------------------------------- /src/L2-trajectories/removeShortTracks.m: -------------------------------------------------------------------------------- 1 | function [ detectionsUpdated, removedIDs ] = removeShortTracks( detections, cutoffLength ) 2 | %This function removes short tracks that have not been associated with any 3 | %trajectory. Those are likely to be false positives. 4 | 5 | detectionsUpdated = detections; 6 | 7 | detections = sortrows(detections, [2, 1]); 8 | 9 | personIDs = unique(detections(:,2)); 10 | lengths = hist(detections(:,2), personIDs)'; 11 | 12 | [~,~, removedIDs] = find( personIDs .* (lengths <= cutoffLength)); 13 | 14 | detectionsUpdated(ismember(detectionsUpdated(:,2),removedIDs),:) = []; 15 | end 16 | 17 | -------------------------------------------------------------------------------- /src/L2-trajectories/trackletsToTrajectories.m: -------------------------------------------------------------------------------- 1 | function trajectories = trackletsToTrajectories(opts, tracklets, labels ) 2 | 3 | trajectories = []; 4 | 5 | uniqueLabels = unique(labels); 6 | 7 | for i = 1:length(uniqueLabels) 8 | 9 | trackletIndices = find(labels == uniqueLabels(i)); 10 | 11 | trajectory = struct('tracklets',[],'startFrame',inf,'endFrame',-inf,'segmentStart',inf,'segmentEnd',-inf,'features',[]); 12 | for k = 1:length(trackletIndices) 13 | ind = trackletIndices(k); 14 | trajectory.tracklets = [trajectory.tracklets; tracklets(ind)]; 15 | trajectory.startFrame = min(trajectory.startFrame, tracklets(ind).startFrame); 16 | trajectory.endFrame = max(trajectory.startFrame, tracklets(ind).endFrame); 17 | trajectory.segmentStart = min(trajectory.segmentStart, tracklets(ind).segmentStart); 18 | trajectory.segmentEnd = max(trajectory.segmentEnd, tracklets(ind).segmentEnd); 19 | % trajectory.feature = tracklets(ind).feature; 20 | trajectory.features = [trajectory.features;tracklets(ind).features]; 21 | end 22 | trajectory.feature = mean(cell2mat(trajectory.features),1); 23 | 24 | % real_frame_length = 0; 25 | % trajectory.feature=zeros(size(trajectory.tracklets(1).feature)); 26 | % for k = 1:length(trajectory.tracklets) 27 | % trajectory.feature = trajectory.feature+trajectory.tracklets(k).feature.*length(trajectory.tracklets(k).realdata); 28 | % real_frame_length = real_frame_length + length(trajectory.tracklets(k).realdata); 29 | % end 30 | % trajectory.feature = trajectory.feature/real_frame_length; 31 | 32 | trajectories = [trajectories; trajectory]; 33 | end 34 | 35 | -------------------------------------------------------------------------------- /src/L2-trajectories/trajectoriesToTop.m: -------------------------------------------------------------------------------- 1 | function data = trajectoriesToTop( trajectories ) 2 | %TRAJECTORIESTOTOP Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | data = zeros(0,8); 6 | 7 | for i = 1:length(trajectories) 8 | 9 | traj = trajectories(i); 10 | 11 | for k = 1:length(traj.tracklets) 12 | 13 | newdata = traj.tracklets(k).data; 14 | newdata(:,2) = i; 15 | data = [data; newdata]; 16 | 17 | 18 | end 19 | 20 | end 21 | 22 | -------------------------------------------------------------------------------- /src/L2-trajectories/trajectoriesVisualizePart1.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % VISUALIZE 1: SHOW ALL TRACKLETS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | % backgroundImage = imfuse(readFrame(dataset, max(1,startTime)),readFrame(dataset,min(endTime,dataset.endingFrame+syncTimeAcrossCameras(dataset.camera))),'blend','Scaling','joint'); 6 | figure(2) 7 | 8 | if opts.dataset ~=2 9 | startImg = opts.reader.getFrame(opts.current_camera, max(1,startTime)); 10 | endImg = opts.reader.getFrame(opts.current_camera, max(1,endTime)); 11 | else 12 | startImg = opts.reader.getFrame(opts.current_scene, opts.current_camera, max(1,startTime)); 13 | endImg = opts.reader.getFrame(opts.current_scene, opts.current_camera, max(1,endTime)); 14 | end 15 | backgroundImage = imfuse(startImg, endImg,'blend','Scaling','joint'); 16 | 17 | imshow(backgroundImage); 18 | 19 | hold on; 20 | 21 | trCount = 0; 22 | for k = 1 : length(currentTrajectories) 23 | 24 | for i = 1:length(currentTrajectories(k).tracklets) 25 | trCount = trCount +1; 26 | detections = currentTrajectories(k).tracklets(i).data; 27 | trackletCentersView = getBoundingBoxCenters(detections(:,[3:6])); 28 | scatter(trackletCentersView(:,1),trackletCentersView(:,2),'filled'); 29 | total = size(trackletCentersView,1); 30 | text(trackletCentersView(round(total/2),1),trackletCentersView(round(total/2),2)+0.01,sprintf('%d',trCount),'color','yellow'); 31 | hold on; 32 | 33 | end 34 | 35 | end 36 | 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38 | 39 | -------------------------------------------------------------------------------- /src/L2-trajectories/trajectoriesVisualizePart2.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % DRAW RELATIONSHIPS WITHIN EACH APPEARANCE GROUP 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | % for kk = 1 : max(appearanceGroups) 6 | % 7 | % relevantTracklets = indices; 8 | % trackletCentersViewTmp = []; 9 | % 10 | % for iii = 1 : length(relevantTracklets) 11 | % data = cell2mat({tracklets(relevantTracklets(iii)).data}); 12 | % centerIndex = 1 + ceil(size(data,1)/2); 13 | % 14 | % trackletCentersViewTmp = [trackletCentersViewTmp; getBoundingBoxCenters(data(centerIndex, 3 : 6))]; %#ok 15 | % end 16 | % 17 | % pairsLocal = combnk(1:length(relevantTracklets),2); 18 | % pairsWindow = combnk(relevantTracklets,2); 19 | % 20 | % pairs_i = pairsLocal(:,1); 21 | % pairs_j = pairsLocal(:,2); 22 | % 23 | % points1 = trackletCentersViewTmp(pairs_i,:); 24 | % points2 = trackletCentersViewTmp(pairs_j,:); 25 | % 26 | % myColorMap = distinguishable_colors(128); 27 | % 28 | % if size(pairsLocal, 1) >2 29 | % 30 | % for p = 1 : length(pairsLocal) 31 | % 32 | % pts = [ points1(p,:); points2(p,:) ]; 33 | % correlation = correlationMatrix(pairsLocal(p,1),pairsLocal(p,2)); 34 | % 35 | % linecolor = [0 1 0]; 36 | % 37 | % if correlation == -inf || correlation == 10000 || correlation == 0 38 | % continue; 39 | % end 40 | % 41 | % if correlation == 10000 || correlation > 1 42 | % linecolor = [0 1 0]; 43 | % end 44 | % 45 | % if correlation >= -10 && correlation <=10 46 | % colorindex = int32( 1 + (1 + correlation) * 63 ); 47 | % colorindex = max(colorindex,1); 48 | % colorindex = min(colorindex, 128); 49 | % linecolor = myColorMap(colorindex,:); 50 | % end 51 | % 52 | % line(pts(:,1),pts(:,2),'color',linecolor); 53 | % hold on; 54 | % 55 | % end 56 | % 57 | % pause(0.1); 58 | % 59 | % end 60 | % 61 | % end 62 | 63 | hold off; 64 | 65 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L2-trajectories/trajectoriesVisualizePart2_5.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % SHOW CLUSTERED DETECTIONS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | figure(2); 6 | hold on; 7 | ids = unique(identities); 8 | 9 | for kkk = 1:length(ids) 10 | id = ids(kkk); 11 | groupped_tracklets = consider_tracklets(identities == id); 12 | gourpped_data = vertcat(groupped_tracklets.data); 13 | detectionCenters = getBoundingBoxCenters(gourpped_data(:,3:6)); 14 | 15 | scatter(detectionCenters(:,1), detectionCenters(:,2), 'fill'); 16 | hold on; 17 | end 18 | 19 | pause(0.5); 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------------------------------------------------------------------- /src/L2-trajectories/trajectoriesVisualizePart3.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % VISUALIZE 3: SHOW ALL MERGED TRACKLETS IN WINDOWS 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | figure(3) 5 | if opts.dataset ~=2 6 | imshow(opts.reader.getFrame(opts.current_camera,endTime)); 7 | else 8 | imshow(opts.reader.getFrame(opts.current_scene, opts.current_camera,endTime)); 9 | end 10 | hold on; 11 | 12 | currentTrajectories = smoothTrajectories; 13 | numTrajectories = length(currentTrajectories); 14 | 15 | colors = distinguishable_colors(numTrajectories); 16 | for k = 1:numTrajectories 17 | 18 | 19 | for i = 1 : length(currentTrajectories(k).tracklets) 20 | 21 | detections = currentTrajectories(k).tracklets(i).data; 22 | trackletCentersView = getBoundingBoxCenters(detections(:, 3:6)); 23 | 24 | plot(trackletCentersView(:,1),trackletCentersView(:,2),'LineWidth',4,'Color',colors(k,:)); 25 | hold on; 26 | 27 | end 28 | 29 | end 30 | 31 | hold off; 32 | drawnow; 33 | 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 35 | -------------------------------------------------------------------------------- /src/L3-identities/loadL2trajectories.m: -------------------------------------------------------------------------------- 1 | function trajectories = loadL2trajectories(opts, scene) 2 | % Loads single camera trajectories that have been written to disk 3 | trajectories = []; 4 | count = 1; 5 | if opts.dataset == 0 6 | cam_pool = 1:opts.num_cam; 7 | elseif opts.dataset == 2 8 | cam_pool = opts.cams_in_scene{scene}; 9 | end 10 | for iCam = cam_pool 11 | if opts.dataset <= 1 12 | tracker_output = dlmread(fullfile(opts.experiment_root, opts.experiment_name, 'L2-trajectories', sprintf('cam%d_%s.txt',iCam, opts.sequence_names{opts.sequence}))); 13 | traj_for_iCam = load(fullfile(opts.experiment_root, opts.experiment_name, 'L2-trajectories', sprintf('trajectories%d_%s.mat',iCam, opts.sequence_names{opts.sequence}))); 14 | elseif opts.dataset == 2 15 | tracker_output = dlmread(fullfile(opts.experiment_root, opts.experiment_name, 'L2-removeOverlapping', sprintf('cam%d_%s.txt',iCam, opts.folder_by_seq{opts.sequence}))); 16 | traj_for_iCam = load(fullfile(opts.experiment_root, opts.experiment_name, 'L2-trajectories', sprintf('trajectories%d_%s.mat',iCam, opts.folder_by_seq{opts.sequence}))); 17 | end 18 | ids = unique(tracker_output(:,2)); 19 | 20 | traj_for_iCam = traj_for_iCam.trajectories; 21 | 22 | for idx = 1:length(ids) 23 | id = ids(idx); 24 | trajectory = []; 25 | trajectory.data = tracker_output(tracker_output(:,2)==id,:); 26 | if opts.dataset~=2 27 | feet_world = image2world(feetPosition(trajectory.data(:,[3:6])), iCam); 28 | trajectory.data(:,[7,8]) = feet_world; 29 | end 30 | trajectory.mcid = count; 31 | trajectory.scid = id; 32 | trajectory.camera = iCam; 33 | trajectory.startFrame = min(trajectory.data(:,1)); 34 | trajectory.endFrame = max(trajectory.data(:,1)); 35 | trajectory.feature = traj_for_iCam(id).feature; 36 | if opts.visualize 37 | i=floor(length(trajectory.data(:,1))/2); 38 | frame = round(trajectory.data(i,1)); 39 | left = round(max(trajectory.data(i,3),1)); 40 | top = round(max(trajectory.data(i,4),1)); 41 | width = round(trajectory.data(i,5)); 42 | height = round(trajectory.data(i,6)); 43 | if opts.dataset ~= 2 44 | img = opts.reader.getFrame(iCam,frame); 45 | else 46 | img = opts.reader.getFrame(scene, iCam,frame); 47 | end 48 | img_size = size(img); 49 | trajectory.snapshot = img(top:min(top+height,img_size(1)),left:min(left+width,img_size(2)),:); 50 | end 51 | trajectories(count).trajectories = trajectory; 52 | count = count + 1; 53 | 54 | end 55 | end 56 | 57 | -------------------------------------------------------------------------------- /src/L3-identities/trajectoriesToIdentities.m: -------------------------------------------------------------------------------- 1 | function identities = trajectoriesToIdentities( trajectories, labels ) 2 | 3 | identities = []; 4 | 5 | uniqueLabels = unique(labels); 6 | 7 | for i = 1:length(uniqueLabels) 8 | 9 | trajectoryIndices = find(labels == uniqueLabels(i)); 10 | 11 | trajectory = struct('trajectories',[],'startFrame',inf,'endFrame',-inf); 12 | 13 | for k = 1:length(trajectoryIndices) 14 | ind = trajectoryIndices(k); 15 | trajectory.trajectories = [trajectory.trajectories; trajectories(ind)]; 16 | trajectory.startFrame = min(trajectory.startFrame, trajectories(ind).startFrame); 17 | trajectory.endFrame = max(trajectory.startFrame, trajectories(ind).endFrame); 18 | % trajectory.segmentStart = min(trajectory.segmentStart, trajectories(ind).segmentStart); 19 | % trajectory.segmentEnd = max(trajectory.segmentEnd, trajectories(ind).segmentEnd); 20 | % trajectory.feature = trajectories(ind).feature; 21 | end 22 | 23 | identities = [identities; trajectory]; 24 | end 25 | 26 | -------------------------------------------------------------------------------- /src/MOT/compute_L2_trajectories_mot.m: -------------------------------------------------------------------------------- 1 | function compute_L2_trajectories_mot(opts) 2 | % Computes single-camera trajectories from tracklets 3 | 4 | appear_model_param = load(fullfile('src','hyper_score/logs',opts.appear_model_name)); 5 | motion_model_param = []; 6 | for i = 1:length(opts.seqs) 7 | iCam = opts.seqs(i); 8 | opts.current_camera = iCam; 9 | seq_name = sprintf('MOT16-%02d',iCam); 10 | % Load MOT detections for current camera 11 | detections = importdata(fullfile(opts.dataset_path, 'train',seq_name,'det','det.txt')); 12 | 13 | % Initialize 14 | load(fullfile(opts.experiment_root, opts.experiment_name, 'L1-tracklets', sprintf('tracklets%d_%s.mat',iCam,opts.sequence_names{opts.sequence}))); 15 | 16 | trajectoriesFromTracklets = trackletsToTrajectories(opts, tracklets,1:length(tracklets)); 17 | 18 | startFrame = min(detections(:,1)); 19 | endFrame = min(detections(:,1)) + opts.trajectories.window_width - 1; 20 | 21 | trajectories = trajectoriesFromTracklets; 22 | 23 | while startFrame <= max(detections(:,1)) 24 | % Display loop state 25 | clc; fprintf('Cam: %d - Window %d...%d\n', iCam, startFrame, endFrame); 26 | 27 | % Compute trajectories in current time window 28 | trajectories = createTrajectories(opts, trajectories, startFrame, endFrame, iCam,appear_model_param,motion_model_param); 29 | 30 | % Update loop range 31 | startFrame = endFrame - opts.trajectories.window_width/2; 32 | endFrame = startFrame + opts.trajectories.window_width; 33 | end 34 | 35 | % Convert trajectories 36 | trackerOutputRaw = trajectoriesToTop(trajectories); 37 | % Interpolate missing detections 38 | trackerOutputFilled = fillTrajectories(trackerOutputRaw); 39 | % Remove spurius tracks 40 | [trackerOutputRemoved, removedIDs] = removeShortTracks(trackerOutputFilled, opts.minimum_trajectory_length); 41 | % Make identities 1-indexed 42 | [~, ~, ic] = unique(trackerOutputRemoved(:,2)); 43 | trackerOutputRemoved(:,2) = ic; 44 | trackerOutput = sortrows(trackerOutputRemoved,[2 1]); 45 | 46 | %% Save output 47 | fprintf('Saving results\n'); 48 | fileOutput = trackerOutput(:, [1:6]); 49 | dlmwrite(sprintf('%s/%s/L2-trajectories/%s.txt', ... 50 | opts.experiment_root, ... 51 | opts.experiment_name, ... 52 | seq_name), ... 53 | fileOutput, 'delimiter', ' ', 'precision', 6); 54 | 55 | end 56 | end -------------------------------------------------------------------------------- /src/compute_L0_features.m: -------------------------------------------------------------------------------- 1 | function compute_L0_features(opts) 2 | % Computes features for the input poses 3 | 4 | for iCam = 1:opts.num_cam 5 | 6 | % Load poses 7 | load(fullfile(opts.dataset_path, 'detections','openpose', sprintf('camera%d.mat',iCam))); 8 | poses = detections; 9 | 10 | % Convert poses to detections 11 | detections = zeros(size(poses,1),6); 12 | for k = 1:size(poses,1) 13 | pose = poses(k,3:end); 14 | bb = pose2bb(pose, opts.render_threshold); 15 | [newbb, newpose] = scale_bb(bb,pose,1.25); 16 | detections(k,:) = [iCam, poses(k,2), newbb]; 17 | end 18 | 19 | % Compute feature embeddings 20 | features = embed_detections(opts,detections); 21 | 22 | % Save features 23 | h5write(sprintf('%s/%s/L0-features/features%d.h5',opts.experiment_root,opts.experiment_name,iCam),'/emb', features); 24 | end 25 | 26 | -------------------------------------------------------------------------------- /src/correlation_clustering/BIPCC/BIPCC.m: -------------------------------------------------------------------------------- 1 | function labels = BIPCC( correlationMatrix, initialGuess ) 2 | % Solves a graph partitioning problem as a Binary Integer Program 3 | % 4 | % Input 5 | % correlationMatrix 6 | % initialGuess - initial guess label vector (optional) 7 | % 8 | % Output 9 | % labels - optimal label vector 10 | % 11 | % Ergys Ristani 12 | % Duke University 13 | 14 | [f, A, b] = createBIP(correlationMatrix); 15 | 16 | [X, ~] = graphPartitioning(f, A, b, correlationMatrix, initialGuess); 17 | 18 | % Create a label vector from the BIP solution 19 | 20 | labels = labelsFromAdjacency(X, correlationMatrix); 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/correlation_clustering/BIPCC/createBIP.m: -------------------------------------------------------------------------------- 1 | function [ f, A, b ] = createBIP( W ) 2 | % Creates a Binary Integer Program for a given correlation matrix 3 | % 4 | % Input 5 | % W - correlation matrix 6 | % 7 | % Output 8 | % f - objective function 9 | % A, b - constraints of type Ax <= b 10 | % 11 | % Ergys Ristani 12 | % Duke University 13 | 14 | fprintf('Num vars: %d\n\n', size(W,1)); 15 | 16 | constraintsTime = tic; 17 | 18 | N = size(W,1); 19 | 20 | % f is the objective function f = sum{W} w_uv * x_uv 21 | f = zeros(N*(N-1)/2,1); 22 | 23 | % pairs - a list of all edges (u,v), v>u 24 | pairs = zeros(N,N-1); 25 | 26 | pos = 1; 27 | for i = 1:N-1 28 | for j = i + 1:N 29 | pairs(i, j) = pos; 30 | f(pos) = W(i,j); 31 | pos = pos + 1; 32 | end 33 | end 34 | 35 | % Constraint matrix x_uv + x_ut - x_vt <= 1 represented by 36 | % Ax<=b 37 | 38 | % Computie all possible triples between observations 39 | 40 | if N>=3 41 | 42 | triples = combinator(N,3,'c','no'); % Equivalent to combnk(1:N,3) but faster 43 | 44 | % Translate triples to observation unique IDs 45 | % Observation (i,j) has pairs(i,j) as unique ID 46 | 47 | idx = zeros(size(triples)); 48 | 49 | idx(:,1) = pairs(sub2ind(size(pairs), triples(:,1),triples(:,2))); 50 | idx(:,2) = pairs(sub2ind(size(pairs), triples(:,1),triples(:,3))); 51 | idx(:,3) = pairs(sub2ind(size(pairs), triples(:,2),triples(:,3))); 52 | 53 | % Express x_uv + x_ut - x_vt <= 1 as three constraints by permutation 54 | idx_x3 = kron(idx,[1 1 1]'); 55 | permutations = idx_x3; 56 | permutations(2:3:end,:)=circshift(idx_x3(2:3:end,:)',1)'; 57 | permutations(3:3:end,:)=circshift(idx_x3(3:3:end,:)',2)'; 58 | 59 | idx = permutations'; 60 | 61 | rows = kron(1:(size(triples,1)*3),[1,1,1])'; 62 | cols = idx(:); 63 | values = kron(ones(size(triples,1)*3,1),[1 1 -1]'); 64 | 65 | % A - constraints matrix 66 | A = sparse(rows,cols,values); 67 | b = ones(size(A,1),1); 68 | 69 | % All columns in A belonging to -inf assignments are removed for 70 | % memory efficiency. This affects how the partial solution is built 71 | % in correlationClustering.m 72 | infIndices = pairs(W==-inf); 73 | infIndices(infIndices==0) = []; 74 | 75 | A(:,infIndices) = []; 76 | f(infIndices) = []; 77 | 78 | elseif N == 2 79 | 80 | % No constraints 81 | A = sparse([0]); 82 | b = [0]; 83 | 84 | else 85 | 86 | % N is 0 or 1 87 | A = sparse([0]); 88 | b = [0]; 89 | f = W; 90 | end 91 | 92 | fprintf('Assembling BIP. '); toc(constraintsTime); 93 | fprintf('Number of constraints: %d\n\n', size(A,1)); 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/correlation_clustering/BIPCC/graphPartitioning.m: -------------------------------------------------------------------------------- 1 | function [ X , objval ] = graphPartitioning( f, A, b, correlationMatrix, initialGuess ) 2 | % Finds the optimal partitioning of a correlation matrix 3 | % 4 | % Input: 5 | % f - the objective function to maximize 6 | % sum w_uv * x_uv 7 | % A, b - constraints of type Ax <= b 8 | % correlationMatrix 9 | % initialGuess (optinal) 10 | % 11 | % Output: 12 | % X - solution in the form of an upper triangular matrix in vector form 13 | % objval - value of the objective 14 | % 15 | % Ergys Ristani 16 | % Duke University 17 | 18 | partialSolution = f; 19 | partialSolution(f == -inf) = 0; 20 | partialSolution(f ~= -inf) = NaN; 21 | 22 | if ~isempty(initialGuess) 23 | N = length(initialGuess); 24 | pos = 1; 25 | for i = 1:N-1 26 | for j = i + 1:N 27 | if correlationMatrix(i,j) == -inf 28 | continue; 29 | end 30 | partialSolution(pos) = initialGuess(i) == initialGuess(j); 31 | pos = pos + 1; 32 | end 33 | end 34 | end 35 | 36 | % Gurobi solver parameters 37 | clear model; 38 | model.obj = f; 39 | model.A = sparse(A); 40 | model.sense = '<'; 41 | model.rhs = b; 42 | model.vtype = 'B'; % binary 43 | model.modelsense = 'max'; 44 | model.start = partialSolution; 45 | model.norelheuristic = 1; 46 | clear params; 47 | 48 | params = struct(); 49 | params.Presolve = 0; 50 | % params.CliqueCuts = 2; 51 | %params.outputflag = 0; % Silence gurobi 52 | % params.NodefileStart = 0.1; 53 | % params.TimeLimit = 10; 54 | 55 | result = gurobi(model, params); 56 | objval = result.objval; 57 | X = [result.x]; 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/correlation_clustering/BIPCC/labelsFromAdjacency.m: -------------------------------------------------------------------------------- 1 | function [ labels ] = labelsFromAdjacency( X, W ) 2 | % Transforms the Binary Integer Program solution vector to a label vector 3 | % 4 | % Input 5 | % X - solution vector representing an upper triangular matrix 6 | % W - correlation matrix 7 | % 8 | % Output 9 | % labels - label vector 10 | % 11 | % Ergys Ristani 12 | % Duke University 13 | 14 | labels = [1:size(W,1)]'; 15 | pos = 1; 16 | 17 | for i = 1:size(W,1) 18 | 19 | for j = i + 1:size(W,1) 20 | 21 | % Skip the -inf assignments that were previously removed from the 22 | % Binary Integer Program (createILP.m) for memory efficiency 23 | if W(i,j)== -inf 24 | continue; 25 | end 26 | 27 | if X(pos)==1 28 | labels(j) = labels(i); 29 | end 30 | 31 | pos = pos + 1; 32 | end 33 | end 34 | 35 | % Assign labels from 1 to n 36 | ids = unique(labels); 37 | tmplabels = labels; 38 | 39 | for i = 1:length(ids) 40 | labels(tmplabels==ids(i)) = i; 41 | end 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/correlation_clustering/external/AL-ICM/AL_ICM.m: -------------------------------------------------------------------------------- 1 | function l = AL_ICM(w, ig) 2 | % 3 | % adaptive-label ICM 4 | % 5 | % Usage: 6 | % l = AL_ICM(w, [ig]) 7 | % 8 | % Inputs: 9 | % w - sparse, symmetric affinity matrix containng BOTH positive and 10 | % negative entries (attraction and repultion). 11 | % ig- initial guess labeling (optional) 12 | % 13 | % Output: 14 | % l - labeling of the nodes into different clusters. 15 | % 16 | 17 | 18 | 19 | n = size(w,1); 20 | 21 | LIMIT = 100*ceil(reallog(n)); 22 | 23 | % ignore diagonal 24 | w = w - spdiags( spdiags(w,0), 0, n, n); 25 | 26 | % initial guess 27 | if nargin == 1 || isempty(ig) || numel(ig) ~= n 28 | l = ones(n, 1); 29 | else 30 | [~, ~, l] = unique(ig); 31 | end 32 | 33 | l = 1:n; 34 | 35 | for itr=1:LIMIT 36 | nl = pure_potts_icm_iter_mex(w, l); 37 | if isequal(l,nl) 38 | break; 39 | end 40 | l = nl; 41 | if mod(itr, 15) == 0 % removing empty labels make code run faster! 42 | [~, ~, l] = unique(l); 43 | l = pure_potts_icm_iter_mex(w, l); 44 | end 45 | end 46 | 47 | % if itr == LIMIT 48 | % warning('ML_ICM:itr','reached LIMIT'); 49 | % end 50 | 51 | % remove "empty" labels 52 | [~, ~, l] = unique(l); 53 | 54 | -------------------------------------------------------------------------------- /src/correlation_clustering/external/AL-ICM/VERSION.txt: -------------------------------------------------------------------------------- 1 | Version 1.0 2 | -------------------------------------------------------------------------------- /src/correlation_clustering/external/KL/KernighanLin.m: -------------------------------------------------------------------------------- 1 | function labels = KernighanLin(correlationMatrix) 2 | 3 | if size(correlationMatrix,1) == 1 4 | labels = [1]; 5 | return; 6 | end 7 | upper_tri = triu(ones(size(correlationMatrix))); 8 | [sourceNode, targetNode] = find(upper_tri); 9 | values = correlationMatrix(sub2ind(size(correlationMatrix),sourceNode,targetNode)); 10 | infidx = find(values == -Inf); 11 | 12 | % [sourceNode,targetNode,values] = find(problemGraph.sparse_correlationMat_Upper); 13 | rmIdx = bsxfun(@eq,sourceNode,targetNode); 14 | % rmIdx(infidx) = 1; 15 | sourceNode(rmIdx) = []; 16 | targetNode(rmIdx) = []; 17 | values(rmIdx) = []; 18 | sourceNode = sourceNode -1; 19 | targetNode = targetNode-1; 20 | 21 | nNodes = numel(diag(upper_tri)); 22 | weightedGraph = [sourceNode,targetNode,values]; 23 | 24 | A = Multicut_KL_MEX(nNodes,size(weightedGraph,1),weightedGraph); 25 | %output is of the form ((u1,v1,u2,v2,...) for all edges {u_i,v_i} 26 | %index starting with 0. 27 | % Converting back to matlab format 28 | A_r = A(1:2:end)'; 29 | A_r(:,2) = A(2:2:end); 30 | A_r= A_r+ 1; 31 | result = A_r; 32 | 33 | 34 | G = graph; 35 | G = addnode(G,nNodes); 36 | G = addedge(G,result(:,1)',result(:,2)'); 37 | labels = conncomp(G)'; 38 | 39 | 40 | 41 | end -------------------------------------------------------------------------------- /src/correlation_clustering/external/KL/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/correlation_clustering/external/KL/LICENSE.txt -------------------------------------------------------------------------------- /src/correlation_clustering/external/KL/Multicut_KL_MEX.cpp: -------------------------------------------------------------------------------- 1 | #include "mex.h" 2 | #include 3 | #include "andres/graph/graph.hxx" 4 | #include "andres/graph/multicut/kernighan-lin.hxx" 5 | #include 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | void mexFunction(int nlhs, mxArray* plhs[], 12 | int nrhs, const mxArray* prhs[]) { 13 | 14 | 15 | double* nNodesP = mxGetPr(prhs[0]); 16 | double* nEdgesP = mxGetPr(prhs[1]); 17 | 18 | int nNodes = nNodesP[0]; 19 | int nEdges = nEdgesP[0]; 20 | std::cout << nNodes << std::endl; 21 | std::cout << nEdges<< std::endl; 22 | 23 | double* nLinks= mxGetPr(prhs[2]); 24 | 25 | andres::graph::Graph<> graph; 26 | graph.insertVertices(nNodes); 27 | std::vector weights(nEdges); 28 | 29 | for (int iEdge=0;iEdge<=nEdges-1;iEdge++){ 30 | graph.insertEdge(nLinks[iEdge],nLinks[iEdge+nEdges]); 31 | weights[iEdge] = nLinks[iEdge+2*nEdges]; 32 | } 33 | 34 | std::vector edge_labels(graph.numberOfEdges()); 35 | andres::graph::multicut::kernighanLin(graph, weights, edge_labels,edge_labels); 36 | //andres::graph::multicut::ilp(graph, weights, edge_labels, edge_labels); 37 | 38 | std::vector > entryList; 39 | 40 | 41 | 42 | for (int i=0; i graphRes = graph.findEdge(i,j); 45 | if (graphRes.first){ 46 | bool label= edge_labels[graphRes.second]; 47 | if (label == 0){ 48 | entryList.push_back(std::make_pair(i,j)); 49 | // resList[i][j]=1; 50 | } 51 | } 52 | } 53 | } 54 | plhs[0] = mxCreateDoubleMatrix(1,entryList.size()*2,mxREAL); 55 | 56 | int linIdx = 0; 57 | double* resP = mxGetPr(plhs[0]); 58 | for(const pair &entry : entryList){ 59 | 60 | resP[linIdx] = entry.first; 61 | resP[linIdx+1] = entry.second; 62 | linIdx = linIdx+2; 63 | 64 | } 65 | // 66 | // for (int i = 0; i< entryList.size()*2; i++){ 67 | // for (int j = 0; j< nNodes; j++){ 68 | // entryList. 69 | // resP[nNodes*i+j]= resList[i][j; 70 | // } 71 | // } 72 | } 73 | -------------------------------------------------------------------------------- /src/correlation_clustering/external/KL/andres/graph/subgraph.hxx: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ANDRES_GRAPH_SUBGRAPH_HXX 3 | #define ANDRES_GRAPH_SUBGRAPH_HXX 4 | 5 | namespace andres { 6 | namespace graph { 7 | 8 | /// An entire graph. 9 | template 10 | struct DefaultSubgraphMask { 11 | typedef T Value; 12 | 13 | bool vertex(const Value v) const 14 | { return true; } 15 | bool edge(const Value e) const 16 | { return true; } 17 | }; 18 | 19 | } // namespace graph 20 | } // namespace andres 21 | 22 | #endif // #ifndef ANDRES_GRAPH_SUBGRAPH_HXX 23 | -------------------------------------------------------------------------------- /src/correlation_clustering/external/KL/andres/graph/visitor.hxx: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ANDRES_GRAPH_VISITOR_HXX 3 | #define ANDRES_GRAPH_VISITOR_HXX 4 | 5 | #include 6 | #include 7 | 8 | namespace andres { 9 | namespace graph { 10 | 11 | /// Visitors can be used to follow the indices of vertices and edges. 12 | /// 13 | /// These indices change due to the insetion and removal of vertices and edges. 14 | /// 15 | template 16 | struct IdleGraphVisitor { 17 | typedef S size_type; 18 | 19 | IdleGraphVisitor() {} 20 | void insertVertex(const size_type a) const {} 21 | void insertVertices(const size_type a, const size_type n) const {} 22 | void eraseVertex(const size_type a) const {} 23 | void relabelVertex(const size_type a, const size_type b) const {} 24 | void insertEdge(const size_type a) const {} 25 | void eraseEdge(const size_type a) const {} 26 | void relabelEdge(const size_type a, const size_type b) const {} 27 | }; 28 | 29 | /// Visitors can be used to follow the indices of vertices and edges. 30 | /// 31 | /// These indices change due to the insetion and removal of vertices and edges. 32 | /// 33 | template 34 | struct VerboseGraphVisitor { 35 | typedef S size_type; 36 | 37 | VerboseGraphVisitor() {} 38 | void insertVertex(const size_type a) const 39 | { std::cout << "inserting vertex " << a << std::endl; } 40 | void insertVertices(const size_type a, const size_type n) const 41 | { std::cout << "inserting " << n << " vertices, starting from index " << a << std::endl; } 42 | void eraseVertex(const size_type a) const 43 | { std::cout << "removing vertex " << a << std::endl; } 44 | void relabelVertex(const size_type a, const size_type b) const 45 | { std::cout << "relabeling vertex " << a << ". new label is " << b << std::endl; } 46 | void insertEdge(const size_type a) const 47 | { std::cout << "inserting edge " << a << std::endl; } 48 | void eraseEdge(const size_type a) const 49 | { std::cout << "removing edge " << a << std::endl; } 50 | void relabelEdge(const size_type a, const size_type b) const 51 | { std::cout << "relabeling edge " << a << ". new label is " << b << std::endl; } 52 | }; 53 | 54 | } // namespace graph 55 | } // namespace andres 56 | 57 | #endif // #ifndef ANDRES_GRAPH_VISITOR_HXX 58 | -------------------------------------------------------------------------------- /src/duke/DukeFrameReader.m: -------------------------------------------------------------------------------- 1 | classdef DukeFrameReader < handle 2 | % Assumes all frames are extracted to DukeMTMC/frames/ 3 | % Example use 4 | % 5 | % reader = DukeFrameReader('g:/dukemtmc/'); 6 | % camera = 2; 7 | % frame = 360720; 8 | % figure, imshow(reader.getFrame(camera, frame)); 9 | 10 | properties 11 | NumCameras = 8; 12 | NumFrames = [359580, 360720, 355380, 374850, 366390, 344400, 337680, 353220]; 13 | DatasetPath = ''; 14 | end 15 | methods 16 | function obj = DukeFrameReader(datasetPath) 17 | obj.DatasetPath = datasetPath; 18 | end 19 | 20 | function img = getFrame(obj, iCam, iFrame) 21 | % DukeMTMC frames are 1-indexed 22 | assert(iFrame > 0 && iFrame <= obj.NumFrames(iCam),'Frame out of range'); 23 | img = imread(sprintf('%sframes/camera%d/%d.jpg',obj.DatasetPath, iCam, iFrame)); 24 | end 25 | 26 | end 27 | end 28 | 29 | -------------------------------------------------------------------------------- /src/duke/MyVideoReader.m: -------------------------------------------------------------------------------- 1 | classdef MyVideoReader < handle 2 | % Example use 3 | % 4 | % reader = DukeVideoReader('F:/datasets/DukeMTMC/'); 5 | % camera = 2; 6 | % frame = 360720; 7 | % figure, imshow(reader.getFrame(camera, frame)); 8 | 9 | properties 10 | NumCameras = 8; 11 | NumFrames = [359580, 360720, 355380, 374850, 366390, 344400, 337680, 353220]; 12 | DatasetPath = ''; 13 | CurrentCamera = 1; 14 | PrevCamera = 1; 15 | PrevFrame = 0; 16 | Video = []; 17 | lastFrame = []; 18 | end 19 | methods 20 | function obj = MyVideoReader(datasetPath) 21 | obj.DatasetPath = datasetPath; 22 | obj.Video = VideoReader(fullfile(obj.DatasetPath, 'videos', sprintf('camera%d.mp4', obj.CurrentCamera))); 23 | end 24 | 25 | function img = getFrame(obj, iCam, iFrame) 26 | % DukeMTMC frames are 1-indexed 27 | assert(iFrame > 0 && iFrame <= obj.NumFrames(iCam),'Frame out of range'); 28 | 29 | if iCam ~= obj.CurrentCamera 30 | obj.CurrentCamera = iCam; 31 | obj.PrevFrame = -1; 32 | obj.Video = VideoReader(fullfile(obj.DatasetPath, 'videos', sprintf('camera%d.mp4', obj.CurrentCamera))); 33 | end 34 | 35 | if iFrame ~= obj.PrevFrame + 1 36 | obj.Video.CurrentTime = iFrame / obj.Video.FrameRate; 37 | end 38 | if abs(obj.Video.CurrentTime*obj.Video.FrameRate - iFrame) >= 2 39 | obj.Video.CurrentTime = iFrame / obj.Video.FrameRate; 40 | end 41 | img = readFrame(obj.Video); 42 | 43 | % Keep track of last read 44 | obj.PrevCamera = iCam; 45 | obj.PrevFrame = iFrame; 46 | end 47 | 48 | end 49 | end 50 | 51 | -------------------------------------------------------------------------------- /src/duke/getROIs.m: -------------------------------------------------------------------------------- 1 | function ROI = getROIs() 2 | 3 | ROI{1} = [214 553;1904 411;1897 1055;216 1051]; 4 | ROI{2} = [35 423;574 413;624 300;1075 284;1150 341;1153 396;1260 393;1610 492;1608 460;1614 446;1771 440;1777 485;1894 483;1894 1048;29 1051]; 5 | ROI{3} = [65 659;926 662;798 592;827 574;1201 573;1500 671;1888 673;1882 1047;68 1044]; 6 | ROI{4} = [1189 1043;1664 1043;1434 240;1267 240]; 7 | ROI{5} = [28 1054;1897 1054;1893 202;410 211;397 313;311 320;104 369;71 449;107 567;27 750]; 8 | ROI{6} = [154 646;957 626;1863 886;1866 1050;40 1059;56 775;103 682]; 9 | ROI{7} = [40 751;40 1049;1862 1050;1862 875;862 817;1004 730;667 710;445 779]; 10 | ROI{8} = [1867 637;1806 1066;53 1047;455 807;457 729;824 531]; -------------------------------------------------------------------------------- /src/duke/global2local.m: -------------------------------------------------------------------------------- 1 | function local_frame = global2local(start_frame, global_frame) 2 | 3 | local_frame = global_frame - start_frame + 1; 4 | 5 | end 6 | 7 | -------------------------------------------------------------------------------- /src/duke/local2global.m: -------------------------------------------------------------------------------- 1 | function global_frame = local2global(start_frame, local_frame) 2 | 3 | global_frame = local_frame + start_frame - 1; 4 | 5 | end 6 | 7 | -------------------------------------------------------------------------------- /src/duke/prepareMOTChallengeSubmission.m: -------------------------------------------------------------------------------- 1 | function prepareMOTChallengeSubmission(opts) 2 | % Prepare submission file duke.txt 3 | 4 | submission_data = []; 5 | for sequence = 3:4 6 | 7 | for iCam = 1:8 8 | filename = sprintf('%s/%s/L3-identities/cam%d_%s.txt', opts.experiment_root, opts.experiment_name, iCam, opts.sequence_names{sequence}); 9 | data = dlmread(filename); 10 | data(:,[1 2]) = data(:,[2 1]); 11 | data = [iCam*ones(size(data,1),1), data]; 12 | data = data(:,[1:7]); 13 | submission_data = [submission_data; data]; 14 | end 15 | end 16 | 17 | % Sanity check 18 | frameIdPairs = submission_data(:,1:3); 19 | [u,I,~] = unique(frameIdPairs, 'rows', 'first'); 20 | hasDuplicates = size(u,1) < size(frameIdPairs,1); 21 | if hasDuplicates 22 | ixDupRows = setdiff(1:size(frameIdPairs,1), I); 23 | dupFrameIdExample = frameIdPairs(ixDupRows(1),:); 24 | rows = find(ismember(frameIdPairs, dupFrameIdExample, 'rows')); 25 | 26 | errorMessage = sprintf('Invalid submission: Found duplicate ID/Frame pairs in result.\nInstance:\n'); 27 | errorMessage = [errorMessage, sprintf('%10.2f', submission_data(rows(1),:)), sprintf('\n')]; 28 | errorMessage = [errorMessage, sprintf('%10.2f', submission_data(rows(2),:)), sprintf('\n')]; 29 | assert(~hasDuplicates, errorMessage); 30 | end 31 | 32 | % Write duke.txt 33 | dlmwrite(sprintf('%s/%s/duke.txt',opts.experiment_root, opts.experiment_name), int32(submission_data), 'delimiter', ' ','precision',6); 34 | 35 | -------------------------------------------------------------------------------- /src/duke/world2map.m: -------------------------------------------------------------------------------- 1 | function [ C ] = world2map( W ) 2 | 3 | image_points = [307.4323 469.2366; 485.2483 708.9507]; 4 | world_points = [0 0; 24.955 32.85]; 5 | 6 | diff = image_points(2,:) - image_points(1,:); 7 | 8 | scale = diff ./ world_points(2,:); 9 | trans = image_points(1,:); 10 | 11 | C(:,1) = W(:,1)*scale(1) + trans(1); 12 | C(:,2) = W(:,2)*scale(2) + trans(2); 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /src/evaluate.m: -------------------------------------------------------------------------------- 1 | function [allMets, metsBenchmark, metsMultiCam] = evaluate(opts) 2 | if opts.dataset == 0 % duke 3 | evalNames = {'trainval', 'trainval-mini', 'test-easy', 'test-hard','','','','val'}; 4 | seqMap = sprintf('DukeMTMCT-%s.txt', evalNames{opts.sequence}); 5 | eval_folder = [opts.experiment_root, filesep, opts.experiment_name, filesep, opts.eval_dir]; 6 | gt_folder = [opts.dataset_path, filesep, 'ground_truth']; 7 | [allMets, metsBenchmark, metsMultiCam] = evaluateTracking(seqMap, eval_folder, gt_folder, 'DukeMTMCT',opts.dataset_path); 8 | elseif opts.dataset == 1 % mot 9 | evalNames = {'trainval', 'trainval-mini', 'test-easy', 'test-hard','','','train','val'}; 10 | seqMap = sprintf('MOT16-%s.txt', evalNames{opts.sequence}); 11 | eval_folder = [opts.experiment_root, filesep, opts.experiment_name, filesep, opts.eval_dir]; 12 | gt_folder = [opts.dataset_path, filesep, 'train', filesep]; 13 | [allMets, metsBenchmark, metsMultiCam] = evaluateTracking(seqMap, eval_folder, gt_folder, 'MOT16',opts.dataset_path); 14 | elseif opts.dataset == 2 % aic 15 | evalNames = {'trainval', 'test', 'test', 'test','test','test','train','val'}; 16 | seqMap = sprintf('AIC19-%s.txt', evalNames{opts.sequence}); 17 | eval_folder = [opts.experiment_root, filesep, opts.experiment_name, filesep, opts.eval_dir]; 18 | gt_folder = [opts.dataset_path, filesep, 'ground_truth']; 19 | [allMets, metsBenchmark, metsMultiCam] = evaluateTracking(seqMap, eval_folder, gt_folder, 'AIC19',opts.dataset_path); 20 | end 21 | end -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/CITATION_DukeMTMC-reID.txt: -------------------------------------------------------------------------------- 1 | @inproceedings{zheng2017unlabeled, 2 | title={Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro}, 3 | author={Zheng, Zhedong and Zheng, Liang and Yang, Yi}, 4 | booktitle={Proceedings of the IEEE International Conference on Computer Vision}, 5 | year={2017} 6 | } 7 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/CITATION_DukeMTMC.txt: -------------------------------------------------------------------------------- 1 | @inproceedings{ristani2016MTMC, 2 | title = {Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking}, 3 | author = {Ristani, Ergys and Solera, Francesco and Zou, Roger and Cucchiara, Rita and Tomasi, Carlo}, 4 | booktitle = {European Conference on Computer Vision workshop on Benchmarking Multi-Target Tracking}, 5 | year = {2016} 6 | } 7 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/Data_Distribution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/DukeMTMC-reID_evaluation/Data_Distribution.jpg -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/DukeMTMC-reID_mosaic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/DukeMTMC-reID_evaluation/DukeMTMC-reID_mosaic.jpg -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/LICENSE_DukeMTMC-reID.txt: -------------------------------------------------------------------------------- 1 | ATTRIBUTION PROTOCOL 2 | 3 | If you use the DukeMTMC-reID data or any data derived from it, please cite our work as follows: 4 | 5 | @article{zheng2017unlabeled, 6 | title={Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro}, 7 | author={Zheng, Zhedong and Zheng, Liang and Yang, Yi}, 8 | journal={arXiv preprint arXiv:1701.07717}, 9 | year={2017} 10 | } 11 | 12 | and include this license and attribution protocol within any derivative work. 13 | 14 | 15 | If you use the DukeMTMC data or any data derived from it, please cite the original work as follows: 16 | 17 | @inproceedings{ristani2016MTMC, 18 | title = {Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking}, 19 | author = {Ristani, Ergys and Solera, Francesco and Zou, Roger and Cucchiara, Rita and Tomasi, Carlo}, 20 | booktitle = {European Conference on Computer Vision workshop on Benchmarking Multi-Target Tracking}, 21 | year = {2016} 22 | } 23 | 24 | and include this license and attribution protocol within any derivative work. 25 | 26 | If you publish data derived from DukeMTMC, the original dataset creators should first be notified. 27 | Any future dataset derived from DukeMTMC should include "DukeMTMC" in the title, as well as link to the 28 | original project website (http://vision.cs.duke.edu/DukeMTMC/). 29 | 30 | The DukeMTMC dataset is made available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt) 31 | 32 | You are free to: 33 | 34 | Share — copy and redistribute the material in any medium or format 35 | Adapt — remix, transform, and build upon the material 36 | 37 | Under the following terms: 38 | 39 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 40 | 41 | NonCommercial — You may not use the material for commercial purposes. 42 | 43 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 44 | 45 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 46 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/LICENSE_DukeMTMC.txt: -------------------------------------------------------------------------------- 1 | ATTRIBUTION PROTOCOL 2 | 3 | If you use the DukeMTMC data or any data derived from it, please cite the original work as follows: 4 | 5 | @inproceedings{ristani2016MTMC, 6 | title = {Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking}, 7 | author = {Ristani, Ergys and Solera, Francesco and Zou, Roger and Cucchiara, Rita and Tomasi, Carlo}, 8 | booktitle = {European Conference on Computer Vision workshop on Benchmarking Multi-Target Tracking}, 9 | year = {2016} 10 | } 11 | 12 | and include this license and attribution protocol within any derivative work. 13 | 14 | If you publish data derived from DukeMTMC, the original dataset creators should first be notified. 15 | Any future dataset derived from DukeMTMC should include "DukeMTMC" in the title, as well as link to the 16 | original project website (http://vision.cs.duke.edu/DukeMTMC/). 17 | 18 | The DukeMTMC dataset is made available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt) 19 | 20 | You are free to: 21 | 22 | Share — copy and redistribute the material in any medium or format 23 | Adapt — remix, transform, and build upon the material 24 | 25 | Under the following terms: 26 | 27 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 28 | 29 | NonCommercial — You may not use the material for commercial purposes. 30 | 31 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 32 | 33 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 34 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/col_sum.m: -------------------------------------------------------------------------------- 1 | function s = col_sum(x) 2 | % COL_SUM Sum for each column. 3 | % A more readable alternative to sum(x,1). 4 | s = sum(x,1); 5 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/compute_AP.m: -------------------------------------------------------------------------------- 1 | function [ap, cmc] = compute_AP(good_image, junk_image, index) 2 | 3 | cmc = zeros(length(index), 1); 4 | ngood = length(good_image); 5 | 6 | old_recall = 0; 7 | old_precision = 1.0; 8 | ap = 0; 9 | intersect_size = 0; 10 | j = 0; 11 | good_now = 0; 12 | njunk = 0; 13 | for n = 1:length(index) 14 | flag = 0; 15 | if ~isempty(find(good_image == index(n), 1)) 16 | cmc(n-njunk:end) = 1; 17 | flag = 1; % good image 18 | good_now = good_now+1; 19 | end 20 | if ~isempty(find(junk_image == index(n), 1)) 21 | njunk = njunk + 1; 22 | continue; % junk image 23 | end 24 | 25 | if flag == 1%good 26 | intersect_size = intersect_size + 1; 27 | end 28 | recall = intersect_size/ngood; 29 | precision = intersect_size/(j + 1); 30 | ap = ap + (recall - old_recall)*((old_precision+precision)/2); 31 | old_recall = recall; 32 | old_precision = precision; 33 | j = j+1; 34 | 35 | if good_now == ngood 36 | return; 37 | end 38 | end 39 | 40 | end 41 | 42 | -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/duke_rank.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/DukeMTMC-reID_evaluation/duke_rank.jpg -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/DukeMTMC-reID_evaluation/file.png -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/generate_train_list_caffe.m: -------------------------------------------------------------------------------- 1 | p = dir('./bounding_box_train/*.jpg'); 2 | 3 | txt = fopen('train_list.txt','w'); 4 | person_id = 0; 5 | last_id = 1; 6 | for i = 1:numel(p) 7 | file_path = sprintf('./bounding_box_train/%s',p(i).name); 8 | 9 | tmp_id = str2num(p(i).name(1:4)); 10 | camera_id = str2num(p(i).name(7)); 11 | 12 | if(tmp_id ~= last_id) 13 | person_id = person_id + 1; 14 | last_id = tmp_id; 15 | end 16 | fprintf(txt,'%s %d\n',file_path,person_id); % caffe start from 0 17 | end -------------------------------------------------------------------------------- /src/external/DukeMTMC-reID_evaluation/sqdist.m: -------------------------------------------------------------------------------- 1 | function m = sqdist(p, q, A) 2 | % SQDIST Squared Euclidean or Mahalanobis distance. 3 | % SQDIST(p,q) returns m(i,j) = (p(:,i) - q(:,j))'*(p(:,i) - q(:,j)). 4 | % SQDIST(p,q,A) returns m(i,j) = (p(:,i) - q(:,j))'*A*(p(:,i) - q(:,j)). 5 | % The Lightspeed Matlab toolbox 6 | % Written by Tom Minka 7 | 8 | [d, pn] = size(p); 9 | [d, qn] = size(q); 10 | 11 | if pn == 0 || qn == 0 12 | m = zeros(pn,qn); 13 | return 14 | end 15 | 16 | if nargin == 2 17 | 18 | pmag = col_sum(p .* p); 19 | qmag = col_sum(q .* q); 20 | m = repmat(qmag, pn, 1) + repmat(pmag', 1, qn) - 2*p'*q; 21 | %m = ones(pn,1)*qmag + pmag'*ones(1,qn) - 2*p'*q; 22 | 23 | else 24 | 25 | Ap = A*p; 26 | Aq = A*q; 27 | pmag = col_sum(p .* Ap); 28 | qmag = col_sum(q .* Aq); 29 | m = repmat(qmag, pn, 1) + repmat(pmag', 1, qn) - 2*p'*Aq; 30 | 31 | end 32 | -------------------------------------------------------------------------------- /src/external/addborder/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Eric Johnson 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 | * Neither the name of the The MathWorks, Inc. nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/external/combinator/cumsumall.m: -------------------------------------------------------------------------------- 1 | %CUMSUMALL cumulative sum of integer elements 2 | % For vectors, CUMSUMALL(X) is a vector containing the cumulative sum of 3 | % the elements of X. For matrices, CUMSUM(X) is a matrix the same size 4 | % as X containing the cumulative sums over each column. 5 | % 6 | % Class suport: 7 | % int8, int16, int32 8 | % 9 | % Keep in mind that the usefullness of this MEX-File is limited because of 10 | % saturation for most problems outside of use with COMBINATOR. 11 | % 12 | % See also cumsum, CUMPROD, SUM, PROD. 13 | -------------------------------------------------------------------------------- /src/external/combinator/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Matt Fig 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 | -------------------------------------------------------------------------------- /src/external/distinguishable_colors/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2011, Tim Holy 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 | -------------------------------------------------------------------------------- /src/external/export-fig/.gitignore: -------------------------------------------------------------------------------- 1 | /.ignore 2 | *.txt 3 | *.asv 4 | *~ 5 | *.mex* 6 | -------------------------------------------------------------------------------- /src/external/export-fig/ImageSelection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/export-fig/ImageSelection.class -------------------------------------------------------------------------------- /src/external/export-fig/ImageSelection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/export-fig/ImageSelection.java -------------------------------------------------------------------------------- /src/external/export-fig/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Oliver J. Woodford, Yair M. Altman 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 met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/external/export-fig/copyfig.m: -------------------------------------------------------------------------------- 1 | function fh = copyfig(fh) 2 | %COPYFIG Create a copy of a figure, without changing the figure 3 | % 4 | % Examples: 5 | % fh_new = copyfig(fh_old) 6 | % 7 | % This function will create a copy of a figure, but not change the figure, 8 | % as copyobj sometimes does, e.g. by changing legends. 9 | % 10 | % IN: 11 | % fh_old - The handle of the figure to be copied. Default: gcf. 12 | % 13 | % OUT: 14 | % fh_new - The handle of the created figure. 15 | 16 | % Copyright (C) Oliver Woodford 2012 17 | 18 | % 26/02/15: If temp dir is not writable, use the dest folder for temp 19 | % destination files (Javier Paredes) 20 | % 15/04/15: Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02) 21 | 22 | % Set the default 23 | if nargin == 0 24 | fh = gcf; 25 | end 26 | % Is there a legend? 27 | if isempty(findall(fh, 'Type', 'axes', 'Tag', 'legend')) 28 | % Safe to copy using copyobj 29 | oldWarn = warning('off'); %#ok %Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02) 30 | fh = copyobj(fh, 0); 31 | warning(oldWarn); 32 | else 33 | % copyobj will change the figure, so save and then load it instead 34 | tmp_nam = [tempname '.fig']; 35 | try 36 | % Ensure that the temp dir is writable (Javier Paredes 26/2/15) 37 | fid = fopen(tmp_nam,'w'); 38 | fwrite(fid,1); 39 | fclose(fid); 40 | delete(tmp_nam); % cleanup 41 | catch 42 | % Temp dir is not writable, so use the current folder 43 | [dummy,fname,fext] = fileparts(tmp_nam); %#ok 44 | fpath = pwd; 45 | tmp_nam = fullfile(fpath,[fname fext]); 46 | end 47 | hgsave(fh, tmp_nam); 48 | fh = hgload(tmp_nam); 49 | delete(tmp_nam); 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /src/external/export-fig/export_fig.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/export-fig/export_fig.m -------------------------------------------------------------------------------- /src/external/export-fig/pdf2eps.m: -------------------------------------------------------------------------------- 1 | %PDF2EPS Convert a pdf file to eps format using pdftops 2 | % 3 | % Examples: 4 | % pdf2eps source dest 5 | % 6 | % This function converts a pdf file to eps format. 7 | % 8 | % This function requires that you have pdftops, from the Xpdf suite of 9 | % functions, installed on your system. This can be downloaded from: 10 | % http://www.foolabs.com/xpdf 11 | % 12 | %IN: 13 | % source - filename of the source pdf file to convert. The filename is 14 | % assumed to already have the extension ".pdf". 15 | % dest - filename of the destination eps file. The filename is assumed to 16 | % already have the extension ".eps". 17 | 18 | % Copyright (C) Oliver Woodford 2009-2010 19 | 20 | % Thanks to Aldebaro Klautau for reporting a bug when saving to 21 | % non-existant directories. 22 | 23 | function pdf2eps(source, dest) 24 | % Construct the options string for pdftops 25 | options = ['-q -paper match -eps -level2 "' source '" "' dest '"']; 26 | % Convert to eps using pdftops 27 | [status, message] = pdftops(options); 28 | % Check for error 29 | if status 30 | % Report error 31 | if isempty(message) 32 | error('Unable to generate eps. Check destination directory is writable.'); 33 | else 34 | error(message); 35 | end 36 | end 37 | % Fix the DSC error created by pdftops 38 | fid = fopen(dest, 'r+'); 39 | if fid == -1 40 | % Cannot open the file 41 | return 42 | end 43 | fgetl(fid); % Get the first line 44 | str = fgetl(fid); % Get the second line 45 | if strcmp(str(1:min(13, end)), '% Produced by') 46 | fseek(fid, -numel(str)-1, 'cof'); 47 | fwrite(fid, '%'); % Turn ' ' into '%' 48 | end 49 | fclose(fid); 50 | end 51 | 52 | -------------------------------------------------------------------------------- /src/external/export-fig/print2eps.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/export-fig/print2eps.m -------------------------------------------------------------------------------- /src/external/export-fig/read_write_entire_textfile.m: -------------------------------------------------------------------------------- 1 | %READ_WRITE_ENTIRE_TEXTFILE Read or write a whole text file to/from memory 2 | % 3 | % Read or write an entire text file to/from memory, without leaving the 4 | % file open if an error occurs. 5 | % 6 | % Reading: 7 | % fstrm = read_write_entire_textfile(fname) 8 | % Writing: 9 | % read_write_entire_textfile(fname, fstrm) 10 | % 11 | %IN: 12 | % fname - Pathname of text file to be read in. 13 | % fstrm - String to be written to the file, including carriage returns. 14 | % 15 | %OUT: 16 | % fstrm - String read from the file. If an fstrm input is given the 17 | % output is the same as that input. 18 | 19 | function fstrm = read_write_entire_textfile(fname, fstrm) 20 | modes = {'rt', 'wt'}; 21 | writing = nargin > 1; 22 | fh = fopen(fname, modes{1+writing}); 23 | if fh == -1 24 | error('Unable to open file %s.', fname); 25 | end 26 | try 27 | if writing 28 | fwrite(fh, fstrm, 'char*1'); 29 | else 30 | fstrm = fread(fh, '*char')'; 31 | end 32 | catch ex 33 | fclose(fh); 34 | rethrow(ex); 35 | end 36 | fclose(fh); 37 | end 38 | -------------------------------------------------------------------------------- /src/external/export-fig/using_hg2.m: -------------------------------------------------------------------------------- 1 | %USING_HG2 Determine if the HG2 graphics engine is used 2 | % 3 | % tf = using_hg2(fig) 4 | % 5 | %IN: 6 | % fig - handle to the figure in question. 7 | % 8 | %OUT: 9 | % tf - boolean indicating whether the HG2 graphics engine is being used 10 | % (true) or not (false). 11 | 12 | % 19/06/2015 - Suppress warning in R2015b; cache result for improved performance 13 | % 06/06/2016 - Fixed issue #156 (bad return value in R2016b) 14 | 15 | function tf = using_hg2(fig) 16 | persistent tf_cached 17 | if isempty(tf_cached) 18 | try 19 | if nargin < 1, fig = figure('visible','off'); end 20 | oldWarn = warning('off','MATLAB:graphicsversion:GraphicsVersionRemoval'); 21 | try 22 | % This generates a [supressed] warning in R2015b: 23 | tf = ~graphicsversion(fig, 'handlegraphics'); 24 | catch 25 | tf = ~verLessThan('matlab','8.4'); % =R2014b 26 | end 27 | warning(oldWarn); 28 | catch 29 | tf = false; 30 | end 31 | if nargin < 1, delete(fig); end 32 | tf_cached = tf; 33 | else 34 | tf = tf_cached; 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: e8ca38554079e281e5684a97ff1b96e7cc884e67 2 | node: 7dccd0fb32147570a02351c29fecff2a79ccaecc 3 | branch: default 4 | latesttag: null 5 | latesttagdistance: 64 6 | changessincelatesttag: 67 7 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | data/clean* 3 | *.orig 4 | res/* 5 | evalResults/* 6 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/compile.m: -------------------------------------------------------------------------------- 1 | mex utils/MinCostMatching.cpp -outdir utils CXXFLAGS="$CXXFLAGS --std=c++11" 2 | mex utils/clearMOTMex.cpp -outdir utils CXXFLAGS="$CXXFLAGS --std=c++11" 3 | mex utils/costBlockMex.cpp -outdir utils COMPFLAGS="/openmp $COMPFLAGS" CXXFLAGS="$CXXFLAGS --std=c++11" 4 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/AIC19-train.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam10_train 3 | cam11_train 4 | cam12_train 5 | cam13_train 6 | cam14_train 7 | cam15_train 8 | cam16_train 9 | cam17_train 10 | cam18_train 11 | cam19_train 12 | cam20_train 13 | cam21_train 14 | cam22_train 15 | cam23_train 16 | cam24_train 17 | cam25_train 18 | cam26_train 19 | cam27_train 20 | cam28_train 21 | cam29_train 22 | cam30_train 23 | cam31_train 24 | cam32_train 25 | cam33_train 26 | cam34_train 27 | cam35_train 28 | cam36_train 29 | cam37_train 30 | cam38_train 31 | cam39_train 32 | cam40_train -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/AIC19-trainval.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_train 3 | cam2_train 4 | cam3_train 5 | cam4_train 6 | cam5_train 7 | cam10_train 8 | cam11_train 9 | cam12_train 10 | cam13_train 11 | cam14_train 12 | cam15_train 13 | cam16_train 14 | cam17_train 15 | cam18_train 16 | cam19_train 17 | cam20_train 18 | cam21_train 19 | cam22_train 20 | cam23_train 21 | cam24_train 22 | cam25_train 23 | cam26_train 24 | cam27_train 25 | cam28_train 26 | cam29_train 27 | cam30_train 28 | cam31_train 29 | cam32_train 30 | cam33_train 31 | cam34_train 32 | cam35_train 33 | cam36_train 34 | cam37_train 35 | cam38_train 36 | cam39_train 37 | cam40_train -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/AIC19-val.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_train 3 | cam2_train 4 | cam3_train 5 | cam4_train 6 | cam5_train -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/DukeMTMCT-test-easy.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_test_easy 3 | cam2_test_easy 4 | cam3_test_easy 5 | cam4_test_easy 6 | cam5_test_easy 7 | cam6_test_easy 8 | cam7_test_easy 9 | cam8_test_easy -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/DukeMTMCT-test-hard.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_test_hard 3 | cam2_test_hard 4 | cam3_test_hard 5 | cam4_test_hard 6 | cam5_test_hard 7 | cam6_test_hard 8 | cam7_test_hard 9 | cam8_test_hard -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/DukeMTMCT-trainval-mini.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_trainval_mini 3 | cam2_trainval_mini 4 | cam3_trainval_mini 5 | cam4_trainval_mini 6 | cam5_trainval_mini 7 | cam6_trainval_mini 8 | cam7_trainval_mini 9 | cam8_trainval_mini -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/DukeMTMCT-trainval.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_trainval 3 | cam2_trainval 4 | cam3_trainval 5 | cam4_trainval 6 | cam5_trainval 7 | cam6_trainval 8 | cam7_trainval 9 | cam8_trainval -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/DukeMTMCT-val.txt: -------------------------------------------------------------------------------- 1 | name 2 | cam1_val 3 | cam2_val 4 | cam3_val 5 | cam4_val 6 | cam5_val 7 | cam6_val 8 | cam7_val 9 | cam8_val -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/seqmaps/MOT16-train.txt: -------------------------------------------------------------------------------- 1 | name 2 | MOT16-02 3 | MOT16-04 4 | MOT16-05 5 | MOT16-09 6 | MOT16-10 7 | MOT16-11 8 | MOT16-13 -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/boxIntersect.m: -------------------------------------------------------------------------------- 1 | function isect=boxIntersect(bboxleft1, bboxright1, bboxbottom1, bboxup1, bboxleft2, bboxright2, bboxbottom2, bboxup2) 2 | % Compute intersection area of two bouding boxes A,B 3 | % A=[bboxleft1 bboxbottom1 abs(bboxright1-bboxleft1) abs(bboxbottom1-bboxup1)]; 4 | % B=[bboxleft2 bboxbottom2 abs(bboxright2-bboxleft2) abs(bboxbottom2-bboxup2)]; 5 | % 6 | % isect=rectint(A,B); 7 | isect=0; 8 | 9 | hor= max(0,min(bboxright1,bboxright2) - max(bboxleft1,bboxleft2)); 10 | 11 | if ~hor, return; end 12 | ver= max(0,min(bboxbottom1,bboxbottom2) - max(bboxup1,bboxup2)); 13 | if ~ver, return; end 14 | 15 | isect = hor*ver; 16 | 17 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/boxUnion.m: -------------------------------------------------------------------------------- 1 | function union=boxUnion(bboxleft1, bboxright1, bboxbottom1, bboxup1, bboxleft2, bboxright2, bboxbottom2, bboxup2,isect) 2 | % Compute union of two bounding boxes 3 | 4 | a1=bboxright1-bboxleft1; 5 | b1=bboxbottom1-bboxup1; 6 | a2=bboxright2-bboxleft2; 7 | b2=bboxbottom2-bboxup2; 8 | union=a1*b1+a2*b2; 9 | if nargin>8 10 | bisect=isect; 11 | else 12 | bisect=boxIntersect(bboxleft1, bboxright1, bboxbottom1, bboxup1, bboxleft2, bboxright2, bboxbottom2, bboxup2); 13 | end 14 | union=union-bisect; 15 | 16 | 17 | end 18 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/boxiou.m: -------------------------------------------------------------------------------- 1 | function iou=boxiou(x1,y1,w1,h1,x2,y2,w2,h2) 2 | % compute intersection over union of two bboxes 3 | % 4 | 5 | bisect=boxIntersect(x1,x1+w1,y1+h1,y1,x2,x2+w2,y2+h2,y2); 6 | iou=0; 7 | if ~bisect, return; end 8 | 9 | bunion=boxUnion(x1,x1+w1,y1+h1,y1,x2,x2+w2,y2+h2,y2,bisect); 10 | 11 | assert(bunion>0,'something wrong with union computation'); 12 | iou=bisect/bunion; 13 | 14 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/README.md: -------------------------------------------------------------------------------- 1 | # Camera Utility Files 2 | 3 | This folder contains scripts for computing image-to-world and world-to-image projections. 4 | 5 | `calib_towncentre.m` is to be used with the AVG-TownCentre sequence. 6 | 7 | The rest is for the PETS sequence, which follows the Tsai camera model. parseCameraParameters can be used to read the camera xml file and the two scripts `imageToWorld.m` and `worldToImage.m` contain the projection routines. -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/distortedToUndistortedImageCoord.m: -------------------------------------------------------------------------------- 1 | function [Xfu Yfu]=distortedToUndistortedImageCoord (Xfd, Yfd, mDpx, mDpy, mCx, mCy, mSx, mKappa1) 2 | 3 | 4 | % /* convert from image to sensor coordinates */ 5 | Xd = mDpx * (Xfd - mCx) / mSx; 6 | Yd = mDpy * (Yfd - mCy); 7 | 8 | % /* convert from distorted sensor to undistorted sensor plane coordinates */ 9 | [Xu Yu]=distortedToUndistortedSensorCoord(Xd, Yd, mKappa1); 10 | 11 | % /* convert from sensor to image coordinates */ 12 | Xfu = Xu * mSx / mDpx + mCx; 13 | Yfu = Yu / mDpy + mCy; 14 | 15 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/distortedToUndistortedSensorCoord.m: -------------------------------------------------------------------------------- 1 | function [Xu Yu]=distortedToUndistortedSensorCoord (Xd, Yd, mKappa1) 2 | % /* convert from distorted to undistorted sensor plane coordinates */ 3 | distortion_factor = 1 + mKappa1 * (Xd*Xd + Yd*Yd); 4 | Xu = Xd * distortion_factor; 5 | Yu = Yd * distortion_factor; 6 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/getRotTrans.m: -------------------------------------------------------------------------------- 1 | function [mR, mT]=getRotTrans(camPar) 2 | % 3 | % 4 | % (C) Anton Andriyenko, 2012 5 | % 6 | % The code may be used free of charge for non-commercial and 7 | % educational purposes, the only requirement is that this text is 8 | % preserved within the derivative work. For any other purpose you 9 | % must contact the authors for permission. This code may not be 10 | % redistributed without written permission from the authors. 11 | 12 | if camPar.ortho 13 | mR=camPar.mR; mT=camPar.mT; 14 | else 15 | %%% Rotation Translation %%% 16 | mT=[camPar.mExt.mTx;camPar.mExt.mTy;camPar.mExt.mTz]; 17 | sa = sin(camPar.mExt.mRx); 18 | ca = cos(camPar.mExt.mRx); 19 | sb = sin(camPar.mExt.mRy); 20 | cb = cos(camPar.mExt.mRy); 21 | sg = sin(camPar.mExt.mRz); 22 | cg = cos(camPar.mExt.mRz); 23 | 24 | mR11 = cb * cg; 25 | mR12 = cg * sa * sb - ca * sg; 26 | mR13 = sa * sg + ca * cg * sb; 27 | mR21 = cb * sg; 28 | mR22 = sa * sb * sg + ca * cg; 29 | mR23 = ca * sb * sg - cg * sa; 30 | mR31 = -sb; 31 | mR32 = cb * sa; 32 | mR33 = ca * cb; 33 | 34 | mR=[mR11 mR12 mR13; 35 | mR21 mR22 mR23; 36 | mR31 mR32 mR33]; 37 | end 38 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/imageToWorld.m: -------------------------------------------------------------------------------- 1 | function [Xw, Yw, Zw]=imageToWorld(Xi, Yi, camPar) 2 | 3 | % if scalar, just up/downscale = orthographic 4 | if camPar.ortho 5 | Xw=Xi*camPar.scale; 6 | Yw=Yi*camPar.scale; 7 | Zw=0; 8 | else 9 | 10 | mGeo=camPar.mGeo; 11 | mExt=camPar.mExt; 12 | mInt=camPar.mInt; 13 | 14 | mTx=mExt.mTx; 15 | mTy=mExt.mTy; 16 | mTz=mExt.mTz; 17 | 18 | mT=[mExt.mTx;mExt.mTy;mExt.mTz]; 19 | 20 | %% internal init 21 | sa = sin(mExt.mRx); 22 | ca = cos(mExt.mRx); 23 | sb = sin(mExt.mRy); 24 | cb = cos(mExt.mRy); 25 | sg = sin(mExt.mRz); 26 | cg = cos(mExt.mRz); 27 | 28 | mR11 = cb * cg; 29 | mR12 = cg * sa * sb - ca * sg; 30 | mR13 = sa * sg + ca * cg * sb; 31 | mR21 = cb * sg; 32 | mR22 = sa * sb * sg + ca * cg; 33 | mR23 = ca * sb * sg - cg * sa; 34 | mR31 = -sb; 35 | mR32 = cb * sa; 36 | mR33 = ca * cb; 37 | 38 | 39 | 40 | % /* convert from image to distorted sensor coordinates */ 41 | Xd = mGeo.mDpx * (Xi - mInt.mCx) / mInt.mSx; 42 | Yd = mGeo.mDpy * (Yi - mInt.mCy); 43 | 44 | % /* convert from distorted sensor to undistorted sensor plane coordinates */ 45 | [Xu Yu]=distortedToUndistortedSensorCoord (Xd, Yd, mInt.mKappa1); 46 | 47 | % /* calculate the corresponding xw and yw world coordinates */ 48 | % /* (these equations were derived by simply inverting */ 49 | % /* the perspective projection equations using Macsyma) */ 50 | Zw=0; 51 | common_denominator = ((mR11 * mR32 - mR12 * mR31) * Yu + ... 52 | (mR22 * mR31 - mR21 * mR32) * Xu - ... 53 | mInt.mFocal * mR11 * mR22 + mInt.mFocal * mR12 * mR21); 54 | 55 | Xw = (((mR12 * mR33 - mR13 * mR32) * Yu + ... 56 | (mR23 * mR32 - mR22 * mR33) * Xu - ... 57 | mInt.mFocal * mR12 * mR23 + mInt.mFocal * mR13 * mR22) * Zw + ... 58 | (mR12 * mTz - mR32 * mTx) * Yu + ... 59 | (mR32 * mTy - mR22 * mTz) * Xu - ... 60 | mInt.mFocal * mR12 * mTy + mInt.mFocal * mR22 * mTx) / common_denominator; 61 | 62 | Yw = -(((mR11 * mR33 - mR13 * mR31) * Yu + ... 63 | (mR23 * mR31 - mR21 * mR33) * Xu - ... 64 | mInt.mFocal * mR11 * mR23 + mInt.mFocal * mR13 * mR21) * Zw + ... 65 | (mR11 * mTz - mR31 * mTx) * Yu + ... 66 | (mR31 * mTy - mR21 * mTz) * Xu - ... 67 | mInt.mFocal * mR11 * mTy + mInt.mFocal * mR21 * mTx) / common_denominator; 68 | % else 69 | % error('imageToWorld: camera parameters format unknown'); 70 | end 71 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/undistortedToDistortedImageCoord.m: -------------------------------------------------------------------------------- 1 | function [Xfd Yfd]=undistortedToDistortedImageCoord (Xfu, Yfu, mDpx, mDpy, mCx, mCy, mSx, mKappa1) 2 | 3 | 4 | % /* convert from image to sensor coordinates */ 5 | Xu = mDpx * (Xfu - mCx) / mSx; 6 | Yu = mDpy * (Yfu - mCy); 7 | 8 | % /* convert from undistorted sensor to distorted sensor plane coordinates */ 9 | [Xd Yd]=undistortedToDistortedSensorCoord(Xu, Yu, mKappa1); 10 | 11 | % /* convert from sensor to image coordinates */ 12 | Xfd = Xd * mSx / mDpx + mCx; 13 | Yfd = Yd / mDpy + mCy; 14 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/undistortedToDistortedSensorCoord.m: -------------------------------------------------------------------------------- 1 | function [Xd Yd]=undistortedToDistortedSensorCoord (Xu, Yu, mKappa1) 2 | 3 | % global ifs elses 4 | 5 | if ((~Xu && ~Yu) || ~mKappa1) 6 | % ifs(1)=ifs(1)+1; 7 | Xd = Xu; 8 | Yd = Yu; 9 | else %% THIS ONE %% 10 | % elses(1)=elses(1)+1; 11 | Ru = sqrt(Xu*Xu + Yu*Yu); 12 | 13 | c = 1.0 / mKappa1; 14 | d = -c * Ru; 15 | 16 | Q = c / 3; 17 | R = -d / 2; 18 | D = Q*Q*Q + R*R; 19 | 20 | if (D >= 0) %% THIS ONE %% 21 | % ifs(2)=ifs(2)+1; 22 | %/* one real root */ 23 | D = sqrt(D); 24 | if (R + D > 0) %% THIS ONE %% 25 | % ifs(3)=ifs(3)+1; 26 | S = (R + D)^ (1.0/3.0); 27 | else 28 | % elses(3)=elses(3)+1; 29 | S = -(-R - D)^ (1.0/3.0); 30 | end 31 | if (R - D > 0) 32 | % ifs(4)=ifs(4)+1; 33 | T = (R - D)^(1.0/3.0); 34 | else %% THIS ONE %% 35 | % elses(4)=elses(4)+1; 36 | T = -(D - R)^(1.0/3.0); 37 | end 38 | Rd = S + T; 39 | 40 | if (Rd < 0) 41 | Rd = sqrt(-1.0 / (3 * mKappa1)); 42 | % /*fprintf (stderr, "\nWarning: undistorted image point to distorted image point mapping limited by\n"); 43 | % fprintf (stderr, " maximum barrel distortion radius of %lf\n", Rd); 44 | % fprintf (stderr, " (Xu = %lf, Yu = %lf) -> (Xd = %lf, Yd = %lf)\n\n", Xu, Yu, Xu * Rd / Ru, Yu * Rd / Ru);*/ 45 | end 46 | else 47 | % elses(2)=elses(2)+1; 48 | % /* three real roots */ 49 | D = sqrt(-D); 50 | S = ( sqrt(R*R + D*D))^(1.0/3.0 ); 51 | T = atan2(D, R) / 3; 52 | sinT = sin(T); 53 | cosT = cos(T); 54 | 55 | % /* the larger positive root is 2*S*cos(T) */ 56 | % /* the smaller positive root is -S*cos(T) + SQRT(3)*S*sin(T) */ 57 | % /* the negative root is -S*cos(T) - SQRT(3)*S*sin(T) */ 58 | 59 | Rd = -S * cosT + sqrt(3.0) * S * sinT; % /* use the smaller positive root */ 60 | end 61 | 62 | lambda = Rd / Ru; 63 | 64 | Xd = Xu * lambda; 65 | Yd = Yu * lambda; 66 | end 67 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/camera/worldToImage.m: -------------------------------------------------------------------------------- 1 | function [Xi Yi]=worldToImage(Xw,Yw,Zw,mR,mT,mInt,mGeo) 2 | 3 | % if scalar, just up/downscale = orthographic 4 | if length(mR)==1 5 | Xi=Xw/mR; 6 | Yi=Yw/mR; 7 | else 8 | 9 | % /* convert from world coordinates to camera coordinates */ 10 | x=[mR mT]*[Xw;Yw;Zw;1]; 11 | xc = x(1); 12 | yc = x(2); 13 | zc = x(3); 14 | 15 | % /* convert from camera coordinates to undistorted sensor plane coordinates */ 16 | Xu = mInt.mFocal * xc / zc; 17 | Yu = mInt.mFocal * yc / zc; 18 | 19 | % /* convert from undistorted to distorted sensor plane coordinates */ 20 | [Xd Yd]=undistortedToDistortedSensorCoord (Xu, Yu, mInt.mKappa1); 21 | % Xd=Xu; 22 | % Yd=Yu; 23 | 24 | % Rusq=Xu*Xu+Yu*Yu; 25 | % Ru=sqrt(Xu*Xu+Yu*Yu); 26 | % Xd=Xu*(1+mInt.mKappa1*Rusq); 27 | % Yd=Yu*(1+mInt.mKappa1*Rusq); 28 | 29 | 30 | % /* convert from distorted sensor plane coordinates to image coordinates */ 31 | Xi = Xd * mInt.mSx / mGeo.mDpx + mInt.mCx; 32 | Yi = Yd / mGeo.mDpy + mInt.mCy; 33 | end 34 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/classIDToString.m: -------------------------------------------------------------------------------- 1 | function classString = classIDToString(classID) 2 | 3 | labels = getClassLabels; 4 | 5 | if classID<1 || classID>length(labels) 6 | classString='unknown'; 7 | else 8 | classString = char(labels{classID}); 9 | end 10 | 11 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/classStringToID.m: -------------------------------------------------------------------------------- 1 | find(strcmp(labels,'occluder')) -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/cleanRequired.m: -------------------------------------------------------------------------------- 1 | function cl=cleanRequired(seqFolder) 2 | 3 | cl = ~isempty(strfind(seqFolder,'MOT16')) || ~isempty(strfind(seqFolder,'MOT17')); -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/evaluateBenchmark.m: -------------------------------------------------------------------------------- 1 | function metsBenchmark = evaluateBenchmark( allMets, world ) 2 | 3 | 4 | % Aggregate scores from all sequences 5 | MT = 0; PT = 0; ML = 0; FRA = 0; 6 | falsepositives = 0; missed = 0; idswitches = 0; 7 | Fgt = 0; distsum = 0; Ngt = 0; sumg = 0; 8 | Nc = 0; 9 | numGT = 0; numPRED = 0; IDTP = 0; IDFP = 0; IDFN = 0; 10 | 11 | for ind = 1:length(allMets) 12 | if isempty(allMets(ind).m) 13 | fprintf('\n\nResults missing for sequence #%d\n', ind) 14 | continue; 15 | end 16 | numGT = numGT + allMets(ind).IDmeasures.numGT; 17 | numPRED = numPRED + allMets(ind).IDmeasures.numPRED; 18 | IDTP = IDTP + allMets(ind).IDmeasures.IDTP; 19 | IDFN = IDFN + allMets(ind).IDmeasures.IDFN; 20 | IDFP = IDFP + allMets(ind).IDmeasures.IDFP; 21 | 22 | MT = MT + allMets(ind).additionalInfo.MT; 23 | PT = PT + allMets(ind).additionalInfo.PT; 24 | ML = ML + allMets(ind).additionalInfo.ML; 25 | FRA = FRA + allMets(ind).additionalInfo.FRA; 26 | Fgt = Fgt + allMets(ind).additionalInfo.Fgt; 27 | Ngt = Ngt + allMets(ind).additionalInfo.Ngt; 28 | Nc = Nc + sum(allMets(ind).additionalInfo.c); 29 | sumg = sumg + sum(allMets(ind).additionalInfo.g); 30 | falsepositives = falsepositives + sum(allMets(ind).additionalInfo.fp); 31 | missed = missed + sum(allMets(ind).additionalInfo.m); 32 | idswitches = idswitches + sum(allMets(ind).additionalInfo.mme); 33 | dists = allMets(ind).additionalInfo.d; 34 | td = allMets(ind).additionalInfo.td; 35 | distsum = distsum + sum(sum(dists)); 36 | end 37 | 38 | IDPrecision = IDTP / (IDTP + IDFP); 39 | IDRecall = IDTP / (IDTP + IDFN); 40 | IDF1 = 2*IDTP/(numGT + numPRED); 41 | if numPRED==0, IDPrecision = 0; end 42 | IDP = IDPrecision * 100; 43 | IDR = IDRecall * 100; 44 | IDF1 = IDF1 * 100; 45 | 46 | 47 | FAR = falsepositives / Fgt; 48 | MOTP = (1-distsum/Nc) * 100; 49 | if world, MOTP = MOTP / td; end 50 | if isnan(MOTP), MOTP = 0; end 51 | MOTAL=(1-(missed+falsepositives+log10(idswitches+1))/sumg)*100; 52 | MOTA=(1-(missed+falsepositives+idswitches)/sumg)*100; 53 | recall=Nc/sumg*100; 54 | precision=Nc/(falsepositives+Nc)*100; 55 | 56 | metsBenchmark = [IDF1, IDP, IDR, recall, precision, FAR, Ngt, MT, PT, ML, falsepositives, missed, idswitches, FRA, MOTA, MOTP, MOTAL]; 57 | 58 | end 59 | 60 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/evaluateMultiCam.m: -------------------------------------------------------------------------------- 1 | function [ metsMultiCam ] = evaluateMultiCam( gtMat, resMat, threshold, world ) 2 | %EVALUATEMULTICAM Summary of this function goes here 3 | % Detailed explanation goes here 4 | % Prepare data for overall evaluation 5 | gtMatAll = []; 6 | resMatAll = []; 7 | countF = 0; 8 | for k = 1:length(gtMat) 9 | newF = max(max(gtMat{k}(:,1)),max(resMat{k}(:,1))); 10 | if isempty(newF), newF = 0; end 11 | gtMat{k}(:,1) = gtMat{k}(:,1) + countF; 12 | resMat{k}(:,1) = resMat{k}(:,1) + countF; 13 | countF = countF + newF; 14 | gtMatAll = [gtMatAll; gtMat{k}]; 15 | resMatAll = [resMatAll; resMat{k}]; 16 | end 17 | 18 | metsID = IDmeasures(gtMatAll, resMatAll, threshold, world); 19 | metsMultiCam = [metsID.IDF1, metsID.IDP, metsID.IDR]; 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/Contents.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/Contents.m -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/acfTrain.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/acfTrain.m -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfCaltechDetector.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfCaltechDetector.mat -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfCaltechRoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfCaltechRoc.png -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfInriaDetector.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfInriaDetector.mat -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfInriaRoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/models/AcfInriaRoc.png -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/dollar/toolbox/detector/writeDets.m: -------------------------------------------------------------------------------- 1 | function writeDets(bbx,outfile) 2 | % write out Dollar's detections to our format 3 | 4 | F=length(bbx); 5 | 6 | alldets=zeros(0,10); 7 | for t=1:F 8 | ndets=size(bbx{t},1); 9 | dets=[repmat(t,ndets,1) repmat(-1,ndets,1) bbx{t} repmat(-1,ndets,1) repmat(-1,ndets,1) repmat(-1,ndets,1)]; 10 | alldets=[alldets; dets]; 11 | end 12 | dlmwrite(outfile,alldets); 13 | 14 | end 15 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/iniconfig/IniConfig.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/external/motchallenge-devkit/utils/external/iniconfig/IniConfig.m -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/external/iniconfig/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010, Evgeny Prilepin aka Iroln 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 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/getClassLabels.m: -------------------------------------------------------------------------------- 1 | function labels = getClassLabels() 2 | 3 | labels={'ped', ... % 1 4 | 'person_on_vhcl', ... % 2 5 | 'car', ... % 3 6 | 'bicycle', ... % 4 7 | 'mbike', ... % 5 8 | 'non_mot_vhcl', ... % 6 9 | 'static_person', ... % 7 10 | 'distractor', ... % 8 11 | 'occluder', ... % 9 12 | 'occluder_on_grnd', ... %10 13 | 'occluder_full', ... % 11 14 | 'reflection', ... % 12 15 | 'crowd' ... % 13 16 | }; 17 | 18 | 19 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/getImgExt.m: -------------------------------------------------------------------------------- 1 | function imgExt = getImgExt(seqFolder) 2 | % return image extension including the dot 3 | % e.g. '.jpg' 4 | 5 | imgExt = '.jpg'; 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/getROIs.m: -------------------------------------------------------------------------------- 1 | function ROI = getROIs() 2 | 3 | ROI{1} = [214 553;1904 411;1897 1055;216 1051]; 4 | ROI{2} = [35 423;574 413;624 300;1075 284;1150 341;1153 396;1260 393;1610 492;1608 460;1614 446;1771 440;1777 485;1894 483;1894 1048;29 1051]; 5 | ROI{3} = [65 659;926 662;798 592;827 574;1201 573;1500 671;1888 673;1882 1047;68 1044]; 6 | ROI{4} = [1189 1043;1664 1043;1434 240;1267 240]; 7 | ROI{5} = [28 1054;1897 1054;1893 202;410 211;397 313;311 320;104 369;71 449;107 567;27 750]; 8 | ROI{6} = [154 646;957 626;1863 886;1866 1050;40 1059;56 775;103 682]; 9 | ROI{7} = [40 751;40 1049;1862 1050;1862 875;862 817;1004 730;667 710;445 779]; 10 | ROI{8} = [1867 637;1806 1066;53 1047;455 807;457 729;824 531]; -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/getSeqInfoFromFile.m: -------------------------------------------------------------------------------- 1 | function [seqName, seqFolder, imgFolder, frameRate, F, imWidth, imHeight, imgExt] ... 2 | = getSeqInfoFromFile(seq, dataDir) 3 | % construct variables with relevant information about the sequence 'seq' 4 | % 5 | 6 | seqName=char(seq); 7 | seqFolder= [dataDir,seqName,filesep]; 8 | 9 | 10 | seqInfoFile = [dataDir,seqName,filesep,'seqinfo.ini']; 11 | ini = IniConfig(); 12 | ini.ReadFile(seqInfoFile); 13 | 14 | imgFolder = ini.GetValues('Sequence','imDir'); 15 | frameRate = ini.GetValues('Sequence','frameRate'); 16 | F=ini.GetValues('Sequence','seqLength'); 17 | imWidth=ini.GetValues('Sequence','imWidth'); 18 | imHeight=ini.GetValues('Sequence','imHeight'); 19 | imgExt = ini.GetValues('Sequence','imExt'); 20 | 21 | end 22 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/ismember_mex.c: -------------------------------------------------------------------------------- 1 | /* 2 | *Expects two sorted arrays !!! 3 | * 4 | *Example: 5 | * >>ismember_mex( [1 3 5], [1 2 3 4 6 7 8] ) 6 | *ans = 7 | 8 | 1 9 | 1 10 | 0 11 | */ 12 | 13 | #include 14 | #include "mex.h" 15 | 16 | #include 17 | 18 | void mexFunction(int nlhs, mxArray *plhs[], 19 | int nrhs, const mxArray *prhs[]) 20 | { 21 | double *in1, *in2, *locb; 22 | mxLogical *out; 23 | int N,M; 24 | 25 | in1 = mxGetPr(prhs[0]); 26 | in2 = mxGetPr(prhs[1]); 27 | 28 | N = (int)mxGetNumberOfElements(prhs[0]); 29 | M = (int)mxGetNumberOfElements(prhs[1]); 30 | 31 | plhs[0] = mxCreateLogicalMatrix(N, 1); 32 | out = mxGetLogicals(plhs[0]); 33 | plhs[1] = mxCreateDoubleMatrix(N, 1, mxREAL); 34 | locb = mxGetPr(plhs[1]); 35 | int pos = 0; 36 | int i = 0; 37 | while (i < N && pos < M) 38 | { 39 | while (pos < M) 40 | { 41 | if (in1[i] == in2[pos]) 42 | { 43 | out[i] = true; 44 | locb[i] = pos + 1; 45 | pos++; 46 | i++; 47 | break; 48 | } 49 | else if (in1[i] < in2[pos]) 50 | { 51 | out[i] = false; 52 | locb[i] = 0; 53 | i++; 54 | if (i == N) break; 55 | } 56 | else 57 | { 58 | pos++; 59 | } 60 | } 61 | 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/parseSequences2.m: -------------------------------------------------------------------------------- 1 | function allseq = parseSequences2(seqmapFile) 2 | % parse sequence map 3 | % seqmapFile - a file containing the sequence names 4 | % to be processed. First line is ignored. e.g. 5 | % 6 | % -------------- 7 | % name 8 | % TUD-Stadtmitte 9 | % TUD-Campus 10 | % -------------- 11 | % 12 | % returns a cell array with all the sequence names 13 | 14 | 15 | assert(exist(seqmapFile,'file')>0,'seqmap file %s does not exist',seqmapFile); 16 | fid = fopen(seqmapFile); 17 | allseq = textscan(fid,'%s','HeaderLines',1); 18 | fclose(fid); 19 | allseq=allseq{1}'; 20 | 21 | 22 | end 23 | -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/printMetrics.m: -------------------------------------------------------------------------------- 1 | function printMetrics(metrics, metricsInfo, dispHeader,dispMetrics,padChar) 2 | % print metrics 3 | % 4 | % ... 5 | % 6 | % extended version with ID Measures 7 | if length(metrics)==17 8 | printMetricsExt(metrics) 9 | return; 10 | end 11 | 12 | % Detections MODP/MODA metrics 13 | if length(metrics)==9 14 | printMetricsDet(metrics) 15 | return; 16 | end 17 | 18 | % default names 19 | if nargin==1 20 | metricsInfo.names.long = {'Recall','Precision','False Alarm Rate', ... 21 | 'GT Tracks','Mostly Tracked','Partially Tracked','Mostly Lost', ... 22 | 'False Positives', 'False Negatives', 'ID Switches', 'Fragmentations', ... 23 | 'MOTA','MOTP', 'MOTA Log'}; 24 | 25 | metricsInfo.names.short = {'Rcll','Prcn','FAR', ... 26 | 'GT','MT','PT','ML', ... 27 | 'FP', 'FN', 'IDs', 'FM', ... 28 | 'MOTA','MOTP', 'MOTAL'}; 29 | 30 | metricsInfo.widths.long = [6 9 16 9 14 17 11 15 15 11 14 5 5 8]; 31 | metricsInfo.widths.short = [5 5 5 4 4 4 4 6 6 5 5 5 5 5]; 32 | 33 | metricsInfo.format.long = {'.1f','.1f','.2f', ... 34 | 'i','i','i','i', ... 35 | 'i','i','i','i', ... 36 | '.1f','.1f','.1f'}; 37 | 38 | metricsInfo.format.short=metricsInfo.format.long; 39 | end 40 | 41 | namesToDisplay=metricsInfo.names.long; 42 | widthsToDisplay=metricsInfo.widths.long; 43 | formatToDisplay=metricsInfo.format.long; 44 | 45 | namesToDisplay=metricsInfo.names.short; 46 | widthsToDisplay=metricsInfo.widths.short; 47 | formatToDisplay=metricsInfo.format.short; 48 | 49 | if nargin<3, dispHeader=1; end 50 | if nargin<4 51 | dispMetrics=1:length(metrics)-1; 52 | end 53 | if nargin<5 54 | padChar={' ',' ','|',' ',' ',' ','|',' ',' ',' ','| ',' ',' ',' '}; 55 | end 56 | 57 | if dispHeader 58 | for m=dispMetrics 59 | printString=sprintf('fprintf(''%%%is%s'',char(namesToDisplay(m)))',widthsToDisplay(m),char(padChar(m))); 60 | eval(printString) 61 | end 62 | fprintf('\n'); 63 | end 64 | 65 | for m=dispMetrics 66 | printString=sprintf('fprintf(''%%%i%s%s'',metrics(m))',widthsToDisplay(m),char(formatToDisplay(m)),char(padChar(m))); 67 | eval(printString) 68 | end 69 | 70 | % if standard, new line 71 | if nargin<4 72 | fprintf('\n'); 73 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/printMetricsDet.m: -------------------------------------------------------------------------------- 1 | function printMetricsDet(metrics, metricsInfo, dispHeader,dispMetrics,padChar) 2 | % print metrics 3 | % 4 | % ... 5 | % 6 | 7 | % default names 8 | if nargin==1 9 | 10 | metricsInfo.names.long = {'Recall','Precision','False Alarm Rate', ... 11 | 'Ground Truth', 'True Positives', 'False Positives', 'False Negatives', 'MODA','MODP'}; 12 | 13 | metricsInfo.names.short = {'Rcll','Prcn','FAR', ... 14 | 'GT', 'TP', 'FP', 'FN', 'MODA','MODP'}; 15 | 16 | metricsInfo.widths.long = [6 9 16 15 15 15 15 5 5]; 17 | metricsInfo.widths.short = [5 5 5 6 6 6 6 5 5]; 18 | 19 | metricsInfo.format.long = {'.1f','.1f','.2f', ... 20 | 'i','i','i','i', '.1f','.1f'}; 21 | 22 | metricsInfo.format.short=metricsInfo.format.long; 23 | end 24 | 25 | namesToDisplay=metricsInfo.names.long; 26 | widthsToDisplay=metricsInfo.widths.long; 27 | formatToDisplay=metricsInfo.format.long; 28 | 29 | namesToDisplay=metricsInfo.names.short; 30 | widthsToDisplay=metricsInfo.widths.short; 31 | formatToDisplay=metricsInfo.format.short; 32 | 33 | if nargin<3, dispHeader=1; end 34 | if nargin<4 35 | dispMetrics=1:length(metrics); 36 | end 37 | if nargin<5 38 | padChar={' ','|',' ',' ',' ',' ','|',' ',' '}; 39 | end 40 | 41 | if dispHeader 42 | for m=dispMetrics 43 | printString=sprintf('fprintf(''%%%is%s'',char(namesToDisplay(m)))',widthsToDisplay(m),char(padChar(m))); 44 | eval(printString) 45 | end 46 | fprintf('\n'); 47 | end 48 | 49 | for m=dispMetrics 50 | printString=sprintf('fprintf(''%%%i%s%s'',metrics(m))',widthsToDisplay(m),char(formatToDisplay(m)),char(padChar(m))); 51 | eval(printString) 52 | end 53 | 54 | % if standard, new line 55 | if nargin<4 56 | fprintf('\n'); 57 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/printMetricsExt.m: -------------------------------------------------------------------------------- 1 | function printMetricsExt(metrics, metricsInfo, dispHeader,dispMetrics,padChar) 2 | % print metrics 3 | % 4 | % ... 5 | % 6 | 7 | % default names 8 | if nargin==1 9 | metricsInfo.names.long = {'IDF1', 'IDP', 'IDR', 'Recall','Precision','False Alarm Rate', ... 10 | 'GT Tracks','Mostly Tracked','Partially Tracked','Mostly Lost', ... 11 | 'False Positives', 'False Negatives', 'ID Switches', 'Fragmentations', ... 12 | 'MOTA','MOTP', 'MOTA Log'}; 13 | 14 | metricsInfo.names.short = {'IDF1', 'IDP', 'IDR', 'Rcll','Prcn','FAR', ... 15 | 'GT','MT','PT','ML', ... 16 | 'FP', 'FN', 'IDs', 'FM', ... 17 | 'MOTA','MOTP', 'MOTAL'}; 18 | 19 | metricsInfo.widths.long = [6 5 5 6 9 16 9 14 17 11 15 15 11 14 5 5 8]; 20 | metricsInfo.widths.short = [6 5 5 5 5 5 4 4 4 4 6 6 5 5 5 5 5]; 21 | 22 | metricsInfo.format.long = {'.2f','.2f','.2f', ... 23 | '.1f','.1f','.2f', ... 24 | 'i','i','i','i', ... 25 | 'i','i','i','i', ... 26 | '.1f','.1f','.1f'}; 27 | 28 | metricsInfo.format.short=metricsInfo.format.long; 29 | end 30 | 31 | namesToDisplay=metricsInfo.names.long; 32 | widthsToDisplay=metricsInfo.widths.long; 33 | formatToDisplay=metricsInfo.format.long; 34 | 35 | namesToDisplay=metricsInfo.names.short; 36 | widthsToDisplay=metricsInfo.widths.short; 37 | formatToDisplay=metricsInfo.format.short; 38 | 39 | if nargin<3, dispHeader=1; end 40 | if nargin<4 41 | dispMetrics=1:length(metrics); 42 | end 43 | if nargin<5 44 | padChar={' ',' ','|',' ',' ','| ','',' ',' ','|','',' ',' ','| ',' ',' ',' ',' '}; 45 | end 46 | 47 | if dispHeader 48 | for m=dispMetrics 49 | printString=sprintf('fprintf(''%%%is%s'',char(namesToDisplay(m)))',widthsToDisplay(m),char(padChar(m))); 50 | eval(printString) 51 | end 52 | fprintf('\n'); 53 | end 54 | 55 | for m=dispMetrics 56 | printString=sprintf('fprintf(''%%%i%s%s'',metrics(m))',widthsToDisplay(m),char(formatToDisplay(m)),char(padChar(m))); 57 | eval(printString) 58 | end 59 | 60 | % if standard, new line 61 | if nargin<4 62 | fprintf('\n'); 63 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/removeObjsSingleCam.m: -------------------------------------------------------------------------------- 1 | function resMatProc = removeObjsSingleCam(resMat) 2 | 3 | resIDMultiCam = []; 4 | resID1stCam = []; 5 | 6 | % Check whether each ID passes through multiple cameras 7 | for camInd = 1:length(resMat) 8 | resdata = resMat{camInd}; 9 | for objInd = 1:size(resdata, 1) 10 | ID = resdata(objInd, 2); 11 | 12 | while ID > length(resIDMultiCam) 13 | resIDMultiCam = [resIDMultiCam, false]; 14 | end 15 | 16 | while ID > length(resID1stCam) 17 | resID1stCam = [resID1stCam, -1]; 18 | end 19 | 20 | if resID1stCam(ID) < 0 21 | resID1stCam(ID) = camInd; 22 | end 23 | 24 | if ~resIDMultiCam(ID) && resID1stCam(ID) >= 0 && resID1stCam(ID) ~= camInd 25 | resIDMultiCam(ID) = true; 26 | end 27 | end 28 | end 29 | 30 | resMatProc = []; 31 | 32 | % Remove ID(s) that only pass through single camera 33 | for camInd = 1:length(resMat) 34 | resdataProc = []; 35 | resdata = resMat{camInd}; 36 | for objInd = 1:size(resdata, 1) 37 | ID = resdata(objInd, 2); 38 | 39 | if resIDMultiCam(ID) 40 | resdataProc = [resdataProc; resdata(objInd, :)]; 41 | end 42 | end 43 | 44 | if ~isempty(resdataProc) 45 | resMatProc{camInd} = resdataProc; 46 | else 47 | resMatProc{camInd} = resdata; 48 | end 49 | end 50 | 51 | end -------------------------------------------------------------------------------- /src/external/motchallenge-devkit/utils/removeOutliersROI.m: -------------------------------------------------------------------------------- 1 | function resdataProc = removeOutliersROI(resdata, cam, dataset_path,seqmap) 2 | 3 | % Fetch data 4 | if ~exist(fullfile(dataset_path, 'ROIs'),'dir') 5 | fprintf('Downloading ROI images...\n'); 6 | url = 'https://drive.google.com/uc?export=download&id=1aT8rZ2sEdBIKNuDJz1EinsBpgvYobZHN'; 7 | if ~exist(fullfile(dataset_path, 'ROIs'),'dir'), mkdir(fullfile(dataset_path, 'ROIs')); end 8 | filename = fullfile(dataset_path, 'ROIs.zip'); 9 | if exist('websave','builtin') 10 | outfilename = websave(filename,url); % exists from MATLAB 2014b 11 | else 12 | outfilename = urlwrite(url, filename); 13 | end 14 | unzip(outfilename,fullfile(dataset_path, 'ROIs')); 15 | delete(filename); 16 | end 17 | 18 | resdataProc = []; 19 | 20 | if contains(seqmap,'test') 21 | folder = 'test'; 22 | else 23 | folder = 'train'; 24 | end 25 | % Read ROI image 26 | roipath = fullfile(dataset_path, sprintf('ROIs/%s/c%03d/roi.jpg', folder, cam)); 27 | 28 | ROI = imread(roipath); 29 | % ROI = rgb2gray(ROI); 30 | 31 | % Remove outliers outside the ROI 32 | for ind = 1:size(resdata, 1) 33 | flagOutlier = false; 34 | 35 | xmin = round(resdata(ind, 3) + 1); 36 | ymin = round(resdata(ind, 4) + 1); 37 | xmax = round(resdata(ind, 3) + resdata(ind, 5)); 38 | ymax = round(resdata(ind, 4) + resdata(ind, 6)); 39 | % xfoot = floor(resdata(ind, 3) + 0.5 * resdata(ind, 5)); 40 | % yfoot = floor(resdata(ind, 4) + resdata(ind, 6)); 41 | 42 | if xmin > 0 && xmin <= size(ROI, 2) && ymin > 0 && ymin <= size(ROI, 1) 43 | if ROI(ymin, xmin) < 255 44 | flagOutlier = true; 45 | end 46 | end 47 | 48 | if xmin > 0 && xmin <= size(ROI, 2) && ymax > 0 && ymax <= size(ROI, 1) 49 | if ROI(ymax, xmin) < 255 50 | flagOutlier = true; 51 | end 52 | end 53 | 54 | if xmax > 0 && xmax <= size(ROI, 2) && ymin > 0 && ymin <= size(ROI, 1) 55 | if ROI(ymin, xmax) < 255 56 | flagOutlier = true; 57 | end 58 | end 59 | 60 | if xmax > 0 && xmax <= size(ROI, 2) && ymax > 0 && ymax <= size(ROI, 1) 61 | if ROI(ymax, xmax) < 255 62 | flagOutlier = true; 63 | end 64 | end 65 | 66 | % if xfoot > 0 && yfoot > 0 && xfoot <= size(ROI, 2) && yfoot <= size(ROI, 1) 67 | % if ROI(yfoot, xfoot) < 255 68 | % flagOutlier = true; 69 | % end 70 | % end 71 | 72 | if ~flagOutlier 73 | resdataProc = [resdataProc; resdata(ind, :)]; 74 | end 75 | end 76 | 77 | if isempty(resdataProc) 78 | resdataProc = resdata; 79 | end 80 | 81 | end -------------------------------------------------------------------------------- /src/external/nestedSortStruct/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Jake Hughey 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 | -------------------------------------------------------------------------------- /src/external/nestedSortStruct/sortStruct.m: -------------------------------------------------------------------------------- 1 | function [sortedStruct index] = sortStruct(aStruct, fieldName, direction) 2 | % [sortedStruct index] = sortStruct(aStruct, fieldName, direction) 3 | % sortStruct returns a sorted struct array, and can also return an index vector. The 4 | % (one-dimensional) struct array (aStruct) is sorted based on the field specified by the 5 | % string fieldName. The field must a single number or logical, or a char array (usually a 6 | % simple string). 7 | % 8 | % direction is an optional argument to specify whether the struct array should be sorted 9 | % in ascending or descending order. By default, the array will be sorted in ascending 10 | % order. If supplied, direction must equal 1 to sort in ascending order or -1 to sort in 11 | % descending order. 12 | 13 | %% check inputs 14 | if ~isstruct(aStruct) 15 | error('first input supplied is not a struct.') 16 | end % if 17 | 18 | if sum(size(aStruct)>1)>1 % if more than one non-singleton dimension 19 | error('I don''t want to sort your multidimensional struct array.') 20 | end % if 21 | 22 | if ~ischar(fieldName) || ~isfield(aStruct, fieldName) 23 | error('second input is not a valid fieldname.') 24 | end % if 25 | 26 | if nargin < 3 27 | direction = 1; 28 | elseif ~isnumeric(direction) || numel(direction)>1 || ~ismember(direction, [-1 1]) 29 | error('direction must equal 1 for ascending order or -1 for descending order.') 30 | end % if 31 | 32 | %% figure out the field's class, and find the sorted index vector 33 | fieldEntry = aStruct(1).(fieldName); 34 | 35 | if (isnumeric(fieldEntry) || islogical(fieldEntry)) && numel(fieldEntry) == 1 % if the field is a single number 36 | [dummy index] = sort([aStruct.(fieldName)]); 37 | elseif ischar(fieldEntry) % if the field is char 38 | [dummy index] = sort({aStruct.(fieldName)}); 39 | else 40 | error('%s is not an appropriate field by which to sort.', fieldName) 41 | end % if ~isempty 42 | 43 | %% apply the index to the struct array 44 | if direction == 1 % ascending sort 45 | sortedStruct = aStruct(index); 46 | else % descending sort 47 | sortedStruct = aStruct(index(end:-1:1)); 48 | end -------------------------------------------------------------------------------- /src/external/nestedSortStruct/sortStruct2.m: -------------------------------------------------------------------------------- 1 | function [sortedStruct index] = sortStruct2(aStruct, fieldName, direction, check) 2 | % [sortedStruct index] = sortStruct2(aStruct, fieldName, direction) 3 | % sortStruct2 returns a sorted struct array, and can also return an index vector. The 4 | % (one-dimensional) struct array is sorted based on the field specified by the string 5 | % fieldName. The field must a single number or logical, or a char array (usually a simple 6 | % string). 7 | % 8 | % direction is an optional argument to specify whether the struct array should be sorted 9 | % in ascending or descending order. By default, the array will be sorted in ascending 10 | % order. If supplied, direction must equal 1 to sort in ascending order or -1 to sort in 11 | % descending order. 12 | % 13 | % check is an optional argument that should not be used if calling sortStruct2 directly. 14 | % Calls to sortStruct2 by nestedSortStruct2 use check to bypass checking inputs. If check 15 | % equals 1 or is not given, inputs are checked. If check equals 0, inputs are not checked. 16 | 17 | %% check inputs 18 | if nargin < 4 || check 19 | if ~isstruct(aStruct) 20 | error('first input supplied is not a struct.') 21 | end % if 22 | 23 | if sum(size(aStruct)>1)>1 % if more than one non-singleton dimension 24 | error('I don''t want to sort your multidimensional struct array.') 25 | end % if 26 | 27 | if ~ischar(fieldName) || ~isfield(aStruct, fieldName) 28 | error('second input is not a valid fieldname.') 29 | end % if 30 | 31 | if nargin < 3 32 | direction = 1; 33 | elseif ~isnumeric(direction) || numel(direction)>1 || ~ismember(direction, [-1 1]) 34 | error('direction must equal 1 for ascending order or -1 for descending order.') 35 | end % if 36 | end % if check 37 | 38 | %% figure out the field's class, and find the sorted index vector 39 | fieldEntry = aStruct(1).(fieldName); 40 | 41 | if (isnumeric(fieldEntry) || islogical(fieldEntry)) && numel(fieldEntry) == 1 % if the field is a single number 42 | [dummy index] = sort([aStruct.(fieldName)]); 43 | elseif ischar(fieldEntry) % if the field is char 44 | [dummy index] = sort({aStruct.(fieldName)}); 45 | else 46 | error('%s is not an appropriate field by which to sort.', fieldName) 47 | end % if ~isempty 48 | 49 | %% apply the index to the struct array 50 | if direction == 1 % ascending sort 51 | sortedStruct = aStruct(index); 52 | else % descending sort 53 | sortedStruct = aStruct(index(end:-1:1)); 54 | end -------------------------------------------------------------------------------- /src/external/tSNE/tsne_d.m: -------------------------------------------------------------------------------- 1 | function ydata = tsne_d(D, labels, no_dims, perplexity) 2 | %TSNE_D Performs symmetric t-SNE on the pairwise Euclidean distance matrix D 3 | % 4 | % mappedX = tsne_d(D, labels, no_dims, perplexity) 5 | % mappedX = tsne_d(D, labels, initial_solution, perplexity) 6 | % 7 | % The function performs symmetric t-SNE on the NxN pairwise Euclidean 8 | % distance matrix D to construct an embedding with no_dims dimensions 9 | % (default = 2). An initial solution obtained from an other dimensionality 10 | % reduction technique may be specified in initial_solution. 11 | % The perplexity of the Gaussian kernel that is employed can be specified 12 | % through perplexity (default = 30). The labels of the data are not used 13 | % by t-SNE itself, however, they are used to color intermediate plots. 14 | % Please provide an empty labels matrix [] if you don't want to plot 15 | % results during the optimization. 16 | % The data embedding is returned in mappedX. 17 | % 18 | % 19 | % (C) Laurens van der Maaten, 2010 20 | % University of California, San Diego 21 | 22 | 23 | if ~exist('labels', 'var') 24 | labels = []; 25 | end 26 | if ~exist('no_dims', 'var') || isempty(no_dims) 27 | no_dims = 2; 28 | end 29 | if ~exist('perplexity', 'var') || isempty(perplexity) 30 | perplexity = 30; 31 | end 32 | 33 | % First check whether we already have an initial solution 34 | if numel(no_dims) > 1 35 | initial_solution = true; 36 | ydata = no_dims; 37 | no_dims = size(ydata, 2); 38 | else 39 | initial_solution = false; 40 | end 41 | 42 | % Compute joint probabilities 43 | D = D / max(D(:)); % normalize distances 44 | P = d2p(D .^ 2, perplexity, 1e-5); % compute affinities using fixed perplexity 45 | 46 | % Run t-SNE 47 | if initial_solution 48 | ydata = tsne_p(P, labels, ydata); 49 | else 50 | ydata = tsne_p(P, labels, no_dims); 51 | end 52 | -------------------------------------------------------------------------------- /src/hyper_score/GT_L1_processing.m: -------------------------------------------------------------------------------- 1 | function [edge_weight,spatialGroup_max] = GT_L1_processing(opts, originalGTs, startFrame, endFrame, spatialGroup_max,use_spaGrp) 2 | % CREATETRACKLETS This function creates short tracks composed of several detections. 3 | % In the first stage our method groups detections into space-time groups. 4 | % In the second stage a Binary Integer Program is solved for every space-time 5 | % group. 6 | 7 | %% DIVIDE DETECTIONS IN SPATIAL GROUPS 8 | % Initialize variables 9 | params = opts.tracklets; 10 | totalLabels = 0; currentInterval = 0; 11 | 12 | % Find detections for the current frame interval 13 | currentGTsIDX = intervalSearch(originalGTs(:,1), startFrame, endFrame); 14 | edge_weight = []; 15 | 16 | % Skip if no more than 1 detection are present in the scene 17 | if isempty(currentGTsIDX) 18 | return; 19 | end 20 | 21 | assert(length(currentGTsIDX) == size(originalGTs,1),'miss in GTs') 22 | 23 | 24 | 25 | 26 | % add bbox position jitter before extracting center & speed 27 | bboxs = originalGTs(currentGTsIDX,3:6); 28 | edge_weight = bboxOverlapRatio(bboxs,bboxs); 29 | 30 | 31 | spatialGroupIDs = ones(size(currentGTsIDX,1),1); 32 | spatialGroupIDs = spatialGroupIDs+spatialGroup_max; 33 | spatialGroup_max = max(spatialGroupIDs); 34 | 35 | 36 | %% 37 | if opts.visualize 38 | detectionCenters = getBoundingBoxCenters(originalGTs(currentGTsIDX, 3:6)); 39 | trackletsVisualizePart1 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /src/hyper_score/GT_L2_fft.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | 4 | opts=get_opts(); 5 | 6 | opts.tracklets.window_width = 40; 7 | opts.trajectories.window_width = 150; 8 | L2_speed = 'mid'; 9 | % L2_speed = 'head-tail'; 10 | 11 | % opts.visualize = true; 12 | opts.sequence = 7; 13 | opts.experiment_name = '1fps_train_IDE_40'; 14 | 15 | newGTs = cellmat(1,8,0,0,0); 16 | spatialGroupID_max = zeros(1,8); 17 | % Computes single-camera trajectories from tracklets 18 | for iCam = 1:8 19 | sequence_window = opts.sequence_intervals{1}; 20 | start_frame = global2local(opts.start_frames(iCam), sequence_window(1)); 21 | end_frame = global2local(opts.start_frames(iCam), sequence_window(end)); 22 | 23 | filename = sprintf('%s/ground_truth/%s/tracklets%d_trainval.mat',opts.dataset_path,opts.experiment_name,iCam); 24 | load(filename) 25 | pids = [tracklets.id]'; 26 | all_fft_feats = zeros(length(tracklets),1024); 27 | freq_energy=0; 28 | tracklets = fft_tracklet_feat(opts, tracklets); 29 | 30 | [~, ~, startpoint, endpoint, intervals, ~, velocity] = getTrackletFeatures(tracklets); 31 | centerFrame = local2global(opts.start_frames(iCam),round(mean(intervals,2))); 32 | centers = 0.5 * (endpoint + startpoint); 33 | newGTs{iCam} = [ones(size(pids))*iCam,pids,centerFrame,zeros(size(pids,1),1),centers,velocity,zeros(size(pids,1),1),all_fft_feats]; 34 | in_time_range_ids = ismember(centerFrame,opts.sequence_intervals{opts.sequence}); 35 | newGTs{iCam} = newGTs{iCam}(in_time_range_ids,:); 36 | 37 | for i=1:ceil(length(sequence_window)/opts.trajectories.window_width) 38 | % Display loop state 39 | window = (sequence_window(1)+(i-1)*opts.trajectories.window_width): (sequence_window(1)+i*opts.trajectories.window_width-1); 40 | clc; fprintf('Cam: %d - Window %d...%d\n', iCam, window(1),window(end)); 41 | indexs = ismember(newGTs{iCam}(:,3),window); 42 | spatialGroupID = 1+spatialGroupID_max(iCam); 43 | spatialGroupID_max(iCam) = spatialGroupID; 44 | newGTs{iCam}(indexs,4)=spatialGroupID; 45 | end 46 | end 47 | res = []; 48 | for iCam = 1:8 49 | newGT = newGTs{iCam}; 50 | newGT(:,4) = newGT(:,4)+sum(spatialGroupID_max(1:iCam-1)); 51 | if opts.trajectories.window_width == inf 52 | newGT(:,4) = 0; 53 | end 54 | res = [res;newGT]; 55 | % hdf5write(fullfile(opts.dataset_path, 'ground_truth',sprintf('hyperGT_%s_%d.h5',opts.sequence_names{opts.sequence},iCam)), '/hyperGT',newGTs{iCam}'); 56 | end 57 | 58 | 59 | % res(:,4) = 0; 60 | hdf5write(fullfile(opts.dataset_path, 'ground_truth',opts.experiment_name,sprintf('hyperGT_L2_fft_%s_%d.h5',opts.sequence_names{opts.sequence},opts.trajectories.window_width)), '/hyperGT',res'); 61 | -------------------------------------------------------------------------------- /src/hyper_score/GT_L3_motion.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | 4 | opts=get_opts(); 5 | 6 | opts.identities.window_width = 12000; 7 | 8 | % opts.visualize = true; 9 | opts.sequence = 8; 10 | opts.experiment_name = '1fps_train_IDE_40'; 11 | 12 | newGTs = cellmat(1,8,0,0,0); 13 | spatialGroupID_max = zeros(1,8); 14 | % Computes single-camera trajectories from tracklets 15 | for iCam = 1:8 16 | sequence_window = opts.sequence_intervals{1}; 17 | start_frame = global2local(opts.start_frames(iCam), sequence_window(1)); 18 | end_frame = global2local(opts.start_frames(iCam), sequence_window(end)); 19 | 20 | filename = sprintf('%s/ground_truth/%s/tracklets%d_trainval.mat',opts.dataset_path,opts.experiment_name,iCam); 21 | load(filename) 22 | pids = [tracklets.id]'; 23 | feat = reshape([tracklets.feature]',length(tracklets(1).feature),[])'; 24 | 25 | 26 | [~, ~, startpoint, endpoint, intervals, ~, ~] = getTrackletFeatures(tracklets); 27 | [startpoint, ~, ~] = image2world( startpoint, iCam ); 28 | [endpoint, ~, ~] = image2world( endpoint, iCam ); 29 | intervals = local2global(opts.start_frames(iCam),intervals); 30 | velocity = (endpoint-startpoint)./(intervals(:,2)-intervals(:,1)); 31 | centerFrame = round(mean(intervals,2)); 32 | centers = 0.5 * (endpoint + startpoint); 33 | newGTs{iCam} = [ones(size(pids))*iCam,pids,centerFrame,zeros(size(pids,1),1),centers,velocity,zeros(size(pids,1),1),feat]; 34 | in_time_range_ids = ismember(centerFrame,opts.sequence_intervals{opts.sequence}); 35 | newGTs{iCam} = newGTs{iCam}(in_time_range_ids,:); 36 | end 37 | 38 | res = []; 39 | for iCam = 1:8 40 | newGT = newGTs{iCam}; 41 | newGT(:,4) = newGT(:,4)+sum(spatialGroupID_max(1:iCam-1)); 42 | newGT(:,4) = floor(newGT(:,3)/opts.identities.window_width); 43 | if opts.identities.window_width == inf 44 | newGT(:,4) = 0; 45 | end 46 | res = [res;newGT]; 47 | % hdf5write(fullfile(opts.dataset_path, 'ground_truth',sprintf('hyperGT_%s_%d.h5',opts.sequence_names{opts.sequence},iCam)), '/hyperGT',newGTs{iCam}'); 48 | end 49 | 50 | 51 | % res(:,4) = 0; 52 | hdf5write(fullfile(opts.dataset_path, 'ground_truth',opts.experiment_name,sprintf('hyperGT_L3_motion_%s_%d.h5',opts.sequence_names{opts.sequence},opts.identities.window_width)), '/hyperGT',res'); -------------------------------------------------------------------------------- /src/hyper_score/README.md: -------------------------------------------------------------------------------- 1 | # metric learning for temporal locality 2 | 3 | Metric Net Architecture: 4 | - Input: `256-dim` absolute difference between a pair of IDE features. 5 | - Output: `2-dim` softmax classification result. 6 | - Hidden layers: 3x `128-dim` hidden layers. 7 | 8 | Dataset & input: 9 | - Dataset: 40-frame-long tracklet appearance feature (IDE feature). Use the first 40 minute as `train` and the rest 11 minute as `val`. 10 | - Sampling: select IDE feature pair within 11 | - Temporal window. 12 | - Saptial window (camera). 13 | 14 | Use cross-entropy loss for training. Train 30 epochs with `lr=1e-3`, and another 10 epochs with `lr=1e-4`. Use SGD optimizer with `momentum=0.5`. 15 | 16 | L2-norm (L2-norm) distance metric is used in tracklets forming. 17 | 18 | Within-Camera Metric Learning (M2) with settings: 19 | - 75-frame-long temporal window; same camera. 20 | - `weight_decay=5e-4`. 21 | 22 | Cross-Camera Metric Learning (M3) with settings: 23 | - 12000-frame-long temporal window; all 8 cameras. 24 | - `weight_decay=5e-2`. 25 | 26 | 27 | The `IDF-1` results are as follows. 28 | 29 | | | `val` | | `easy` | | `hard` | | 30 | | --- | :---: | :---: | :---: | :---: | :---: | :---: | 31 | | | SCT (%) | MCT (%) | SCT (%) | MCT (%) | SCT (%) | MCT (%) | 32 | | (L2-norm)/M2/M2 | **87.74** | 83.61 | 92.8 | 88.7 | **86.0** | **80.9** | 33 | | (L2-norm)/M2/**M3** | 87.71 | **84.01** | **92.9** | **88.8** | 85.8 | 80.3 | -------------------------------------------------------------------------------- /src/hyper_score/models.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from torch.nn import init 5 | import numpy as np 6 | 7 | 8 | class MetricNet(nn.Module): 9 | def __init__(self, feature_dim=256, num_class=0): 10 | super(MetricNet, self).__init__() 11 | self.num_class = num_class 12 | 13 | if feature_dim == 384 or feature_dim == 512: 14 | layer_dim = 128 15 | elif feature_dim <= 16: 16 | layer_dim = 4 17 | else: 18 | layer_dim = int(feature_dim / 2) 19 | 20 | self.fc1 = nn.Linear(feature_dim, layer_dim) 21 | if layer_dim == 4: 22 | self.fc1.weight = nn.Parameter( 23 | torch.from_numpy(np.array([[-1, -1, 1, 1, -1, -1, 0, 0], [1, 1, -1, -1, 0, 0, -1, -1], 24 | [0, 0, 0, 0, 1, 1, -1, -1], [0, 0, 0, 0, -1, -1, 1, 1]])).float()) 25 | init.constant_(self.fc1.bias, 0) 26 | 27 | self.fc2 = nn.Linear(layer_dim, layer_dim) 28 | self.fc3 = nn.Linear(layer_dim, layer_dim) 29 | self.out_layer = nn.Linear(layer_dim, self.num_class) 30 | init.normal_(self.out_layer.weight, std=0.001) 31 | init.constant_(self.out_layer.bias, 0) 32 | 33 | def forward(self, x): 34 | out = self.fc1(x) 35 | out = F.relu(out) 36 | out = self.fc2(out) 37 | out = F.relu(out) 38 | out = self.fc3(out) 39 | out = F.relu(out) 40 | out = self.out_layer(out) 41 | return out 42 | -------------------------------------------------------------------------------- /src/hyper_score/new_GT_feat.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | opts=get_opts(); 5 | opts.feature_dir = 'gt_features_pcb_basis_fc64_train_1fps'; 6 | opts.tracklets.window_width = 40; 7 | 8 | features=[]; 9 | for iCam = 1:8 10 | tmp = h5read(sprintf('%s/L0-features/%s/features%d.h5',opts.dataset_path,opts.feature_dir,iCam),'/emb')'; 11 | tmp(:,3) = local2global(opts.start_frames(iCam), tmp(:,3)); 12 | pids = unique(tmp(:,2)); 13 | all_pooled_lines = []; 14 | for i = 1:length(pids) 15 | pid = pids(i); 16 | same_pid_lines = tmp(tmp(:,2)==pid,:); 17 | tracklet_grp = floor(same_pid_lines(:,3)/opts.tracklets.window_width); 18 | unique_grp = unique(tracklet_grp); 19 | pooled_lines = zeros(length(unique_grp),384+3); 20 | for j = 1:length(unique_grp) 21 | target_grp = unique_grp(j); 22 | pooled_lines(j,:) = mean(same_pid_lines(tracklet_grp==target_grp,:),1); 23 | end 24 | all_pooled_lines = [all_pooled_lines;pooled_lines]; 25 | end 26 | 27 | features = [features;all_pooled_lines]; 28 | end 29 | 30 | 31 | 32 | hdf5write(sprintf('%s/L0-features/%s/tracklet_features.h5',opts.dataset_path,opts.feature_dir),'/emb',features'); -------------------------------------------------------------------------------- /src/hyper_score/new_GT_feat_aic.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | opts=get_opts_aic(); 5 | opts.feature_dir = 'gt_features_zju_lr001_ensemble'; 6 | opts.tracklets.window_width = 10; 7 | opts.sequence = 1; 8 | 9 | features=[]; 10 | for scene = opts.seqs{opts.sequence} 11 | frame_offset = opts.frame_offset{scene} .* opts.fps; 12 | for iCam = opts.cams_in_scene{scene} 13 | tmp = h5read(sprintf('%s/L0-features/%s/features%d.h5',opts.dataset_path,opts.feature_dir,iCam),'/emb')'; 14 | 15 | tmp(:,3) = local2global(frame_offset(iCam), tmp(:,3)); 16 | pids = unique(tmp(:,2)); 17 | all_pooled_lines = []; 18 | for i = 1:length(pids) 19 | pid = pids(i); 20 | same_pid_lines = tmp(tmp(:,2)==pid,:); 21 | tracklet_grp = floor(same_pid_lines(:,3)/opts.tracklets.window_width); 22 | unique_grp = unique(tracklet_grp); 23 | pooled_lines = zeros(length(unique_grp),3072+3); 24 | for j = 1:length(unique_grp) 25 | target_grp = unique_grp(j); 26 | pooled_lines(j,:) = mean(same_pid_lines(tracklet_grp==target_grp,:),1); 27 | end 28 | all_pooled_lines = [all_pooled_lines;pooled_lines]; 29 | end 30 | 31 | features = [features;all_pooled_lines]; 32 | end 33 | end 34 | features = features'; 35 | 36 | h5create(sprintf('%s/L0-features/%s/tracklet_features.h5',opts.dataset_path,opts.feature_dir),'/emb',size(features)) 37 | h5write(sprintf('%s/L0-features/%s/tracklet_features.h5',opts.dataset_path,opts.feature_dir),'/emb',features); 38 | 39 | -------------------------------------------------------------------------------- /src/hyper_score/regress_AM.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | opts = get_opts(); 4 | all_data = h5read(fullfile(opts.dataset_path,'ground_truth','target_data.h5'),'/emb'); 5 | appear_score = all_data(1,:)'; 6 | % appear_score = (appear_score-0.49)/0.46; 7 | motion_score = all_data(2,:)'; 8 | target = all_data(3,:)'; 9 | X = [ones(size(appear_score)),appear_score,motion_score,appear_score.*motion_score,appear_score.^2,motion_score.^2]; 10 | % X = [ones(size(appear_score)),appear_score,appear_score.^2]; 11 | b = regress(2*target-1,X) 12 | y=X*b; 13 | figure() 14 | subplot(1,2,1) 15 | title('softmax: 2*A-1') 16 | miss1=sum(abs((appear_score-0.49)/0.46-2*target+1)>1) 17 | histogram((appear_score-0.49)/0.46-2*target+1) 18 | subplot(1,2,2) 19 | title('2nd order A/M') 20 | miss2=sum(abs(y-2*target+1)>1) 21 | histogram(y-2*target+1) -------------------------------------------------------------------------------- /src/hyper_score/sampler.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import numpy as np 4 | import torch 5 | from torch.utils.data.sampler import Sampler 6 | 7 | 8 | class HyperScoreSampler(Sampler): 9 | def __init__(self, data_source, num_instances=1): 10 | self.data_source = data_source 11 | self.num_instances = num_instances 12 | self.index_pool_dic = data_source.index_pool_dic 13 | self.pid_pool_dic = data_source.pid_pool_dic 14 | self.spaGrpID_length = data_source.num_spatialGroup 15 | self.spaGrpID = data_source.min_groupID 16 | 17 | def __len__(self): 18 | return len(self.data_source) 19 | 20 | def __iter__(self): 21 | ret = [] 22 | t_s = [] 23 | for pid in np.unique(self.pid_pool_dic[self.spaGrpID]): 24 | if pid == -1: 25 | continue 26 | t = np.array(self.index_pool_dic[self.spaGrpID][pid]) 27 | if len(t) >= self.num_instances: 28 | t = np.random.choice(t, size=self.num_instances, replace=False).tolist() 29 | else: 30 | t = t.tolist() 31 | # t = np.random.choice(t, size=self.num_instances, replace=True).tolist() 32 | t_s += t 33 | self.spaGrpID += 1 34 | if self.spaGrpID == self.spaGrpID_length + 1: 35 | self.spaGrpID = self.data_source.min_groupID 36 | ret.extend(t_s) 37 | ret = np.unique(ret) 38 | return iter(ret) 39 | -------------------------------------------------------------------------------- /src/hyper_score/train_L2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | task(){ 4 | CUDA_VISIBLE_DEVICES=4 python main.py --train --window "$1" --triplet; 5 | } 6 | 7 | 8 | for thing in 75 150 300 600 1200 2400 4800 9600 19200 'Inf'; do 9 | task "$thing" & 10 | done 11 | -------------------------------------------------------------------------------- /src/hyper_score/train_L3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | task(){ 4 | CUDA_VISIBLE_DEVICES=5 python main.py --train --window "$1" -L L3 --triplet; 5 | } 6 | 7 | 8 | for thing in 75 150 300 600 1200 2400 4800 9600 19200 'Inf'; do 9 | task "$thing" & 10 | done 11 | -------------------------------------------------------------------------------- /src/prepare_bbox/gen_det_function.m: -------------------------------------------------------------------------------- 1 | function gen_det_function(opts,iCam) 2 | detection_type='OpenPose'; 3 | 4 | sequence_window = global2local(opts.start_frames(iCam),opts.sequence_intervals{opts.sequence}); 5 | 6 | % Load OpenPose detections for current camera 7 | load(fullfile(opts.dataset_path, 'detections',detection_type, sprintf('camera%d.mat',iCam))); 8 | in_time_range_ids = ismember(detections(:,2),sequence_window); 9 | detections = detections(in_time_range_ids,:); 10 | 11 | poses = detections; 12 | % Convert poses to detections 13 | detections = zeros(size(poses,1),6); 14 | for k = 1:size(poses,1) 15 | pose = poses(k,3:end); 16 | bb = pose2bb(pose, opts.render_threshold); 17 | [newbb, ~] = scale_bb(bb,pose,1.25); 18 | detections(k,:) = [iCam, poses(k,2), newbb]; 19 | end 20 | 21 | folder_dir = fullfile(opts.dataset_path, 'ALL_det_bbox', sprintf('det_bbox_%s_%s',detection_type,opts.sequence_names{opts.sequence})); 22 | if exist(folder_dir,'dir') == 0 23 | mkdir(folder_dir); 24 | end 25 | 26 | for i = 1:length(sequence_window) 27 | frame = sequence_window(i); 28 | image = opts.reader.getFrame(iCam,frame); 29 | 30 | det_ids = find(detections(:,2) == frame); 31 | if isempty(det_ids) 32 | continue; 33 | end 34 | det_in_frame = (detections(det_ids,:)); 35 | bboxes = det_in_frame(:,3:end); 36 | for i = 1:size(det_in_frame,1) 37 | if bboxes(i,3) < 20 || bboxes(i,4) < 20 38 | det_image=uint8(zeros(1,1,3)); 39 | else 40 | det_image=get_bb(image, bboxes(i,:)); 41 | end 42 | imwrite(det_image,fullfile(folder_dir,sprintf('c%d_f%06d_%04d.jpg',iCam,frame,i))) 43 | end 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /src/prepare_bbox/gen_gt_function.m: -------------------------------------------------------------------------------- 1 | function gen_gt_function(opts,iCam,fps) 2 | 3 | sequence_window = global2local(opts.start_frames(iCam),opts.sequence_intervals{opts.sequence}); 4 | 5 | ground_truth = load(fullfile(opts.dataset_path,'ground_truth/trainval.mat')); 6 | ground_truth = ground_truth.trainData; 7 | ground_truth = ground_truth(ground_truth(:,1)==iCam & ismember(ground_truth(:,3),sequence_window),:); 8 | 9 | folder_dir = fullfile(opts.dataset_path, 'ALL_gt_bbox',opts.sequence_names{opts.sequence}, sprintf('gt_bbox_%d_fps',fps)); 10 | if exist(folder_dir,'dir') == 0 11 | mkdir(folder_dir); 12 | end 13 | if exist(fullfile(folder_dir,sprintf('camera%d',iCam)),'dir') == 0 14 | mkdir(fullfile(folder_dir,sprintf('camera%d',iCam))); 15 | end 16 | 17 | for i = 1:round(60/fps):length(sequence_window) 18 | frame = sequence_window(i); 19 | image = opts.reader.getFrame(iCam,frame); 20 | gt_ids = find(ground_truth(:,3) == frame); 21 | if isempty(gt_ids) 22 | continue; 23 | end 24 | gt_in_frame = (ground_truth(gt_ids,:)); 25 | left = max(1,gt_in_frame(:,4)); 26 | top = max(1,gt_in_frame(:,5)); 27 | width = min(1920,gt_in_frame(:,6)); 28 | height = min(1080,gt_in_frame(:,7)); 29 | for i = 1:size(gt_in_frame,1) 30 | gt_image = image(top(i):top(i)+height(i),left(i):left(i)+width(i),:); 31 | 32 | imwrite(gt_image,fullfile(folder_dir,sprintf('camera%d/%04d_c%d_f%06d.jpg',iCam,gt_in_frame(i,2),iCam,frame))) 33 | end 34 | end 35 | 36 | 37 | 38 | end 39 | -------------------------------------------------------------------------------- /src/prepare_bbox/get_ALL_det_bbox.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath 2 | clear; 3 | close all; 4 | opts = get_opts(); 5 | opts.sequence=5; 6 | 7 | for iCam = 1:8 8 | gen_det_function(opts,iCam); 9 | end -------------------------------------------------------------------------------- /src/prepare_bbox/get_ALL_gt_bbox.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath 2 | clear; 3 | close all; 4 | opts = get_opts(); 5 | opts.sequence=8; 6 | 7 | % fps at 1/30/60 8 | fps = 1; 9 | for iCam = 1:8 10 | gen_gt_function(opts,iCam,fps); 11 | end -------------------------------------------------------------------------------- /src/test_tracker.m: -------------------------------------------------------------------------------- 1 | function [DukeSCT, DukeMCT] = test_tracker(opts,compute_L1,compute_L2,compute_L3) 2 | if compute_L1 3 | compute_L1_tracklets(opts); 4 | end 5 | if compute_L2 6 | compute_L2_trajectories(opts); 7 | opts.eval_dir = 'L2-trajectories'; 8 | [allMets, metsBenchmark, metsMultiCam] = evaluate(opts); 9 | end 10 | if compute_L3 11 | compute_L3_identities(opts); 12 | opts.eval_dir = 'L3-identities'; 13 | [allMets, metsBenchmark, metsMultiCam] = evaluate(opts); 14 | end 15 | DukeSCT = metsBenchmark(1:3); 16 | DukeMCT = metsMultiCam; 17 | end 18 | -------------------------------------------------------------------------------- /src/util/create_experiment_dir.m: -------------------------------------------------------------------------------- 1 | function create_experiment_dir(opts) 2 | warning off; 3 | mkdir([opts.experiment_root, filesep, opts.experiment_name]); 4 | mkdir([opts.experiment_root, filesep, opts.experiment_name, filesep, 'L0-features']); 5 | mkdir([opts.experiment_root, filesep, opts.experiment_name, filesep, 'L1-tracklets']); 6 | mkdir([opts.experiment_root, filesep, opts.experiment_name, filesep, 'L2-trajectories']); 7 | mkdir([opts.experiment_root, filesep, opts.experiment_name, filesep, 'L3-identities']); 8 | -------------------------------------------------------------------------------- /src/util/feetPosition.m: -------------------------------------------------------------------------------- 1 | function [ feet ] = feetPosition( boxes ) 2 | %FEETPOSITION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | x = boxes(:,1) + boxes(:,3)/2; 6 | y = boxes(:,2) + boxes(:,4); 7 | feet = [x, y]; 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /src/util/getBoundingBoxCenters.m: -------------------------------------------------------------------------------- 1 | function [ centers ] = getBoundingBoxCenters( boundingBoxes ) 2 | % Returns the centers of the bounding boxes provided in the format: 3 | % left, top, right, botom 4 | 5 | centers = [ boundingBoxes(:,1) + 0.5*boundingBoxes(:,3), boundingBoxes(:,2) + 0.5* boundingBoxes(:,4)]; 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/util/getSpatialGroupIDs.m: -------------------------------------------------------------------------------- 1 | function spatialGroupIDs = getSpatialGroupIDs(useGrouping, currentDetectionsIDX, detectionCenters, params ) 2 | % Perfroms spatial groupping of detections and returns a vector of IDs 3 | 4 | spatialGroupIDs = ones(length(currentDetectionsIDX), 1); 5 | if useGrouping == true 6 | 7 | pairwiseDistances = pdist2(detectionCenters, detectionCenters); 8 | agglomeration = linkage(pairwiseDistances); 9 | numSpatialGroups = round(params.cluster_coeff * length(currentDetectionsIDX) / params.window_width); 10 | numSpatialGroups = max(numSpatialGroups, 1); 11 | 12 | while true 13 | 14 | spatialGroupIDs = cluster(agglomeration, 'maxclust', numSpatialGroups); 15 | uid = unique(spatialGroupIDs); 16 | freq = [histc(spatialGroupIDs(:),uid)]; 17 | 18 | largestGroupSize = max(freq); 19 | % The BIP solver might run out of memory for large graphs 20 | if largestGroupSize <= 150 21 | return 22 | end 23 | 24 | numSpatialGroups = numSpatialGroups + 1; 25 | 26 | end 27 | 28 | end 29 | 30 | end 31 | 32 | -------------------------------------------------------------------------------- /src/util/get_bb.m: -------------------------------------------------------------------------------- 1 | function snapshot = get_bb( img, bb ) 2 | %SHOW_BB Summary of this function goes here 3 | % Detailed explanation goes here 4 | bb = round(bb); 5 | snapshot = img(max(1,bb(2)):min(1080,bb(2)+bb(4)),max(1,bb(1)):min(1920,bb(1)+bb(3)),:); 6 | 7 | end 8 | 9 | -------------------------------------------------------------------------------- /src/util/identities2mat.m: -------------------------------------------------------------------------------- 1 | function data = identities2mat( identities ) 2 | 3 | data = zeros(0,8); 4 | 5 | for i = 1:length(identities) 6 | 7 | identity = identities(i); 8 | 9 | for k = 1:length(identity.trajectories) 10 | 11 | newdata = identity.trajectories(k).data; 12 | newdata(:,2) = i; 13 | cam_data = identity.trajectories(k).camera * ones(size(identity.trajectories(k).data,1),1) ; 14 | data = [data; cam_data, newdata]; 15 | 16 | 17 | end 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /src/util/intervalSearch.m: -------------------------------------------------------------------------------- 1 | function result = intervalSearch( data, first, last ) 2 | %INTERVALSEARCH Returns indices of data elements that are within the range 3 | %[first, last] 4 | result = find((data >= first) & (data <= last)); 5 | 6 | end 7 | 8 | -------------------------------------------------------------------------------- /src/util/pose2bb.m: -------------------------------------------------------------------------------- 1 | function [ bb ] = pose2bb( pose, renderThreshold ) 2 | %POSETOBB Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | % Template pose 6 | ref_pose = [0 0; ... %nose 7 | 0, 23; ... % neck 8 | 28 23; ... % rshoulder 9 | 39 66; ... %relbow 10 | 45 108; ... %rwrist 11 | -28 23; ... % lshoulder 12 | -39 66; ... %lelbow 13 | -45 108; ... %lwrist 14 | 20 106; ... %rhip 15 | 20 169; ... %rknee 16 | 20 231; ... %rankle 17 | -20 106; ... %lhip 18 | -20 169; ... %lknee 19 | -20 231; ... %lankle 20 | 5 -7; ... %reye 21 | 11 -8; ... %rear 22 | -5 -7; ... %leye 23 | -11 -8; ... %lear 24 | ]; 25 | 26 | % Template bounding box 27 | ref_bb = [-50, -15; ...%left top 28 | 50, 240]; % right bottom 29 | 30 | pose = reshape(pose,[3,18])'; 31 | valid = pose(:,1) ~= 0 & pose(:,2) ~=0 & pose(:,3) >= renderThreshold; 32 | 33 | if sum(valid) < 2 34 | bb = [0 0 0 0]; 35 | return; 36 | end 37 | 38 | points_det = pose(valid,[1 2]); 39 | points_reference = ref_pose(valid,:); 40 | 41 | % 1a) Compute minimum enclosing rectangle 42 | 43 | base_left = min(points_det(:,1)); 44 | base_top = min(points_det(:,2)); 45 | base_right = max(points_det(:,1)); 46 | base_bottom = max(points_det(:,2)); 47 | 48 | % 1b) Fit pose to template 49 | 50 | % Find transformation parameters 51 | M = size(points_det,1); 52 | B = points_det(:); 53 | A = [points_reference(:,1) zeros(M,1) ones(M,1) zeros(M,1); ... 54 | zeros(M,1) points_reference(:,2) zeros(M,1) ones(M,1)]; 55 | 56 | params = A \ B; 57 | M = 2; 58 | A2 = [ref_bb(:,1) zeros(M,1) ones(M,1) zeros(M,1); ... 59 | zeros(M,1) ref_bb(:,2) zeros(M,1) ones(M,1)]; 60 | 61 | % Visualize 62 | % C = A*params; 63 | % figure(2); 64 | % clf('reset'); 65 | % scatter(B(1:end/2),-B(end/2+1:end),'b'); axis equal; hold on 66 | % scatter(C(1:end/2),-C(end/2+1:end),'r+'); axis equal; hold on 67 | result = A2 * params; 68 | 69 | fit_left = min(result([1,2])); 70 | fit_top = min(result([3,4])); 71 | fit_right = max(result([1,2])); 72 | fit_bottom = max(result([3,4])); 73 | 74 | % 2. Fuse bounding boxes 75 | left = min(base_left,fit_left); 76 | top = min(base_top,fit_top); 77 | right = max(base_right,fit_right); 78 | bottom = max(base_bottom,fit_bottom); 79 | 80 | left = left*1920; 81 | top = top*1080; 82 | right = right*1920; 83 | bottom = bottom*1080; 84 | 85 | height = bottom - top + 1; 86 | width = right - left + 1; 87 | 88 | bb = [left, top, width, height]; 89 | 90 | % sanity check for bb size 91 | if sum(bb<0) 92 | bb = [0 0 0 0]; 93 | end 94 | 95 | end 96 | -------------------------------------------------------------------------------- /src/util/scale_bb.m: -------------------------------------------------------------------------------- 1 | function [ newbb, newpose ] = scale_bb( bb, pose, scalingFactor ) 2 | % Scales bounding box by scaling factor 3 | 4 | newbb([1,2]) = bb([1,2]) - 0.5*(scalingFactor-1) * bb([3,4]); 5 | newbb([3,4]) = bb([3,4]) * scalingFactor; 6 | 7 | % X, Y, strength 8 | newpose = reshape(pose,3,18)'; 9 | 10 | % Scale to original bounding box 11 | newpose(:,1) = (newpose(:,1) - bb(1)/1920.0) / (bb(3)/1920.0); 12 | newpose(:,2) = (newpose(:,2) - bb(2)/1080.0) / (bb(4)/1080.0); 13 | 14 | % Scale to stretched bounding box 15 | newpose(:,1) = (newpose(:,1) + 0.5*(scalingFactor-1))/scalingFactor; 16 | newpose(:,2) = (newpose(:,2) + 0.5*(scalingFactor-1))/scalingFactor; 17 | 18 | % Return in the original format 19 | newpose(newpose(:,3)==0,[1 2]) = 0; 20 | newpose = newpose'; 21 | newpose = newpose(:); 22 | newpose = newpose'; 23 | -------------------------------------------------------------------------------- /src/visualization/data/duke_easy_scores.txt: -------------------------------------------------------------------------------- 1 | 67.0376 48.4422 83.5614 60.3825 2 | 67.0376 48.4422 83.5614 60.3825 3 | 68.8362 49.7086 88.159 63.6622 4 | 72.6222 48.2122 88.0984 58.4864 5 | 68.3192 53.4863 87.6443 68.6157 6 | 71.1437 60.5927 87.2972 74.3506 7 | 71.1437 60.5927 87.2972 74.3506 8 | 73.8175 69.0928 82.8243 77.5231 9 | 84.4251 66.4456 89.8731 70.7334 10 | 82.6388 74.3368 91.1633 82.0049 11 | 84.3691 79.8149 91.6953 86.7457 12 | 13 | -------------------------------------------------------------------------------- /src/visualization/data/duke_hard_scores.txt: -------------------------------------------------------------------------------- 1 | 59.566 39.211 81.2117 53.4598 2 | 59.566 39.211 81.2117 53.4598 3 | 60.5851 40.2177 80.4166 53.3823 4 | 60.5851 40.2177 80.4166 53.3823 5 | 58.2769 43.8663 73.9304 55.649 6 | 58.2769 43.8663 73.9304 55.649 7 | 63.2482 42.5523 81.3663 54.7417 8 | 69.4285 56.8633 80.6971 66.0925 9 | 78.1022 56.5077 85.3221 61.7313 10 | 78.6354 59.3885 90.1264 68.067 11 | 75.8566 62.4472 87.4329 71.9771 12 | 13 | -------------------------------------------------------------------------------- /src/visualization/data/map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hou-yz/DeepCC-local/d280f0aa0cee60fe30da07e5a62b55ec344da4c2/src/visualization/data/map.jpg -------------------------------------------------------------------------------- /src/visualization/find_consecute_iCam_part2.m: -------------------------------------------------------------------------------- 1 | 2 | iCam_i_reintro_time_avgs = zeros(1,8); 3 | iCam_i_reintro_time_95ths = zeros(1,8); 4 | iCam_i_reintro_time_995ths = zeros(1,8); 5 | iCam_i_reintro_time_hists = cell(8,1); 6 | iCam_i_reintro_times = cellmat(8,1,0,0,0); 7 | all_reintro_times = []; 8 | same_track_6000 = zeros(8); 9 | same_track_12000 = zeros(8); 10 | for i=1:8 11 | for j=1:8 12 | same_track_6000(i,j) = sum(same_track_intervals{i,j}<6000); 13 | same_track_12000(i,j) = sum(same_track_intervals{i,j}<12000); 14 | if isempty(iCam_i_reintro_time_lists{i,j}) 15 | continue 16 | end 17 | iCam_i_reintro_times{i} = [iCam_i_reintro_times{i},iCam_i_reintro_time_lists{i,j}]; 18 | all_reintro_times = [all_reintro_times,iCam_i_reintro_time_lists{i,j}]; 19 | end 20 | iCam_i_reintro_time_avgs(i) = mean(iCam_i_reintro_times{i}); 21 | 22 | iCam_i_reintro_time_95ths(i) = prctile(iCam_i_reintro_times{i},95); 23 | iCam_i_reintro_time_995ths(i) = prctile(iCam_i_reintro_times{i},99.5); 24 | % figure() 25 | % iCam_i_reintro_time_hists{i} = histogram(iCam_i_reintro_times{i}); 26 | end 27 | figure() 28 | % set(gca, 'XScale', 'log') 29 | yyaxis left 30 | reintro_freq = histogram(all_reintro_times,1000); 31 | yyaxis right 32 | cum_reintro_freq = cdfplot(all_reintro_times); 33 | 34 | 35 | sum_outage_icams = sum(consecutive_cam_matrix,2); 36 | compare_mat = repmat(diag(same_track_12000)*0.1,1,8); 37 | compare_mat = max(compare_mat,compare_mat'); 38 | consider_icam_matrix = same_track_12000>compare_mat; 39 | consider_icam_matrix = consider_icam_matrix-diag(diag(consider_icam_matrix)); 40 | disp(consider_icam_matrix) 41 | % fprintf('%.0f,',iCam_i_reintro_time_95ths) 42 | % fprintf('%.0f,',iCam_i_reintro_time_995ths) -------------------------------------------------------------------------------- /src/visualization/render_state_of_the_art.m: -------------------------------------------------------------------------------- 1 | % Shows state of the art on ID precision/recall plot 2 | % Scores need to be updated from MOTChallenge. To be used as reference. 3 | 4 | opts = get_opts(); 5 | 6 | close all; 7 | difficulty = {'Hard', 'Easy'}; 8 | scenario = {'Multi', 'Single'}; 9 | 10 | % Create folder 11 | folder = 'state-of-the-art'; 12 | mkdir([opts.experiment_root, filesep, opts.experiment_name, filesep, folder]); 13 | 14 | % Difficulty 15 | for ii = 1:2 16 | data = dlmread(sprintf('src/visualization/data/duke_%s_scores.txt',lower(difficulty{ii}))); 17 | 18 | % Scenario 19 | for jj = 1:2 20 | P = data(:,jj*2-1)/100; 21 | R = data(:,jj*2)/100; 22 | figure; 23 | clf('reset'); 24 | axis equal; 25 | axis([0 1 0 1]); 26 | % F-score isocontours 27 | for f = 0.2:0.1:0.9 28 | p = linspace(0.1,1,1000); 29 | r = (p*f)./(2*p-f); 30 | r(r<0) = 1.01; 31 | r(r>1) = 1.01; 32 | hold on; plot(p,r,'g-'); 33 | end 34 | 35 | hold on; scatter(P,R,'filled'); 36 | xlabel('ID Precision'); 37 | ylabel('ID Recall'); 38 | title(sprintf('DukeMTMC %s-Camera %s',scenario{jj},difficulty{ii})); 39 | set(gca, 'Color', 'none'); 40 | figure_name = sprintf('duke_%s_%s.pdf',scenario{jj},difficulty{ii}); 41 | figure_name = fullfile(opts.experiment_root, opts.experiment_name, folder, figure_name); 42 | export_fig('-transparent', figure_name); 43 | 44 | end 45 | end -------------------------------------------------------------------------------- /src/visualization/show_bbox.m: -------------------------------------------------------------------------------- 1 | function fig1=show_bbox(opts,iCam,frame,bbox) 2 | if opts.dataset ~= 2 3 | img = opts.reader.getFrame(iCam,frame); 4 | else 5 | img = opts.reader.getFrame(opts.current_scene, iCam,frame); 6 | end 7 | fig1 = img(bbox(2):min(bbox(2)+bbox(4),size(img,1)),bbox(1):min(bbox(1)+bbox(3),size(img,2)),:); 8 | % imshow(fig1) 9 | end 10 | 11 | -------------------------------------------------------------------------------- /src/visualization/show_detections.m: -------------------------------------------------------------------------------- 1 | % Demo visualizing OpenPose detections 2 | opts = get_opts(); 3 | 4 | frame = 245000; 5 | cam = 2; 6 | 7 | load(fullfile(opts.dataset_path, 'detections', 'OpenPose', sprintf('camera%d.mat',cam))); 8 | 9 | %% 10 | 11 | img = opts.reader.getFrame(cam, frame); 12 | poses = detections(detections(:,1) == cam & detections(:,2) == frame,3:end); 13 | 14 | img = renderPoses(img, poses); 15 | % Transform poses into boxes 16 | bboxes = []; 17 | for i = 1:size(poses,1) 18 | bboxes(i,:) = pose2bb(poses(i,:), opts.render_threshold); 19 | bboxes(i,:) = scale_bb(bboxes(i,:), poses(i,:), 1.25); 20 | end 21 | img = insertObjectAnnotation(img,'rectangle',bboxes, ones(size(bboxes,1),1)); 22 | figure, imshow(img); 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/visualization/view_consecutive_score.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | opts = get_opts(); 4 | all_data = h5read(fullfile(opts.dataset_path,'ground_truth','1fps_train_IDE_40','hyperGT_L2_train_75.h5'),'/hyperGT'); 5 | % iCam, pid, centerFrame, SpaGrpID, pos*2, v*2, 0, 256-dim feat 6 | considered_line = all_data(2,:)~=-1; 7 | all_pids = all_data(2,considered_line)'; 8 | all_cams = all_data(1,considered_line)'; 9 | spagrp_ids = all_data(4,considered_line)'; 10 | all_feats = all_data(10:end,considered_line)'; 11 | 12 | interest_pid = 71; 13 | pos_dists = []; 14 | neg_dists = []; 15 | cams = ones(10,1)*all_cams(all_pids==interest_pid)'; 16 | feats = all_feats(all_pids==interest_pid,:)'; 17 | 18 | feats = mat2gray(feats); 19 | feats = feats(mean(feats,2)>0.1,:); 20 | cams = mat2gray(cams).*ones(1,1,3); 21 | feats = feats.*reshape([51,204,51],1,1,3)/255; 22 | feats = imadjust(feats,[],[],1.5); 23 | img = [cams;feats]; 24 | x=3;y=10; 25 | new_img = zeros(size(img,1),75*y,3); 26 | for i=1:75 27 | new_img(:,(i-1)*y+1:i*y,:) = repmat(img(:,i,:),1,y,1); 28 | end 29 | img = new_img; 30 | new_img = zeros(size(img,1)*x,75*y,3); 31 | for i=1:size(img,1) 32 | new_img((i-1)*x+1:i*x,:,:) = repmat(img(i,:,:),x,1,1); 33 | end 34 | 35 | imwrite(new_img,'temporal locality.png') 36 | imshow(new_img) 37 | 38 | -------------------------------------------------------------------------------- /src/visualization/view_tsne.m: -------------------------------------------------------------------------------- 1 | function view_tsne(distance,labels) 2 | figure(6) 3 | clf('reset'); 4 | hold on 5 | %% Perform tSNE 6 | uni_labels = unique(labels); 7 | no_dims = 2; 8 | perplexity = 30; 9 | yd = tsne_d(distance, [], no_dims, perplexity); 10 | %% Plot results 11 | for i = 1:length(uni_labels) 12 | label = uni_labels(i); 13 | scatter(yd(labels==label, 1), yd(labels==label, 2)) 14 | end 15 | hold off 16 | title('tSNE embedding') 17 | end 18 | 19 | -------------------------------------------------------------------------------- /src/visualization/view_tsne_2.m: -------------------------------------------------------------------------------- 1 | 2 | figure(5) 3 | set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.1, 1, 0.7]); 4 | clf('reset'); 5 | 6 | uni_labels = unique(in_window_pids); 7 | no_dims = 2; 8 | if mct 9 | perplexity = 8; 10 | uni_labels = uni_labels(num_traj_per_pid>1); 11 | else 12 | perplexity = 18; 13 | end 14 | 15 | map_size=100; 16 | 17 | %% Perform tSNE 18 | % yd = tsne_d(exp(-distanceG), [], no_dims, perplexity); 19 | % yd(:,1) = yd(:,1)*map_size/(mean(yd(:,1).^2)^0.5); 20 | % yd(:,2) = yd(:,2)*map_size/(mean(yd(:,2).^2)^0.5); 21 | % ydG=yd; 22 | 23 | yd=ydG; 24 | % axis([-map_size(2),map_size(2),-map_size(1),map_size(1)]*2) 25 | %% Plot results 26 | subplot(1,2,1) 27 | 28 | view_tsne_2_function 29 | 30 | title(['tSNE embedding',newline,'traditional metric learning']) 31 | 32 | %% Perform tSNE 33 | % yd = tsne_d(exp(-distanceL), [], no_dims, perplexity); 34 | % yd(:,1) = yd(:,1)*map_size/(mean(yd(:,1).^2)^0.5); 35 | % yd(:,2) = yd(:,2)*map_size/(mean(yd(:,2).^2)^0.5); 36 | % ydL=yd; 37 | 38 | yd=ydL; 39 | % axis([-map_size(2),map_size(2),-map_size(1),map_size(1)]*2) 40 | %% Plot results 41 | subplot(1,2,2) 42 | 43 | view_tsne_2_function 44 | 45 | title(['tSNE embedding',newline,'TLML']) 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/visualization/view_tsne_2_function.m: -------------------------------------------------------------------------------- 1 | 2 | colors = distinguishable_colors(1000); 3 | % colors(1,:) = [237,177,32]/255;%yellow[126,47,142]/255;%purple 4 | colors([2,4,5],:) = colors([3,5,4],:); 5 | colors(3,:) = [217,83,25]/255;%orange colors(3,:);% bright green 6 | % colors(3,:) = [126,47,142]/255;%purple[237,177,32]/255;%yellow 7 | % colors(4,:) = colors(5,:);% bright pink 8 | % colors(5,:) = [0,114,189]/255;%blue 9 | % colors(6,:) = [217,83,25]/255;%orange 10 | % colors(9,:) = [116,170,43]/255;%green 11 | % [2,3,4,5] 12 | % 1:length(uni_labels) 13 | hold on 14 | for i = 1:length(uni_labels) 15 | label = uni_labels(i); 16 | target_yd = yd(in_window_pids==label,:); 17 | scatter(target_yd(:, 1), target_yd(:, 2),36,colors(i,:),'filled'); 18 | % if num_traj_per_pid(i)>1 19 | % scatter(target_yd(:, 1), target_yd(:, 2),60,colors(i,:)); 20 | % else 21 | % scatter(target_yd(:, 1), target_yd(:, 2),36,colors(i,:),'filled'); 22 | % end 23 | 24 | if opts.visualize 25 | target_tracklets = in_window_tracklet(in_window_pids==label); 26 | for j = length(target_tracklets):-1:1 27 | tracklet = target_tracklets(j); 28 | iCam = tracklet.iCam; 29 | frame = tracklet.data(round(end/2),1); 30 | bbox = tracklet.data(round(end/2),3:6); 31 | fig=show_bbox(opts,iCam,frame,bbox); 32 | fig = fig(end:-1:1,:,:); %# vertical flip 33 | fig = imresize(fig,[map_size*2,map_size,]/3); 34 | fig = addborder(fig,3,colors(i,:)*255,'outer'); 35 | 36 | image(target_yd(j,1),target_yd(j,2),fig) 37 | end 38 | end 39 | end 40 | hold off 41 | -------------------------------------------------------------------------------- /test_aic_zju_ensemble.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_aic(); 6 | opts.experiment_name = 'aic_zju_test'; 7 | % opts.detections = 'yolo3'; 8 | % basis setting for DeepCC 9 | opts.tracklets.window_width = 10; 10 | opts.trajectories.window_width = 30; 11 | opts.identities.window_width = [500,4800]; 12 | % correlation threshold setting according to `view_distance_distribution(opts)` 13 | opts.feature_dir = 'det_features_zju_lr001_ensemble_test_ssd'; 14 | opts.tracklets.threshold = 0.65; 15 | opts.trajectories.threshold = 0.65; 16 | opts.identities.threshold = 0.71; 17 | opts.tracklets.diff_p = 0.26; 18 | opts.trajectories.diff_p = 0.26; 19 | opts.identities.diff_p = 0.26; 20 | opts.tracklets.diff_n = 0.26; 21 | opts.trajectories.diff_n = 0.26; 22 | opts.identities.diff_n = 0.26; 23 | 24 | %% lr001 ensemble 25 | % 0.65/0.65/0.73 26 | % s02: 83.9/80.0; s134: 27 | % fix accute + < 80: 75->80 28 | create_experiment_dir(opts); 29 | %% Setup Gurobi 30 | if ~exist('setup_done','var') 31 | setup; 32 | setup_done = true; 33 | end 34 | 35 | %% Run Tracker 36 | % opts.visualize = true; 37 | % 'train_134', 'test_6', 'test_2', 'test_5', 'test_26','test_25','train_34','train_1' 38 | opts.sequence = 6; 39 | 40 | %% Tracklets 41 | % opts.tracklets.spatial_groups = 0; 42 | opts.optimization = 'KL'; 43 | compute_L1_tracklets_aic(opts); 44 | 45 | %% Single-camera trajectories 46 | opts.trajectories.appearance_groups = 1; 47 | compute_L2_trajectories_aic(opts); 48 | opts.eval_dir = 'L2-trajectories'; 49 | % evaluate(opts); 50 | 51 | %% remove waiting cars 52 | removeOverlapping(opts); 53 | opts.eval_dir = 'L2-removeOverlapping'; 54 | % evaluate(opts); 55 | 56 | %% Multi-camera identities 57 | opts.identities.consecutive_icam_matrix = ones(40); 58 | opts.identities.reintro_time_matrix = ones(1,40)*inf; 59 | opts.identities.appearance_groups = 1; 60 | compute_L3_identities_aic(opts); 61 | opts.eval_dir = 'L3-identities'; 62 | % evaluate(opts); 63 | 64 | prepareMOTChallengeSubmission_aic(opts); 65 | 66 | -------------------------------------------------------------------------------- /train_mot_full.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_mot(); 6 | opts.experiment_name = 'mot_full'; 7 | % basis setting for DeepCC 8 | opts.tracklets.window_width = 20; 9 | opts.trajectories.window_width = 80; 10 | opts.trajectories.overlap = 40; 11 | % correlation threshold setting according to `view_distance_distribution(opts)` 12 | opts.tracklets.threshold = 1; 13 | opts.trajectories.threshold = 1; 14 | 15 | opts.tracklets.diff_p = 0.64; 16 | opts.trajectories.diff_p = 0.64; 17 | opts.tracklets.diff_n = 0.64; 18 | opts.trajectories.diff_n = 0.64; 19 | 20 | % alpha 21 | opts.tracklets.alpha = 0; 22 | opts.trajectories.alpha = 1; 23 | 24 | create_experiment_dir(opts); 25 | 26 | %% Setup Gurobi 27 | if ~exist('setup_done','var') 28 | setup; 29 | setup_done = true; 30 | end 31 | 32 | %% Run Tracker 33 | 34 | opts.appear_model_name = 'MOT/og512/model_param_L2_inf.mat'; 35 | % opts.visualize = true; 36 | 37 | % Tracklets 38 | % compute_L1_tracklets_mot(opts); 39 | 40 | % Single-camera trajectories 41 | opts.trajectories.appearance_groups = 1; 42 | opts.trajectories.og_appear_score = false; 43 | compute_L2_trajectories_mot(opts); 44 | evaluate(opts,1); -------------------------------------------------------------------------------- /train_mot_og.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_mot(); 6 | opts.experiment_name = 'mot_og'; 7 | % basis setting for DeepCC 8 | opts.tracklets.window_width = 20; 9 | opts.trajectories.window_width = 80; 10 | opts.trajectories.overlap = 40; 11 | % correlation threshold setting according to `view_distance_distribution(opts)` 12 | opts.tracklets.threshold = 1; 13 | opts.trajectories.threshold = 1; 14 | 15 | opts.tracklets.diff_p = 0.64; 16 | opts.trajectories.diff_p = 0.64; 17 | opts.tracklets.diff_n = 0.64; 18 | opts.trajectories.diff_n = 0.64; 19 | 20 | % alpha 21 | opts.tracklets.alpha = 0; 22 | opts.trajectories.alpha = 1; 23 | 24 | create_experiment_dir(opts); 25 | 26 | %% Setup Gurobi 27 | if ~exist('setup_done','var') 28 | setup; 29 | setup_done = true; 30 | end 31 | 32 | %% Run Tracker 33 | 34 | % opts.visualize = true; 35 | 36 | % Tracklets 37 | compute_L1_tracklets_mot(opts); 38 | 39 | % Single-camera trajectories 40 | opts.trajectories.appearance_groups = 1; 41 | compute_L2_trajectories_mot(opts); 42 | evaluate(opts,1); -------------------------------------------------------------------------------- /val_aic_ensemble.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_aic(); 6 | opts.experiment_name = 'aic_zju_ensemble'; 7 | % basis setting for DeepCC 8 | opts.tracklets.window_width = 10; 9 | opts.trajectories.window_width = 30; 10 | opts.identities.window_width = [500,4800]; 11 | % correlation threshold setting according to `view_distance_distribution(opts)` 12 | opts.feature_dir = 'det_features_zju_lr001_ensemble_trainval_ssd'; 13 | 14 | %% lr001 ensemble 15 | % 0.65/0.71/0.73 16 | % s02: 83.9/80.0; s134: 17 | % fix accute + < 80: 75->80 18 | 19 | create_experiment_dir(opts); 20 | %% Setup Gurobi 21 | if ~exist('setup_done','var') 22 | setup; 23 | setup_done = true; 24 | end 25 | 26 | %% Run Tracker 27 | opts.optimization = 'KL'; 28 | % opts.visualize = true; 29 | % 'train_134', 'test_6', 'test_2', 'test_5', 'test_26','test_25','train_34','train_1' 30 | opts.sequence = 1; 31 | 32 | % %% GRID SEARCH 33 | % thresholds = 1%0.8:-0.03:0.5; 34 | % l2_scts = zeros(length(thresholds),3); 35 | % removed_scts = zeros(length(thresholds),3); 36 | % l3_scts = zeros(length(thresholds),3); 37 | % l3_mcts = zeros(length(thresholds),3); 38 | % for i = 1:length(thresholds) 39 | % thres = thresholds(i); 40 | 41 | opts.tracklets.threshold = 0.65; 42 | opts.trajectories.threshold = 0.65; 43 | opts.identities.threshold = 0.71; 44 | opts.tracklets.diff_p = 0.26; 45 | opts.trajectories.diff_p = 0.26; 46 | opts.identities.diff_p = 0.26; 47 | opts.tracklets.diff_n = 0.26; 48 | opts.trajectories.diff_n = 0.26; 49 | opts.identities.diff_n = 0.26; 50 | 51 | %% Tracklets 52 | opts.tracklets.spatial_groups = 0; 53 | compute_L1_tracklets_aic(opts); 54 | 55 | %% Single-camera trajectories 56 | opts.trajectories.appearance_groups = 1; 57 | compute_L2_trajectories_aic(opts); 58 | opts.eval_dir = 'L2-trajectories'; 59 | [~, metsSCT, ~] = evaluate(opts); 60 | % l2_scts(i,:) = metsSCT(1:3); 61 | 62 | %% remove waiting cars 63 | removeOverlapping(opts); 64 | opts.eval_dir = 'L2-removeOverlapping'; 65 | [~, metsSCT, ~] = evaluate(opts); 66 | % removed_scts(i,:) = metsSCT(1:3); 67 | 68 | %% Multi-camera identities 69 | opts.identities.consecutive_icam_matrix = ones(40); 70 | opts.identities.reintro_time_matrix = ones(1,40)*inf; 71 | opts.identities.appearance_groups = 0; 72 | compute_L3_identities_aic(opts); 73 | opts.eval_dir = 'L3-identities'; 74 | [~, metsSCT, metsMCT] = evaluate(opts); 75 | % l3_scts(i,:) = metsSCT(1:3); 76 | % l3_mcts(i,:) = metsMCT; 77 | % end -------------------------------------------------------------------------------- /val_aic_tc_ssd.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_aic(); 6 | opts.experiment_name = 'aic_tc_ssd'; 7 | opts.sequence = 8; 8 | opts.eval_dir = 'L2-trajectories'; 9 | evaluate(opts); 10 | -------------------------------------------------------------------------------- /val_aic_zju.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts_aic(); 6 | opts.experiment_name = 'aic_zju'; 7 | % opts.detections = 'yolo3'; 8 | % basis setting for DeepCC 9 | opts.tracklets.window_width = 10; 10 | opts.trajectories.window_width = 30; 11 | opts.identities.window_width = [500,4800]; 12 | % correlation threshold setting according to `view_distance_distribution(opts)` 13 | opts.feature_dir = 'det_features_zju_lr001_test_ssd'; 14 | 15 | %% lr001 16 | % 4.5/4.9/5.3 17 | % s02: 81.4/72.6; s134: 81.6/80.9 18 | % 3.9/4.1/5.3 19 | % s02: 59.5/58.5; s134: 82.9/82.2 20 | 21 | % fix acute cam: 72->74 22 | % speed change < 80: 72->74 23 | % fix accute + < 80: 72->77 24 | 25 | create_experiment_dir(opts); 26 | %% Setup Gurobi 27 | if ~exist('setup_done','var') 28 | setup; 29 | setup_done = true; 30 | end 31 | 32 | %% Run Tracker 33 | % opts.visualize = true; 34 | opts.sequence = 3; 35 | 36 | %% GRID SEARCH 37 | thresholds = 1;%5.5:-0.2:3.5; 38 | l2_scts = zeros(length(thresholds),3); 39 | removed_scts = zeros(length(thresholds),3); 40 | l3_scts = zeros(length(thresholds),3); 41 | l3_mcts = zeros(length(thresholds),3); 42 | for i = 1:length(thresholds) 43 | thres = thresholds(i); 44 | 45 | opts.tracklets.threshold = 4.5; 46 | opts.trajectories.threshold = 4.5; 47 | opts.identities.threshold = 4.9; 48 | opts.tracklets.diff_p = 1.82; 49 | opts.trajectories.diff_p = 1.82; 50 | opts.identities.diff_p = 1.82; 51 | opts.tracklets.diff_n = 1.82; 52 | opts.trajectories.diff_n = 1.82; 53 | opts.identities.diff_n = 1.82; 54 | 55 | % alpha 56 | % opts.tracklets.alpha = 1; 57 | % opts.trajectories.alpha = 1; 58 | % opts.identities.alpha = 1; 59 | 60 | %% Tracklets 61 | % opts.tracklets.spatial_groups = 0; 62 | % opts.optimization = 'KL'; 63 | % compute_L1_tracklets_aic(opts); 64 | % 65 | % %% Single-camera trajectories 66 | % opts.trajectories.appearance_groups = 0; 67 | % compute_L2_trajectories_aic(opts); 68 | % opts.eval_dir = 'L2-trajectories'; 69 | % [~, metsSCT, ~] = evaluate(opts); 70 | % l2_scts(i,:) = metsSCT(1:3); 71 | % 72 | % %% remove waiting cars 73 | % removeOverlapping(opts); 74 | % opts.eval_dir = 'L2-removeOverlapping'; 75 | % [~, metsSCT, ~] = evaluate(opts); 76 | % removed_scts(i,:) = metsSCT(1:3); 77 | 78 | %% Multi-camera identities 79 | opts.identities.consecutive_icam_matrix = ones(40); 80 | opts.identities.reintro_time_matrix = ones(1,40)*inf; 81 | opts.identities.appearance_groups = 0; 82 | compute_L3_identities_aic(opts); 83 | opts.eval_dir = 'L3-identities'; 84 | [~, metsSCT, metMCT] = evaluate(opts); 85 | l3_scts(i,:) = metsSCT(1:3); 86 | l3_mcts(i,:) = metMCT; 87 | end -------------------------------------------------------------------------------- /val_duke_L2.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts(); 6 | opts.experiment_name = '1fps_full'; 7 | opts.feature_dir = 'det_features_ide_basis_train_1fps_val'; 8 | % basis setting for DeepCC 9 | opts.tracklets.window_width = 40; 10 | opts.trajectories.window_width = 150; 11 | opts.identities.window_width = 6000; 12 | % correlation threshold setting according to `view_distance_distribution(opts)` 13 | opts.tracklets.threshold = 18.45; 14 | opts.trajectories.threshold = 0;%0.468; 15 | opts.identities.threshold = 0;%0.468; 16 | 17 | opts.tracklets.diff_p = 11; 18 | opts.trajectories.diff_p = 0.1; 19 | opts.identities.diff_p = 0.1; 20 | opts.tracklets.diff_n = 11; 21 | opts.trajectories.diff_n = 0.1; 22 | opts.identities.diff_n = 0.1; 23 | 24 | % alpha 25 | opts.tracklets.alpha = 0; 26 | opts.trajectories.alpha = 1; 27 | opts.identities.alpha = 0; 28 | 29 | create_experiment_dir(opts); 30 | 31 | %% Setup Gurobi 32 | if ~exist('setup_done','var') 33 | setup; 34 | setup_done = true; 35 | end 36 | 37 | %% Run Tracker 38 | 39 | % opts.visualize = true; 40 | opts.sequence = 8; % val 41 | 42 | opts.appear_model_name = '1fps_train_IDE_40/GT/model_param_L2_600.mat'; 43 | % Tracklets 44 | opts.tracklets.spatial_groups = 0; 45 | opts.optimization = 'KL'; 46 | 47 | % Single-camera trajectories 48 | %opts.trajectories.use_indiff = false; 49 | opts.trajectories.og_appear_score = false; 50 | opts.trajectories.appearance_groups = 1; 51 | 52 | 53 | opts.soft = 0.1; 54 | 55 | % Multi-camera identities 56 | %opts.optimization = 'BIPCC'; 57 | opts.identities.optimal_filter = false; 58 | opts.identities.og_appear_score = false; 59 | opts.identities.consecutive_icam_matrix = ones(8); 60 | opts.identities.reintro_time_matrix = ones(1,8)*inf; 61 | 62 | opts.identities.appearance_groups = 0; 63 | 64 | 65 | DukeSCTs = []; 66 | DukeMCTs = []; 67 | for i = 1:10 68 | [DukeSCTs(i,:), DukeMCTs(i,:)] = test_tracker(opts,0,1,1); 69 | end 70 | DukeSCT = mean(DukeSCTs,1) 71 | DukeMCT = mean(DukeMCTs,1) 72 | -------------------------------------------------------------------------------- /val_duke_og.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | 4 | %% Options 5 | opts = get_opts(); 6 | opts.experiment_name = '1fps_og'; 7 | opts.feature_dir = 'det_features_ide_basis_train_1fps_trainval'; 8 | % basis setting for DeepCC 9 | opts.tracklets.window_width = 40; 10 | opts.trajectories.window_width = 150; 11 | opts.identities.window_width = 6000; 12 | % correlation threshold setting according to `view_distance_distribution(opts)` 13 | opts.tracklets.threshold = 18.45; 14 | opts.trajectories.threshold = 18.45; 15 | opts.identities.threshold = 18.45; 16 | 17 | opts.tracklets.diff_p = 11; 18 | opts.trajectories.diff_p = 11; 19 | opts.identities.diff_p = 11; 20 | opts.tracklets.diff_n = 11; 21 | opts.trajectories.diff_n = 11; 22 | opts.identities.diff_n = 11; 23 | 24 | % alpha 25 | opts.tracklets.alpha = 0; 26 | opts.trajectories.alpha = 1; 27 | opts.identities.alpha = 0; 28 | 29 | create_experiment_dir(opts); 30 | 31 | %% Setup Gurobi 32 | if ~exist('setup_done','var') 33 | setup; 34 | setup_done = true; 35 | end 36 | 37 | %% Run Tracker 38 | 39 | % opts.visualize = true; 40 | opts.sequence = 8; 41 | 42 | % Tracklets 43 | opts.tracklets.spatial_groups = 0; 44 | opts.optimization = 'KL'; 45 | 46 | % Single-camera trajectories 47 | %opts.trajectories.use_indiff = false; 48 | opts.trajectories.appearance_groups = 0; 49 | 50 | % Multi-camera identities 51 | %opts.optimization = 'BIPCC'; 52 | opts.identities.optimal_filter = true; 53 | opts.identities.consecutive_icam_matrix = ones(8); 54 | opts.identities.reintro_time_matrix = ones(1,8)*inf; 55 | opts.identities.appearance_groups = 0; 56 | 57 | DukeSCTs = []; 58 | DukeMCTs = []; 59 | for i = 1:1 60 | [DukeSCTs(i,:), DukeMCTs(i,:)] = test_tracker(opts,0,1,1); 61 | end 62 | DukeSCT = mean(DukeSCTs,1) 63 | DukeMCT = mean(DukeMCTs,1) 64 | -------------------------------------------------------------------------------- /view_appear_score.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | %% Options 4 | dataset=2; 5 | if dataset ==0 6 | opts = get_opts(); 7 | opts.sequence = 7; 8 | opts.net.experiment_root = 'experiments/pcb_basis_fc64_train_1fps'; 9 | elseif dataset == 1 10 | opts = get_opts_mot(); 11 | opts.feature_dir = 'D:/Data/MOT16/gt_feat/'; 12 | opts.net.experiment_root = 'ide256'; 13 | elseif dataset == 2 14 | opts = get_opts_aic(); 15 | opts.sequence = 1; 16 | opts.net.experiment_root = 'experiments/zju_lr001_colorjitter_256_gt_val'; 17 | end 18 | type='mid' %'1x'% 19 | 20 | [thres_uni,diff_p_uni,diff_n_uni]=view_distance_distribution(opts,type,dataset); 21 | --------------------------------------------------------------------------------