├── demo-data ├── .gitignore ├── depth.png ├── images.png └── rawdepth.png ├── mcg ├── src │ ├── external │ │ ├── BSR │ │ │ ├── buildW │ │ │ │ ├── .gitignore │ │ │ │ ├── util │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── exception.cc │ │ │ │ │ └── exception.hh │ │ │ │ ├── README │ │ │ │ ├── GPL │ │ │ │ ├── ictest.m │ │ │ │ └── affinity.hh │ │ │ ├── include │ │ │ │ ├── lang │ │ │ │ │ ├── null.hh │ │ │ │ │ ├── types │ │ │ │ │ │ └── type_info.hh │ │ │ │ │ ├── exceptions │ │ │ │ │ │ ├── throwable.hh │ │ │ │ │ │ ├── ex_bad_cast.hh │ │ │ │ │ │ ├── ex_not_found.hh │ │ │ │ │ │ ├── ex_file_error.hh │ │ │ │ │ │ ├── ex_not_implemented.hh │ │ │ │ │ │ ├── ex_invalid_argument.hh │ │ │ │ │ │ ├── ex_null_pointer_dereference.hh │ │ │ │ │ │ ├── ex_index_out_of_bounds.hh │ │ │ │ │ │ ├── ex_file_open_error.hh │ │ │ │ │ │ ├── ex_file_read_error.hh │ │ │ │ │ │ ├── ex_file_write_error.hh │ │ │ │ │ │ └── exception.hh │ │ │ │ │ ├── iterators │ │ │ │ │ │ └── iterator.hh │ │ │ │ │ ├── typecasts │ │ │ │ │ │ └── dynamic_typecast.hh │ │ │ │ │ └── lambda.hh │ │ │ │ ├── io │ │ │ │ │ ├── streams │ │ │ │ │ │ ├── cin.hh │ │ │ │ │ │ ├── cerr.hh │ │ │ │ │ │ ├── clog.hh │ │ │ │ │ │ ├── cout.hh │ │ │ │ │ │ ├── istream.hh │ │ │ │ │ │ ├── ostream.hh │ │ │ │ │ │ ├── ifstream.hh │ │ │ │ │ │ ├── ios.hh │ │ │ │ │ │ ├── iostream.hh │ │ │ │ │ │ ├── ofstream.hh │ │ │ │ │ │ ├── fstream.hh │ │ │ │ │ │ ├── stringstream.hh │ │ │ │ │ │ ├── istringstream.hh │ │ │ │ │ │ ├── ostringstream.hh │ │ │ │ │ │ └── iomanip.hh │ │ │ │ │ └── serialization │ │ │ │ │ │ ├── serial_input_stream.hh │ │ │ │ │ │ └── serial_output_stream.hh │ │ │ │ ├── config │ │ │ │ │ └── safety.hh │ │ │ │ ├── concurrent │ │ │ │ │ └── threads │ │ │ │ │ │ ├── runnable.hh │ │ │ │ │ │ └── synchronization │ │ │ │ │ │ ├── semaphore.hh │ │ │ │ │ │ ├── mutex.hh │ │ │ │ │ │ └── counter.hh │ │ │ │ ├── vision │ │ │ │ │ ├── features │ │ │ │ │ │ └── feature_id.hh │ │ │ │ │ ├── segmentation │ │ │ │ │ │ ├── boundary.hh │ │ │ │ │ │ ├── region.hh │ │ │ │ │ │ └── segmentation.hh │ │ │ │ │ └── recognition │ │ │ │ │ │ └── classifiers │ │ │ │ │ │ └── abstract │ │ │ │ │ │ └── classifier.hh │ │ │ │ ├── math │ │ │ │ │ ├── random │ │ │ │ │ │ ├── generators │ │ │ │ │ │ │ └── rand_gen.hh │ │ │ │ │ │ ├── util │ │ │ │ │ │ │ └── randperm.hh │ │ │ │ │ │ └── sources │ │ │ │ │ │ │ ├── system_entropy.hh │ │ │ │ │ │ │ ├── rand_source_32.hh │ │ │ │ │ │ │ └── rand_source_64.hh │ │ │ │ │ ├── matrices │ │ │ │ │ │ ├── exceptions │ │ │ │ │ │ │ ├── ex_matrix_singular.hh │ │ │ │ │ │ │ └── ex_matrix_dimension_mismatch.hh │ │ │ │ │ │ └── functors │ │ │ │ │ │ │ └── matrix_equal_functors.hh │ │ │ │ │ └── geometry │ │ │ │ │ │ ├── triangle_2D.hh │ │ │ │ │ │ └── triangle_3D.hh │ │ │ │ ├── interfaces │ │ │ │ │ ├── hashable.hh │ │ │ │ │ ├── iterable.hh │ │ │ │ │ ├── mappable.hh │ │ │ │ │ ├── filterable.hh │ │ │ │ │ ├── foldable.hh │ │ │ │ │ └── key_hashable.hh │ │ │ │ ├── functors │ │ │ │ │ ├── hashable_functors.hh │ │ │ │ │ └── key_hashable_functors.hh │ │ │ │ └── mlearning │ │ │ │ │ └── clustering │ │ │ │ │ └── metrics │ │ │ │ │ └── metric.hh │ │ │ ├── src │ │ │ │ ├── lang │ │ │ │ │ └── exceptions │ │ │ │ │ │ ├── throwable.cc │ │ │ │ │ │ ├── ex_bad_cast.cc │ │ │ │ │ │ ├── ex_not_found.cc │ │ │ │ │ │ ├── ex_file_error.cc │ │ │ │ │ │ ├── ex_not_implemented.cc │ │ │ │ │ │ ├── ex_invalid_argument.cc │ │ │ │ │ │ ├── ex_null_pointer_dereference.cc │ │ │ │ │ │ ├── ex_index_out_of_bounds.cc │ │ │ │ │ │ ├── ex_file_open_error.cc │ │ │ │ │ │ ├── ex_file_read_error.cc │ │ │ │ │ │ └── ex_file_write_error.cc │ │ │ │ ├── concurrent │ │ │ │ │ └── threads │ │ │ │ │ │ └── runnable.cc │ │ │ │ ├── math │ │ │ │ │ ├── matrices │ │ │ │ │ │ └── exceptions │ │ │ │ │ │ │ ├── ex_matrix_singular.cc │ │ │ │ │ │ │ └── ex_matrix_dimension_mismatch.cc │ │ │ │ │ ├── random │ │ │ │ │ │ ├── generators │ │ │ │ │ │ │ └── rand_gen_normal.cc │ │ │ │ │ │ └── sources │ │ │ │ │ │ │ └── rand_source_64.cc │ │ │ │ │ ├── math.cc │ │ │ │ │ └── libraries │ │ │ │ │ │ └── lib_matrix.cc │ │ │ │ └── mlearning │ │ │ │ │ └── clustering │ │ │ │ │ └── clusterers │ │ │ │ │ ├── abstract │ │ │ │ │ └── weighted_clusterer.cc │ │ │ │ │ └── kmeans │ │ │ │ │ └── basic_clusterer.cc │ │ │ └── LICENSE │ │ ├── RF_Reg_C │ │ │ ├── data │ │ │ │ └── diabetes.mat │ │ │ ├── Version_History.txt │ │ │ ├── src │ │ │ │ ├── reg_RF.h │ │ │ │ └── cokus_test.cpp │ │ │ ├── Compile_Check_kcachegrind │ │ │ ├── Compile_Check_memcheck │ │ │ ├── compile_windows.m │ │ │ ├── compile_linux.m │ │ │ ├── test_RegRF_extensively.m │ │ │ └── diabetes_C_devc.dev │ │ ├── README.txt │ │ └── paretofront │ │ │ ├── license.txt │ │ │ └── paretoGroup.m │ ├── bboxes │ │ ├── boxes_iou.m │ │ ├── box_area.m │ │ ├── box2mask.m │ │ ├── mask2box.m │ │ └── boxes_intersection.m │ ├── ucms │ │ ├── apply_sigmoid.m │ │ ├── project_ucms_wrap.m │ │ ├── resample_ucm2.m │ │ ├── seg2bdry.m │ │ └── seg2bdry_wt.m │ ├── aux │ │ ├── write_jaccard_to_file.m │ │ ├── plot_one_soa.m │ │ ├── ms_matrix2struct.m │ │ ├── cands2masks.m │ │ ├── cands2labels.m │ │ ├── gridbmap2seg.m │ │ ├── create_train_samples.m │ │ └── loadvar.m │ ├── tests │ │ ├── test_base_perimeters.m │ │ ├── check_hier_correctness.m │ │ ├── test_jaccard.m │ │ └── test_cands2masks.m │ └── cands │ │ └── hole_filling.m ├── ._root_dir.m ├── datasets │ ├── ._database_root_dir.m │ ├── get_image.m │ ├── database_ids.m │ ├── get_ground_truth.m │ └── database_root_dir.m ├── mcg_root_dir.m ├── depth_features │ └── processDepthImage.m ├── wrapper_rgbd_to_ucm.m ├── get_best_region.m └── License.txt ├── structured-edges ├── .gitignore ├── Contents.m ├── edgeBoxes.m ├── models │ └── README.md ├── ng │ ├── applySG.m │ ├── wrapperNormalCues.m │ ├── wrapperYDirHeight.m │ ├── normalCues.m │ ├── computeCues.m │ ├── visualizeNormals.m │ ├── fitparab.m │ ├── wrapperColorCues.m │ ├── yCues.m │ ├── getAllCues.m │ └── make_filters.m ├── structured_edges_build.m ├── spDemo.m ├── detectEdge.m └── edgesDemo.m ├── rcnn ├── external │ └── liblinear-1.94 │ │ ├── python │ │ └── Makefile │ │ ├── matlab │ │ ├── linear_model_matlab.h │ │ └── make.m │ │ ├── blas │ │ ├── Makefile │ │ ├── blas.h │ │ ├── dscal.c │ │ ├── daxpy.c │ │ ├── ddot.c │ │ └── dnrm2.c │ │ ├── linear.def │ │ ├── tron.h │ │ ├── Makefile.win │ │ ├── Makefile │ │ └── COPYRIGHT ├── mkdir_if_missing.m ├── procid.m ├── create_folds.m ├── rcnn_build.m ├── get_features.m ├── get_features_i.m ├── rcnn_scale_features.m ├── finetuning │ └── make_protofiles.m ├── tic_toc_print.m ├── rcnn_seed_rand.m ├── saveHHA.m ├── saveDisparity.m ├── rcnn_pool5_to_fcX.m ├── boxoverlap.m ├── rcnn_load_model.m ├── nms.m └── rcnn_feature_stats.m ├── .gitignore ├── demo.m ├── nyud2_finetuning ├── nyud2_finetune_solver.hha ├── nyud2_finetune_solver.color └── nyud2_finetune_solver.disparity ├── tar_command.sh ├── startup.m └── LICENSE /demo-data/.gitignore: -------------------------------------------------------------------------------- 1 | *.mat 2 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.mex* 3 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/util/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | -------------------------------------------------------------------------------- /structured-edges/.gitignore: -------------------------------------------------------------------------------- 1 | *.mat 2 | *.mexa* 3 | *.mexw* 4 | -------------------------------------------------------------------------------- /mcg/._root_dir.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/mcg/._root_dir.m -------------------------------------------------------------------------------- /demo-data/depth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/demo-data/depth.png -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/python/Makefile: -------------------------------------------------------------------------------- 1 | all = lib 2 | 3 | lib: 4 | make -C .. lib 5 | -------------------------------------------------------------------------------- /demo-data/images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/demo-data/images.png -------------------------------------------------------------------------------- /demo-data/rawdepth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/demo-data/rawdepth.png -------------------------------------------------------------------------------- /structured-edges/Contents.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/structured-edges/Contents.m -------------------------------------------------------------------------------- /structured-edges/edgeBoxes.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/structured-edges/edgeBoxes.m -------------------------------------------------------------------------------- /structured-edges/models/README.md: -------------------------------------------------------------------------------- 1 | Stores the color BSDS model. Gets downloaded when you download the data. 2 | -------------------------------------------------------------------------------- /mcg/datasets/._database_root_dir.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/mcg/datasets/._database_root_dir.m -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/data/diabetes.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-gupta/rcnn-depth/HEAD/mcg/src/external/RF_Reg_C/data/diabetes.mat -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ._.DS_Store 2 | .DS_Store 3 | *.mexa64 4 | rgbdutils/* 5 | utils/* 6 | nyu-hooks/* 7 | caffe/* 8 | caffe-data/* 9 | .git-* 10 | -------------------------------------------------------------------------------- /rcnn/mkdir_if_missing.m: -------------------------------------------------------------------------------- 1 | function made = mkdir_if_missing(path) 2 | made = false; 3 | if exist(path) == 0 4 | unix(['mkdir -p ' path]); 5 | made = true; 6 | end 7 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/README: -------------------------------------------------------------------------------- 1 | this code modified from 2 | 3 | http://www.cs.berkeley.edu/~fowlkes/BSE/ 4 | 5 | for use in gPb intervening contour computation 6 | 7 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/null.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Define NULL. 3 | */ 4 | #ifndef LANG__NULL_HH 5 | #define LANG__NULL_HH 6 | 7 | #ifndef NULL 8 | #define NULL 0 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/matlab/linear_model_matlab.h: -------------------------------------------------------------------------------- 1 | const char *model_to_matlab_structure(mxArray *plhs[], struct model *model_); 2 | const char *matlab_matrix_to_model(struct model *model_, const mxArray *matlab_struct); 3 | -------------------------------------------------------------------------------- /mcg/src/external/README.txt: -------------------------------------------------------------------------------- 1 | All the code provided in this folder come from external sources as described 2 | in each header. They have been, however, slightly modified to correct some 3 | compilation warning and errors on Linux, Mac, and Windows. 4 | -------------------------------------------------------------------------------- /demo.m: -------------------------------------------------------------------------------- 1 | I = imread(fullfile('demo-data', 'images.png')); 2 | D = imread(fullfile('demo-data', 'depth.png')); 3 | RD = imread(fullfile('demo-data', 'rawdepth.png')); 4 | C = cropCamera(getCameraParam('color')); 5 | out_file = fullfile('demo-data', 'output.mat'); 6 | run_all(I, D, RD, C, out_file); 7 | -------------------------------------------------------------------------------- /rcnn/procid.m: -------------------------------------------------------------------------------- 1 | function s = procid() 2 | % Returns a string identifying the process. 3 | 4 | % s1 = mfilename('fullpath'); 5 | % [s1, s2] = fileparts(s1); 6 | % [s1, s2] = fileparts(s1); 7 | % s = s1; 8 | 9 | d = pwd(); 10 | i = strfind(d, filesep); 11 | d = d(i(end)+1:end); 12 | s = d; 13 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/Version_History.txt: -------------------------------------------------------------------------------- 1 | CHANGES 2 | 3 | svn-v9? 4 | Added almost 95% of the total options provided by the R-package to classification. 5 | Added tutorial for regression based RF in tutorial_RegRF.m 6 | Moving now to version 0.02 7 | 8 | svn-v2 9 | initial commit - mapped to v0.01preview version -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/throwable.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Throwable. 3 | */ 4 | #include "lang/exceptions/throwable.hh" 5 | 6 | namespace lang { 7 | namespace exceptions { 8 | 9 | /* 10 | * Pure virtual destructor. 11 | */ 12 | throwable::~throwable() { } 13 | 14 | } /* namespace exceptions */ 15 | } /* namespace lang */ 16 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/concurrent/threads/runnable.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Runnable. 3 | */ 4 | #include "concurrent/threads/runnable.hh" 5 | 6 | namespace concurrent { 7 | namespace threads { 8 | 9 | /* 10 | * Pure virtual destructor. 11 | */ 12 | runnable::~runnable() { } 13 | 14 | } /* namespace threads */ 15 | } /* namespace concurrent */ 16 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/cin.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard input stream. 3 | */ 4 | #ifndef IO__STREAMS__CIN_HH 5 | #define IO__STREAMS__CIN_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::cin class. 13 | */ 14 | using std::cin; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/cerr.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard error stream. 3 | */ 4 | #ifndef IO__STREAMS__CERR_HH 5 | #define IO__STREAMS__CERR_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::cerr class. 13 | */ 14 | using std::cerr; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/clog.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard log stream. 3 | */ 4 | #ifndef IO__STREAMS__CLOG_HH 5 | #define IO__STREAMS__CLOG_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::clog class. 13 | */ 14 | using std::clog; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /structured-edges/ng/applySG.m: -------------------------------------------------------------------------------- 1 | function szg = applySG(zg, radSG, gtheta) 2 | filters = make_filters(radSG, gtheta); 3 | for i = 1:length(zg), 4 | if(radSG(i) == 0) 5 | szg{i} = zg{i}; 6 | else 7 | for o = 1:size(zg{i},3), 8 | szg{i}(:,:,o) = fitparab(abs(zg{i}(:,:,o)),radSG(i),radSG(i)/4,gtheta(o),filters{i,o}); 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/cout.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard output stream. 3 | */ 4 | #ifndef IO__STREAMS__COUT_HH 5 | #define IO__STREAMS__COUT_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::cout class. 13 | */ 14 | using std::cout; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/istream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Input stream. 3 | */ 4 | #ifndef IO__STREAMS__ISTREAM_HH 5 | #define IO__STREAMS__ISTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::istream class. 13 | */ 14 | using std::istream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/ostream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Output stream. 3 | */ 4 | #ifndef IO__STREAMS__OSTREAM_HH 5 | #define IO__STREAMS__OSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::ostream class. 13 | */ 14 | using std::ostream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/ifstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Input file stream. 3 | */ 4 | #ifndef IO__STREAMS__IFSTREAM_HH 5 | #define IO__STREAMS__IFSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::ifstream class. 13 | */ 14 | using std::ifstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/ios.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Base class for both input and output streams. 3 | */ 4 | #ifndef IO__STREAMS__IOS_HH 5 | #define IO__STREAMS__IOS_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::ios class. 13 | */ 14 | using std::ios; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/iostream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Input/Output stream. 3 | */ 4 | #ifndef IO__STREAMS__IOSTREAM_HH 5 | #define IO__STREAMS__IOSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::iostream class. 13 | */ 14 | using std::iostream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/ofstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Output file stream. 3 | */ 4 | #ifndef IO__STREAMS__OFSTREAM_HH 5 | #define IO__STREAMS__OFSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::ofstream class. 13 | */ 14 | using std::ofstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /rcnn/create_folds.m: -------------------------------------------------------------------------------- 1 | function folds = create_folds(N, k_folds) 2 | 3 | prev_rng = rcnn_seed_rand(); 4 | 5 | perm = randperm(N); 6 | fold_points = floor(linspace(1, N, k_folds+1)); 7 | fold_points(end) = N+1; 8 | folds = cell(k_folds, 1); 9 | for i = 1:k_folds 10 | folds{i} = perm(fold_points(i):fold_points(i+1)-1); 11 | end 12 | assert(isempty(setdiff(1:N, cat(2, folds{:})))); 13 | 14 | rng(prev_rng); 15 | -------------------------------------------------------------------------------- /nyud2_finetuning/nyud2_finetune_solver.hha: -------------------------------------------------------------------------------- 1 | train_net: "PROTODIR/nyud2_finetune_train.hha" 2 | test_net: "PROTODIR/nyud2_finetune_val.hha" 3 | test_iter: 100 4 | test_interval: 1000 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | stepsize: 20000 9 | display: 20 10 | max_iter: 30000 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | snapshot: 10000 14 | snapshot_prefix: "SNAPSHOTDIR/nyud2_finetune_hha" 15 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/fstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * File stream (for both input and output). 3 | */ 4 | #ifndef IO__STREAMS__FSTREAM_HH 5 | #define IO__STREAMS__FSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::fstream class. 13 | */ 14 | using std::fstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/stringstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * String stream. 3 | */ 4 | #ifndef IO__STREAMS__STRINGSTREAM_HH 5 | #define IO__STREAMS__STRINGSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::stringstream class. 13 | */ 14 | using std::stringstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /nyud2_finetuning/nyud2_finetune_solver.color: -------------------------------------------------------------------------------- 1 | train_net: "PROTODIR/nyud2_finetune_train.color" 2 | test_net: "PROTODIR/nyud2_finetune_val.color" 3 | test_iter: 100 4 | test_interval: 1000 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | stepsize: 20000 9 | display: 20 10 | max_iter: 30000 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | snapshot: 10000 14 | snapshot_prefix: "SNAPSHOTDIR/nyud2_finetune_color" 15 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/istringstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Input string stream. 3 | */ 4 | #ifndef IO__STREAMS__ISTRINGSTREAM_HH 5 | #define IO__STREAMS__ISTRINGSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::istringstream class. 13 | */ 14 | using std::istringstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/ostringstream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Ouput string stream. 3 | */ 4 | #ifndef IO__STREAMS__OSTRINGSTREAM_HH 5 | #define IO__STREAMS__OSTRINGSTREAM_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | /* 12 | * Export std::ostringstream class. 13 | */ 14 | using std::ostringstream; 15 | 16 | } /* namespace streams */ 17 | } /* namespace io */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /structured-edges/ng/wrapperNormalCues.m: -------------------------------------------------------------------------------- 1 | function wrapperNormalCues(inName, outName) 2 | % Load the image 3 | z = imread(inName); 4 | 5 | % Convert to cm to pass into the computeCues function 6 | z = double(z)./10; 7 | 8 | % The camera matrix from somewhere 9 | C = cropCamera(getCameraParam('color')); 10 | 11 | [dt.ng1, dt.ng2, dt.dg] = normalCues(z, C, 1); 12 | save(outName, '-STRUCT', 'dt'); 13 | end 14 | -------------------------------------------------------------------------------- /structured-edges/ng/wrapperYDirHeight.m: -------------------------------------------------------------------------------- 1 | function wrapperYDirHeight(inName, outName) 2 | % Load the point cloud from somewhere 3 | z = imread(inName); 4 | C = cropCamera(getCameraParam('color')); 5 | 6 | % Convert to cm to pass into the computeCues function 7 | z = double(z)./10; 8 | D = z; 9 | 10 | [y1 y2 y3 angl1 angl2] = yCues(D, C, 1); 11 | save(outName, 'y1', 'y2', 'y3', 'angl1', 'angl2'); 12 | end 13 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/Makefile: -------------------------------------------------------------------------------- 1 | AR = ar rcv 2 | RANLIB = ranlib 3 | 4 | HEADERS = blas.h blasp.h 5 | FILES = dnrm2.o daxpy.o ddot.o dscal.o 6 | 7 | CFLAGS = $(OPTFLAGS) 8 | FFLAGS = $(OPTFLAGS) 9 | 10 | blas: $(FILES) $(HEADERS) 11 | $(AR) blas.a $(FILES) 12 | $(RANLIB) blas.a 13 | 14 | clean: 15 | - rm -f *.o 16 | - rm -f *.a 17 | - rm -f *~ 18 | 19 | .c.o: 20 | $(CC) $(CFLAGS) -c $*.c 21 | 22 | 23 | -------------------------------------------------------------------------------- /nyud2_finetuning/nyud2_finetune_solver.disparity: -------------------------------------------------------------------------------- 1 | train_net: "PROTODIR/nyud2_finetune_train.disparity" 2 | test_net: "PROTODIR/nyud2_finetune_val.disparity" 3 | test_iter: 100 4 | test_interval: 1000 5 | base_lr: 0.001 6 | lr_policy: "step" 7 | gamma: 0.1 8 | stepsize: 20000 9 | display: 20 10 | max_iter: 30000 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | snapshot: 10000 14 | snapshot_prefix: "SNAPSHOTDIR/nyud2_finetune_disparity" 15 | -------------------------------------------------------------------------------- /mcg/datasets/get_image.m: -------------------------------------------------------------------------------- 1 | function image = get_image( database, image_id ) 2 | if strcmp(database,'pascal2012') 3 | image = imread(fullfile(database_root_dir(database), 'JPEGImages', [image_id '.jpg'])); 4 | elseif strcmp(database,'bsds500') 5 | image = imread(fullfile(database_root_dir(database), 'images', [image_id '.jpg'])); 6 | else 7 | error(['Unknown database: ' database]); 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /mcg/datasets/database_ids.m: -------------------------------------------------------------------------------- 1 | function ids = database_ids( database, gt_set ) 2 | switch database, 3 | case 'nyud4oObj', 4 | ids = getImageSet(gt_set); 5 | otherwise, 6 | index_file = fullfile(mcg_root_dir,'datasets',database, 'gt_sets',[gt_set '.txt']); 7 | fileID = fopen(index_file); 8 | ids = textscan(fileID, '%s'); 9 | ids = ids{1}; 10 | fclose(fileID); 11 | end 12 | end 13 | 14 | -------------------------------------------------------------------------------- /structured-edges/ng/normalCues.m: -------------------------------------------------------------------------------- 1 | function [ng1, ng2, dg] = normalCues(z, C, s) 2 | % Convert to cm to pass into the computeCues function 3 | z = double(z); 4 | ss = 1.4; 5 | depthParam = struct('qzc', 2.9e-5, 'sigmaSpace', ss*[1 2], 'rr', ss*3*[1 2], 'sigmaDisparity', [3 3], 'nori', 4, 'savgolFactor', 1.0); 6 | % [ng1, ng2, dg, sng1, sng2, sdg] = computeDepthCues(z, C, s, depthParam); 7 | [ng1, ng2, dg] = computeDepthCues(z, C, s, depthParam); 8 | end 9 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/linear.def: -------------------------------------------------------------------------------- 1 | LIBRARY liblinear 2 | EXPORTS 3 | train @1 4 | cross_validation @2 5 | save_model @3 6 | load_model @4 7 | get_nr_feature @5 8 | get_nr_class @6 9 | get_labels @7 10 | predict_values @8 11 | predict @9 12 | predict_probability @10 13 | free_and_destroy_model @11 14 | free_model_content @12 15 | destroy_param @13 16 | check_parameter @14 17 | check_probability_model @15 18 | set_print_string_function @16 19 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/types/type_info.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Run-time type information. 3 | * Type info can be obtained using the typeid(...) operator. 4 | */ 5 | #ifndef LANG__TYPES__TYPE_INFO_HH 6 | #define LANG__TYPES__TYPE_INFO_HH 7 | 8 | #include 9 | 10 | namespace lang { 11 | namespace types { 12 | /* 13 | * Export std::type_info class. 14 | */ 15 | using std::type_info; 16 | 17 | } /* namespace types */ 18 | } /* namespace lang */ 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /structured-edges/ng/computeCues.m: -------------------------------------------------------------------------------- 1 | function [dg, ng1, ng2, sdg, sng1, sng2] = computeCues(z, C, s, depthParam) 2 | % Input: 3 | % z is the depth image at cropped size - in units of cm from the camera 4 | % C is the camera 5 | % s is the scale that you want to use on the image 6 | 7 | % Compute the local cues 8 | [ng1, ng2, dg, raw] = computeDepthCues(pc, pcf, depthParam); 9 | 10 | % Do cue smoothing if needed 11 | if(nargout() > 3) 12 | % Do cue smoothing here 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/config/safety.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Safety settings. 3 | */ 4 | #ifndef CONFIG__SAFETY_HH 5 | #define CONFIG__SAFETY_HH 6 | 7 | /* 8 | * Check smart pointer dereference? 9 | * If true, smart pointers should throw exceptions on null dereference. 10 | */ 11 | #define CONFIG__SAFETY__CHECK_DEREFERENCE (true) 12 | 13 | /* 14 | * Check bounds when accessing arrays? 15 | * If true, arrays should throw exceptions on access to an out of bounds index. 16 | */ 17 | #define CONFIG__SAFETY__CHECK_BOUNDS (true) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /structured-edges/ng/visualizeNormals.m: -------------------------------------------------------------------------------- 1 | function out = visualizeNormals(Z) 2 | 3 | if size(Z,3) == 3 4 | N = Z; 5 | else 6 | N = getNormals(Z); 7 | end 8 | 9 | % hue = (atan2(N(:,:,1), N(:,:,2)) + pi)/(2*pi); 10 | % sat = sqrt(N(:,:,1).^2 + N(:,:,2).^2); 11 | % val = N(:,:,3)/2+0.5; 12 | % V = hsv2rgb(cat(3, hue, sat, val)); 13 | 14 | N = N(:,:,[3,1,2]); 15 | N(:,:,2:3) = N(:,:,2:3) / 1.25; 16 | V = max(0, min(1, yuv2rgb_simple(N))); 17 | 18 | V(isnan(N)) = 0; 19 | 20 | if nargout == 0 21 | imagesc(V); 22 | imtight; 23 | else 24 | out = V; 25 | end 26 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/streams/iomanip.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard stream manipulators. 3 | */ 4 | #ifndef IO__STREAMS__IOMANIP_HH 5 | #define IO__STREAMS__IOMANIP_HH 6 | 7 | #include 8 | 9 | namespace io { 10 | namespace streams { 11 | namespace iomanip { 12 | /* 13 | * Export standard manipulators. 14 | */ 15 | using std::setiosflags; 16 | using std::resetiosflags; 17 | using std::setw; 18 | using std::setfill; 19 | using std::setprecision; 20 | using std::setbase; 21 | 22 | } /* namespace iomanip */ 23 | } /* namespace streams */ 24 | } /* namespace io */ 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /structured-edges/ng/fitparab.m: -------------------------------------------------------------------------------- 1 | function a = fitparab(z,ra,rb,theta,filt) 2 | % function [a,b,c] = fitparab(z,ra,rb,theta) 3 | % 4 | % Fit cylindrical parabolas to elliptical patches of z at each 5 | % pixel. 6 | % 7 | % INPUT 8 | % z Values to fit. 9 | % ra,rb Radius of elliptical neighborhood, ra=major axis. 10 | % theta Orientation of fit (i.e. of minor axis). 11 | % 12 | % OUTPUT 13 | % a,b,c Coefficients of fit: a + bx + cx^2 14 | % 15 | 16 | 17 | % compute the interior quickly with convolutions 18 | a = conv2(z,filt(:,:,1),'same'); 19 | %fix border with mex file 20 | a = savgol_border(a, z, ra, rb, theta); 21 | 22 | -------------------------------------------------------------------------------- /mcg/src/bboxes/boxes_iou.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % 5 | % Jordi Pont-Tuset 6 | % June 2013 7 | % ------------------------------------------------------------------------ 8 | 9 | function iou = boxes_iou( bbox1, bbox2 ) 10 | area1 = box_area(bbox1); 11 | area2 = box_area(bbox2); 12 | inters = boxes_intersection(bbox1, bbox2); 13 | union = area1+area2-inters; 14 | 15 | assert(union>0) 16 | iou = inters/union; 17 | end 18 | 19 | -------------------------------------------------------------------------------- /structured-edges/structured_edges_build.m: -------------------------------------------------------------------------------- 1 | function structured_edges_build() 2 | cd('structured-edges'); 3 | OMPPARAMS = ['-DUSEOMP CXXFLAGS="\$CXXFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp"']; 4 | s = sprintf('mex private/edgesDetectMex.cpp -outdir private %s', OMPPARAMS); eval(s); 5 | s = sprintf('mex private/edgesDetectMexNormal.cpp -outdir private %s', OMPPARAMS); eval(s); 6 | s = sprintf('mex private/edgesNmsMex.cpp -outdir private %s', OMPPARAMS); eval(s); 7 | s = sprintf('mex private/spDetectMex.cpp -outdir private %s', OMPPARAMS); eval(s); 8 | s = sprintf('mex private/edgeBoxesMex.cpp -outdir private'); eval(s); 9 | cd('..'); 10 | end 11 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/src/reg_RF.h: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * mex interface to Andy Liaw et al.'s C code (used in R package randomForest) 3 | * Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 4 | * License: GPLv2 5 | * Version: 0.02 6 | * 7 | * Supporting file that has some declarations. 8 | *************************************************************/ 9 | 10 | #define uint32 unsigned long 11 | #define SMALL_INT char 12 | 13 | #ifdef MATLAB 14 | #define SMALL_INT_CLASS mxCHAR_CLASS //will be used to allocate memory t 15 | #endif 16 | 17 | void seedMT(uint32 seed); 18 | uint32 randomMT(void); 19 | 20 | -------------------------------------------------------------------------------- /rcnn/rcnn_build.m: -------------------------------------------------------------------------------- 1 | function rcnn_build() 2 | cd('rcnn'); 3 | % Compile liblinear 4 | if ~exist('liblinear_train') 5 | fprintf('Compiling liblinear version 1.94\n'); 6 | fprintf('Source code page:\n'); 7 | fprintf(' http://www.csie.ntu.edu.tw/~cjlin/liblinear/\n'); 8 | mex -outdir . ... 9 | CFLAGS="\$CFLAGS -std=c99 -O3 -fPIC" -largeArrayDims ... 10 | external/liblinear-1.94/matlab/train.c ... 11 | external/liblinear-1.94/matlab/linear_model_matlab.c ... 12 | external/liblinear-1.94/linear.cpp ... 13 | external/liblinear-1.94/tron.cpp ... 14 | "external/liblinear-1.94/blas/*.c" ... 15 | -output liblinear_train; 16 | cd('..'); 17 | end 18 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/concurrent/threads/runnable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Runnable interface. 3 | * 4 | * This interface should be extended by any object to be executed by a thread. 5 | */ 6 | #ifndef CONCURRENT__THREADS__RUNNABLE_HH 7 | #define CONCURRENT__THREADS__RUNNABLE_HH 8 | 9 | namespace concurrent { 10 | namespace threads { 11 | 12 | /* 13 | * Runnable interface. 14 | */ 15 | class runnable { 16 | public: 17 | /* 18 | * Destructor. 19 | */ 20 | virtual ~runnable() = 0; 21 | 22 | /* 23 | * Method to be executed by the thread. 24 | */ 25 | virtual void run() = 0; 26 | }; 27 | 28 | } /* namespace threads */ 29 | } /* namespace concurrent */ 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/vision/features/feature_id.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Feature identity. 3 | * 4 | * This abstract base class serves as an identity tag that can be attached 5 | * to feature descriptors. It can be extended to store useful identity 6 | * information. 7 | */ 8 | #ifndef VISION__FEATURES__FEATURE_ID_HH 9 | #define VISION__FEATURES__FEATURE_ID_HH 10 | 11 | namespace vision { 12 | namespace features { 13 | 14 | /* 15 | * Abstract base class for feature identity. 16 | */ 17 | class feature_id { 18 | public: 19 | /* 20 | * Destructor. 21 | */ 22 | virtual ~feature_id() = 0; 23 | }; 24 | 25 | } /* namespace features */ 26 | } /* namespace vision */ 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/Compile_Check_kcachegrind: -------------------------------------------------------------------------------- 1 | # Note will work only on linux 2 | # check for various not-visible errors by using valgrind 3 | # this code just profiles the timings of the code. 4 | # checked on linux with valgrind and kcachegrind installed 5 | # Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 6 | # run as: sh Compile_Check_kcachegrind 7 | rm callgrind.out.* 8 | 9 | #if you have icc uncomment below 10 | #icc cokus.cpp reg_RF.cpp diabetes_C_wrapper.cpp -g -pg -funroll-loops -msse3 -fast 11 | 12 | g++ cokus.cpp reg_RF.cpp diabetes_C_wrapper.cpp -g -pg -funroll-loops -msse3 13 | valgrind -v --error-limit=no --tool=callgrind --dump-instr=yes ./a.out 14 | 15 | kcachegrind& 16 | 17 | -------------------------------------------------------------------------------- /rcnn/get_features.m: -------------------------------------------------------------------------------- 1 | function dOut = get_features(imdb, image_ids_i, opts, onlyGt) 2 | % function get_features(imName, opts) 3 | % Various types of features, as encoded by opts 4 | 5 | % AUTORIGHTS 6 | 7 | for i = 1:length(opts), 8 | d{i} = get_features_i(imdb, image_ids_i, opts(i), onlyGt); 9 | % if(isfield(opts(i).param, 'wt')) 10 | % d{i}.feat = (opts(i).param.wt).*d{i}.feat; 11 | % end 12 | end 13 | for i = 2:length(d), 14 | assert(isequal(d{1}.boxes, d{i}.boxes)); 15 | end 16 | dOut = d{1}; 17 | for i = 1:length(d), 18 | dd(i).feat = d{i}.feat; 19 | end 20 | dOut.feat = cat(2, dd(:).feat); 21 | assert(any(isnan(dOut.feat(:))) == false, 'Features were NaN!!'); 22 | end 23 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/Compile_Check_memcheck: -------------------------------------------------------------------------------- 1 | # Note will work only on linux 2 | # check for various not-visible errors by using valgrind 3 | # this code checks for memory allocs in the code 4 | # checked on linux with valgrind and kcachegrind installed 5 | # Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 6 | # run as: sh Compile_Check_kcachegrind 7 | rm callgrind.out.* 8 | 9 | #if you want to use icc uncomment below 10 | #icc cokus.cpp reg_RF.cpp diabetes_C_wrapper.cpp -g -pg -funroll-loops -msse3 -fast 11 | 12 | g++ cokus.cpp reg_RF.cpp diabetes_C_wrapper.cpp -g -pg -funroll-loops -msse3 13 | valgrind -v --error-limit=no --tool=memcheck --track-origins=yes --leak-check=full ./a.out 14 | 15 | 16 | -------------------------------------------------------------------------------- /rcnn/get_features_i.m: -------------------------------------------------------------------------------- 1 | function d = get_features_i(imdb, image_ids_i, opts, onlyGt) 2 | % function d = get_features_i(imdb, image_ids_i, opts, onlyGt) 3 | 4 | % AUTORIGHTS 5 | 6 | d = load(fullfile(opts.featDir, imdb.image_ids{image_ids_i})); 7 | 8 | % % Inject code to sample features from the classes is class_id is not empty 9 | if(onlyGt) 10 | sel = find(d.gt); 11 | assert(isequal(sel, [1:length(sel)]')); 12 | d.gt = d.gt(sel); 13 | d.overlap = d.overlap(sel,:); 14 | d.boxes = d.boxes(sel, :); 15 | d.feat = d.feat(sel, :); 16 | d.class = d.class(sel, :); 17 | end 18 | 19 | d.boxes = double(d.boxes); 20 | % d.feat = rcnn_pool5_to_fcX(d.feat, opts.param.layer, opts.param.cnnWeightsFile); 21 | 22 | end 23 | -------------------------------------------------------------------------------- /tar_command.sh: -------------------------------------------------------------------------------- 1 | cd ../ 2 | tar -cf eccv14-external-data.tgz eccv14-code/caffe-data eccv14-code/structured-edges/models/forest/ 3 | 4 | cd ../ 5 | tar -cf eccv14-models.tgz \ 6 | eccv14-cachedir/release/contours/models/forest \ 7 | eccv14-cachedir/release/regions/classifiers \ 8 | eccv14-cachedir/release/regions/features \ 9 | eccv14-cachedir/release/regions/pareto \ 10 | eccv14-cachedir/release/detection/finetuning/protodir \ 11 | eccv14-cachedir/release/detection/finetuning/windowfile \ 12 | eccv14-cachedir/release/detection/finetuning/snapshot/*30000.caffemodel \ 13 | eccv14-cachedir/release/detection/detector/rgb_hha_30000_trainval/rcnn_model.mat \ 14 | eccv14-cachedir/release/detection/detector/rgb_hha_30000_trainval/pr-curves 15 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2008 Michael Maire 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Affero General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Affero General Public License for more details. 12 | 13 | You should have received a copy of the GNU Affero General Public License 14 | along with this program. If not, see . 15 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/throwable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Throwable. 3 | * 4 | * Any object which can be thrown as an exception should derive from throwable. 5 | */ 6 | #ifndef LANG__EXCEPTIONS__THROWABLE_HH 7 | #define LANG__EXCEPTIONS__THROWABLE_HH 8 | 9 | namespace lang { 10 | namespace exceptions { 11 | 12 | /* 13 | * Throwable interface. 14 | */ 15 | class throwable { 16 | public: 17 | /* 18 | * Destructor. 19 | */ 20 | virtual ~throwable() = 0; 21 | 22 | /* 23 | * Clone the object. 24 | */ 25 | virtual throwable* clone() const = 0; 26 | 27 | /* 28 | * Throw the object. 29 | */ 30 | virtual void raise() const = 0; 31 | }; 32 | 33 | } /* namespace exceptions */ 34 | } /* namespace lang */ 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /structured-edges/ng/wrapperColorCues.m: -------------------------------------------------------------------------------- 1 | function wrapperColorCues(inName, outName) 2 | I = imread(inName); 3 | 4 | dt = load('/work3/sgupta/eccv14-code/piotr-structured-edges-pami/models/forest/modelBsds.mat'); 5 | model = dt.model; 6 | 7 | %% set detection parameters (can set after training) 8 | model.opts.multiscale=1; % for top accuracy set multiscale=1 9 | model.opts.sharpen=0; % for top speed set sharpen=0 10 | model.opts.nTreesEval=4; % for top speed set nTreesEval=1 11 | model.opts.nThreads=4; % max number threads for evaluation 12 | model.opts.nms=0; % set to true to enable nms 13 | 14 | 15 | [Es] = edgesDetect(I, model, zeros([size(I(:,:,1)), 0])); 16 | E = Es; 17 | save(outName, 'E', 'Es'); 18 | end 19 | -------------------------------------------------------------------------------- /rcnn/rcnn_scale_features.m: -------------------------------------------------------------------------------- 1 | function f = rcnn_scale_features(f, feat_norm_mean) 2 | % My initial experiments were conducted on features with an average norm 3 | % very close to 20. Using those features, I determined a good range of SVM 4 | % C values to cross-validate over. Features from different layers end up 5 | % have very different norms. We rescale all features to have an average norm 6 | % of 20 (why 20? simply so that I can use the range of C values found in my 7 | % initial experiments), to make the same search range for C reasonable 8 | % regardless of whether these are pool5, fc6, or fc7 features. This strategy 9 | % seems to work well. In practice, the optimal value for C ends up being the 10 | % same across all features. 11 | target_norm = 20; 12 | f = f .* (target_norm / feat_norm_mean); 13 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/blas.h: -------------------------------------------------------------------------------- 1 | /* blas.h -- C header file for BLAS Ver 1.0 */ 2 | /* Jesse Bennett March 23, 2000 */ 3 | 4 | /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." 5 | 6 | - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ 7 | 8 | #ifndef BLAS_INCLUDE 9 | #define BLAS_INCLUDE 10 | 11 | /* Data types specific to BLAS implementation */ 12 | typedef struct { float r, i; } fcomplex; 13 | typedef struct { double r, i; } dcomplex; 14 | typedef int blasbool; 15 | 16 | #include "blasp.h" /* Prototypes for all BLAS functions */ 17 | 18 | #define FALSE 0 19 | #define TRUE 1 20 | 21 | /* Macro functions */ 22 | #define MIN(a,b) ((a) <= (b) ? (a) : (b)) 23 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /rcnn/finetuning/make_protofiles.m: -------------------------------------------------------------------------------- 1 | function make_protofiles(protodir, file_name, args), 2 | % function make_protofiles(protodir, file_name, args) 3 | 4 | % AUTORIGHTS 5 | 6 | in_dir = 'nyud2_finetuning'; 7 | for i = 1:length(file_name), 8 | copyfile(fullfile(in_dir, file_name{i}), fullfile(protodir, file_name{i})); 9 | for j = 1:2:length(args), 10 | helper(fullfile(protodir, file_name{i}), fullfile(protodir, file_name{i}), args{j}, args{j+1}); 11 | end 12 | end 13 | end 14 | 15 | 16 | function helper(inFile, outFile, str_a, str_b) 17 | % Replaces all occurences of string str_a in inFile with str_b 18 | f = fopen(inFile); 19 | text = fread(f, inf, '*char')'; 20 | fclose(f); 21 | text = regexprep(text, str_a, str_b); 22 | 23 | f = fopen(outFile, 'w'); 24 | fwrite(f, text); 25 | fclose(f); 26 | end 27 | -------------------------------------------------------------------------------- /rcnn/tic_toc_print.m: -------------------------------------------------------------------------------- 1 | function tic_toc_print(fmt, varargin) 2 | % Print only after 1 second has passed since the last print. 3 | % Arguments are the same as for fprintf. 4 | 5 | % AUTORIGHTS 6 | % ------------------------------------------------------- 7 | % Copyright (C) 2009-2012 Ross Girshick 8 | % 9 | % This file is part of the voc-releaseX code 10 | % (http://people.cs.uchicago.edu/~rbg/latent/) 11 | % and is available under the terms of an MIT-like license 12 | % provided in COPYING. Please retain this notice and 13 | % COPYING if you use this file (or a portion of it) in 14 | % your project. 15 | % ------------------------------------------------------- 16 | 17 | persistent th; 18 | 19 | if isempty(th) 20 | th = tic(); 21 | end 22 | 23 | if toc(th) > 1 24 | fprintf(fmt, varargin{:}); 25 | drawnow; 26 | th = tic(); 27 | end 28 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/tron.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRON_H 2 | #define _TRON_H 3 | 4 | class function 5 | { 6 | public: 7 | virtual double fun(double *w) = 0 ; 8 | virtual void grad(double *w, double *g) = 0 ; 9 | virtual void Hv(double *s, double *Hs) = 0 ; 10 | 11 | virtual int get_nr_variable(void) = 0 ; 12 | virtual ~function(void){} 13 | }; 14 | 15 | class TRON 16 | { 17 | public: 18 | TRON(const function *fun_obj, double eps = 0.1, int max_iter = 1000); 19 | ~TRON(); 20 | 21 | void tron(double *w); 22 | void set_print_string(void (*i_print) (const char *buf)); 23 | 24 | private: 25 | int trcg(double delta, double *g, double *s, double *r); 26 | double norm_inf(int n, double *x); 27 | 28 | double eps; 29 | int max_iter; 30 | function *fun_obj; 31 | void info(const char *fmt,...); 32 | void (*tron_print_string)(const char *buf); 33 | }; 34 | #endif 35 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/random/generators/rand_gen.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Abstract interface for pseudorandom number generators. 3 | */ 4 | #ifndef MATH__RANDOM__GENERATORS__RAND_GEN_HH 5 | #define MATH__RANDOM__GENERATORS__RAND_GEN_HH 6 | 7 | namespace math { 8 | namespace random { 9 | namespace generators { 10 | 11 | /* 12 | * Abstract interface for pseudorandom number generator. 13 | */ 14 | template 15 | class rand_gen { 16 | public: 17 | /* 18 | * Destructor. 19 | */ 20 | virtual ~rand_gen() = 0; 21 | 22 | /* 23 | * Generate a pseudorandom number. 24 | */ 25 | virtual T generate() = 0; 26 | }; 27 | 28 | /* 29 | * Pure virtual destructor. 30 | */ 31 | template 32 | rand_gen::~rand_gen() { } 33 | 34 | } /* namespace generators */ 35 | } /* namespace random */ 36 | } /* namespace math */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /rcnn/rcnn_seed_rand.m: -------------------------------------------------------------------------------- 1 | function prev_rng = rcnn_seed_rand() 2 | % seed_rand - Set random number generator to a fixed seed. 3 | % prev_rng = rcnn_seed_rand(seed) 4 | % 5 | % Strategic use ensures that results are reproducible. 6 | % 7 | % To restore the previous rng after calling this do: 8 | % rng(prev_rng); 9 | 10 | % AUTORIGHTS 11 | % --------------------------------------------------------- 12 | % Copyright (c) 2014, Ross Girshick 13 | % 14 | % This file is part of the R-CNN code and is available 15 | % under the terms of the Simplified BSD License provided in 16 | % LICENSE. Please retain this notice and LICENSE if you use 17 | % this file (or any portion of it) in your project. 18 | % --------------------------------------------------------- 19 | 20 | % This value works best for me. 21 | seed = 3; 22 | % Just kidding, of course ;-). 23 | 24 | prev_rng = rng; 25 | rng(seed, 'twister') 26 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/iterators/iterator.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Iterators. 3 | */ 4 | #ifndef LANG__ITERATORS__ITERATOR_HH 5 | #define LANG__ITERATORS__ITERATOR_HH 6 | 7 | namespace lang { 8 | namespace iterators { 9 | 10 | /* 11 | * Abstract base class for iterators. 12 | */ 13 | template 14 | class iterator { 15 | public: 16 | /* 17 | * Destructor. 18 | */ 19 | virtual ~iterator() = 0; 20 | 21 | /* 22 | * Check if there is another item available. 23 | */ 24 | virtual bool has_next() const = 0; 25 | 26 | /* 27 | * Return the next item. 28 | * Throw an exception (ex_not_found) if there are no more items. 29 | */ 30 | virtual T& next() = 0; 31 | }; 32 | 33 | /* 34 | * Iterator pure virtual destructor. 35 | */ 36 | template 37 | iterator::~iterator() { } 38 | 39 | } /* namespace iterators */ 40 | } /* namespace lang */ 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /rcnn/saveHHA.m: -------------------------------------------------------------------------------- 1 | function HHA = saveHHA(imName, C, outDir, D, RD) 2 | % function HHA = saveHHA(imName, C, outDir, D, RD) 3 | 4 | % AUTORIGHTS 5 | 6 | if(isempty(D)), D = getImage(imName, 'depth'); end 7 | if(isempty(RD)), RD = getImage(imName, 'rawdepth'); end 8 | 9 | D = double(D)./1000; 10 | missingMask = RD == 0; 11 | [pc, N, yDir, h, pcRot, NRot] = processDepthImage(D*100, missingMask, C); 12 | angl = acosd(min(1,max(-1,sum(bsxfun(@times, N, reshape(yDir, 1, 1, 3)), 3)))); 13 | 14 | % Making the minimum depth to be 100, to prevent large values for disparity!!! 15 | pc(:,:,3) = max(pc(:,:,3), 100); 16 | I(:,:,1) = 31000./pc(:,:,3); 17 | I(:,:,2) = h; 18 | I(:,:,3) = (angl+128-90); %Keeping some slack 19 | I = uint8(I); 20 | 21 | % Save if can save 22 | if(~isempty(outDir) && ~isempty(imName)), imwrite(I, fullfile_ext(outDir, imName, 'png')); end 23 | 24 | HHA = I; 25 | end 26 | -------------------------------------------------------------------------------- /rcnn/saveDisparity.m: -------------------------------------------------------------------------------- 1 | function HHH = saveDisparity(imName, C, outDir, D, RD) 2 | % function HHH = saveDisparity(imName, C, outDir, D, RD) 3 | 4 | % AUTORIGHTS 5 | 6 | if(isempty(D)), D = getImage(imName, 'depth'); end 7 | if(isempty(RD)), RD = getImage(imName, 'rawdepth'); end 8 | 9 | D = double(D)./1000; 10 | missingMask = RD == 0; 11 | 12 | [pc, N, yDir, h, pcRot, NRot] = processDepthImage(D*100, missingMask, C); 13 | angl = acosd(min(1,max(-1,sum(bsxfun(@times, N, reshape(yDir, 1, 1, 3)), 3)))); 14 | 15 | % Making the minimum depth to be 100, to prevent large values for disparity!!! 16 | pc(:,:,3) = max(pc(:,:,3), 100); 17 | I(:,:,1) = 31000./pc(:,:,3); 18 | I(:,:,2) = I(:,:,1); 19 | I(:,:,3) = I(:,:,1); 20 | I = uint8(I); 21 | 22 | % Save if you can 23 | if(~isempty(outDir) && ~isempty(imName)), imwrite(I, fullfile_ext(outDir, imName, 'png')); end 24 | 25 | HHH = I; 26 | end 27 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/typecasts/dynamic_typecast.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Dynamic typecast. 3 | * 4 | * This is equivalent to the built-in dynamic_cast, except that it throws an 5 | * ex_bad_cast exception on error instead of the built-in bad_cast exception. 6 | */ 7 | #ifndef LANG__TYPECASTS__DYNAMIC_TYPECAST_HH 8 | #define LANG__TYPECASTS__DYNAMIC_TYPECAST_HH 9 | 10 | #include "lang/exceptions/ex_bad_cast.hh" 11 | #include 12 | 13 | namespace lang { 14 | namespace typecasts { 15 | /* 16 | * Imports. 17 | */ 18 | using lang::exceptions::ex_bad_cast; 19 | 20 | /* 21 | * Dynamic typecast. 22 | */ 23 | template 24 | T dynamic_typecast(U& u) { 25 | try { 26 | return dynamic_cast(u); 27 | } catch (std::bad_cast&) { 28 | throw ex_bad_cast( 29 | "dynamic typecast failed" 30 | ); 31 | } 32 | } 33 | 34 | } /* namespace typecasts */ 35 | } /* namespace lang */ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/vision/segmentation/boundary.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Boundary. 3 | * 4 | * A boundary separates two distinct regions. 5 | */ 6 | #ifndef VISION__SEGMENTATION__BOUNDARY_HH 7 | #define VISION__SEGMENTATION__BOUNDARY_HH 8 | 9 | namespace vision { 10 | namespace segmentation { 11 | 12 | /* 13 | * Boundary of a region. 14 | */ 15 | class boundary { 16 | public: 17 | /* 18 | * Constructor. 19 | */ 20 | boundary(); 21 | 22 | /* 23 | * Destructor. 24 | */ 25 | virtual ~boundary(); 26 | 27 | /* 28 | * Boundary id. 29 | */ 30 | unsigned long _id; 31 | 32 | /* 33 | * Boundary data. 34 | */ 35 | unsigned long _size; /* number of pixels along boundary */ 36 | double _sum_contrast; /* sum of local contrast measures */ 37 | double _sum_pb; /* sum of pb along boundary */ 38 | }; 39 | 40 | } /* namespace segmentation */ 41 | } /* namespace vision */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/GPL: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Charless C. Fowlkes 2 | // Copyright (C) 2002 David R. Martin 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation; either version 2 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, but 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | // General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 18 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_bad_cast.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Bad cast exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_bad_cast.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_bad_cast::ex_bad_cast(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "bad cast") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_bad_cast::ex_bad_cast(const ex_bad_cast& e) 24 | : exception(e) 25 | { } 26 | 27 | /* 28 | * Destructor. 29 | */ 30 | ex_bad_cast::~ex_bad_cast() { 31 | /* do nothing */ 32 | } 33 | 34 | /* 35 | * Clone the exception. 36 | */ 37 | ex_bad_cast* ex_bad_cast::clone() const { 38 | return (new ex_bad_cast(*this)); 39 | } 40 | 41 | /* 42 | * Throw the exception. 43 | */ 44 | void ex_bad_cast::raise() const { 45 | throw *this; 46 | } 47 | 48 | } /* namespace exceptions */ 49 | } /* namespace lang */ 50 | -------------------------------------------------------------------------------- /mcg/src/bboxes/box_area.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function area = box_area( bbox ) 17 | up = bbox(1); 18 | left = bbox(2); 19 | down = bbox(3); 20 | right = bbox(4); 21 | 22 | area = (down-up+1)*(right-left+1); 23 | end 24 | 25 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_not_found.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Not found exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_not_found.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_not_found::ex_not_found(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "not found") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_not_found::ex_not_found(const ex_not_found& e) 24 | : exception(e) 25 | { } 26 | 27 | /* 28 | * Destructor. 29 | */ 30 | ex_not_found::~ex_not_found() { 31 | /* do nothing */ 32 | } 33 | 34 | /* 35 | * Clone the exception. 36 | */ 37 | ex_not_found* ex_not_found::clone() const { 38 | return (new ex_not_found(*this)); 39 | } 40 | 41 | /* 42 | * Throw the exception. 43 | */ 44 | void ex_not_found::raise() const { 45 | throw *this; 46 | } 47 | 48 | } /* namespace exceptions */ 49 | } /* namespace lang */ 50 | -------------------------------------------------------------------------------- /startup.m: -------------------------------------------------------------------------------- 1 | function startup() 2 | % genPath = {'piotr-structured-edges-pami', 'rgbdutils', 'utils'}; 3 | if(~exist('nyu-hooks', 'dir')), warning('Missing nyu-hooks. You will need it for some functions. Get it from here: https://github.com/s-gupta/nyu-hooks'); end 4 | if(~exist('utils', 'dir')), warning('Missing utils. You will need it for some fuctions. Get it from here: https://github.com/s-gupta/utils/'); end 5 | if(~exist('rgbdutils', 'dir')), warning('Missing rgbd-utils. You will need it for some functions. Get it from here: https://github.com/s-gupta/rgbdutils'); end 6 | 7 | addPath = {'nyu-hooks', 'scripts', 'mcg', 'utils', 'caffe/matlab/caffe/', 'rgbdutils'}; 8 | genPath = {'structured-edges', 'rcnn'}; 9 | 10 | for i = 1:length(addPath), 11 | addpath(addPath{i}); 12 | end 13 | 14 | for i = 1:length(genPath), 15 | addpath(genpath_exclude(genPath{i}, '.git')); 16 | end 17 | startup_utils; 18 | startup_rgbdutils; 19 | startup_mcg; 20 | fprintf('startup done\n'); 21 | end 22 | -------------------------------------------------------------------------------- /mcg/src/ucms/apply_sigmoid.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function cmap_proba = apply_sigmoid(cmap, thr, fq) 17 | if nargin<3, fq=1; end, 18 | if nargin<2, thr =0.5; end 19 | cmap_proba=cmap; 20 | cmap_proba(:) = 1./(1+exp(-fq*(cmap(:)-thr))); 21 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/lambda.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Lambda abstractions. 3 | */ 4 | #ifndef LANG__LAMBDA_HH 5 | #define LANG__LAMBDA_HH 6 | 7 | #define LambdaXY(X,Y) X##Y 8 | #define LambdaMakeNameXY(FX,LINE) LambdaXY(FX,LINE) 9 | #define LambdaMakeName(FX) LambdaMakeNameXY(FX,__LINE__) 10 | 11 | /* #define _ , */ 12 | 13 | #define lambda(args, ret_type, body) \ 14 | class LambdaMakeName(__lambda__) {\ 15 | public: \ 16 | ret_type operator() args { body; } \ 17 | } 18 | 19 | #define lambda_named(name, args, ret_type, body) \ 20 | class LambdaMakeName(name) { \ 21 | public: \ 22 | ret_type operator() args { body; } \ 23 | } 24 | 25 | #define lambda_derived(parents, args, ret_type, body) \ 26 | class LambdaMakeName(__lambda_derived__) parents {\ 27 | public: \ 28 | ret_type operator() args { body; } \ 29 | } 30 | 31 | #define lambda_named_derived(name, parents, args, ret_type, body) \ 32 | class LambdaMakeName(name) parents { \ 33 | public: \ 34 | ret_type operator() args { body; } \ 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_file_error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File error exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_file_error.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_file_error::ex_file_error(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "file error") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_file_error::ex_file_error(const ex_file_error& e) 24 | : exception(e) 25 | { } 26 | 27 | /* 28 | * Destructor. 29 | */ 30 | ex_file_error::~ex_file_error() { 31 | /* do nothing */ 32 | } 33 | 34 | /* 35 | * Clone the exception. 36 | */ 37 | ex_file_error* ex_file_error::clone() const { 38 | return (new ex_file_error(*this)); 39 | } 40 | 41 | /* 42 | * Throw the exception. 43 | */ 44 | void ex_file_error::raise() const { 45 | throw *this; 46 | } 47 | 48 | } /* namespace exceptions */ 49 | } /* namespace lang */ 50 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/matlab/make.m: -------------------------------------------------------------------------------- 1 | % This make.m is for MATLAB and OCTAVE under Windows, Mac, and Unix 2 | 3 | try 4 | Type = ver; 5 | % This part is for OCTAVE 6 | if(strcmp(Type(1).Name, 'Octave') == 1) 7 | mex libsvmread.c 8 | mex libsvmwrite.c 9 | mex train.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/*.c 10 | mex predict.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/*.c 11 | % This part is for MATLAB 12 | % Add -largeArrayDims on 64-bit machines of MATLAB 13 | else 14 | mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmread.c 15 | mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmwrite.c 16 | mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims train.c linear_model_matlab.c ../linear.cpp ../tron.cpp "../blas/*.c" 17 | mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims predict.c linear_model_matlab.c ../linear.cpp ../tron.cpp "../blas/*.c" 18 | end 19 | catch 20 | fprintf('If make.m fails, please check README about detailed instructions.\n'); 21 | end 22 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/compile_windows.m: -------------------------------------------------------------------------------- 1 | % ******************************************************************** 2 | % * mex File compiling code for Random Forest (for windows) 3 | % * mex interface to Andy Liaw et al.'s C code (used in R package randomForest) 4 | % * Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 5 | % * License: GPLv2 6 | % * Version: 0.02 7 | % ********************************************************************/ 8 | 9 | 10 | function compile_windows 11 | 12 | %need to do tricks for making Makfile run on windows as one needs cygwin. 13 | %so instead use mex to compile everything up. 14 | 15 | if strcmp(computer,'PCWIN64') 16 | system('del *.mexw64;'); 17 | elseif strcmp(computer,'PCWIN') 18 | system('del *.mexw32;'); 19 | end 20 | 21 | mex -O src/cokus.cpp src/reg_RF.cpp src/mex_regressionRF_train.cpp -DMATLAB -output mexRF_train 22 | mex -O src/cokus.cpp src/reg_RF.cpp src/mex_regressionRF_predict.cpp -DMATLAB -output mexRF_predict 23 | 24 | fprintf('\n Mex`s compiled correctly\n') -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_bad_cast.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Bad cast exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_BAD_CAST_HH 5 | #define LANG__EXCEPTIONS__EX_BAD_CAST_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * Bad cast exception. 15 | */ 16 | class ex_bad_cast : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_bad_cast( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_bad_cast(const ex_bad_cast&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_bad_cast(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_bad_cast* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_not_found.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Not found exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_NOT_FOUND_HH 5 | #define LANG__EXCEPTIONS__EX_NOT_FOUND_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * Not found exception. 15 | */ 16 | class ex_not_found : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_not_found( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_not_found(const ex_not_found&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_not_found(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_not_found* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_file_error.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * File error exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_FILE_ERROR_HH 5 | #define LANG__EXCEPTIONS__EX_FILE_ERROR_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * File error exception. 15 | */ 16 | class ex_file_error : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_file_error( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_file_error(const ex_file_error&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_file_error(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_file_error* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/Makefile.win: -------------------------------------------------------------------------------- 1 | #You must ensure nmake.exe, cl.exe, link.exe are in system path. 2 | #VCVARS32.bat 3 | #Under dosbox prompt 4 | #nmake -f Makefile.win 5 | 6 | ########################################## 7 | CXX = cl.exe 8 | CFLAGS = -nologo -O2 -EHsc -I. -D __WIN32__ -D _CRT_SECURE_NO_DEPRECATE 9 | TARGET = windows 10 | 11 | all: $(TARGET)\train.exe $(TARGET)\predict.exe 12 | 13 | $(TARGET)\train.exe: tron.obj linear.obj train.c blas\*.c 14 | $(CXX) $(CFLAGS) -Fe$(TARGET)\train.exe tron.obj linear.obj train.c blas\*.c 15 | 16 | $(TARGET)\predict.exe: tron.obj linear.obj predict.c blas\*.c 17 | $(CXX) $(CFLAGS) -Fe$(TARGET)\predict.exe tron.obj linear.obj predict.c blas\*.c 18 | 19 | linear.obj: linear.cpp linear.h 20 | $(CXX) $(CFLAGS) -c linear.cpp 21 | 22 | tron.obj: tron.cpp tron.h 23 | $(CXX) $(CFLAGS) -c tron.cpp 24 | 25 | lib: linear.cpp linear.h linear.def tron.obj 26 | $(CXX) $(CFLAGS) -LD linear.cpp tron.obj blas\*.c -Fe$(TARGET)\liblinear -link -DEF:linear.def 27 | 28 | clean: 29 | -erase /Q *.obj $(TARGET)\. 30 | 31 | -------------------------------------------------------------------------------- /rcnn/rcnn_pool5_to_fcX.m: -------------------------------------------------------------------------------- 1 | function feat = rcnn_pool5_to_fcX(feat, layer, rcnn_model) 2 | % feat = rcnn_pool5_to_fcX(feat, layer, rcnn_model) 3 | % On-the-fly conversion of pool5 features to fc6 or fc7 4 | % using the weights and biases stored in rcnn_model.cnn.layers. 5 | 6 | % AUTORIGHTS 7 | % --------------------------------------------------------- 8 | % Copyright (c) 2014, Ross Girshick 9 | % 10 | % This file is part of the R-CNN code and is available 11 | % under the terms of the Simplified BSD License provided in 12 | % LICENSE. Please retain this notice and LICENSE if you use 13 | % this file (or any portion of it) in your project. 14 | % --------------------------------------------------------- 15 | 16 | % no-op for layer <= 5 17 | if layer > 5 18 | for i = 6:layer 19 | % weights{1} = matrix of CNN weights [input_dim x output_dim] 20 | % weights{2} = column vector of biases 21 | feat = max(0, bsxfun(@plus, feat*rcnn_model.cnn.layers(i).weights{1}, ... 22 | rcnn_model.cnn.layers(i).weights{2}')); 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /mcg/src/aux/write_jaccard_to_file.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function write_jaccard_to_file( stats, filename ) 17 | 18 | fid = fopen(filename,'w'); 19 | fprintf(fid, 'ncands\tjac_class\tjac_instance\n'); 20 | fprintf(fid, '%d\t%f\t%f\n', [stats.mean_n_masks; stats.jaccard_class; stats.jaccard_object]); 21 | fclose(fid); 22 | 23 | 24 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_not_implemented.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Not implemented exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_not_implemented.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_not_implemented::ex_not_implemented(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "not implemented") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_not_implemented::ex_not_implemented(const ex_not_implemented& e) 24 | : exception(e) 25 | { } 26 | 27 | /* 28 | * Destructor. 29 | */ 30 | ex_not_implemented::~ex_not_implemented() { 31 | /* do nothing */ 32 | } 33 | 34 | /* 35 | * Clone the exception. 36 | */ 37 | ex_not_implemented* ex_not_implemented::clone() const { 38 | return (new ex_not_implemented(*this)); 39 | } 40 | 41 | /* 42 | * Throw the exception. 43 | */ 44 | void ex_not_implemented::raise() const { 45 | throw *this; 46 | } 47 | 48 | } /* namespace exceptions */ 49 | } /* namespace lang */ 50 | -------------------------------------------------------------------------------- /mcg/src/aux/plot_one_soa.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | 17 | function new_legends = plot_one_soa(soa, id, measure, color, old_legends) 18 | if isfield(soa,id) 19 | plot(soa.(id).mean_n_masks, soa.(id).(measure), color) 20 | new_legends = {old_legends{:}, soa.(id).id}; 21 | else 22 | new_legends = old_legends; 23 | end 24 | 25 | end 26 | 27 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/compile_linux.m: -------------------------------------------------------------------------------- 1 | % ******************************************************************** 2 | % * mex File compiling code for Random Forest (for linux) 3 | % * mex interface to Andy Liaw et al.'s C code (used in R package randomForest) 4 | % * Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 5 | % * License: GPLv2 6 | % * Version: 0.02 7 | % ********************************************************************/ 8 | 9 | function compile_linux 10 | 11 | % a simple way to compile on linux is to call the Makefile with 'make mex' 12 | system('rm *.mexglx *.mexa64;'); 13 | 14 | %Matlab mex requires optimization to be all set in the mexopts.sh(or 15 | %.bat) file. So set it there not here 16 | 17 | %if you want to emulate what the makefile does ucomment below 2 lines: 18 | mex src/mex_regressionRF_train.cpp src/reg_RF.cpp src/cokus.cpp -o mexRF_train -DMATLAB 19 | mex src/mex_regressionRF_predict.cpp src/reg_RF.cpp src/cokus.cpp -o mexRF_predict -DMATLAB 20 | 21 | % system('make mex;'); 22 | 23 | fprintf('Mex compiled\n') 24 | 25 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_invalid_argument.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Invalid argument exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_invalid_argument.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_invalid_argument::ex_invalid_argument(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "invalid argument") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_invalid_argument::ex_invalid_argument(const ex_invalid_argument& e) 24 | : exception(e) 25 | { } 26 | 27 | /* 28 | * Destructor. 29 | */ 30 | ex_invalid_argument::~ex_invalid_argument() { 31 | /* do nothing */ 32 | } 33 | 34 | /* 35 | * Clone the exception. 36 | */ 37 | ex_invalid_argument* ex_invalid_argument::clone() const { 38 | return (new ex_invalid_argument(*this)); 39 | } 40 | 41 | /* 42 | * Throw the exception. 43 | */ 44 | void ex_invalid_argument::raise() const { 45 | throw *this; 46 | } 47 | 48 | } /* namespace exceptions */ 49 | } /* namespace lang */ 50 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_not_implemented.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Not implemented exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_NOT_IMPLEMENTED_HH 5 | #define LANG__EXCEPTIONS__EX_NOT_IMPLEMENTED_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * Not implemented exception. 15 | */ 16 | class ex_not_implemented : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_not_implemented( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_not_implemented(const ex_not_implemented&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_not_implemented(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_not_implemented* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_invalid_argument.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Invalid argument exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_INVALID_ARGUMENT_HH 5 | #define LANG__EXCEPTIONS__EX_INVALID_ARGUMENT_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * Invalid argument exception. 15 | */ 16 | class ex_invalid_argument : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_invalid_argument( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_invalid_argument(const ex_invalid_argument&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_invalid_argument(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_invalid_argument* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mcg/src/aux/ms_matrix2struct.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | 17 | function ms_struct = ms_matrix2struct( ms_matrix ) 18 | for ii=1:size(ms_matrix,1) 19 | ms_struct(ii).parent = ms_matrix(ii,end); %#ok 20 | children = ms_matrix(ii,1:end-1); 21 | children(children==0) = []; 22 | ms_struct(ii).children = children; %#ok 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /mcg/src/bboxes/box2mask.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function mask = box2mask( bbox, sx, sy ) 17 | % up = bbox(1); 18 | % left = bbox(2); 19 | % down = bbox(3); 20 | % right = bbox(4); 21 | 22 | horiz = zeros(1,sy); 23 | vert = zeros(1,sx); 24 | horiz(bbox(2):bbox(4)) = 1; 25 | vert(bbox(1):bbox(3)) = 1; 26 | mask = vert'*horiz; 27 | end 28 | 29 | -------------------------------------------------------------------------------- /mcg/src/bboxes/mask2box.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function bbox = mask2box( mask ) 17 | tmp = regionprops(double(mask),'BoundingBox'); % Double to force a single bbox 18 | bbox(1) = tmp.BoundingBox(2)+0.5; 19 | bbox(2) = tmp.BoundingBox(1)+0.5; 20 | bbox(3) = tmp.BoundingBox(2)+tmp.BoundingBox(4)-0.5; 21 | bbox(4) = tmp.BoundingBox(1)+tmp.BoundingBox(3)-0.5; 22 | end 23 | 24 | -------------------------------------------------------------------------------- /structured-edges/ng/yCues.m: -------------------------------------------------------------------------------- 1 | function [y1 y2 y3 angl1 angl2] = yCues(D, C, s) 2 | % function [y1 y2 y3 angl1 angl2] = yCues(D, C, s) 3 | % Expects D to be in centimetres 4 | % The camera matrix from somewhere 5 | % C = getCameraParam('color', 'nyu2'); 6 | % C = fixCamera(C); 7 | 8 | % AUTORIGHTS 9 | 10 | % Compute the normals, wrapperComputeNormals expects input in m 11 | [N, b, pc] = wrapperComputeNormals(double(D)./100, false(size(D)), 3, s, C); 12 | 13 | % Compute the direction with gravity 14 | yDirParam.angleThresh = [45 15]; 15 | yDirParam.iter = [5 5]; 16 | yDirParam.y0 = [0 1 0]'; 17 | yDir = getYDir(N, yDirParam); 18 | 19 | % Compute the height above ground 20 | y0 = [0 1 0]'; 21 | R = getRMatrix2(y0,yDir); pcRot = rotatePC(pc,R'); yMin = min(linIt(pcRot(:,:,2))); 22 | y = fillHoles(pcRot(:,:,2)); y = -y; yMin = min(y(:)); 23 | if(yMin > -90) yMin = -130; end; y = y-yMin; 24 | y1 = pc(:,:,2); 25 | y2 = pcRot(:,:,2); 26 | y3 = y; 27 | 28 | % Compute the angle with gravity vector 29 | angl1 = sum(bsxfun(@times, N, reshape(yDirParam.y0, 1, 1, 3)), 3); 30 | angl2 = sum(bsxfun(@times, N, reshape(yDir, 1, 1, 3)), 3); 31 | end 32 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/ictest.m: -------------------------------------------------------------------------------- 1 | 2 | addpath /home/fowlkes/gpb_owt/grouping/lib/ 3 | outFile = '/home/fowlkes/gpb_owt/grouping/data/101087_gPb.mat_pbs.mat'; 4 | simFile = '/home/fowlkes/gpb_owt/grouping/data/101087_gPb.mat_pbs.mat_sim.tmp'; 5 | imgFile = '/home/fowlkes/gpb_owt/grouping/data/101087_gPb.mat_pbs.mat_img.jpg'; 6 | latFile = '/home/fowlkes/gpb_owt/grouping/data/101087_gPb.mat_pbs.mat_lat.tmp'; 7 | load /home/fowlkes/gpb_owt/grouping/data/mPb.mat %load in mPb data. 8 | 9 | % 10 | % old code 11 | % 12 | l{1} = zeros(size(mPb, 1) + 1, size(mPb, 2)); 13 | l{1}(2:end, :) = mPb; 14 | l{2} = zeros(size(mPb, 1), size(mPb, 2) + 1); 15 | l{2}(:, 2:end) = mPb; 16 | latFile = strcat(outFile, '_lat.tmp'); 17 | write_array(latFile, l); 18 | 19 | system(sprintf('/home/fowlkes/gpb_owt/grouping/lib/segment -image %s -smatrixfile %s -readlattice true -latticefile %s -dthresh 5', imgFile, simFile, latFile)); 20 | Wold = read_smatrix(simFile); 21 | 22 | 23 | % 24 | % new code 25 | % 26 | 27 | % mex buildW.cpp -Iutil smatrix.cc ic.cc affinity.cc util/libutil.a 28 | 29 | [x,y,z] = buildW(l{1},l{2}); 30 | Wnew = sparse(x,y,z); 31 | 32 | sum(sum( (Wold-Wnew).^2 )) 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/Makefile: -------------------------------------------------------------------------------- 1 | CXX ?= g++ 2 | CC ?= gcc 3 | CFLAGS = -Wall -Wconversion -O3 -fPIC 4 | LIBS = blas/blas.a 5 | SHVER = 1 6 | OS = $(shell uname) 7 | #LIBS = -lblas 8 | 9 | all: train predict 10 | 11 | lib: linear.o tron.o blas/blas.a 12 | if [ "$(OS)" = "Darwin" ]; then \ 13 | SHARED_LIB_FLAG="-dynamiclib -Wl,-install_name,liblinear.so.$(SHVER)"; \ 14 | else \ 15 | SHARED_LIB_FLAG="-shared -Wl,-soname,liblinear.so.$(SHVER)"; \ 16 | fi; \ 17 | $(CXX) $${SHARED_LIB_FLAG} linear.o tron.o blas/blas.a -o liblinear.so.$(SHVER) 18 | 19 | train: tron.o linear.o train.c blas/blas.a 20 | $(CXX) $(CFLAGS) -o train train.c tron.o linear.o $(LIBS) 21 | 22 | predict: tron.o linear.o predict.c blas/blas.a 23 | $(CXX) $(CFLAGS) -o predict predict.c tron.o linear.o $(LIBS) 24 | 25 | tron.o: tron.cpp tron.h 26 | $(CXX) $(CFLAGS) -c -o tron.o tron.cpp 27 | 28 | linear.o: linear.cpp linear.h 29 | $(CXX) $(CFLAGS) -c -o linear.o linear.cpp 30 | 31 | blas/blas.a: blas/*.c blas/*.h 32 | make -C blas OPTFLAGS='$(CFLAGS)' CC='$(CC)'; 33 | 34 | clean: 35 | make -C blas clean 36 | make -C matlab clean 37 | rm -f *~ tron.o linear.o train predict liblinear.so.$(SHVER) 38 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_null_pointer_dereference.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Null pointer dereference exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_NULL_POINTER_DEREFERENCE_HH 5 | #define LANG__EXCEPTIONS__EX_NULL_POINTER_DEREFERENCE_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * Null pointer dereference exception. 15 | */ 16 | class ex_null_pointer_dereference : public exception { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_null_pointer_dereference( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_null_pointer_dereference(const ex_null_pointer_dereference&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_null_pointer_dereference(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_null_pointer_dereference* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | }; 45 | 46 | } /* namespace exceptions */ 47 | } /* namespace lang */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mcg/src/tests/test_base_perimeters.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % 5 | % Jordi Pont-Tuset 6 | % June 2013 7 | % ------------------------------------------------------------------------ 8 | 9 | lp = [1 1 2 10 | 1 2 2 11 | 3 4 5]; 12 | [~,neighs] = seg2gridbmap(lp,1); 13 | nregs = max(lp(:)); 14 | K = max(neighs.matrix_max(:)) + 1; 15 | neigh_pairs_matrix = neighs.matrix_min+K*neighs.matrix_max; 16 | neigh_pairs = unique(neigh_pairs_matrix); 17 | neigh_pairs(neigh_pairs==0) = []; 18 | neigh_pairs_min = mod(neigh_pairs,K); 19 | neigh_pairs_max = (neigh_pairs-neigh_pairs_min)/K; 20 | 21 | [perims,b_perims] = mex_base_perimeters(nregs,neigh_pairs_min,neigh_pairs_max,neigh_pairs,neigh_pairs_matrix,ones(size(neigh_pairs_matrix))); 22 | assert(isequal(perims,[0 3 1 0 0 23 | 0 0 0 1 1 24 | 0 0 0 1 0 25 | 0 0 0 0 1 26 | 0 0 0 0 0])); 27 | 28 | assert(isequal(b_perims,[4 3 2 1 2]')); -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_null_pointer_dereference.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Null pointer dereference exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_null_pointer_dereference.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_null_pointer_dereference::ex_null_pointer_dereference(const char* msg) 15 | : exception( 16 | ((msg != NULL) ? msg : "null pointer dereference") 17 | ) 18 | { } 19 | 20 | /* 21 | * Copy constructor. 22 | */ 23 | ex_null_pointer_dereference::ex_null_pointer_dereference( 24 | const ex_null_pointer_dereference& e) 25 | : exception(e) 26 | { } 27 | 28 | /* 29 | * Destructor. 30 | */ 31 | ex_null_pointer_dereference::~ex_null_pointer_dereference() { 32 | /* do nothing */ 33 | } 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | ex_null_pointer_dereference* ex_null_pointer_dereference::clone() const { 39 | return (new ex_null_pointer_dereference(*this)); 40 | } 41 | 42 | /* 43 | * Throw the exception. 44 | */ 45 | void ex_null_pointer_dereference::raise() const { 46 | throw *this; 47 | } 48 | 49 | } /* namespace exceptions */ 50 | } /* namespace lang */ 51 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/matrices/exceptions/ex_matrix_singular.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Singular matrix exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/null.hh" 6 | #include "math/matrices/exceptions/ex_matrix_singular.hh" 7 | 8 | namespace math { 9 | namespace matrices { 10 | namespace exceptions { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::exceptions::exception; 15 | 16 | /* 17 | * Constructor. 18 | */ 19 | ex_matrix_singular::ex_matrix_singular(const char* msg) 20 | : exception( 21 | ((msg != NULL) ? msg : "singular matrix") 22 | ) 23 | { } 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_matrix_singular::ex_matrix_singular(const ex_matrix_singular& e) 29 | : exception(e) 30 | { } 31 | 32 | /* 33 | * Destructor. 34 | */ 35 | ex_matrix_singular::~ex_matrix_singular() { 36 | /* do nothing */ 37 | } 38 | 39 | /* 40 | * Clone the exception. 41 | */ 42 | ex_matrix_singular* ex_matrix_singular::clone() const { 43 | return (new ex_matrix_singular(*this)); 44 | } 45 | 46 | /* 47 | * Throw the exception. 48 | */ 49 | void ex_matrix_singular::raise() const { 50 | throw *this; 51 | } 52 | 53 | } /* namespace exceptions */ 54 | } /* namespace matrices */ 55 | } /* namespace math */ 56 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/dscal.c: -------------------------------------------------------------------------------- 1 | #include "blas.h" 2 | 3 | int dscal_(int *n, double *sa, double *sx, int *incx) 4 | { 5 | long int i, m, nincx, nn, iincx; 6 | double ssa; 7 | 8 | /* scales a vector by a constant. 9 | uses unrolled loops for increment equal to 1. 10 | jack dongarra, linpack, 3/11/78. 11 | modified 3/93 to return if incx .le. 0. 12 | modified 12/3/93, array(1) declarations changed to array(*) */ 13 | 14 | /* Dereference inputs */ 15 | nn = *n; 16 | iincx = *incx; 17 | ssa = *sa; 18 | 19 | if (nn > 0 && iincx > 0) 20 | { 21 | if (iincx == 1) /* code for increment equal to 1 */ 22 | { 23 | m = nn-4; 24 | for (i = 0; i < m; i += 5) 25 | { 26 | sx[i] = ssa * sx[i]; 27 | sx[i+1] = ssa * sx[i+1]; 28 | sx[i+2] = ssa * sx[i+2]; 29 | sx[i+3] = ssa * sx[i+3]; 30 | sx[i+4] = ssa * sx[i+4]; 31 | } 32 | for ( ; i < nn; ++i) /* clean-up loop */ 33 | sx[i] = ssa * sx[i]; 34 | } 35 | else /* code for increment not equal to 1 */ 36 | { 37 | nincx = nn * iincx; 38 | for (i = 0; i < nincx; i += iincx) 39 | sx[i] = ssa * sx[i]; 40 | } 41 | } 42 | 43 | return 0; 44 | } /* dscal_ */ 45 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/matrices/exceptions/ex_matrix_singular.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Singular matrix exception. 3 | */ 4 | #ifndef MATH__MATRICES__EXCEPTIONS__MATRIX_SINGULAR_HH 5 | #define MATH__MATRICES__EXCEPTIONS__MATRIX_SINGULAR_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace math { 11 | namespace matrices { 12 | namespace exceptions { 13 | /* 14 | * Imports. 15 | */ 16 | using lang::exceptions::exception; 17 | 18 | /* 19 | * Singular matrix exception. 20 | */ 21 | class ex_matrix_singular : public exception { 22 | public: 23 | /* 24 | * Constructor. 25 | */ 26 | explicit ex_matrix_singular( 27 | const char* = NULL /* message (use default if NULL) */ 28 | ); 29 | 30 | /* 31 | * Copy constructor. 32 | */ 33 | ex_matrix_singular(const ex_matrix_singular&); 34 | 35 | /* 36 | * Destructor. 37 | */ 38 | virtual ~ex_matrix_singular(); 39 | 40 | /* 41 | * Clone the exception. 42 | */ 43 | virtual ex_matrix_singular* clone() const; 44 | 45 | /* 46 | * Throw the exception. 47 | */ 48 | virtual void raise() const; 49 | }; 50 | 51 | } /* namespace exceptions */ 52 | } /* namespace matrices */ 53 | } /* namespace math */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /mcg/src/ucms/project_ucms_wrap.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function ucms_sp = project_ucms_wrap(ucms,thr) 17 | 18 | ucms_sp=zeros([size(ucms{1},1),size(ucms{1},2),numel(ucms)]); 19 | 20 | for d = 1:numel(ucms), 21 | ucm_sp = ucms{d}; 22 | for u = d:-1:2 23 | labels2 = bwlabel(ucms{u-1} <= thr); 24 | superpixels = labels2(2:2:end, 2:2:end); 25 | [ucm_sp] = resample_ucm2_sp(ucm_sp, superpixels); 26 | end 27 | ucms_sp(:,:,d) = ucm_sp; 28 | end 29 | 30 | -------------------------------------------------------------------------------- /rcnn/boxoverlap.m: -------------------------------------------------------------------------------- 1 | function o = boxoverlap(a, b) 2 | % Compute the symmetric intersection over union overlap between a set of 3 | % bounding boxes in a and a single bounding box in b. 4 | % 5 | % a a matrix where each row specifies a bounding box 6 | % b a single bounding box 7 | 8 | % AUTORIGHTS 9 | % ------------------------------------------------------- 10 | % Copyright (C) 2011-2012 Ross Girshick 11 | % Copyright (C) 2008, 2009, 2010 Pedro Felzenszwalb, Ross Girshick 12 | % 13 | % This file is part of the voc-releaseX code 14 | % (http://people.cs.uchicago.edu/~rbg/latent/) 15 | % and is available under the terms of an MIT-like license 16 | % provided in COPYING. Please retain this notice and 17 | % COPYING if you use this file (or a portion of it) in 18 | % your project. 19 | % ------------------------------------------------------- 20 | 21 | x1 = max(a(:,1), b(1)); 22 | y1 = max(a(:,2), b(2)); 23 | x2 = min(a(:,3), b(3)); 24 | y2 = min(a(:,4), b(4)); 25 | 26 | w = x2-x1+1; 27 | h = y2-y1+1; 28 | inter = w.*h; 29 | aarea = (a(:,3)-a(:,1)+1) .* (a(:,4)-a(:,2)+1); 30 | barea = (b(3)-b(1)+1) * (b(4)-b(2)+1); 31 | % intersection over union overlap 32 | o = inter ./ (aarea+barea-inter); 33 | % set invalid entries to 0 overlap 34 | o(w <= 0) = 0; 35 | o(h <= 0) = 0; 36 | -------------------------------------------------------------------------------- /mcg/src/aux/cands2masks.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | % 17 | % function masks = cands2masks(candidates,lp,ms) 18 | % 19 | % From a hierarchy (lp: leaves partition and ms: merging sequence) and a 20 | % list of candidates as sets of labels (candidates), we get all the binary 21 | % masks of these candidates 22 | % ------------------------------------------------------------------------ 23 | function masks = cands2masks(candidates,lp,ms) 24 | masks = mex_cands2masks(double(lp),double(ms),candidates); 25 | end 26 | 27 | 28 | -------------------------------------------------------------------------------- /mcg/src/aux/cands2labels.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | % 17 | % function masks = cands2labels(candidates,ms) 18 | % 19 | % From a hierarchy (lp: leaves partition and ms: merging sequence) and a 20 | % list of candidates as sets of labels (candidates), we get each candidate 21 | % as a list of labels of the leaves partition lp. 22 | % ------------------------------------------------------------------------ 23 | function labels = cands2labels(candidates,ms) 24 | labels = mex_cands2labels(double(ms),candidates); 25 | end 26 | 27 | 28 | -------------------------------------------------------------------------------- /mcg/datasets/get_ground_truth.m: -------------------------------------------------------------------------------- 1 | function ground_truth = get_ground_truth( database, image_id ) 2 | if strcmp(database,'pascal2012') 3 | ground_truth.object = imread(fullfile(database_root_dir(database), 'SegmentationObject', [image_id '.png'])); 4 | ground_truth.class = imread(fullfile(database_root_dir(database), 'SegmentationClass', [image_id '.png'])); 5 | elseif strcmp(database,'bsds500') 6 | ground_truth = loadvar(fullfile(database_root_dir(database), 'ground_truth', [image_id '.mat']),'gt_seg'); 7 | elseif strcmp(database,'nyud40Obj') 8 | ground_truth.object = getGroundTruth(image_id, 'instance'); 9 | ground_truth.class = getGroundTruth(image_id, 'segmentation', 'classMapping40'); 10 | ground_truth.class(ismember(ground_truth.class, [1 2 8 22 38])) = 0; %tmp.groundTruth{1}.SegmentationClass; 11 | % Remove class 0 instances 12 | ground_truth.object(ground_truth.class == 0) = 0; 13 | obj = ground_truth.object; 14 | newobj = zeros(size(obj)); 15 | uq = unique(obj(obj > 0)); 16 | for i = 1:length(uq), 17 | newobj(obj == uq(i)) = i; 18 | end 19 | ground_truth.object = newobj; 20 | else 21 | error(['Unknown database: ' database]); 22 | end 23 | end 24 | 25 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/vision/segmentation/region.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Region. 3 | */ 4 | #ifndef VISION__SEGMENTATION__REGION_HH 5 | #define VISION__SEGMENTATION__REGION_HH 6 | 7 | #include "collections/map.hh" 8 | 9 | namespace vision { 10 | namespace segmentation { 11 | /* 12 | * Imports. 13 | */ 14 | using collections::map; 15 | 16 | /* 17 | * Region. 18 | */ 19 | class region { 20 | public: 21 | /* 22 | * Constructor. 23 | */ 24 | region(); 25 | 26 | /* 27 | * Copy constructor. 28 | */ 29 | region(const region&); 30 | 31 | /* 32 | * Destructor. 33 | */ 34 | virtual ~region(); 35 | 36 | /* 37 | * Region id and connectivity. 38 | * Map of region id -> id of shared boundary. 39 | */ 40 | unsigned long _id; 41 | map _boundary_map; 42 | 43 | /* 44 | * Region data. 45 | */ 46 | unsigned long _size; /* number of pixels in region */ 47 | double _sum_L; /* sums for L channel */ 48 | double _sum_L2; 49 | double _sum_a; /* sums for a channel */ 50 | double _sum_a2; 51 | double _sum_b; /* sums for b channel */ 52 | double _sum_b2; 53 | }; 54 | 55 | } /* namespace segmentation */ 56 | } /* namespace vision */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /mcg/mcg_root_dir.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % 5 | % Jordi Pont-Tuset 6 | % June 2013 7 | % ------------------------------------------------------------------------ 8 | % Code obtained from: 9 | % https://imatge.upc.edu/web/resources/supervised-evaluation-image-segmentation 10 | % ------------------------------------------------------------------------ 11 | % This file is part of the SEISM package presented in: 12 | % Jordi Pont-Tuset, Ferran Marques, 13 | % "Measures and Meta-Measures for the Supervised Evaluation of Image Segmentation," 14 | % Computer Vision and Pattern Recognition (CVPR), 2013. 15 | % If you use this code, please consider citing the paper. 16 | % ------------------------------------------------------------------------ 17 | % 18 | % This function returns the root directory where the package is installed. 19 | % Before running the script 'install.m', this directory should be updated 20 | % 21 | % ------------------------------------------------------------------------ 22 | 23 | function mcg_root_dir = mcg_root_dir() 24 | mcg_root_dir = fullfile(fileparts(mfilename('fullpath'))); %pwd(), 'regions'); 25 | end 26 | -------------------------------------------------------------------------------- /mcg/src/aux/gridbmap2seg.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | % seg = gridbmap2seg(gridbmap) 17 | % 18 | % From a binary boundary map in the countour grid (as ucm2), get 19 | % the represented partition as matrix of labels in the image plane 20 | % 21 | % INPUT 22 | % - gridbmap : Binary boundary map on contour grid. 23 | % 24 | % OUTPUT 25 | % - seg : Segments labeled from 1..k. 26 | function seg = gridbmap2seg(gridbmap) 27 | tmp = gridbmap; 28 | tmp(1:2:end,1:2:end)=1; 29 | filled_contours = bwlabel(1-tmp',4); 30 | seg = filled_contours(2:2:end,2:2:end)'; 31 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/hashable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Hashable interface. 3 | */ 4 | #ifndef INTERFACES__HASHABLE_HH 5 | #define INTERFACES__HASHABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template interface for hashable objects. 11 | * 12 | * If a class X extends hashable then: 13 | * (1) X must be a T, and 14 | * (2) X must hash to an object of type H via its hash() method. 15 | * 16 | * Note that the interface is the same regardless of T's const qualifier. 17 | */ 18 | template 19 | class hashable { 20 | public: 21 | /* 22 | * Destructor. 23 | */ 24 | virtual ~hashable(); 25 | 26 | /* 27 | * Function for hashing a hashable object. 28 | */ 29 | static H& hash(const hashable&); 30 | 31 | /* 32 | * Hash method. 33 | */ 34 | virtual H& hash() const = 0; 35 | }; 36 | 37 | template 38 | class hashable : public hashable { }; 39 | 40 | /* 41 | * Destructor. 42 | */ 43 | template 44 | hashable::~hashable() { } 45 | 46 | /* 47 | * Function for hashing a hashable object. 48 | */ 49 | template 50 | H& hashable::hash(const hashable& t) { 51 | return (t.hash()); 52 | } 53 | 54 | } /* namespace interfaces */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_index_out_of_bounds.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Index out of bounds exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_INDEX_OUT_OF_BOUNDS_HH 5 | #define LANG__EXCEPTIONS__EX_INDEX_OUT_OF_BOUNDS_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | 9 | namespace lang { 10 | namespace exceptions { 11 | 12 | /* 13 | * Index out of bounds exception. 14 | */ 15 | class ex_index_out_of_bounds : public exception { 16 | public: 17 | /* 18 | * Constructor. 19 | */ 20 | explicit ex_index_out_of_bounds( 21 | const char*, /* message (use default if NULL) */ 22 | unsigned long /* index */ 23 | ); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_index_out_of_bounds(const ex_index_out_of_bounds&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~ex_index_out_of_bounds(); 34 | 35 | /* 36 | * Clone the exception. 37 | */ 38 | virtual ex_index_out_of_bounds* clone() const; 39 | 40 | /* 41 | * Throw the exception. 42 | */ 43 | virtual void raise() const; 44 | 45 | /* 46 | * Get the out-of-bounds index. 47 | */ 48 | virtual unsigned long index() const; 49 | 50 | protected: 51 | unsigned long _index; /* index */ 52 | }; 53 | 54 | } /* namespace exceptions */ 55 | } /* namespace lang */ 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/iterable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Iterable interface. 3 | */ 4 | #ifndef INTERFACES__ITERABLE_HH 5 | #define INTERFACES__ITERABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template interface for iterables. 11 | * 12 | * If a class extends iterable then it must define a method (iter_apply) 13 | * that can be used as an iterator over collections of objects of type T. 14 | */ 15 | template 16 | class iterable { 17 | public: 18 | /* 19 | * Destructor. 20 | */ 21 | virtual ~iterable(); 22 | 23 | /* 24 | * Iterate method. 25 | */ 26 | virtual void iter_apply(T&) const = 0; 27 | }; 28 | 29 | template 30 | iterable::~iterable() { } 31 | 32 | /* 33 | * An interable over const T also serves as an interable over T. 34 | */ 35 | template 36 | class iterable : public iterable { 37 | public: 38 | /* 39 | * Iterate method. 40 | * Call the iter_apply version for const items. 41 | */ 42 | void iter_apply(T&) const; 43 | 44 | /* 45 | * Iterate method. 46 | */ 47 | virtual void iter_apply(const T&) const = 0; 48 | }; 49 | 50 | template 51 | void iterable::iter_apply(T& t) const { 52 | const T& t_const = t; 53 | this->iter_apply(t_const); 54 | } 55 | 56 | } /* namespace interfaces */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/matrices/exceptions/ex_matrix_dimension_mismatch.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Matrix dimension mismatch exception. 3 | */ 4 | #ifndef MATH__MATRICES__EXCEPTIONS__MATRIX_DIMENSION_MISMATCH_HH 5 | #define MATH__MATRICES__EXCEPTIONS__MATRIX_DIMENSION_MISMATCH_HH 6 | 7 | #include "lang/exceptions/exception.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace math { 11 | namespace matrices { 12 | namespace exceptions { 13 | /* 14 | * Imports. 15 | */ 16 | using lang::exceptions::exception; 17 | 18 | /* 19 | * Matrix dimension mismatch exception. 20 | */ 21 | class ex_matrix_dimension_mismatch : public exception { 22 | public: 23 | /* 24 | * Constructor. 25 | */ 26 | explicit ex_matrix_dimension_mismatch( 27 | const char* = NULL /* message (use default if NULL) */ 28 | ); 29 | 30 | /* 31 | * Copy constructor. 32 | */ 33 | ex_matrix_dimension_mismatch(const ex_matrix_dimension_mismatch&); 34 | 35 | /* 36 | * Destructor. 37 | */ 38 | virtual ~ex_matrix_dimension_mismatch(); 39 | 40 | /* 41 | * Clone the exception. 42 | */ 43 | virtual ex_matrix_dimension_mismatch* clone() const; 44 | 45 | /* 46 | * Throw the exception. 47 | */ 48 | virtual void raise() const; 49 | }; 50 | 51 | } /* namespace exceptions */ 52 | } /* namespace matices */ 53 | } /* namespace math */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/random/generators/rand_gen_normal.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file implements helper functions for generators that produce 3 | * normally distributed pseudorandom numbers. 4 | */ 5 | #include "math/random/generators/rand_gen_normal.hh" 6 | #include "math/random/sources/rand_source.hh" 7 | 8 | namespace math { 9 | namespace random { 10 | namespace generators { 11 | /* 12 | * Imports. 13 | */ 14 | using math::random::sources::rand_source; 15 | 16 | /* 17 | * Pure virtual destructor. 18 | */ 19 | rand_gen_normal_base::~rand_gen_normal_base() { } 20 | 21 | /* 22 | * Overloaded functions for generating normally distributed pseudorandom 23 | * elements of the built-in floating point types. 24 | */ 25 | float rand_gen_normal_base::generate( 26 | rand_source& r, 27 | float mean, 28 | float variance) 29 | { 30 | return r.gen_normal_float(mean, variance); 31 | } 32 | 33 | double rand_gen_normal_base::generate( 34 | rand_source& r, 35 | double mean, 36 | double variance) 37 | { 38 | return r.gen_normal_double(mean, variance); 39 | } 40 | 41 | long double rand_gen_normal_base::generate( 42 | rand_source& r, 43 | long double mean, 44 | long double variance) 45 | { 46 | return r.gen_normal_long_double(mean, variance); 47 | } 48 | 49 | } /* namespace generators */ 50 | } /* namespace random */ 51 | } /* namespace math */ 52 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_file_open_error.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * File open error exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_FILE_OPEN_ERROR_HH 5 | #define LANG__EXCEPTIONS__EX_FILE_OPEN_ERROR_HH 6 | 7 | #include "lang/exceptions/ex_file_error.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * File open error exception. 15 | */ 16 | class ex_file_open_error : public ex_file_error { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_file_open_error( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and mode. 28 | */ 29 | explicit ex_file_open_error( 30 | const char*, /* filename */ 31 | const char* /* mode */ 32 | ); 33 | 34 | /* 35 | * Copy constructor. 36 | */ 37 | ex_file_open_error(const ex_file_open_error&); 38 | 39 | /* 40 | * Destructor. 41 | */ 42 | virtual ~ex_file_open_error(); 43 | 44 | /* 45 | * Clone the exception. 46 | */ 47 | virtual ex_file_open_error* clone() const; 48 | 49 | /* 50 | * Throw the exception. 51 | */ 52 | virtual void raise() const; 53 | }; 54 | 55 | } /* namespace exceptions */ 56 | } /* namespace lang */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_index_out_of_bounds.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Index out of bounds exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/exceptions/ex_index_out_of_bounds.hh" 6 | #include "lang/null.hh" 7 | 8 | namespace lang { 9 | namespace exceptions { 10 | 11 | /* 12 | * Constructor. 13 | */ 14 | ex_index_out_of_bounds::ex_index_out_of_bounds( 15 | const char* msg, 16 | unsigned long idx) 17 | : exception( 18 | ((msg != NULL) ? msg : "index out of bounds") 19 | ), 20 | _index(idx) 21 | { } 22 | 23 | /* 24 | * Copy constructor. 25 | */ 26 | ex_index_out_of_bounds::ex_index_out_of_bounds(const ex_index_out_of_bounds& e) 27 | : exception(e), 28 | _index(e._index) 29 | { } 30 | 31 | /* 32 | * Destructor. 33 | */ 34 | ex_index_out_of_bounds::~ex_index_out_of_bounds() { 35 | /* do nothing */ 36 | } 37 | 38 | /* 39 | * Clone the exception. 40 | */ 41 | ex_index_out_of_bounds* ex_index_out_of_bounds::clone() const { 42 | return (new ex_index_out_of_bounds(*this)); 43 | } 44 | 45 | /* 46 | * Throw the exception. 47 | */ 48 | void ex_index_out_of_bounds::raise() const { 49 | throw *this; 50 | } 51 | 52 | /* 53 | * Get the out-of-bounds index. 54 | */ 55 | unsigned long ex_index_out_of_bounds::index() const { 56 | return _index; 57 | } 58 | 59 | } /* namespace exceptions */ 60 | } /* namespace lang */ 61 | -------------------------------------------------------------------------------- /mcg/depth_features/processDepthImage.m: -------------------------------------------------------------------------------- 1 | function [pc, N, yDir, h, pcRot, NRot] = processDepthImage(z, missingMask, C) 2 | % function [pc, N, yDir, h, pcRot, NRot] = processDepthImage(z, missingMask, C) 3 | % Input: 4 | % z is in centimetres 5 | % C is the camera matrix 6 | 7 | % AUTORIGHTS 8 | 9 | yDirParam.angleThresh = [45 15]; 10 | yDirParam.iter = [5 5]; 11 | yDirParam.y0 = [0 1 0]'; 12 | 13 | normalParam.patchSize = [3 10]; 14 | 15 | [X, Y, Z] = getPointCloudFromZ(z, C, 1); 16 | pc = cat(3, X, Y, Z); 17 | 18 | % Compute the normals for this image 19 | [N1 b1] = computeNormalsSquareSupport(z./100, missingMask, normalParam.patchSize(1),... 20 | 1, C, ones(size(z))); 21 | [N2 b2] = computeNormalsSquareSupport(z./100, missingMask, normalParam.patchSize(2),... 22 | 1, C, ones(size(z))); 23 | % [N1 b1] = computeNormals2(pc(:,:,1), pc(:,:,2), pc(:,:,3), ones(size(pc(:,:,1))), normalParam.patchSize(1)); 24 | % [N2 b2] = computeNormals2(pc(:,:,1), pc(:,:,2), pc(:,:,3), ones(size(pc(:,:,1))), normalParam.patchSize(2)); 25 | 26 | N = N1; 27 | 28 | % Compute the direction of gravity 29 | yDir = getYDir(N2, yDirParam); 30 | y0 = [0 1 0]'; 31 | R = getRMatrix(y0, yDir); 32 | NRot = rotatePC(N, R'); 33 | pcRot = rotatePC(pc, R'); 34 | h = -pcRot(:,:,2); 35 | yMin = prctile(h(:), 0); if(yMin > -90) yMin = -130; end 36 | h = h-yMin; 37 | end 38 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/mappable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Mappable interface. 3 | */ 4 | #ifndef INTERFACES__MAPPABLE_HH 5 | #define INTERFACES__MAPPABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template class for mappables. 11 | * If a class extends mappable then it must define a method (map_apply) 12 | * that can be used to map objects of type T to objects of type U. 13 | */ 14 | template 15 | class mappable { 16 | public: 17 | /* 18 | * Destructor. 19 | */ 20 | virtual ~mappable(); 21 | 22 | /* 23 | * Map method. 24 | */ 25 | virtual U& map_apply(T&) const = 0; 26 | }; 27 | 28 | template 29 | mappable::~mappable() { } 30 | 31 | /* 32 | * A mappable over const T also serves as a mappable over T. 33 | */ 34 | template 35 | class mappable : public mappable { 36 | public: 37 | /* 38 | * Map method. 39 | * Call the map_apply version for const items. 40 | */ 41 | U& map_apply(T&) const; 42 | 43 | /* 44 | * Map method. 45 | */ 46 | virtual U& map_apply(const T&) const = 0; 47 | }; 48 | 49 | template 50 | U& mappable::map_apply(T& t) const { 51 | const T& t_const = t; 52 | return (this->map_apply(t_const)); 53 | } 54 | 55 | } /* namespace interfaces */ 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/affinity.hh: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2002 Charless C. Fowlkes 2 | // Copyright (C) 2002 David R. Martin 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation; either version 2 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, but 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | // General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 18 | 19 | #ifndef PAIRWISE_H 20 | #define PAIRWISE_H 21 | 22 | #include "smatrix.hh" 23 | #include "ic.hh" 24 | 25 | namespace Group 26 | { 27 | // 28 | // compute similarities for a subset of an image given by mask 29 | // 30 | void computeAffinities2(const SupportMap& ic, const float sigma, const float dthresh, SMatrix** affinity); 31 | 32 | } //namespace Group 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/matrices/exceptions/ex_matrix_dimension_mismatch.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Matrix dimension mismatch exception. 3 | */ 4 | #include "lang/exceptions/exception.hh" 5 | #include "lang/null.hh" 6 | #include "math/matrices/exceptions/ex_matrix_dimension_mismatch.hh" 7 | 8 | namespace math { 9 | namespace matrices { 10 | namespace exceptions { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::exceptions::exception; 15 | 16 | /* 17 | * Constructor. 18 | */ 19 | ex_matrix_dimension_mismatch::ex_matrix_dimension_mismatch(const char* msg) 20 | : exception( 21 | ((msg != NULL) ? msg : "matrix dimension mismatch") 22 | ) 23 | { } 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | ex_matrix_dimension_mismatch::ex_matrix_dimension_mismatch( 29 | const ex_matrix_dimension_mismatch& e) 30 | : exception(e) 31 | { } 32 | 33 | /* 34 | * Destructor. 35 | */ 36 | ex_matrix_dimension_mismatch::~ex_matrix_dimension_mismatch() { 37 | /* do nothing */ 38 | } 39 | 40 | /* 41 | * Clone the exception. 42 | */ 43 | ex_matrix_dimension_mismatch* ex_matrix_dimension_mismatch::clone() const { 44 | return (new ex_matrix_dimension_mismatch(*this)); 45 | } 46 | 47 | /* 48 | * Throw the exception. 49 | */ 50 | void ex_matrix_dimension_mismatch::raise() const { 51 | throw *this; 52 | } 53 | 54 | } /* namespace exceptions */ 55 | } /* namespace matrices */ 56 | } /* namespace math */ 57 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/src/cokus_test.cpp: -------------------------------------------------------------------------------- 1 | //this is a simple file to test the cokus.cpp mersenne twister code. 2 | 3 | //free code with no guarantee. No restrictions on usage 4 | //written by: Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 5 | 6 | #define uint32 unsigned long 7 | #define SMALL_INT char 8 | #define SMALL_INT_CLASS mxCHAR_CLASS 9 | extern void seedMT(uint32 seed); 10 | extern uint32 randomMT(void); 11 | 12 | #include "stdio.h" 13 | #include "math.h" 14 | 15 | //generate lots of random number and check if they are within the limits 16 | //else cry about it 17 | 18 | int main(void) { 19 | int j, k; 20 | 21 | // you can seed with any uint32, but the best are odds in 0..(2^32 - 1) 22 | 23 | seedMT(4357); 24 | uint32 MAX=pow(2, 32)-1; 25 | 26 | // print the first 2,002 random numbers seven to a line as an example 27 | // for(j=0; j<2002; j++) 28 | // printf(" %10lu%s", (unsigned long) randomMT(), (j%7)==6 ? "\n" : ""); 29 | 30 | double test_val; 31 | for(k=0;k<100;k++) 32 | for(j=0; j<2000002; j++) { 33 | test_val = ((double)randomMT()/(double)MAX); 34 | if (test_val>=1.0){ 35 | printf("Problem"); 36 | return(0); 37 | } 38 | //printf(" %f%s", test_val , (j%7)==6 ? "\n" : ""); 39 | } 40 | printf("Success"); 41 | return(1); 42 | } 43 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/util/exception.cc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2002 David R. Martin 2 | // 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License as 5 | // published by the Free Software Foundation; either version 2 of the 6 | // License, or (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but 9 | // WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 16 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 17 | 18 | #include 19 | #include 20 | #include "exception.hh" 21 | 22 | namespace Util 23 | { 24 | Exception::Exception(const char *msg) 25 | :_msg(strdup(msg)) 26 | { 27 | } 28 | 29 | Exception::Exception(const Exception & that) 30 | :_msg(strdup(that._msg)) 31 | { 32 | } 33 | 34 | Exception::~Exception() 35 | { 36 | free(_msg); 37 | } 38 | 39 | const char *Exception::msg() const 40 | { 41 | return _msg; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/filterable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Filterable interface. 3 | */ 4 | #ifndef INTERFACES__FILTERABLE_HH 5 | #define INTERFACES__FILTERABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template interface for filterables. 11 | * 12 | * If a class entends filterable then it must define a method (filter_apply) 13 | * that can be used as a filter over collections of objects of type T. 14 | */ 15 | template 16 | class filterable { 17 | public: 18 | /* 19 | * Destructor. 20 | */ 21 | virtual ~filterable(); 22 | 23 | /* 24 | * Filter method. 25 | */ 26 | virtual bool filter_apply(T&) const = 0; 27 | }; 28 | 29 | template 30 | filterable::~filterable() { } 31 | 32 | /* 33 | * A filterable over const T also serves as a filterable over T. 34 | */ 35 | template 36 | class filterable : public filterable { 37 | public: 38 | /* 39 | * Filter method. 40 | * Call the filter version for const items. 41 | */ 42 | bool filter_apply(T&) const; 43 | 44 | /* 45 | * Filter method. 46 | */ 47 | virtual bool filter_apply(const T&) const = 0; 48 | }; 49 | 50 | template 51 | bool filterable::filter_apply(T& t) const { 52 | const T& t_const = t; 53 | return (this->filter_apply(t_const)); 54 | } 55 | 56 | } /* namespace interfaces */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_file_read_error.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * File read error exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_FILE_READ_ERROR_HH 5 | #define LANG__EXCEPTIONS__EX_FILE_READ_ERROR_HH 6 | 7 | #include "lang/exceptions/ex_file_error.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * File read error exception. 15 | */ 16 | class ex_file_read_error : public ex_file_error { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_file_read_error( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and error description. 28 | */ 29 | explicit ex_file_read_error( 30 | const char*, /* filename */ 31 | const char* /* error description */ 32 | ); 33 | 34 | /* 35 | * Copy constructor. 36 | */ 37 | ex_file_read_error(const ex_file_read_error&); 38 | 39 | /* 40 | * Destructor. 41 | */ 42 | virtual ~ex_file_read_error(); 43 | 44 | /* 45 | * Clone the exception. 46 | */ 47 | virtual ex_file_read_error* clone() const; 48 | 49 | /* 50 | * Throw the exception. 51 | */ 52 | virtual void raise() const; 53 | }; 54 | 55 | } /* namespace exceptions */ 56 | } /* namespace lang */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, The Regents of the University of California (Regents) 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 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/ex_file_write_error.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * File write error exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EX_FILE_WRITE_ERROR_HH 5 | #define LANG__EXCEPTIONS__EX_FILE_WRITE_ERROR_HH 6 | 7 | #include "lang/exceptions/ex_file_error.hh" 8 | #include "lang/null.hh" 9 | 10 | namespace lang { 11 | namespace exceptions { 12 | 13 | /* 14 | * File write error exception. 15 | */ 16 | class ex_file_write_error : public ex_file_error { 17 | public: 18 | /* 19 | * Constructor. 20 | */ 21 | explicit ex_file_write_error( 22 | const char* = NULL /* message (use default if NULL) */ 23 | ); 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and error description. 28 | */ 29 | explicit ex_file_write_error( 30 | const char*, /* filename */ 31 | const char* /* error description */ 32 | ); 33 | 34 | /* 35 | * Copy constructor. 36 | */ 37 | ex_file_write_error(const ex_file_write_error&); 38 | 39 | /* 40 | * Destructor. 41 | */ 42 | virtual ~ex_file_write_error(); 43 | 44 | /* 45 | * Clone the exception. 46 | */ 47 | virtual ex_file_write_error* clone() const; 48 | 49 | /* 50 | * Throw the exception. 51 | */ 52 | virtual void raise() const; 53 | }; 54 | 55 | } /* namespace exceptions */ 56 | } /* namespace lang */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /mcg/src/external/paretofront/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Yi Cao 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 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/daxpy.c: -------------------------------------------------------------------------------- 1 | #include "blas.h" 2 | 3 | int daxpy_(int *n, double *sa, double *sx, int *incx, double *sy, 4 | int *incy) 5 | { 6 | long int i, m, ix, iy, nn, iincx, iincy; 7 | register double ssa; 8 | 9 | /* constant times a vector plus a vector. 10 | uses unrolled loop for increments equal to one. 11 | jack dongarra, linpack, 3/11/78. 12 | modified 12/3/93, array(1) declarations changed to array(*) */ 13 | 14 | /* Dereference inputs */ 15 | nn = *n; 16 | ssa = *sa; 17 | iincx = *incx; 18 | iincy = *incy; 19 | 20 | if( nn > 0 && ssa != 0.0 ) 21 | { 22 | if (iincx == 1 && iincy == 1) /* code for both increments equal to 1 */ 23 | { 24 | m = nn-3; 25 | for (i = 0; i < m; i += 4) 26 | { 27 | sy[i] += ssa * sx[i]; 28 | sy[i+1] += ssa * sx[i+1]; 29 | sy[i+2] += ssa * sx[i+2]; 30 | sy[i+3] += ssa * sx[i+3]; 31 | } 32 | for ( ; i < nn; ++i) /* clean-up loop */ 33 | sy[i] += ssa * sx[i]; 34 | } 35 | else /* code for unequal increments or equal increments not equal to 1 */ 36 | { 37 | ix = iincx >= 0 ? 0 : (1 - nn) * iincx; 38 | iy = iincy >= 0 ? 0 : (1 - nn) * iincy; 39 | for (i = 0; i < nn; i++) 40 | { 41 | sy[iy] += ssa * sx[ix]; 42 | ix += iincx; 43 | iy += iincy; 44 | } 45 | } 46 | } 47 | 48 | return 0; 49 | } /* daxpy_ */ 50 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/ddot.c: -------------------------------------------------------------------------------- 1 | #include "blas.h" 2 | 3 | double ddot_(int *n, double *sx, int *incx, double *sy, int *incy) 4 | { 5 | long int i, m, nn, iincx, iincy; 6 | double stemp; 7 | long int ix, iy; 8 | 9 | /* forms the dot product of two vectors. 10 | uses unrolled loops for increments equal to one. 11 | jack dongarra, linpack, 3/11/78. 12 | modified 12/3/93, array(1) declarations changed to array(*) */ 13 | 14 | /* Dereference inputs */ 15 | nn = *n; 16 | iincx = *incx; 17 | iincy = *incy; 18 | 19 | stemp = 0.0; 20 | if (nn > 0) 21 | { 22 | if (iincx == 1 && iincy == 1) /* code for both increments equal to 1 */ 23 | { 24 | m = nn-4; 25 | for (i = 0; i < m; i += 5) 26 | stemp += sx[i] * sy[i] + sx[i+1] * sy[i+1] + sx[i+2] * sy[i+2] + 27 | sx[i+3] * sy[i+3] + sx[i+4] * sy[i+4]; 28 | 29 | for ( ; i < nn; i++) /* clean-up loop */ 30 | stemp += sx[i] * sy[i]; 31 | } 32 | else /* code for unequal increments or equal increments not equal to 1 */ 33 | { 34 | ix = 0; 35 | iy = 0; 36 | if (iincx < 0) 37 | ix = (1 - nn) * iincx; 38 | if (iincy < 0) 39 | iy = (1 - nn) * iincy; 40 | for (i = 0; i < nn; i++) 41 | { 42 | stemp += sx[ix] * sy[iy]; 43 | ix += iincx; 44 | iy += iincy; 45 | } 46 | } 47 | } 48 | 49 | return stemp; 50 | } /* ddot_ */ 51 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/foldable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Foldable interface. 3 | */ 4 | #ifndef INTERFACES__FOLDABLE_HH 5 | #define INTERFACES__FOLDABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template interface for foldables. 11 | * 12 | * If a class extends foldable then it must define a method (fold_apply) 13 | * that can be used as a fold function over collections of objects of type T, 14 | * starting with a given object of type U. 15 | */ 16 | template 17 | class foldable { 18 | public: 19 | /* 20 | * Destructor. 21 | */ 22 | virtual ~foldable(); 23 | 24 | /* 25 | * Fold method. 26 | */ 27 | virtual U& fold_apply(T&, U&) const = 0; 28 | }; 29 | 30 | template 31 | foldable::~foldable() { } 32 | 33 | /* 34 | * A foldable over const T also serves as a foldable over T. 35 | */ 36 | template 37 | class foldable : public foldable { 38 | public: 39 | /* 40 | * Fold method. 41 | * Call the fold_apply version for const items. 42 | */ 43 | U& fold_apply(T&) const; 44 | 45 | /* 46 | * Fold method. 47 | */ 48 | virtual U& fold_apply(const T&, U&) const = 0; 49 | }; 50 | 51 | template 52 | U& foldable::fold_apply(T& t) const { 53 | const T& t_const = t; 54 | return (this->fold_apply(t_const)); 55 | } 56 | 57 | } /* namespace interfaces */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /mcg/wrapper_rgbd_to_ucm.m: -------------------------------------------------------------------------------- 1 | function wrapper_rgbd_to_ucm(imset, modelfile, ucm_dir, contours_cues_dir, C) 2 | sc = [2 1 0.5]; 3 | imlist = getImageSet(imset); 4 | 5 | model = load(modelfile); %fullfile_ext(contours_model_dir, 'forest', modelname, 'mat')); 6 | model = model.model; 7 | 8 | exists_or_mkdir(fullfile(ucm_dir, 'multi')); 9 | exists_or_mkdir(fullfile(ucm_dir, 'scale_2.0')); 10 | exists_or_mkdir(fullfile(ucm_dir, 'scale_1.0')); 11 | exists_or_mkdir(fullfile(ucm_dir, 'edges_1.0')); 12 | exists_or_mkdir(fullfile(ucm_dir, 'scale_0.5')); 13 | exists_or_mkdir(fullfile(ucm_dir, 'multi-png')); 14 | 15 | for i = 1:length(imlist), 16 | id = imlist{i}; 17 | I = getImage(id, 'images'); 18 | D = getImage(id, 'depth'); 19 | cacheFile = fullfile_ext(contours_cues_dir, id, 'mat'); 20 | [E, Es, O] = detectEdge(I, D, [], C, model, sc, [], cacheFile); 21 | [ucm2 ucms] = contours_to_ucm(I, sc, Es, O); 22 | parsave(fullfile_ext(ucm_dir, 'multi', id, 'mat'), 'ucm2', ucm2); 23 | parsave(fullfile_ext(ucm_dir, 'edges_1.0', id, 'mat'), 'E', E{2}, 'Es', Es{2}, 'O', O{2}); 24 | parsave(fullfile_ext(ucm_dir, 'scale_2.0', id, 'mat'), 'ucm2', ucms(:,:,1)); 25 | parsave(fullfile_ext(ucm_dir, 'scale_1.0', id, 'mat'), 'ucm2', ucms(:,:,2)); 26 | parsave(fullfile_ext(ucm_dir, 'scale_0.5', id, 'mat'), 'ucm2', ucms(:,:,3)); 27 | imwrite(im2uint8(ucm2(3:2:end, 3:2:end)), fullfile_ext(ucm_dir, 'multi-png', id, 'png')); 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /rcnn/rcnn_load_model.m: -------------------------------------------------------------------------------- 1 | function rcnn_model = rcnn_load_model(rcnn_model_or_file, use_gpu) 2 | % rcnn_model = rcnn_load_model(rcnn_model_or_file, use_gpu) 3 | % Takes an rcnn_model structure and loads the associated Caffe 4 | % CNN into memory. Since this is nasty global state that is carried 5 | % around, a randomly generated 'key' (or handle) is returned. 6 | % Before making calls to caffe it's a good idea to check that 7 | % rcnn_model.cnn.key is the same as caffe('get_init_key'). 8 | 9 | % AUTORIGHTS 10 | % --------------------------------------------------------- 11 | % Copyright (c) 2014, Ross Girshick 12 | % 13 | % This file is part of the R-CNN code and is available 14 | % under the terms of the Simplified BSD License provided in 15 | % LICENSE. Please retain this notice and LICENSE if you use 16 | % this file (or any portion of it) in your project. 17 | % --------------------------------------------------------- 18 | 19 | if isstr(rcnn_model_or_file) 20 | assert(exist(rcnn_model_or_file, 'file') ~= 0); 21 | ld = load(rcnn_model_or_file); 22 | rcnn_model = ld.rcnn_model; clear ld; 23 | else 24 | rcnn_model = rcnn_model_or_file; 25 | end 26 | 27 | rcnn_model.cnn.init_key = ... 28 | caffe('init', rcnn_model.cnn.definition_file, rcnn_model.cnn.binary_file); 29 | if exist('use_gpu', 'var') && ~use_gpu 30 | caffe('set_mode_cpu'); 31 | else 32 | caffe('set_mode_gpu'); 33 | end 34 | caffe('set_phase_test'); 35 | rcnn_model.cnn.layers = caffe('get_weights'); 36 | -------------------------------------------------------------------------------- /structured-edges/ng/getAllCues.m: -------------------------------------------------------------------------------- 1 | function cues = getAllCues(Iin, Din, C, colorModel, vars, cacheFile) 2 | % function cues = getAllCues(Iin, Din, C, colorModel, vars, cacheFile) 3 | 4 | % AUTORIGHTS 5 | 6 | cache = ~isempty(cacheFile); 7 | try 8 | assert(cache); 9 | load(cacheFile, vars{:}); 10 | catch 11 | D = double(Din)./10; 12 | [y1, y2, y3, angl1, angl2] = yCues(D, C, 1); 13 | [ng1, ng2, dg] = normalCues(D, C, 1); 14 | 15 | model = colorModel; 16 | %% set detection parameters (can set after training) 17 | model.opts.multiscale=1; % for top accuracy set multiscale=1 18 | model.opts.sharpen=0; % for top speed set sharpen=0 19 | model.opts.nTreesEval=4; % for top speed set nTreesEval=1 20 | model.opts.nThreads=4; % max number threads for evaluation 21 | model.opts.nms=0; % set to true to enable nms 22 | 23 | Es = edgesDetect(Iin, model, zeros([size(Iin(:,:,1)), 0])); 24 | if(cache), save(cacheFile, 'y1', 'y2', 'y3', 'angl1', 'angl2', 'ng1', 'ng2', 'dg', 'Es'); end 25 | end 26 | 27 | for ii = 1:length(vars), 28 | eval(sprintf('cues{ii} = %s;', vars{ii})); 29 | %% Add the ng at scale 1 and 2 and use that for scale 3 30 | if(size(cues{ii},4) > 1), cues{ii}(:,:,:,3) = cues{ii}(:,:,:,1)+cues{ii}(:,:,:,2); end 31 | cues{ii}(:,:,end+1,:) = max(cues{ii}, [], 3); 32 | cues{ii} = reshape(cues{ii}, size(cues{ii},1), size(cues{ii},2), []); 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /mcg/src/ucms/resample_ucm2.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function ucm2_sz = resample_ucm2(ucm2, sz) 17 | nthresh=100; 18 | 19 | sz2 = 2*sz+1; 20 | thresh = linspace(max(ucm2(:))/nthresh, max(ucm2(:)), nthresh)'; 21 | 22 | ucm2_sz = zeros(sz2); 23 | old_bw = zeros([ (size(ucm2, 1)-1)/2, (size(ucm2, 2)-1)/2]); 24 | 25 | for t = 1 : numel(thresh), 26 | bw = (ucm2 <= thresh(t) ); 27 | if ~isequal(bw, old_bw), 28 | labels2 = bwlabel(bw); 29 | seg = labels2(2:2:end, 2:2:end); 30 | seg = imresize(seg,sz,'nearest'); 31 | bdry = seg2bdry(seg); 32 | old_bw = bw; 33 | end 34 | ucm2_sz = max(ucm2_sz, thresh(t)*bdry); 35 | end 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/random/util/randperm.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Functions for random permutations. 3 | */ 4 | #ifndef MATH__RANDOM__UTIL__RANDPERM_HH 5 | #define MATH__RANDOM__UTIL__RANDPERM_HH 6 | 7 | #include "collections/abstract/collection.hh" 8 | #include "lang/array.hh" 9 | #include "math/random/generators/rand_gen.hh" 10 | 11 | namespace math { 12 | namespace random { 13 | namespace util { 14 | /* 15 | * Imports. 16 | */ 17 | using collections::abstract::collection; 18 | using lang::array; 19 | using math::random::generators::rand_gen; 20 | 21 | /* 22 | * Random permutation. 23 | * Return a random permutation of the integers {0,1,...,N-1}. 24 | */ 25 | array randperm(unsigned long /* N */); 26 | 27 | /* 28 | * Random permutation. 29 | * Return a random permutation of the integers {0,1,...,N-1}. 30 | * Use the given random number generator as the source of randomness. 31 | */ 32 | array randperm(unsigned long /* N */, rand_gen<>&); 33 | 34 | /* 35 | * Weighted random permutation. 36 | * 37 | * Return a weighted random permutation of the integers {0,1,...,N-1}, where 38 | * N is the number of weights in the given collection. Each integer is put 39 | * into a bag and samples are drawn, without replacement, with probability 40 | * proportional to the corresponding weight. 41 | */ 42 | array randperm(const collection&); 43 | 44 | } /* namespace util */ 45 | } /* namespace random */ 46 | } /* namespace math */ 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_file_open_error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File open error exception. 3 | */ 4 | #include "lang/exceptions/ex_file_error.hh" 5 | #include "lang/exceptions/ex_file_open_error.hh" 6 | #include "lang/null.hh" 7 | #include "lang/string.hh" 8 | 9 | namespace lang { 10 | namespace exceptions { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::string; 15 | 16 | /* 17 | * Constructor. 18 | */ 19 | ex_file_open_error::ex_file_open_error(const char* msg) 20 | : ex_file_error( 21 | ((msg != NULL) ? msg : "file open error") 22 | ) 23 | { } 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and mode. 28 | */ 29 | ex_file_open_error::ex_file_open_error(const char* filename, const char* mode) 30 | : ex_file_error( 31 | string<>("unable to open ").concat(filename).concat(" for ").concat(mode) 32 | ) 33 | { } 34 | 35 | /* 36 | * Copy constructor. 37 | */ 38 | ex_file_open_error::ex_file_open_error(const ex_file_open_error& e) 39 | : ex_file_error(e) 40 | { } 41 | 42 | /* 43 | * Destructor. 44 | */ 45 | ex_file_open_error::~ex_file_open_error() { 46 | /* do nothing */ 47 | } 48 | 49 | /* 50 | * Clone the exception. 51 | */ 52 | ex_file_open_error* ex_file_open_error::clone() const { 53 | return (new ex_file_open_error(*this)); 54 | } 55 | 56 | /* 57 | * Throw the exception. 58 | */ 59 | void ex_file_open_error::raise() const { 60 | throw *this; 61 | } 62 | 63 | } /* namespace exceptions */ 64 | } /* namespace lang */ 65 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_file_read_error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File read error exception. 3 | */ 4 | #include "lang/exceptions/ex_file_error.hh" 5 | #include "lang/exceptions/ex_file_read_error.hh" 6 | #include "lang/null.hh" 7 | #include "lang/string.hh" 8 | 9 | namespace lang { 10 | namespace exceptions { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::string; 15 | 16 | /* 17 | * Constructor. 18 | */ 19 | ex_file_read_error::ex_file_read_error(const char* msg) 20 | : ex_file_error( 21 | ((msg != NULL) ? msg : "file read error") 22 | ) 23 | { } 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and error description. 28 | */ 29 | ex_file_read_error::ex_file_read_error(const char* filename, const char* err) 30 | : ex_file_error( 31 | string<>("error reading ").concat(filename).concat(": ").concat(err) 32 | ) 33 | { } 34 | 35 | /* 36 | * Copy constructor. 37 | */ 38 | ex_file_read_error::ex_file_read_error(const ex_file_read_error& e) 39 | : ex_file_error(e) 40 | { } 41 | 42 | /* 43 | * Destructor. 44 | */ 45 | ex_file_read_error::~ex_file_read_error() { 46 | /* do nothing */ 47 | } 48 | 49 | /* 50 | * Clone the exception. 51 | */ 52 | ex_file_read_error* ex_file_read_error::clone() const { 53 | return (new ex_file_read_error(*this)); 54 | } 55 | 56 | /* 57 | * Throw the exception. 58 | */ 59 | void ex_file_read_error::raise() const { 60 | throw *this; 61 | } 62 | 63 | } /* namespace exceptions */ 64 | } /* namespace lang */ 65 | -------------------------------------------------------------------------------- /structured-edges/spDemo.m: -------------------------------------------------------------------------------- 1 | % Demo for Sticky Superpixels (please see readme.txt first). 2 | 3 | %% load pre-trained edge detection model and set opts (see edgesDemo.m) 4 | model=load('models/forest/modelBsds'); model=model.model; 5 | model.opts.nms=-1; model.opts.nThreads=4; 6 | model.opts.multiscale=0; model.opts.sharpen=2; 7 | 8 | %% set up opts for spDetect (see spDetect.m) 9 | opts = spDetect; 10 | opts.nThreads = 4; % number of computation threads 11 | opts.k = 512; % controls scale of superpixels (big k -> big sp) 12 | opts.alpha = .5; % relative importance of regularity versus data terms 13 | opts.beta = .9; % relative importance of edge versus color terms 14 | opts.merge = 0; % set to small value to merge nearby superpixels at end 15 | 16 | %% detect and display superpixels (see spDetect.m) 17 | I = imread('peppers.png'); 18 | [E,~,~,segs]=edgesDetect(I,model); 19 | tic, [S,V] = spDetect(I,E,opts); toc 20 | figure(1); im(I); figure(2); im(V); 21 | 22 | %% compute ultrametric contour map from superpixels (see spAffinities.m) 23 | tic, [~,~,U]=spAffinities(S,E,segs,opts.nThreads); toc 24 | figure(3); im(1-U); return; 25 | 26 | %% compute video superpixels reusing initialization from previous frame 27 | Is=seqIo(which('peds30.seq'),'toImgs'); Vs=single(Is); opts.bounds=0; tic 28 | for i=1:size(Is,4), I=Is(:,:,:,i); E=edgesDetect(I,model); 29 | [opts.seed,Vs(:,:,:,i)]=spDetect(I,E,opts); end; opts.seed=[]; toc 30 | Vs=uint8(Vs*255); playMovie([Is Vs],15,-10,struct('hasChn',1)) 31 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/functors/hashable_functors.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Hashable functors. 3 | */ 4 | #ifndef FUNCTORS__HASHABLE_FUNCTORS_HH 5 | #define FUNCTORS__HASHABLE_FUNCTORS_HH 6 | 7 | #include "functors/mappable_functors.hh" 8 | #include "interfaces/hashable.hh" 9 | 10 | namespace functors { 11 | /* 12 | * Imports. 13 | */ 14 | using interfaces::hashable; 15 | 16 | /* 17 | * Functor for hashing items. 18 | * Call the underlying hash method. 19 | */ 20 | template 21 | class hash_functor : public mappable_functor { 22 | public: 23 | using mappable_functor::operator(); 24 | H& operator()(const T&) const; 25 | }; 26 | 27 | template 28 | H& hash_functor::operator()(const T& t) const { 29 | return hashable::hash(t); 30 | } 31 | 32 | /* 33 | * Functor for hashing items with const qualifier. 34 | * The same functor is used as for types without the qualifier. 35 | */ 36 | template 37 | class hash_functor : public hash_functor { }; 38 | 39 | /* 40 | * Globally accessible set of default hash functors. 41 | */ 42 | template 43 | class hash_functors { 44 | public: 45 | static const hash_functor& f_hash(); 46 | }; 47 | 48 | template 49 | const hash_functor& hash_functors::f_hash() { 50 | static const hash_functor* f = new hash_functor(); 51 | return *f; 52 | } 53 | 54 | } /* namespace functors */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /mcg/src/bboxes/boxes_intersection.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function [int_area, int_bbox] = boxes_intersection( bbox1, bbox2 ) 17 | up1 = bbox1(1); 18 | left1 = bbox1(2); 19 | down1 = bbox1(3); 20 | right1 = bbox1(4); 21 | 22 | up2 = bbox2(1); 23 | left2 = bbox2(2); 24 | down2 = bbox2(3); 25 | right2 = bbox2(4); 26 | 27 | int_left = max(left1,left2); 28 | int_right = min(right1,right2); 29 | int_up = max(up1,up2); 30 | int_down = min(down1,down2); 31 | 32 | if (int_left<=int_right) && (int_up<=int_down) 33 | int_bbox = [int_up, int_left, int_down, int_right]; 34 | int_area = box_area(int_bbox); 35 | else 36 | int_bbox = []; 37 | int_area = 0; 38 | end 39 | end 40 | 41 | -------------------------------------------------------------------------------- /mcg/src/cands/hole_filling.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function [cands_hf, cands_comp] = hole_filling(lp, ms_matrix,cands) 17 | 18 | % Get all pairs of neighboring leave regions (including border) 19 | [~, idx_neighbors] = seg2gridbmap(lp,1); 20 | K = max(idx_neighbors.matrix_max(:)) + 1; 21 | neigh_pairs = unique(idx_neighbors.matrix_min+K*idx_neighbors.matrix_max); 22 | neigh_pairs(neigh_pairs==0) = []; 23 | neigh_pairs_min = mod(neigh_pairs,K); 24 | neigh_pairs_max = (neigh_pairs-neigh_pairs_min)/K; 25 | 26 | if isrow(neigh_pairs_min) 27 | neigh_pairs_min = neigh_pairs_min'; 28 | end 29 | if isrow(neigh_pairs_max) 30 | neigh_pairs_max = neigh_pairs_max'; 31 | end 32 | 33 | [cands_hf, cands_comp] = mex_hole_filling(lp, ms_matrix,cands,neigh_pairs_min,neigh_pairs_max); 34 | 35 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/lang/exceptions/ex_file_write_error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File write error exception. 3 | */ 4 | #include "lang/exceptions/ex_file_error.hh" 5 | #include "lang/exceptions/ex_file_write_error.hh" 6 | #include "lang/null.hh" 7 | #include "lang/string.hh" 8 | 9 | namespace lang { 10 | namespace exceptions { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::string; 15 | 16 | /* 17 | * Constructor. 18 | */ 19 | ex_file_write_error::ex_file_write_error(const char* msg) 20 | : ex_file_error( 21 | ((msg != NULL) ? msg : "file write error") 22 | ) 23 | { } 24 | 25 | /* 26 | * Constructor. 27 | * Generate an error message reporting the filename and error description. 28 | */ 29 | ex_file_write_error::ex_file_write_error(const char* filename, const char* err) 30 | : ex_file_error( 31 | string<>("error writing ").concat(filename).concat(": ").concat(err) 32 | ) 33 | { } 34 | 35 | /* 36 | * Copy constructor. 37 | */ 38 | ex_file_write_error::ex_file_write_error(const ex_file_write_error& e) 39 | : ex_file_error(e) 40 | { } 41 | 42 | /* 43 | * Destructor. 44 | */ 45 | ex_file_write_error::~ex_file_write_error() { 46 | /* do nothing */ 47 | } 48 | 49 | /* 50 | * Clone the exception. 51 | */ 52 | ex_file_write_error* ex_file_write_error::clone() const { 53 | return (new ex_file_write_error(*this)); 54 | } 55 | 56 | /* 57 | * Throw the exception. 58 | */ 59 | void ex_file_write_error::raise() const { 60 | throw *this; 61 | } 62 | 63 | } /* namespace exceptions */ 64 | } /* namespace lang */ 65 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/matrices/functors/matrix_equal_functors.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Functors for checking equality of matrices. 3 | */ 4 | #ifndef MATH__MATRICES__FUNCTORS__MATRIX_EQUAL_FUNCTORS_HH 5 | #define MATH__MATRICES__FUNCTORS__MATRIX_EQUAL_FUNCTORS_HH 6 | 7 | #include "functors/equalable_functors.hh" 8 | #include "math/matrices/matrix.hh" 9 | 10 | namespace math { 11 | namespace matrices { 12 | namespace functors { 13 | /* 14 | * Imports. 15 | */ 16 | using ::functors::equalable_functor; 17 | using math::matrices::matrix; 18 | 19 | /* 20 | * Exact equality of all elements. 21 | */ 22 | template 23 | class matrix_equal : public equalable_functor< const matrix > { 24 | public: 25 | bool operator()(const matrix& m0, const matrix& m1) const { 26 | matrix::assert_dims_equal(m0._dims, m1._dims); 27 | bool eq = true; 28 | for (unsigned long n = 0; (n < m0._size) && eq; n++) 29 | eq = (m0._data[n] == m1._data[n]); 30 | return eq; 31 | } 32 | }; 33 | 34 | /* 35 | * Globally accessible set of useful matrix eqaulity test functors. 36 | */ 37 | template 38 | class matrix_equal_functors { 39 | public: 40 | static const matrix_equal& f_equal(); 41 | }; 42 | 43 | template 44 | const matrix_equal& matrix_equal_functors::f_equal() { 45 | static const matrix_equal* f = new matrix_equal(); 46 | return *f; 47 | } 48 | 49 | } /* namespace functors */ 50 | } /* namespace matrices */ 51 | } /* namespace math */ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/serialization/serial_input_stream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Input stream for deserialization. 3 | */ 4 | #ifndef IO__SERIALIZATION__SERIAL_INPUT_STREAM_HH 5 | #define IO__SERIALIZATION__SERIAL_INPUT_STREAM_HH 6 | 7 | namespace io { 8 | namespace serialization { 9 | 10 | /* 11 | * Input stream for deserialization. 12 | */ 13 | class serial_input_stream { 14 | public: 15 | /* 16 | * Destructor. 17 | */ 18 | virtual ~serial_input_stream() = 0; 19 | 20 | /* 21 | * Deserialization operators. 22 | * Read the specified data from the stream. 23 | */ 24 | virtual serial_input_stream& operator>>(bool&) = 0; 25 | virtual serial_input_stream& operator>>(char&) = 0; 26 | virtual serial_input_stream& operator>>(unsigned char&) = 0; 27 | virtual serial_input_stream& operator>>(short&) = 0; 28 | virtual serial_input_stream& operator>>(unsigned short&) = 0; 29 | virtual serial_input_stream& operator>>(int&) = 0; 30 | virtual serial_input_stream& operator>>(unsigned int&) = 0; 31 | virtual serial_input_stream& operator>>(long&) = 0; 32 | virtual serial_input_stream& operator>>(unsigned long&) = 0; 33 | virtual serial_input_stream& operator>>(long long&) = 0; 34 | virtual serial_input_stream& operator>>(unsigned long long&) = 0; 35 | virtual serial_input_stream& operator>>(float&) = 0; 36 | virtual serial_input_stream& operator>>(double&) = 0; 37 | virtual serial_input_stream& operator>>(long double&) = 0; 38 | }; 39 | 40 | } /* namespace serialization */ 41 | } /* namespace io */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /rcnn/nms.m: -------------------------------------------------------------------------------- 1 | function pick = nms(boxes, overlap) 2 | % top = nms(boxes, overlap) 3 | % Non-maximum suppression. (FAST VERSION) 4 | % Greedily select high-scoring detections and skip detections 5 | % that are significantly covered by a previously selected 6 | % detection. 7 | % 8 | % NOTE: This is adapted from Pedro Felzenszwalb's version (nms.m), 9 | % but an inner loop has been eliminated to significantly speed it 10 | % up in the case of a large number of boxes 11 | 12 | % Copyright (C) 2011-12 by Tomasz Malisiewicz 13 | % All rights reserved. 14 | % 15 | % This file is part of the Exemplar-SVM library and is made 16 | % available under the terms of the MIT license (see COPYING file). 17 | % Project homepage: https://github.com/quantombone/exemplarsvm 18 | 19 | 20 | if isempty(boxes) 21 | pick = []; 22 | return; 23 | end 24 | 25 | x1 = boxes(:,1); 26 | y1 = boxes(:,2); 27 | x2 = boxes(:,3); 28 | y2 = boxes(:,4); 29 | s = boxes(:,end); 30 | 31 | area = (x2-x1+1) .* (y2-y1+1); 32 | [vals, I] = sort(s); 33 | 34 | pick = s*0; 35 | counter = 1; 36 | while ~isempty(I) 37 | last = length(I); 38 | i = I(last); 39 | pick(counter) = i; 40 | counter = counter + 1; 41 | 42 | xx1 = max(x1(i), x1(I(1:last-1))); 43 | yy1 = max(y1(i), y1(I(1:last-1))); 44 | xx2 = min(x2(i), x2(I(1:last-1))); 45 | yy2 = min(y2(i), y2(I(1:last-1))); 46 | 47 | w = max(0.0, xx2-xx1+1); 48 | h = max(0.0, yy2-yy1+1); 49 | 50 | inter = w.*h; 51 | o = inter ./ (area(i) + area(I(1:last-1)) - inter); 52 | 53 | I = I(find(o<=overlap)); 54 | end 55 | 56 | pick = pick(1:(counter-1)); 57 | -------------------------------------------------------------------------------- /mcg/datasets/database_root_dir.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | % Adapt the paths to the place where you have downloaded PASCAL and BSDS. 17 | % In the case of BSDS500, you should put all images and ground truths 18 | % into the same folder, discarding the "val", "test", "train" folders 19 | % ------------------------------------------------------------------------ 20 | function db_root_dir = database_root_dir( database ) 21 | if strcmp(database,'pascal2012') 22 | db_root_dir = '/path/to/PASCAL2012/'; 23 | elseif strcmp(database,'bsds500') 24 | db_root_dir = '/path/to/BSDS500/'; 25 | elseif strcmp(database, 'nyud40Obj') 26 | db_root_dir = '/work5/arbelaez/saurabh/RELEASE/data/groundTruth40/'; 27 | % db_root_dir = '/work5/sgupta/datasets/nyud2/'; 28 | else 29 | error(['Unknown database: ' database]); 30 | end 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /structured-edges/detectEdge.m: -------------------------------------------------------------------------------- 1 | function [E, Es, O] = detectEdge(Iin, Din, id, C, model, sc, outFile, cacheFile) 2 | if(isstr(Iin)), Iin = imread(Iin); end 3 | if(isstr(Din)), Din = imread(Din); end 4 | if(isstr(model)), load(model); end 5 | 6 | 7 | opts = model.opts; 8 | rgbd = opts.rgbd; 9 | 10 | model.opts.multiscale=1; % for top accuracy set multiscale=1 11 | model.opts.nTreesEval=4; % for top speed set nTreesEval=1 12 | model.opts.nThreads=1; % max number threads for evaluation 13 | model.opts.sharpen=0; % for top speed set sharpen=0 14 | 15 | if(rgbd == 3), 16 | colorModel = model.colorModel.model; 17 | cues = getAllCues(Iin, Din, C, colorModel, opts.rgbd3opts.vars, cacheFile); 18 | end 19 | 20 | for i = 1:length(sc), 21 | I = imresize(Iin, sc(i), 'lanczos3'); 22 | ng = zeros(size(I,1), size(I,2), 0); 23 | 24 | if(rgbd), 25 | D = imresize(Din, sc(i), 'nearest'); 26 | D=single(D)/1e4; 27 | end 28 | if(rgbd==1), 29 | I=D; 30 | elseif(rgbd==2), 31 | I=cat(3,single(I)/255,D); 32 | elseif(rgbd==3), 33 | I=cat(3,single(I)/255,D,1e-3./D); 34 | ng = cat(3, cues{:}); 35 | ng = imresize(ng, sc(i), 'lanczos3'); 36 | end 37 | model.opts.nms = 0; 38 | [Es{i}, O{i}] = edgesDetect(I,model,ng); 39 | E{i} = edgesNmsMex(Es{i}, O{i}, 1, 5, 1.01, model.opts.nThreads); 40 | 41 | % model.opts.nms = 1; 42 | % [E{i} O{i}] = edgesDetect(I,model,ng); 43 | end 44 | if(~isempty(outFile)), save(outFile, 'E', 'Es', 'O'); end 45 | end 46 | -------------------------------------------------------------------------------- /mcg/get_best_region.m: -------------------------------------------------------------------------------- 1 | function [IIgt, II] = get_best_region(imName, oid) 2 | %% 3 | % outDir = 'rmrc-talk'; 4 | % imName = 'img_6449'; 5 | % for i = 1:20, 6 | % [IIgt, II] = get_best_region(imName, i); 7 | % imwrite(IIgt, fullfile_ext(outDir, sprintf('%s_%02d_gt', imName, i), 'png')); 8 | % imwrite(II, fullfile_ext(outDir, sprintf('%s_%02d_pr', imName, i), 'png')); 9 | % end 10 | REGIONDIR = '/work4/sgupta/regions-nyu/datasets/nyud40Obj/mcg_sfdnV03_3_3_depthV2_030/'; 11 | gt = getGroundTruth(imName, 'instance'); 12 | I = getImage(imName, 'images'); 13 | mask = gt == oid; 14 | dt = load(fullfile(REGIONDIR, [imName '_cands.mat'])); 15 | for i = 1:500, %size(sp2reg,1), 16 | spi = dt.sp2reg(:,i); 17 | maskReg = spi(dt.sp); 18 | ii(i) = nnz(maskReg(:) & mask(:)); 19 | uu(i) = nnz(maskReg(:) | mask(:)); 20 | end 21 | o = ii./uu; 22 | [~, ind] = max(o); 23 | spi = dt.sp2reg(:,ind); 24 | maskReg = spi(dt.sp); 25 | figure(1); 26 | subplot(2,2,1); imagesc(maskReg); 27 | IIgt = im2double(overlay(im2double(I), mask, zeros(size(mask)))); 28 | [ii, jj ] = find(mask); 29 | bbox(1) = min(jj); bbox(2) = min(ii); bbox(3) = max(jj); bbox(4) = max(ii); 30 | IIgt = draw_rect_vec(IIgt, bbox', [0 1 0], 3); 31 | 32 | subplot(2,2,2); imagesc(IIgt); 33 | % II = im2double(overlay(repmat(rgb2gray(im2double(I)), [1 1 3]), maskReg, zeros(size(mask)))); 34 | II = im2double(overlay(im2double(I), maskReg, zeros(size(mask)))); 35 | II = draw_rect_vec(II, dt.bboxes(ind, [2 1 4 3])', [0 1 0], 3); 36 | subplot(2,2,3); imagesc(II); 37 | subplot(2,2,4); imagesc(gt); 38 | end 39 | 40 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/vision/recognition/classifiers/abstract/classifier.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Classifier. 3 | * 4 | * A classifier takes an exemplar and determines the category (if any) to which 5 | * it belongs. 6 | */ 7 | #ifndef VISION__RECOGNITION__CLASSIFIERS__ABSTRACT__CLASSIFIER_HH 8 | #define VISION__RECOGNITION__CLASSIFIERS__ABSTRACT__CLASSIFIER_HH 9 | 10 | #include "lang/pointers/safe_ptr.hh" 11 | #include "vision/recognition/databases/category_db.hh" 12 | #include "vision/recognition/models/exemplar.hh" 13 | #include "vision/recognition/models/ids/category_id.hh" 14 | 15 | namespace vision { 16 | namespace recognition { 17 | namespace classifiers { 18 | namespace abstract { 19 | /* 20 | * Imports. 21 | */ 22 | using lang::pointers::safe_ptr; 23 | using vision::recognition::databases::category_db; 24 | using vision::recognition::models::exemplar; 25 | using vision::recognition::models::ids::category_id; 26 | 27 | /* 28 | * Abstract base class for classifiers. 29 | */ 30 | class classifier { 31 | public: 32 | /* 33 | * Destructor. 34 | */ 35 | virtual ~classifier() = 0; 36 | 37 | /* 38 | * Classify the exemplar. 39 | * Return the identity of the category to which the exemplar belongs. 40 | * The returned id is NULL if the exemplar does not belong to any category. 41 | */ 42 | virtual safe_ptr classify( 43 | const category_db&, 44 | const exemplar& 45 | ) = 0; 46 | }; 47 | 48 | } /* namespace abstract */ 49 | } /* namespace classifiers */ 50 | } /* namespace recognition */ 51 | } /* namespace vision */ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/test_RegRF_extensively.m: -------------------------------------------------------------------------------- 1 | %************************************************************** 2 | %* Test of mex interface to Andy Liaw et al.'s C code (used in R package randomForest) 3 | %* Added by Abhishek Jaiantilal ( abhishek.jaiantilal@colorado.edu ) 4 | %* License: GPLv2 5 | %* Version: 0.02 6 | % 7 | % This file runs tests about 10 times on the diabetes dataset 8 | % 9 | %************************************************************** 10 | 11 | %compile everything 12 | if strcmpi(computer,'PCWIN') |strcmpi(computer,'PCWIN64') 13 | compile_windows 14 | else 15 | compile_linux 16 | end 17 | 18 | load data/diabetes 19 | 20 | %diabetes, N=442, D=10 21 | total_train_time=0; 22 | total_test_time=0; 23 | for i=1:10 24 | fprintf('%d,',i); 25 | tic; 26 | model=regRF_train(diabetes.x,diabetes.y,1000); 27 | total_train_time=toc; 28 | tic; 29 | y_hat =regRF_predict(diabetes.x,model); 30 | total_test_time=total_test_time+toc; 31 | end 32 | fprintf('\nnum_tree %d: Avg train time %d, test time %d\n',1000,total_train_time/100,total_test_time/100); 33 | 34 | %diabetes, N=442, D=64 35 | %this second version of the diabetes dataset has 64 dimensions rather than 36 | %10 37 | total_train_time=0; 38 | total_test_time=0; 39 | for i=1:1 40 | fprintf('%d,',i); 41 | tic; 42 | model=regRF_train(diabetes.x2,diabetes.y,1000); 43 | total_train_time=total_train_time+toc; 44 | tic; 45 | y_hat =regRF_predict(diabetes.x2,model); 46 | total_test_time=total_test_time+toc; 47 | end 48 | fprintf('\nnum_tree %d: Avg train time %d, test time %d\n',1000,total_train_time/100,total_test_time/100); 49 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/blas/dnrm2.c: -------------------------------------------------------------------------------- 1 | #include /* Needed for fabs() and sqrt() */ 2 | #include "blas.h" 3 | 4 | double dnrm2_(int *n, double *x, int *incx) 5 | { 6 | long int ix, nn, iincx; 7 | double norm, scale, absxi, ssq, temp; 8 | 9 | /* DNRM2 returns the euclidean norm of a vector via the function 10 | name, so that 11 | 12 | DNRM2 := sqrt( x'*x ) 13 | 14 | -- This version written on 25-October-1982. 15 | Modified on 14-October-1993 to inline the call to SLASSQ. 16 | Sven Hammarling, Nag Ltd. */ 17 | 18 | /* Dereference inputs */ 19 | nn = *n; 20 | iincx = *incx; 21 | 22 | if( nn > 0 && iincx > 0 ) 23 | { 24 | if (nn == 1) 25 | { 26 | norm = fabs(x[0]); 27 | } 28 | else 29 | { 30 | scale = 0.0; 31 | ssq = 1.0; 32 | 33 | /* The following loop is equivalent to this call to the LAPACK 34 | auxiliary routine: CALL SLASSQ( N, X, INCX, SCALE, SSQ ) */ 35 | 36 | for (ix=(nn-1)*iincx; ix>=0; ix-=iincx) 37 | { 38 | if (x[ix] != 0.0) 39 | { 40 | absxi = fabs(x[ix]); 41 | if (scale < absxi) 42 | { 43 | temp = scale / absxi; 44 | ssq = ssq * (temp * temp) + 1.0; 45 | scale = absxi; 46 | } 47 | else 48 | { 49 | temp = absxi / scale; 50 | ssq += temp * temp; 51 | } 52 | } 53 | } 54 | norm = scale * sqrt(ssq); 55 | } 56 | } 57 | else 58 | norm = 0.0; 59 | 60 | return norm; 61 | 62 | } /* dnrm2_ */ 63 | -------------------------------------------------------------------------------- /structured-edges/edgesDemo.m: -------------------------------------------------------------------------------- 1 | % Demo for Structured Edge Detector (please see readme.txt first). 2 | 3 | error(['This is a demo for Stuctured Edges and not for our RGB-D edge detector.', ... 4 | ' Please look at run_all.m for how to run our RGB-D edge detector and look at scripts/script_edges.m' ... 5 | ' for how to train the RGB-D edge detector.']); 6 | 7 | %% set opts for training (see edgesTrain.m) 8 | opts=edgesTrain(); % default options (good settings) 9 | opts.modelDir='models/'; % model will be in models/forest 10 | opts.modelFnm='modelBsds'; % model name 11 | opts.nPos=5e5; opts.nNeg=5e5; % decrease to speedup training 12 | opts.useParfor=0; % parallelize if sufficient memory 13 | 14 | %% train edge detector (~20m/8Gb per tree, proportional to nPos/nNeg) 15 | tic, model=edgesTrain(opts); toc; % will load model if already trained 16 | 17 | %% set detection parameters (can set after training) 18 | model.opts.multiscale=0; % for top accuracy set multiscale=1 19 | model.opts.sharpen=2; % for top speed set sharpen=0 20 | model.opts.nTreesEval=4; % for top speed set nTreesEval=1 21 | model.opts.nThreads=4; % max number threads for evaluation 22 | model.opts.nms=0; % set to true to enable nms 23 | 24 | %% evaluate edge detector on BSDS500 (see edgesEval.m) 25 | if(0), edgesEval( model, 'show',1, 'name','' ); end 26 | 27 | %% detect edge and visualize results 28 | I = imread('peppers.png'); 29 | tic, E=edgesDetect(I,model); toc 30 | figure(1); im(I); figure(2); im(1-E); 31 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/concurrent/threads/synchronization/semaphore.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Semaphore. 3 | */ 4 | #ifndef CONCURRENT__THREADS__SYNCHRONIZATION__SEMAPHORE_HH 5 | #define CONCURRENT__THREADS__SYNCHRONIZATION__SEMAPHORE_HH 6 | 7 | #include "concurrent/threads/synchronization/mutex.hh" 8 | 9 | namespace concurrent { 10 | namespace threads { 11 | namespace synchronization { 12 | 13 | class semaphore { 14 | public: 15 | /* 16 | * Constructor. 17 | * Initialize the semaphore with value 1. 18 | */ 19 | semaphore(); 20 | 21 | /* 22 | * Constructor. 23 | * Initialize the semaphore with the specified value. 24 | * Semaphores initialized to zero are initially locked. 25 | */ 26 | explicit semaphore(unsigned long); 27 | 28 | /* 29 | * Copy constructor. 30 | * Create a new semaphore with the same value. 31 | */ 32 | explicit semaphore(const semaphore&); 33 | 34 | /* 35 | * Destructor. 36 | */ 37 | virtual ~semaphore(); 38 | 39 | /* 40 | * Acquire the semaphore. 41 | */ 42 | void acquire(); 43 | void acquire(unsigned long); 44 | 45 | /* 46 | * Release the semaphore. 47 | */ 48 | void release(); 49 | void release(unsigned long); 50 | 51 | protected: 52 | unsigned long _value; /* number of remaining acquires allowed */ 53 | mutable mutex _value_mutex; /* mutex for reading/writing semaphore value */ 54 | mutex _access_mutex; /* mutex for taking semaphore lock */ 55 | }; 56 | 57 | } /* namespace synchronization */ 58 | } /* namespace threads */ 59 | } /* namespace concurrent */ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/interfaces/key_hashable.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Key-hashable interface. 3 | */ 4 | #ifndef INTERFACES__KEY_HASHABLE_HH 5 | #define INTERFACES__KEY_HASHABLE_HH 6 | 7 | namespace interfaces { 8 | 9 | /* 10 | * Template interface for key-hashable objects. 11 | * 12 | * If a class X extends key_hashable then: 13 | * (1) X must be a T, and 14 | * (2) X must hash to an object of type H given a key of type K. 15 | * 16 | * Note that the interface is the same regardless of T or K's const qualifier. 17 | */ 18 | template 19 | class key_hashable { 20 | public: 21 | /* 22 | * Destructor. 23 | */ 24 | virtual ~key_hashable(); 25 | 26 | /* 27 | * Function for hashing a key_hashable object. 28 | */ 29 | static H& hash(const key_hashable&, const K&); 30 | 31 | /* 32 | * Hash method. 33 | */ 34 | virtual H& hash(const K&) const = 0; 35 | }; 36 | 37 | template 38 | class hashable : public hashable { }; 39 | 40 | template 41 | class hashable : public hashable { }; 42 | 43 | template 44 | class hashable : public hashable { }; 45 | 46 | template 47 | key_hashable::~key_hashable() { } 48 | 49 | template 50 | H& key_hashable::hash(const key_hashable& t, const K& k) { 51 | return (t.hash(k)); 52 | } 53 | 54 | } /* namespace interfaces */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/lang/exceptions/exception.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception. 3 | */ 4 | #ifndef LANG__EXCEPTIONS__EXCEPTION_HH 5 | #define LANG__EXCEPTIONS__EXCEPTION_HH 6 | 7 | #include "io/streams/ostream.hh" 8 | #include "lang/exceptions/throwable.hh" 9 | #include "lang/null.hh" 10 | 11 | namespace lang { 12 | namespace exceptions { 13 | /* 14 | * Imports. 15 | */ 16 | using io::streams::ostream; 17 | 18 | /* 19 | * Exception base class. 20 | */ 21 | class exception : public throwable { 22 | public: 23 | /* 24 | * Constructor. 25 | */ 26 | explicit exception( 27 | const char* = NULL /* message */ 28 | ); 29 | 30 | /* 31 | * Copy constructor. 32 | */ 33 | exception(const exception&); 34 | 35 | /* 36 | * Destructor. 37 | */ 38 | virtual ~exception(); 39 | 40 | /* 41 | * Clone the exception. 42 | */ 43 | virtual exception* clone() const; 44 | 45 | /* 46 | * Throw the exception. 47 | */ 48 | virtual void raise() const; 49 | 50 | /* 51 | * Get the exception's message. 52 | */ 53 | virtual const char* what() const; 54 | 55 | /* 56 | * Get the stack trace at the time the exception was thrown. 57 | */ 58 | const char* const* stack_trace() const; 59 | 60 | /* 61 | * Output message and stack trace to stream. 62 | */ 63 | friend ostream& operator<<(ostream&, const exception&); 64 | 65 | protected: 66 | char* _message; 67 | char** _stack_trace; 68 | unsigned long _stack_trace_size; 69 | }; 70 | 71 | } /* namespace exceptions */ 72 | } /* namespace lang */ 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/mlearning/clustering/clusterers/abstract/weighted_clusterer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Abstract weighted clusterer. 3 | */ 4 | #include "collections/abstract/collection.hh" 5 | #include "lang/array.hh" 6 | #include "lang/iterators/iterator.hh" 7 | #include "lang/pointers/auto_ptr.hh" 8 | #include "mlearning/clustering/clusterers/abstract/weighted_clusterer.hh" 9 | 10 | namespace mlearning { 11 | namespace clustering { 12 | namespace clusterers { 13 | namespace abstract { 14 | /* 15 | * Imports. 16 | */ 17 | using collections::abstract::collection; 18 | using lang::array; 19 | using lang::iterators::iterator; 20 | using lang::pointers::auto_ptr; 21 | 22 | /* 23 | * Pure virtual destructor. 24 | */ 25 | weighted_clusterer_base::~weighted_clusterer_base() { } 26 | 27 | /* 28 | * Compute the total weight assigned to each cluster (the sum 29 | * of the weights of its members) given the item weights and 30 | * assignment map. 31 | */ 32 | array weighted_clusterer_base::cluster_weights( 33 | const collection& weights, 34 | const array& assignments) 35 | { 36 | unsigned long n_items = assignments.size(); 37 | unsigned long n_clusters = clusterer_base::number_of_clusters(assignments); 38 | array total_weights(n_clusters); 39 | auto_ptr< iterator > i = weights.iter_create(); 40 | for (unsigned long n = 0; n < n_items; n++) 41 | total_weights[assignments[n]] += i->next(); 42 | return total_weights; 43 | } 44 | 45 | } /* namespace abstract */ 46 | } /* namesapce clusterers */ 47 | } /* namespace clustering */ 48 | } /* namespace mlearning */ 49 | -------------------------------------------------------------------------------- /rcnn/external/liblinear-1.94/COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2007-2013 The LIBLINEAR Project. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | 3. Neither name of copyright holders nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/random/sources/system_entropy.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Pseudorandom source that uses system entropy to generate random numbers. 3 | * This generator is useful for initializing other generators with random 4 | * seeds. 5 | */ 6 | #ifndef MATH__RANDOM__SOURCES__SYSTEM_ENTROPY_HH 7 | #define MATH__RANDOM__SOURCES__SYSTEM_ENTROPY_HH 8 | 9 | #include "math/random/sources/rand_source.hh" 10 | 11 | namespace math { 12 | namespace random { 13 | namespace sources { 14 | 15 | /* 16 | * Pseudorandom source that uses system entropy. 17 | */ 18 | class system_entropy : public rand_source { 19 | public: 20 | /* 21 | * Constructor. 22 | */ 23 | system_entropy(); 24 | 25 | /* 26 | * Copy constructor. 27 | */ 28 | system_entropy(const system_entropy&); 29 | 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~system_entropy(); 34 | 35 | /* 36 | * Generate a pseudorandom boolean uniformly distributed on {true, false}. 37 | */ 38 | bool gen_uniform_bool(); 39 | 40 | /* 41 | * Generate a pseudorandom integer uniformly distributed on the closed 42 | * interval [0, 2^N - 1], where N is the number of bits of precision in 43 | * the corresponding datatype. 44 | */ 45 | unsigned char gen_uniform_unsigned_char(); 46 | unsigned short gen_uniform_unsigned_short(); 47 | unsigned int gen_uniform_unsigned_int(); 48 | unsigned long gen_uniform_unsigned_long(); 49 | unsigned long long gen_uniform_unsigned_long_long(); 50 | }; 51 | 52 | } /* namespace sources */ 53 | } /* namespace random */ 54 | } /* namespace math */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /mcg/src/aux/create_train_samples.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | % 17 | % Create random divisions of the training set for cross-validation 18 | % 19 | % ------------------------------------------------------------------------ 20 | 21 | % Create random divisions of the training set 22 | id = '3'; 23 | percentage_train = 0.5; 24 | full_set = 'train2012'; 25 | 26 | % Get full ids 27 | im_ids = database_ids('pascal2012',full_set); 28 | 29 | ids_a = sort(randperm(length(im_ids),floor(percentage_train*length(im_ids)))); 30 | ids_b = setdiff(1:length(im_ids),ids_a); 31 | im_ids_a = im_ids(ids_a); 32 | im_ids_b = im_ids(ids_b); 33 | 34 | % Write to file 35 | file_a = fullfile(root_dir,'datasets', 'pascal2012','gt_sets',[full_set '_' id 'a.txt']); 36 | file_b = fullfile(root_dir,'datasets', 'pascal2012','gt_sets',[full_set '_' id 'b.txt']); 37 | 38 | dlmwrite(file_a,im_ids_a,'') 39 | dlmwrite(file_b,im_ids_b,'') -------------------------------------------------------------------------------- /rcnn/rcnn_feature_stats.m: -------------------------------------------------------------------------------- 1 | function [mean_norm, stdd] = rcnn_feature_stats(imdb, rcnn_model) 2 | % AUTORIGHTS 3 | % --------------------------------------------------------- 4 | % Copyright (c) 2014, Ross Girshick 5 | % 6 | % This file is part of the R-CNN code and is available 7 | % under the terms of the Simplified BSD License provided in 8 | % LICENSE. Please retain this notice and LICENSE if you use 9 | % this file (or any portion of it) in your project. 10 | % --------------------------------------------------------- 11 | 12 | % conf = rcnn_config(); 13 | % save_file = sprintf('%s/feature_stats_%s_layer_%d_%s.mat', ... 14 | % conf.cache_dir, imdb.name, layer, rcnn_model.cache_name); 15 | 16 | feat_opts = rcnn_model.feat_opts; 17 | 18 | try 19 | ld = load(save_file); 20 | mean_norm = ld.mean_norm; 21 | stdd = ld.stdd; 22 | clear ld; 23 | catch 24 | % fix the random seed for repeatability 25 | prev_rng = rcnn_seed_rand(); 26 | 27 | image_ids = imdb.image_ids; 28 | 29 | num_images = min(length(image_ids), 100); 30 | boxes_per_image = 200; 31 | 32 | image_ids = image_ids(randperm(length(image_ids), num_images)); 33 | 34 | parfor i = 1:length(image_ids) 35 | tic_toc_print('feature stats: %d/%d\n', i, length(image_ids)); 36 | d = get_features(imdb, i, feat_opts, false); 37 | X = d.feat(randperm(size(d.feat,1), min(boxes_per_image, size(d.feat,1))), :); 38 | ns{i} = sqrt(sum(X.^2, 2)); 39 | end 40 | 41 | ns = cat(1, ns{:}); 42 | 43 | mean_norm = mean(ns); 44 | stdd = std(ns); 45 | % save(save_file, 'mean_norm', 'stdd'); 46 | 47 | % restore previous rng 48 | rng(prev_rng); 49 | end 50 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/io/serialization/serial_output_stream.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Output stream for serialization. 3 | */ 4 | #ifndef IO__SERIALIZATION__SERIAL_OUTPUT_STREAM_HH 5 | #define IO__SERIALIZATION__SERIAL_OUTPUT_STREAM_HH 6 | 7 | namespace io { 8 | namespace serialization { 9 | 10 | /* 11 | * Output stream for serialization. 12 | */ 13 | class serial_output_stream { 14 | public: 15 | /* 16 | * Destructor. 17 | */ 18 | virtual ~serial_output_stream() = 0; 19 | 20 | /* 21 | * Serialization operators. 22 | * Write the specified data to the stream. 23 | */ 24 | virtual serial_output_stream& operator<<(const bool&) = 0; 25 | virtual serial_output_stream& operator<<(const char&) = 0; 26 | virtual serial_output_stream& operator<<(const unsigned char&) = 0; 27 | virtual serial_output_stream& operator<<(const short&) = 0; 28 | virtual serial_output_stream& operator<<(const unsigned short&) = 0; 29 | virtual serial_output_stream& operator<<(const int&) = 0; 30 | virtual serial_output_stream& operator<<(const unsigned int&) = 0; 31 | virtual serial_output_stream& operator<<(const long&) = 0; 32 | virtual serial_output_stream& operator<<(const unsigned long&) = 0; 33 | virtual serial_output_stream& operator<<(const long long&) = 0; 34 | virtual serial_output_stream& operator<<(const unsigned long long&) = 0; 35 | virtual serial_output_stream& operator<<(const float&) = 0; 36 | virtual serial_output_stream& operator<<(const double&) = 0; 37 | virtual serial_output_stream& operator<<(const long double&) = 0; 38 | }; 39 | 40 | } /* namespace serialization */ 41 | } /* namespace io */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/random/sources/rand_source_32.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Pseudorandom source for 32-bit generators. 3 | * This class implements the transformations to all other built-in types for 4 | * generators which produce random data in 32-bit (unsigned long) chunks. 5 | */ 6 | #ifndef MATH__RANDOM__SOURCES__RAND_SOURCE_32_HH 7 | #define MATH__RANDOM__SOURCES__RAND_SOURCE_32_HH 8 | 9 | #include "math/random/sources/rand_source.hh" 10 | 11 | namespace math { 12 | namespace random { 13 | namespace sources { 14 | 15 | /* 16 | * Abstract base class for pseudorandom 32-bit source. 17 | */ 18 | class rand_source_32 : public rand_source { 19 | public: 20 | /* 21 | * Destructor. 22 | */ 23 | virtual ~rand_source_32() = 0; 24 | 25 | /* 26 | * Generate a pseudorandom boolean uniformly distributed on {true, false}. 27 | */ 28 | bool gen_uniform_bool(); 29 | 30 | /* 31 | * Generate a pseudorandom integer uniformly distributed on the closed 32 | * interval [0, 2^N - 1], where N is the number of bits of precision in 33 | * the corresponding datatype. 34 | */ 35 | unsigned char gen_uniform_unsigned_char(); 36 | unsigned short gen_uniform_unsigned_short(); 37 | unsigned int gen_uniform_unsigned_int(); 38 | unsigned long gen_uniform_unsigned_long(); 39 | unsigned long long gen_uniform_unsigned_long_long(); 40 | 41 | protected: 42 | /* 43 | * Generate a pseudorandom uniformly distributed 32-bit chunk. 44 | */ 45 | virtual unsigned int generate() = 0; 46 | }; 47 | 48 | } /* namespace sources */ 49 | } /* namespace random */ 50 | } /* namespace math */ 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/random/sources/rand_source_64.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Pseudorandom source for 64-bit generators. 3 | * This class implements the transformations to all other built-in types for 4 | * generators which produce random data in 64-bit (unsigned long long) chunks. 5 | */ 6 | #ifndef MATH__RANDOM__SOURCES__RAND_SOURCE_64_HH 7 | #define MATH__RANDOM__SOURCES__RAND_SOURCE_64_HH 8 | 9 | #include "math/random/sources/rand_source.hh" 10 | 11 | namespace math { 12 | namespace random { 13 | namespace sources { 14 | 15 | /* 16 | * Abstract base class for pseudorandom 64-bit source. 17 | */ 18 | class rand_source_64 : public rand_source { 19 | public: 20 | /* 21 | * Destructor. 22 | */ 23 | virtual ~rand_source_64() = 0; 24 | 25 | /* 26 | * Generate a pseudorandom boolean uniformly distributed on {true, false}. 27 | */ 28 | bool gen_uniform_bool(); 29 | 30 | /* 31 | * Generate a pseudorandom integer uniformly distributed on the closed 32 | * interval [0, 2^N - 1], where N is the number of bits of precision in 33 | * the corresponding datatype. 34 | */ 35 | unsigned char gen_uniform_unsigned_char(); 36 | unsigned short gen_uniform_unsigned_short(); 37 | unsigned int gen_uniform_unsigned_int(); 38 | unsigned long gen_uniform_unsigned_long(); 39 | unsigned long long gen_uniform_unsigned_long_long(); 40 | 41 | protected: 42 | /* 43 | * Generate a pseudorandom uniformly distributed 64-bit chunk. 44 | */ 45 | virtual unsigned long long generate() = 0; 46 | }; 47 | 48 | } /* namespace sources */ 49 | } /* namespace random */ 50 | } /* namespace math */ 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/mlearning/clustering/metrics/metric.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Clustering metric. 3 | * 4 | * This is an abstract template class for a distance metric that can be used 5 | * in a clustering problem. 6 | */ 7 | #ifndef MLEARNING__CLUSTERING__METRICS__METRIC_HH 8 | #define MLEARNING__CLUSTERING__METRICS__METRIC_HH 9 | 10 | #include "collections/abstract/collection.hh" 11 | #include "lang/pointers/auto_ptr.hh" 12 | 13 | namespace mlearning { 14 | namespace clustering { 15 | namespace metrics { 16 | /* 17 | * Imports. 18 | */ 19 | using collections::abstract::collection; 20 | using lang::pointers::auto_ptr; 21 | 22 | /* 23 | * Clustering metric. 24 | * T is the type of object being clustered. 25 | * V is the numeric type used to represent distance. 26 | */ 27 | template 28 | class metric { 29 | public: 30 | /* 31 | * Destructor. 32 | */ 33 | virtual ~metric() { } 34 | 35 | /* 36 | * Distance computation. 37 | * Return the distance from the item to the centroid. 38 | */ 39 | virtual V distance( 40 | const T&, /* item */ 41 | const T& /* centroid */ 42 | ) const = 0; 43 | 44 | /* 45 | * Centroid computation. 46 | * Return the cluster centroid given the items in the cluster. 47 | * Note that the cluster must not be empty. 48 | */ 49 | virtual auto_ptr centroid( 50 | const collection&, /* items in cluster */ 51 | const collection& /* weight of each item */ 52 | ) const = 0; 53 | }; 54 | 55 | } /* namespace metrics */ 56 | } /* namespace clustering */ 57 | } /* namespace mlearning */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /mcg/src/external/RF_Reg_C/diabetes_C_devc.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=diabetes_C_devc.dev 3 | Name=diabetes_C_devc 4 | UnitCount=4 5 | Type=1 6 | Ver=1 7 | ObjFiles= 8 | Includes= 9 | Libs= 10 | PrivateResource= 11 | ResourceIncludes= 12 | MakeIncludes= 13 | Compiler= 14 | CppCompiler= 15 | Linker= 16 | IsCpp=1 17 | Icon= 18 | ExeOutput= 19 | ObjectOutput= 20 | OverrideOutput=0 21 | OverrideOutputName= 22 | HostApplication= 23 | Folders= 24 | CommandLine= 25 | UseCustomMakefile=0 26 | CustomMakefile= 27 | IncludeVersionInfo=0 28 | SupportXPThemes=0 29 | CompilerSet=0 30 | CompilerSettings= 31 | 32 | [Unit3] 33 | FileName=src\cokus.cpp 34 | CompileCpp=1 35 | Folder=diabetes_C_devc 36 | Compile=1 37 | Link=1 38 | Priority=1000 39 | OverrideBuildCmd=0 40 | BuildCmd= 41 | 42 | [VersionInfo] 43 | Major=0 44 | Minor=1 45 | Release=1 46 | Build=1 47 | LanguageID=1033 48 | CharsetID=1252 49 | CompanyName= 50 | FileVersion= 51 | FileDescription=Developed using the Dev-C++ IDE 52 | InternalName= 53 | LegalCopyright= 54 | LegalTrademarks= 55 | OriginalFilename= 56 | ProductName= 57 | ProductVersion= 58 | AutoIncBuildNr=0 59 | 60 | [Unit4] 61 | FileName=src\diabetes_C_wrapper.cpp 62 | CompileCpp=1 63 | Folder=diabetes_C_devc 64 | Compile=1 65 | Link=1 66 | Priority=1000 67 | OverrideBuildCmd=0 68 | BuildCmd= 69 | 70 | [Unit1] 71 | FileName=src\reg_RF.cpp 72 | CompileCpp=1 73 | Folder=diabetes_C_devc 74 | Compile=1 75 | Link=1 76 | Priority=1000 77 | OverrideBuildCmd=0 78 | BuildCmd= 79 | 80 | [Unit2] 81 | FileName=src\reg_RF.h 82 | CompileCpp=1 83 | Folder=diabetes_C_devc 84 | Compile=1 85 | Link=1 86 | Priority=1000 87 | OverrideBuildCmd=0 88 | BuildCmd= 89 | 90 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/random/sources/rand_source_64.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Pseudorandom source for 64-bit generators. 3 | */ 4 | #include "lang/types/type_ranges.hh" 5 | #include "lang/types/type_sizes.hh" 6 | #include "math/random/sources/rand_source_64.hh" 7 | 8 | namespace math { 9 | namespace random { 10 | namespace sources { 11 | 12 | /* 13 | * Pure virtual destructor. 14 | */ 15 | rand_source_64::~rand_source_64() { } 16 | 17 | /* 18 | * Generate a pseudorandom boolean uniformly distributed on {true, false}. 19 | */ 20 | bool rand_source_64::gen_uniform_bool() { 21 | return static_cast(this->generate() >> (ULONG_LONG_BITS - 1)); 22 | } 23 | 24 | /* 25 | * Generate a pseudorandom integer uniformly distributed on the closed 26 | * interval [0, 2^N - 1], where N is the number of bits of precision in 27 | * the corresponding datatype. 28 | */ 29 | unsigned char rand_source_64::gen_uniform_unsigned_char() { 30 | return static_cast(this->generate() >> (ULONG_LONG_BITS - UCHAR_BITS)); 31 | } 32 | 33 | unsigned short rand_source_64::gen_uniform_unsigned_short() { 34 | return static_cast(this->generate() >> (ULONG_LONG_BITS - USHRT_BITS)); 35 | } 36 | 37 | unsigned int rand_source_64::gen_uniform_unsigned_int() { 38 | return static_cast(this->generate() >> (ULONG_LONG_BITS - UINT_BITS)); 39 | } 40 | 41 | unsigned long rand_source_64::gen_uniform_unsigned_long() { 42 | return static_cast(this->generate() >> (ULONG_LONG_BITS - ULONG_BITS)); 43 | } 44 | 45 | unsigned long long rand_source_64::gen_uniform_unsigned_long_long() { 46 | return this->generate(); 47 | } 48 | 49 | } /* namespace sources */ 50 | } /* namespace random */ 51 | } /* namespace math */ 52 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/mlearning/clustering/clusterers/kmeans/basic_clusterer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Basic K-means clusterer. 3 | */ 4 | #include "lang/array.hh" 5 | #include "mlearning/clustering/clusterers/kmeans/basic_clusterer.hh" 6 | 7 | namespace mlearning { 8 | namespace clustering { 9 | namespace clusterers { 10 | namespace kmeans { 11 | /* 12 | * Imports. 13 | */ 14 | using lang::array; 15 | 16 | /* 17 | * Pure virtual destructor. 18 | */ 19 | basic_clusterer_base::~basic_clusterer_base() { } 20 | 21 | /* 22 | * Compute ids of changed centroids given change flags. 23 | */ 24 | array basic_clusterer_base::compute_changed_ids( 25 | const array& has_changed) 26 | { 27 | unsigned long n_clusters = has_changed.size(); 28 | return basic_clusterer_base::compute_changed_ids(has_changed, n_clusters); 29 | } 30 | 31 | /* 32 | * Compute ids of changed centroids given change flags. 33 | * Specify the number of centroids to consider. 34 | */ 35 | array basic_clusterer_base::compute_changed_ids( 36 | const array& has_changed, unsigned long n_clusters) 37 | { 38 | /* compute how many centroids have changed */ 39 | unsigned long n_changed = 0; 40 | for (unsigned long n = 0; n < n_clusters; n++) { 41 | if (has_changed[n]) 42 | n_changed++; 43 | } 44 | /* get array of changed centroid ids */ 45 | array changed_ids(n_changed); 46 | for (unsigned long n = 0, chngd = 0; chngd < n_changed; n++) { 47 | if (has_changed[n]) { 48 | changed_ids[chngd] = n; 49 | chngd++; 50 | } 51 | } 52 | return changed_ids; 53 | } 54 | 55 | } /* namespace kmeans */ 56 | } /* namesapce clusterers */ 57 | } /* namespace clustering */ 58 | } /* namespace mlearning */ 59 | -------------------------------------------------------------------------------- /mcg/src/tests/check_hier_correctness.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % 5 | % Jordi Pont-Tuset 6 | % June 2013 7 | % ------------------------------------------------------------------------ 8 | % 9 | % If compute_mcg_cands is run in parallel, since the writing to TXT is not 10 | % 'atomic', sometimes two processes wirte in the same file and 11 | % thus corrupt it. 12 | % This script checks the correctness of the hierarchies. 13 | % 14 | % ------------------------------------------------------------------------ 15 | function check_hier_correctness(params) 16 | 17 | if nargin==0 18 | params = get_params(); 19 | end 20 | 21 | % Load which images to consider from the params.database (train, val, etc.) 22 | im_ids = database_ids(params.database,params.gt_set_test); 23 | 24 | res_dir = fullfile(root_dir,'datasets',params.database,params.mcg_id); 25 | 26 | % Sweep all images 27 | num_images = length(im_ids); 28 | disp(['Starting test on: ' res_dir]) 29 | for im_id = 1:num_images 30 | 31 | hier_file = fullfile(res_dir,[im_ids{im_id} '_hier.txt']); 32 | 33 | if ~exist(hier_file,'file') 34 | disp(['Missing: ' hier_file]) 35 | else 36 | try 37 | hier = read_hier(hier_file); 38 | n_leaves = length(unique(hier.leaves_part)); 39 | n_merges = size(hier.ms_matrix,1); 40 | if ~isequal(n_merges+n_leaves,hier.ms_matrix(end,end)) 41 | disp(['Bad formed: ' hier_file]) 42 | end 43 | catch %#ok 44 | disp(['Bad formed: ' hier_file]) 45 | end 46 | end 47 | end 48 | disp('Done!') -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/concurrent/threads/synchronization/mutex.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Mutex. 3 | */ 4 | #ifndef CONCURRENT__THREADS__SYNCHRONIZATION__MUTEX_HH 5 | #define CONCURRENT__THREADS__SYNCHRONIZATION__MUTEX_HH 6 | 7 | #include 8 | 9 | namespace concurrent { 10 | namespace threads { 11 | namespace synchronization { 12 | 13 | class mutex { 14 | public: 15 | /* 16 | * Constructor. 17 | * Initialize the mutex to an unlocked state. 18 | */ 19 | inline mutex(); 20 | 21 | /* 22 | * Destructor. 23 | */ 24 | inline ~mutex(); 25 | 26 | /* 27 | * Lock the mutex. 28 | */ 29 | inline void lock(); 30 | 31 | /* 32 | * Unlock the mutex. 33 | */ 34 | inline void unlock(); 35 | 36 | protected: 37 | /* 38 | * Private copy constructor. 39 | * A mutex should not be copied. 40 | */ 41 | explicit inline mutex(const mutex&); 42 | 43 | pthread_mutex_t _m; /* mutex */ 44 | }; 45 | 46 | /* 47 | * Constructor. 48 | * Initialize the mutex to an unlocked state. 49 | */ 50 | inline mutex::mutex() { 51 | pthread_mutex_init(&_m, NULL); 52 | } 53 | 54 | /* 55 | * Private copy constructor. 56 | * A mutex should not be copied. 57 | */ 58 | inline mutex::mutex(const mutex&) { 59 | pthread_mutex_init(&_m, NULL); 60 | } 61 | 62 | /* 63 | * Destructor. 64 | */ 65 | inline mutex::~mutex() { 66 | pthread_mutex_destroy(&_m); 67 | } 68 | 69 | /* 70 | * Lock the mutex. 71 | */ 72 | inline void mutex::lock() { 73 | pthread_mutex_lock(&_m); 74 | } 75 | 76 | /* 77 | * Unlock the mutex. 78 | */ 79 | inline void mutex::unlock() { 80 | pthread_mutex_unlock(&_m); 81 | } 82 | 83 | } /* namespace synchronization */ 84 | } /* namespace threads */ 85 | } /* namespace concurrent */ 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/functors/key_hashable_functors.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Key-hashable functors. 3 | */ 4 | #ifndef FUNCTORS__KEY_HASHABLE_HH 5 | #define FUNCTORS__KEY_HASHABLE_HH 6 | 7 | #include "functors/mappable_functors.hh" 8 | #include "interfaces/key_hashable.hh" 9 | 10 | namespace functors { 11 | /* 12 | * Imports. 13 | */ 14 | using interfaces::key_hashable; 15 | 16 | /* 17 | * Functor for hashing items given a key. 18 | * Call the underlying hash method. 19 | */ 20 | template 21 | class key_hash_functor : public mappable_functor { 22 | public: 23 | /* 24 | * Constructors. 25 | * Set the key to use for the hash. 26 | */ 27 | key_hash_functor(const K&); 28 | key_hash_functor(const key_hash_functor&); 29 | 30 | /* 31 | * Hash method. 32 | */ 33 | using mappable_functor::operator(); 34 | H& operator()(const T&) const; 35 | 36 | private: 37 | const K& _key; 38 | }; 39 | 40 | template 41 | key_hash_functor::key_hash_functor(const K& k) 42 | : _key(k) 43 | { } 44 | 45 | template 46 | key_hash_functor::key_hash_functor(const key_hash_functor& f) 47 | : _key(f._key) 48 | { } 49 | 50 | template 51 | H& key_hash_functor::operator()(const T& t) const { 52 | return key_hashable::hash(t, _key); 53 | } 54 | 55 | /* 56 | * Functor for hashing items with const qualifier (given a key). 57 | * The same functor is used as for types without the qualifier. 58 | */ 59 | template 60 | class key_hash_functor : public key_hash_functor { }; 61 | 62 | } /* namespace functors */ 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /mcg/License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 2 | Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 3 | University of California Berkeley (UCB) - USA 4 | 5 | Jordi Pont-Tuset 6 | Pablo Arbelaez 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | The views and conclusions contained in the software and documentation are those 31 | of the authors and should not be interpreted as representing official policies, 32 | either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- /mcg/src/external/paretofront/paretoGroup.m: -------------------------------------------------------------------------------- 1 | function front=paretoGroup(X) 2 | 3 | % PARETOGROUP To get the Pareto Front from a given set of points. 4 | % synopsis: front =paretoGroup (objectiveMatrix) 5 | % where: 6 | % objectiveMatrix: [number of points X number of objectives] array 7 | % front: [number of points X 1] logical vector to indicate if ith 8 | % point belongs to the Pareto Front (true) or not (false). 9 | % 10 | % by Yi Cao, Cranfield University, 31 June 2007 11 | % 12 | % Identify the Pareto Front from a set of points in objective space is the 13 | % most important and also the most time-consuming task in multi-objective 14 | % optimization. This code splits the given objective set into several 15 | % smaller groups to be examined by the efficient paretofront algorithm. 16 | % Then, the Pareto Fronts of each group are combined as one set to be 17 | % checked by the paretofront algorithm to determine the overall Pareto 18 | % Front. In this way, the overal computation time can be reduced about 19 | % half. 20 | % 21 | % Example: 22 | % X = rand(1000000,4); 23 | % t0 = cputime; 24 | % Y1=paretoGroup(X); %mex implementation without sorting. 25 | % t1=cputime - t0; 26 | % t0 = cputime; 27 | % Y2=paretofront(X); 28 | % t2=cputime - t0; 29 | % isequal(Y1,Y2) %shoudl be 1 30 | % disp([t1 t2]) 31 | % Computation time based on Intel(R) Core(TM)2 CPU T2500 @ 2.0GHz, 2.0 GB of RAM 32 | % 0.6844 1.4404 33 | % 34 | 35 | [m,n]=size(X); 36 | groupcut=floor(2^13/n); 37 | gRoup=max(1,ceil(m/groupcut)); 38 | front=false(m,1); 39 | for k=1:gRoup 40 | z0=(k-1)*groupcut; 41 | z=(z0+1):min(z0+groupcut,m); 42 | front(z)=paretofront(X(z,:)); 43 | end 44 | if gRoup>1 45 | front(front)=paretofront(X(front,:)); 46 | end -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/vision/segmentation/segmentation.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Segmentation. 3 | */ 4 | #ifndef VISION__SEGMENTATION__SEGMENTATION_HH 5 | #define VISION__SEGMENTATION__SEGMENTATION_HH 6 | 7 | #include "collections/array_list.hh" 8 | #include "collections/pointers/auto_collection.hh" 9 | #include "lang/array.hh" 10 | #include "math/matrices/matrix.hh" 11 | #include "vision/segmentation/boundary.hh" 12 | #include "vision/segmentation/region.hh" 13 | 14 | namespace vision { 15 | namespace segmentation { 16 | /* 17 | * Imports. 18 | */ 19 | using collections::array_list; 20 | using collections::pointers::auto_collection; 21 | using lang::array; 22 | using math::matrices::matrix; 23 | 24 | /* 25 | * Compute region features given an oversegmentation. 26 | * Return the regions and boundaries. 27 | */ 28 | void compute_regions( 29 | const matrix&, /* oversegmentation pixel assignments */ 30 | const matrix<>&, /* image L channel */ 31 | const matrix<>&, /* image a channel */ 32 | const matrix<>&, /* image b channel */ 33 | const matrix<>&, /* local contrast at each pixel */ 34 | const matrix<>&, /* pb at each pixel */ 35 | auto_collection< region, array_list >&, /* returned regions */ 36 | auto_collection< boundary, array_list >& /* returned boundaries */ 37 | ); 38 | 39 | /* 40 | * Create a segmentation given initial regions and boundaries. 41 | * Return the assignment of initial regions -> final regions. 42 | */ 43 | array segment( 44 | auto_collection< region, array_list >, /* regions */ 45 | auto_collection< boundary, array_list > /* boundaries */ 46 | ); 47 | 48 | } /* namespace segmentation */ 49 | } /* namespace vision */ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /mcg/src/tests/test_jaccard.m: -------------------------------------------------------------------------------- 1 | 2 | % Simple 3 | object = [1 1 0 4 | 1 1 0 5 | 1 1 1]; 6 | ground_truth = [1 1 1 7 | 1 1 0 8 | 0 0 0]; 9 | [J, inters, fp, fn] = jaccard( object, ground_truth ); 10 | assert(J==0.5) 11 | assert(isequal(inters, [1 1 0 12 | 1 1 0 13 | 0 0 0])) 14 | assert(isequal(fp, [0 0 0 15 | 0 0 0 16 | 1 1 1])) 17 | assert(isequal(fn, [0 0 1 18 | 0 0 0 19 | 0 0 0])) 20 | 21 | 22 | % With ignore 23 | object = [1 1 0 24 | 1 1 0 25 | 1 1 1]; 26 | ground_truth = [1 1 1 27 | 1 0 0 28 | 0 0 0]; 29 | valid_pixels = [1 1 1 30 | 1 0 1 31 | 1 0 1]; 32 | [J, inters, fp, fn] = jaccard( object, ground_truth, valid_pixels); 33 | assert(J==0.5) 34 | assert(isequal(inters, [1 1 0 35 | 1 0 0 36 | 0 0 0])) 37 | assert(isequal(fp, [0 0 0 38 | 0 0 0 39 | 1 0 1])) 40 | assert(isequal(fn, [0 0 1 41 | 0 0 0 42 | 0 0 0])) 43 | 44 | 45 | %% Eval masks 46 | masks = cat(3, [1 0; 1 0], [1 1; 1 1], [1 1; 0 0]); 47 | masks = masks>0; 48 | gt = uint8([1 1; 2 0]); 49 | objs = unique(gt); 50 | objs(objs==0) = []; 51 | n_obj = length(objs); 52 | 53 | valid_pixels = ([1 1; 1 0]>0); 54 | 55 | [areas,int,fn] = mex_eval_masks(masks,gt,valid_pixels); 56 | fp = repmat(areas,n_obj,1)-int; 57 | assert(size(fp,1)==n_obj) 58 | assert(size(fp,2)==size(masks,3)) 59 | assert(isequal(int,[1 2 2; 1 1 0])) 60 | assert(isequal(fp,[1 1 0; 1 2 2])) 61 | assert(isequal(areas,[2 3 2])) 62 | 63 | assert(isequal(fn,[1 0 0; 0 0 1])) 64 | -------------------------------------------------------------------------------- /structured-edges/ng/make_filters.m: -------------------------------------------------------------------------------- 1 | function filters = make_filters(radii, gtheta) 2 | 3 | d = 2; 4 | 5 | filters = cell(numel(radii), numel(gtheta)); 6 | for r = 1:numel(radii), 7 | for t = 1:numel(gtheta), 8 | 9 | ra = radii(r); 10 | rb = ra / 4; 11 | theta = gtheta(t); 12 | 13 | ra = max(1.5, ra); 14 | rb = max(1.5, rb); 15 | ira2 = 1 / ra^2; 16 | irb2 = 1 / rb^2; 17 | wr = floor(max(ra, rb)); 18 | wd = 2*wr+1; 19 | sint = sin(theta); 20 | cost = cos(theta); 21 | 22 | % 1. compute linear filters for coefficients 23 | % (a) compute inverse of least-squares problem matrix 24 | filt = zeros(wd,wd,d+1); 25 | xx = zeros(2*d+1,1); 26 | for u = -wr:wr, 27 | for v = -wr:wr, 28 | ai = -u*sint + v*cost; % distance along major axis 29 | bi = u*cost + v*sint; % distance along minor axis 30 | if ai*ai*ira2 + bi*bi*irb2 > 1, continue; end % outside support 31 | xx = xx + cumprod([1;ai+zeros(2*d,1)]); 32 | end 33 | end 34 | A = zeros(d+1,d+1); 35 | for i = 1:d+1, 36 | A(:,i) = xx(i:i+d); 37 | end 38 | 39 | % (b) solve least-squares problem for delta function at each pixel 40 | for u = -wr:wr, 41 | for v = -wr:wr, 42 | ai = -u*sint + v*cost; % distance along major axis 43 | bi = u*cost + v*sint; % distance along minor axis 44 | if (ai*ai*ira2 + bi*bi*irb2) > 1, continue; end % outside support 45 | yy = cumprod([1;ai+zeros(d,1)]); 46 | filt(v+wr+1,u+wr+1,:) = A\yy; 47 | end 48 | end 49 | 50 | filters{r,t}=filt; 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /mcg/src/ucms/seg2bdry.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function [ bdry ] = seg2bdry(seg, fmt) 17 | if nargin<2, fmt = 'doubleSize'; end; 18 | 19 | if ~strcmp(fmt,'imageSize') && ~strcmp(fmt,'doubleSize'), 20 | error('possible values for fmt are: imageSize and doubleSize'); 21 | end 22 | 23 | [tx, ty, nch] = size(seg); 24 | 25 | if nch ~=1, 26 | error('seg must be a scalar image'); 27 | end 28 | 29 | bdry = zeros(2*tx+1, 2*ty+1); 30 | 31 | edgels_v = ( seg(1:end-1, :) ~= seg(2:end, :) ); 32 | edgels_v(end+1, :) = 0; 33 | edgels_h = ( seg(:, 1:end-1) ~= seg(:, 2:end) ); 34 | edgels_h(:, end+1) = 0; 35 | 36 | bdry(3:2:end, 2:2:end) = edgels_v; 37 | bdry(2:2:end, 3:2:end) = edgels_h; 38 | bdry(3:2:end-1, 3:2:end-1)= max ( max(edgels_h(1:end-1, 1:end-1), edgels_h(2:end, 1:end-1)), max(edgels_v(1:end-1,1:end-1), edgels_v(1:end-1,2:end)) ); 39 | 40 | bdry(1, :) = bdry(2, :); 41 | bdry(:, 1) = bdry(:, 2); 42 | bdry(end, :) = bdry(end-1, :); 43 | bdry(:, end) = bdry(:, end-1); 44 | 45 | if strcmp(fmt,'imageSize'), 46 | bdry = bdry(3:2:end, 3:2:end); 47 | end -------------------------------------------------------------------------------- /mcg/src/aux/loadvar.m: -------------------------------------------------------------------------------- 1 | function varargout = loadvar(filename, varargin) 2 | % Load the contents of a .MAT file directly into a returned variable 3 | 4 | % ====================================================================== 5 | % Copyright (c) 2012 David Weiss 6 | % 7 | % Permission is hereby granted, free of charge, to any person obtaining 8 | % a copy of this software and associated documentation files (the 9 | % "Software"), to deal in the Software without restriction, including 10 | % without limitation the rights to use, copy, modify, merge, publish, 11 | % distribute, sublicense, and/or sell copies of the Software, and to 12 | % permit persons to whom the Software is furnished to do so, subject to 13 | % the following conditions: 14 | % 15 | % The above copyright notice and this permission notice shall be 16 | % included in all copies or substantial portions of the Software. 17 | % 18 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | % EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | % NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | % LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | % OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | % WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | % ====================================================================== 26 | 27 | x = load(filename, varargin{:}); 28 | 29 | if nargin==1 30 | fs = fieldnames(x); 31 | if numel(fs) == 1 32 | x = x.(fs{1}); 33 | end 34 | varargout{1} = x; 35 | else 36 | if nargout == numel(varargin) 37 | for i = 1:numel(varargin) 38 | varargout{i} = x.(varargin{i}); 39 | end 40 | else 41 | varargout{1} = x; 42 | end 43 | end -------------------------------------------------------------------------------- /mcg/src/ucms/seg2bdry_wt.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % University of California Berkeley (UCB) - USA 5 | % 6 | % Jordi Pont-Tuset 7 | % Pablo Arbelaez 8 | % June 2014 9 | % ------------------------------------------------------------------------ 10 | % This file is part of the MCG package presented in: 11 | % Arbelaez P, Pont-Tuset J, Barron J, Marques F, Malik J, 12 | % "Multiscale Combinatorial Grouping," 13 | % Computer Vision and Pattern Recognition (CVPR) 2014. 14 | % Please consider citing the paper if you use this code. 15 | % ------------------------------------------------------------------------ 16 | function [ bdry ] = seg2bdry_wt(seg, fmt) 17 | if nargin<2, fmt = 'doubleSize'; end; 18 | 19 | if ~strcmp(fmt,'imageSize') && ~strcmp(fmt,'doubleSize'), 20 | error('possible values for fmt are: imageSize and doubleSize'); 21 | end 22 | 23 | [tx, ty, nch] = size(seg); 24 | 25 | if nch ~=1, 26 | error('seg must be a scalar image'); 27 | end 28 | 29 | bdry = zeros(2*tx+1, 2*ty+1); 30 | 31 | edgels_v = abs( seg(1:end-1, :) - seg(2:end, :) ); 32 | edgels_v(end+1, :) = 0; 33 | edgels_h = abs( seg(:, 1:end-1) - seg(:, 2:end) ); 34 | edgels_h(:, end+1) = 0; 35 | 36 | bdry(3:2:end, 2:2:end) = edgels_v; 37 | bdry(2:2:end, 3:2:end) = edgels_h; 38 | bdry(3:2:end-1, 3:2:end-1)= max ( max(edgels_h(1:end-1, 1:end-1), edgels_h(2:end, 1:end-1)), max(edgels_v(1:end-1,1:end-1), edgels_v(1:end-1,2:end)) ); 39 | 40 | bdry(1, :) = bdry(2, :); 41 | bdry(:, 1) = bdry(:, 2); 42 | bdry(end, :) = bdry(end-1, :); 43 | bdry(:, end) = bdry(:, end-1); 44 | 45 | if strcmp(fmt,'imageSize'), 46 | bdry = bdry(3:2:end, 3:2:end); 47 | end -------------------------------------------------------------------------------- /mcg/src/tests/test_cands2masks.m: -------------------------------------------------------------------------------- 1 | % ------------------------------------------------------------------------ 2 | % Copyright (C) 3 | % Universitat Politecnica de Catalunya BarcelonaTech (UPC) - Spain 4 | % 5 | % Jordi Pont-Tuset 6 | % June 2013 7 | % ------------------------------------------------------------------------ 8 | 9 | %% Dummy dummy 10 | lp = [ 1 1 1 11 | 2 3 2 12 | 2 2 2]; 13 | ms_matrix = [ 1 2 4 14 | 3 4 5]; 15 | 16 | cands = [1 2 0 17 | 1 2 3 18 | 2 0 0]; 19 | masks = cands2masks(cands, lp, ms_matrix); 20 | assert(isequal(masks(:,:,1),[1 1 1 21 | 1 0 1 22 | 1 1 1])) 23 | assert(isequal(masks(:,:,2),[1 1 1 24 | 1 1 1 25 | 1 1 1])) 26 | assert(isequal(masks(:,:,3),[0 0 0 27 | 1 0 1 28 | 1 1 1])) 29 | 30 | 31 | 32 | %% Real test 33 | im_id = '2008_000008'; 34 | load(fullfile(root_dir,'datasets','pascal2012','multiscale','multi', [im_id '.mat'])); 35 | 36 | curr_hier = ucm2hier(ucm2); 37 | ths{1}.start_ths = curr_hier.start_ths'; 38 | ths{1}.end_ths = curr_hier.end_ths'; 39 | ms{1} = curr_hier.ms_matrix; 40 | lps = curr_hier.leaves_part; 41 | 42 | [f_lp,f_ms,cands] = full_cands_from_hiers(lps,ms,ths,[500 500 500 500]'); 43 | 44 | tic 45 | % Get masks 46 | masks = cands2masks(cands, f_lp, f_ms); 47 | toc 48 | 49 | % Compute Areas from candidates 50 | b_feats = compute_base_features(f_lp, f_ms, ucm2); 51 | [~,areas1] = mex_fast_features(cands-1,b_feats.areas,2); 52 | 53 | % Compute areas way 2 54 | areas2 = zeros(size(masks,3),1); 55 | for ii=1:size(masks,3) 56 | tmp = masks(:,:,ii); 57 | areas2(ii) = sum(tmp(:)); 58 | end 59 | 60 | assert(isequal(areas1, areas2)) 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/math.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Math. 3 | */ 4 | #include "lang/types/type_ranges.hh" 5 | #include "math/math.hh" 6 | 7 | namespace math { 8 | 9 | /* 10 | * Define inverse hyperbolic trig functions. 11 | * (if the standard library does not define them) 12 | */ 13 | #if MATH__MATH__DEFINE_ACOSH 14 | float acosh(float x) { 15 | return log(x + sqrt(x*x - 1)); 16 | } 17 | 18 | double acosh(double x) { 19 | return log(x + sqrt(x*x - 1)); 20 | } 21 | 22 | long double acosh(long double x) { 23 | return log(x + sqrt(x*x - 1)); 24 | } 25 | #endif 26 | 27 | #if MATH__MATH__DEFINE_ASINH 28 | float asinh(float x) { 29 | return log(x + sqrt(x*x + 1)); 30 | } 31 | 32 | double asinh(double x) { 33 | return log(x + sqrt(x*x + 1)); 34 | } 35 | 36 | long double asinh(long double x) { 37 | return log(x + sqrt(x*x + 1)); 38 | } 39 | #endif 40 | 41 | #if MATH__MATH__DEFINE_ATANH 42 | float atanh(float x) { 43 | return (log((1 + x)/(1 - x)))/2; 44 | } 45 | 46 | double atanh(double x) { 47 | return (log((1 + x)/(1 - x)))/2; 48 | } 49 | 50 | long double atanh(long double x) { 51 | return (log((1 + x)/(1 - x)))/2; 52 | } 53 | #endif 54 | 55 | #if MATH__MATH__DEFINE_ROUND 56 | float round(float x) { 57 | return ((x < 0) ? ceil(x - 0.5) : floor(x + 0.5)); 58 | } 59 | 60 | double round(double x) { 61 | return ((x < 0) ? ceil(x - 0.5) : floor(x + 0.5)); 62 | } 63 | 64 | long double round(long double x) { 65 | return ((x < 0) ? ceil(x - 0.5) : floor(x + 0.5)); 66 | } 67 | #endif 68 | 69 | /* 70 | * Return epsilon (numeric precision) for the given built-in numeric type. 71 | */ 72 | template <> 73 | float eps() { 74 | return FLT_EPSILON; 75 | } 76 | 77 | template <> 78 | double eps() { 79 | return DBL_EPSILON; 80 | } 81 | 82 | template <> 83 | long double eps() { 84 | return LDBL_EPSILON; 85 | } 86 | 87 | } /* namespace math */ 88 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/concurrent/threads/synchronization/counter.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Counter. 3 | * This class implements a thread-safe counter. 4 | */ 5 | #ifndef CONCURRENT__THREADS__SYNCHRONIZATION__COUNTER_HH 6 | #define CONCURRENT__THREADS__SYNCHRONIZATION__COUNTER_HH 7 | 8 | #include "concurrent/threads/synchronization/mutex.hh" 9 | 10 | namespace concurrent { 11 | namespace threads { 12 | namespace synchronization { 13 | 14 | /* 15 | * Counter class (thread-safe). 16 | */ 17 | class counter { 18 | public: 19 | /* 20 | * Constructor. 21 | * Initialize the counter with value zero. 22 | */ 23 | counter(); 24 | 25 | /* 26 | * Constructor. 27 | * Initialize the counter with the specified value. 28 | */ 29 | explicit counter(unsigned long); 30 | 31 | /* 32 | * Copy constructor. 33 | * Create a counter with the same value as the original. 34 | */ 35 | explicit counter(const counter&); 36 | 37 | /* 38 | * Destructor. 39 | */ 40 | virtual ~counter(); 41 | 42 | /* 43 | * Get the counter value. 44 | */ 45 | unsigned long get() const; 46 | 47 | /* 48 | * Set the counter value. 49 | */ 50 | void set(unsigned long); 51 | 52 | /* 53 | * Increment the counter and return the new value. 54 | */ 55 | unsigned long increment(unsigned long = 1 /* increment amount */); 56 | 57 | /* 58 | * Decrement the counter and return the new value. 59 | * A decrement by more than the counter value sets the counter to zero. 60 | */ 61 | unsigned long decrement(unsigned long = 1 /* decrement amount */); 62 | 63 | protected: 64 | unsigned long _value; /* counter value */ 65 | mutable mutex _value_mutex; /* mutex for reading/writing counter value */ 66 | }; 67 | 68 | } /* namespace synchronization */ 69 | } /* namespace threads */ 70 | } /* namespace concurrent */ 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/src/math/libraries/lib_matrix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Matrix library. 3 | */ 4 | #include "lang/pointers/auto_ptr.hh" 5 | #include "math/complex.hh" 6 | #include "math/libraries/lib_matrix.hh" 7 | #include "math/math.hh" 8 | #include "math/matrices/cmatrix.hh" 9 | #include "math/matrices/matrix.hh" 10 | 11 | /* FIXME */ 12 | #include "lang/exceptions/ex_not_implemented.hh" 13 | 14 | namespace math { 15 | namespace libraries { 16 | /* 17 | * Imports. 18 | */ 19 | using lang::pointers::auto_ptr; 20 | using math::complex; 21 | using math::matrices::matrix; 22 | using math::matrices::cmatrix; 23 | 24 | /* FIXME */ 25 | using lang::exceptions::ex_not_implemented; 26 | 27 | /* 28 | * Eigenvalues and eigenvectors. 29 | */ 30 | void lib_matrix::eig( 31 | const matrix<>& m, 32 | auto_ptr< matrix<> >& evals, 33 | auto_ptr< matrix<> >& evecs) 34 | { 35 | /* FIXME */ 36 | throw ex_not_implemented(); 37 | } 38 | 39 | void lib_matrix::eig( 40 | const cmatrix<>& m, 41 | auto_ptr< cmatrix<> >& evals, 42 | auto_ptr< cmatrix<> >& evecs) 43 | { 44 | /* FIXME */ 45 | throw ex_not_implemented(); 46 | } 47 | 48 | /* 49 | * Singular value decomposition. 50 | * Return a diagonal matrix S of the same dimensions as the input matrix X 51 | * and unitary matrices U and V, such that X = U*S*V'. The diagonal 52 | * entries of S are nonnegative and in decreasing order. 53 | */ 54 | void lib_matrix::svd( 55 | const matrix<>& m, 56 | auto_ptr< matrix<> >& u, 57 | auto_ptr< matrix<> >& s, 58 | auto_ptr< matrix<> >& v) 59 | { 60 | /* FIXME */ 61 | throw ex_not_implemented(); 62 | } 63 | 64 | void lib_matrix::svd( 65 | const cmatrix<>& m, 66 | auto_ptr< cmatrix<> >& u, 67 | auto_ptr< cmatrix<> >& s, 68 | auto_ptr< cmatrix<> >& v) 69 | { 70 | /* FIXME */ 71 | throw ex_not_implemented(); 72 | } 73 | 74 | } /* namespace libraries */ 75 | } /* namespace math */ 76 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/geometry/triangle_2D.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Triangle with 2D vertex coordinates. 3 | */ 4 | #ifndef MATH__GEOMETRY__TRIANGLE_2D_HH 5 | #define MATH__GEOMETRY__TRIANGLE_2D_HH 6 | 7 | #include "io/streams/ostream.hh" 8 | #include "math/geometry/point_2D.hh" 9 | 10 | namespace math { 11 | namespace geometry { 12 | /* 13 | * Imports. 14 | */ 15 | using io::streams::ostream; 16 | 17 | /* 18 | * Triangle with 2D vertex coordinates. 19 | * Note that vertices are stored by reference. 20 | */ 21 | class triangle_2D { 22 | public: 23 | /* 24 | * Constructor. 25 | */ 26 | explicit triangle_2D(point_2D&, point_2D&, point_2D&); 27 | 28 | /* 29 | * Copy constructor. 30 | */ 31 | triangle_2D(const triangle_2D&); 32 | 33 | /* 34 | * Destructor. 35 | */ 36 | virtual ~triangle_2D(); 37 | 38 | /* 39 | * Formatted output to stream. 40 | */ 41 | friend ostream& operator<<(ostream&, const triangle_2D&); 42 | 43 | /* 44 | * Vertex reference. 45 | */ 46 | point_2D& vertex(unsigned long /* vertex # (0, 1, or 2) */) const; 47 | 48 | /* 49 | * Angle at vertex. 50 | */ 51 | double angle(unsigned long /* vertex # (0, 1, or 2) */) const; 52 | 53 | /* 54 | * Altitude from vertex to opposite side. 55 | */ 56 | double altitude(unsigned long /* vertex # (0, 1, or 2) */) const; 57 | 58 | /* 59 | * Length of side opposite vertex. 60 | */ 61 | double side_length(unsigned long /* vertex # (0, 1, or 2) */) const; 62 | 63 | /* 64 | * Area of triangle. 65 | */ 66 | double area() const; 67 | 68 | /* 69 | * Centroid. 70 | */ 71 | point_2D centroid() const; 72 | 73 | protected: 74 | point_2D& _v0; /* vertex 0 */ 75 | point_2D& _v1; /* vertex 1 */ 76 | point_2D& _v2; /* vertex 2 */ 77 | }; 78 | 79 | } /* namespace geometry */ 80 | } /* namespace math */ 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/include/math/geometry/triangle_3D.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Triangle with 3D vertex coordinates. 3 | */ 4 | #ifndef MATH__GEOMETRY__TRIANGLE_3D_HH 5 | #define MATH__GEOMETRY__TRIANGLE_3D_HH 6 | 7 | #include "io/streams/ostream.hh" 8 | #include "math/geometry/point_3D.hh" 9 | 10 | namespace math { 11 | namespace geometry { 12 | /* 13 | * Imports. 14 | */ 15 | using io::streams::ostream; 16 | 17 | /* 18 | * Triangle with 3D vertex coordinates. 19 | * Note that vertices are stored by reference. 20 | */ 21 | class triangle_3D { 22 | public: 23 | /* 24 | * Constructor. 25 | */ 26 | explicit triangle_3D(point_3D&, point_3D&, point_3D&); 27 | 28 | /* 29 | * Copy constructor. 30 | */ 31 | triangle_3D(const triangle_3D&); 32 | 33 | /* 34 | * Destructor. 35 | */ 36 | virtual ~triangle_3D(); 37 | 38 | /* 39 | * Formatted output to stream. 40 | */ 41 | friend ostream& operator<<(ostream&, const triangle_3D&); 42 | 43 | /* 44 | * Vertex reference. 45 | */ 46 | point_3D& vertex(unsigned long /* vertex # (0, 1, or 2) */) const; 47 | 48 | /* 49 | * Angle at vertex. 50 | */ 51 | double angle(unsigned long /* vertex # (0, 1, or 2) */) const; 52 | 53 | /* 54 | * Altitude from vertex to opposite side. 55 | */ 56 | double altitude(unsigned long /* vertex # (0, 1, or 2) */) const; 57 | 58 | /* 59 | * Length of side opposite vertex. 60 | */ 61 | double side_length(unsigned long /* vertex # (0, 1, or 2) */) const; 62 | 63 | /* 64 | * Area of triangle. 65 | */ 66 | double area() const; 67 | 68 | /* 69 | * Centroid. 70 | */ 71 | point_3D centroid() const; 72 | 73 | protected: 74 | point_3D& _v0; /* vertex 0 */ 75 | point_3D& _v1; /* vertex 1 */ 76 | point_3D& _v2; /* vertex 2 */ 77 | }; 78 | 79 | } /* namespace geometry */ 80 | } /* namespace math */ 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /mcg/src/external/BSR/buildW/util/exception.hh: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2002 David R. Martin 2 | // 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License as 5 | // published by the Free Software Foundation; either version 2 of the 6 | // License, or (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but 9 | // WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 16 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 17 | 18 | #ifndef EXCEPTION_HH 19 | #define EXCEPTION_HH 20 | 21 | #include 22 | 23 | namespace Util 24 | { 25 | // A simple exception class that contains an error message. 26 | 27 | class Exception { 28 | public: 29 | 30 | // Always construct exception with a message, so we can print 31 | // a useful error/log message. 32 | Exception(const char *msg); 33 | 34 | // We need to implement the copy constructor so that rethrowing 35 | // works. 36 | Exception(const Exception & that); 37 | 38 | virtual ~ Exception(); 39 | 40 | // Retrieve the message that this exception carries. 41 | virtual const char *msg() const; 42 | 43 | protected: 44 | 45 | char *_msg; 46 | 47 | }; 48 | 49 | // write to output stream 50 | inline std::ostream & operator<<(std::ostream & out, const Exception & e) 51 | { 52 | out << e.msg(); 53 | return out; 54 | } 55 | } 56 | 57 | #endif // __Exception_h__ 58 | --------------------------------------------------------------------------------