initWorkspaceCaffeTools.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. function initWorkspaceCaffeTools
  2. % function initWorkspaceCaffeTools
  3. %
  4. % Author: Alexander Freytag
  5. %
  6. % BRIEF:
  7. % Add local subfolders and 3rd party libraries to Matlabs work space.
  8. % Needs to be adapted to your system!
  9. %
  10. %
  11. % Exemplary call from external position:
  12. % CAFFETOOLDIR = '/place/to/this/repository/';
  13. % currentDir = pwd;
  14. % cd ( CAFFETOOLDIR );
  15. % initWorkspaceCaffeTools;
  16. % cd ( currentDir );
  17. %
  18. %% setup paths of 3rd-party libraries in a user-specific manner
  19. CAFFEDIR = [];
  20. if strcmp( getenv('USER'), 'freytag')
  21. [~, s_hostname] = system( 'hostname' );
  22. s_hostname = s_hostname ( 1:(length(s_hostname)-1) ) ;
  23. s_dest_caffebuild = sprintf( '/home/freytag/lib/caffe_%s/matlab/', s_hostname );
  24. CAFFEDIR = s_dest_caffebuild;
  25. % note: try that one on pollux
  26. CAFFEDIR = '/home/freytag/lib/caffe_pollux_2016_08_23';
  27. %note: temporary usage of marcels recent caffe version
  28. %CAFFEDIR = '/home/simon/Research/lib/caffe.current/matlab/';
  29. elseif strcmp( getenv('USER'), 'rodner')
  30. [~, s_hostname] = system( 'hostname' );
  31. s_hostname = 'pollux';%s_hostname ( 1:(length(s_hostname)-1) ) ;
  32. s_dest_caffebuild = sprintf( '/home/freytag/lib/caffe_%s/matlab/', s_hostname );
  33. CAFFEDIR = s_dest_caffebuild;
  34. elseif strcmp( getenv('USER'), 'simon')
  35. [~, s_hostname] = system( 'hostname' );
  36. s_hostname = s_hostname ( 1:(length(s_hostname)-1) ) ;
  37. s_dest_caffebuild = sprintf( '/home/freytag/lib/caffe_%s/matlab/', s_hostname );
  38. CAFFEDIR = '/home/simon/Research/lib/caffe.current/matlab/';%s_dest_caffebuild;
  39. else
  40. fprintf('Unknown user %s and unknown default settings', getenv('USER') );
  41. end
  42. %% add paths which come with this repository
  43. %%
  44. % add main path
  45. b_recursive = false;
  46. b_overwrite = true;
  47. s_pathMain = fullfile(pwd);
  48. addPathSafely ( s_pathMain, b_recursive, b_overwrite )
  49. clear ( 's_pathMain' );
  50. %% 3rd party, untouched
  51. if ( isempty(CAFFEDIR) )
  52. fprintf('initWorkspaceCaffeTools-WARNING - no CAFFEDIR dir found on your machine. Code is available at http://caffe.berkeleyvision.org/installation.html \n');
  53. else
  54. b_recursive = true;
  55. b_overwrite = true;
  56. addPathSafely ( CAFFEDIR, b_recursive, b_overwrite );
  57. end
  58. %% clean up
  59. clear( 'CAFFEDIR' );
  60. end
  61. function addPathSafely ( s_path, b_recursive, b_overwrite )
  62. if ( ~isempty(strfind(path, [s_path , pathsep])) )
  63. if ( b_overwrite )
  64. if ( b_recursive )
  65. rmpath( genpath( s_path ) );
  66. else
  67. rmpath( s_path );
  68. end
  69. else
  70. fprintf('initWorkspaceCaffeTools - %s already in your path but overwriting de-activated.\n', s_path);
  71. return;
  72. end
  73. end
  74. if ( b_recursive )
  75. addpath( genpath( s_path ) );
  76. else
  77. addpath( s_path );
  78. end
  79. end