Skip to content

Commit

Permalink
overhaul update for pose_estimation ros package and cleanup for rgbd-…
Browse files Browse the repository at this point in the history
…utils
  • Loading branch information
andyzeng committed Aug 29, 2016
1 parent af39d2b commit 0137ec6
Show file tree
Hide file tree
Showing 192 changed files with 6,227 additions and 1,037 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ UNFINISHED ... PLEASE DO NOT USE
## Documentation
* [Realsense Standalone](#realsense-standalone)
* [Realsense ROS Package](#realsense-ros-package)
* [Marvin FCN ROS Package](#marvin-fcn-ros-package)
* [Deep Learning FCN ROS Package](#deep-learning-fcn-ros-package)

## Realsense Standalone

Expand Down Expand Up @@ -47,7 +47,7 @@ This ROS packages comes in two different versions. Which version is installed wi
* Version #1: only returns RGB-D frame data on service calls (does not require OpenCV or PCL)
* Version #2: returns RGB-D frame data on service calls and publishes 3D point clouds (requires OpenCV and PCL)

See `ros_packages/realsense_camera`
See `ros-packages/realsense_camera`

### Dependencies

Expand Down Expand Up @@ -77,17 +77,17 @@ rosrun realsense_camera capture
* The service `/realsense_camera` returns data from the sensor (response data format described in `realsense_camera/srv/StreamSensor.srv`)
* If you need a GL window to see the streamed RGB-D data, run `rosrun realsense_camera capture _display:=True`

## Marvin FCN ROS Package
## Deep Learning FCN ROS Package

A C++ ROS package for deep learning based object segmentation using [FCNs (Fully Convolutional Networks)](https://arxiv.org/abs/1411.4038) with [Marvin](http://marvin.is/), a lightweight GPU-only neural network framework. This package feeds RGB-D data forward through a pre-trained ConvNet to retrieve object segmentation results. The neural networks are trained offline with [Marvin](http://marvin.is/).
A C++ ROS package for deep learning based object segmentation using [FCNs (Fully Convolutional Networks)](https://arxiv.org/abs/1411.4038) with [Marvin](http://marvin.is/), a lightweight GPU-only neural network framework. This package feeds RGB-D data forward through a pre-trained ConvNet to retrieve object segmentation results. The neural networks are trained offline with Marvin.

See `ros_packages/marvin_fcn`
See `ros-packages/marvin_convnet`

### Dependencies

1. [Realsense ROS Package](#realsense-ros-package)
1. [Realsense ROS Package](#realsense-ros-package) needs to be compiled first.

2. [CUDA 7.5](https://developer.nvidia.com/cuda-downloads) and [cuDNN 5](https://developer.nvidia.com/cudnn) to support [Marvin](http://marvin.is/). You may need to register with NVIDIA. Below are some additional steps to set up cuDNN 5. **NOTE** We highly recommend that you install different versions of cuDNN to different directories (e.g., ```/usr/local/cudnn/vXX```) because different software packages may require different versions.
2. [CUDA 7.5](https://developer.nvidia.com/cuda-downloads) and [cuDNN 5](https://developer.nvidia.com/cudnn). You may need to register with NVIDIA. Below are some additional steps to set up cuDNN 5. **NOTE** We highly recommend that you install different versions of cuDNN to different directories (e.g., ```/usr/local/cudnn/vXX```) because different software packages may require different versions.

```shell
LIB_DIR=lib$([[ $(uname) == "Linux" ]] && echo 64)
Expand All @@ -98,6 +98,7 @@ tar zxvf cudnn*.tgz
sudo cp cuda/$LIB_DIR/* $CUDNN_LIB_DIR/
sudo cp cuda/include/* /usr/local/cudnn/v5/include/
```

3. OpenCV (tested with OpenCV 2.4.11)
* Used for saving images

Expand All @@ -113,11 +114,11 @@ make sure where data is going to be read and written

ros package to compute hha

`rosrun marvin_fcn detect _service_mode:=1 _write_directory:="/home/andyz/apc/toolbox/ros_pacges/catkin_ws/src/marvin_fcn/data"`
`rosrun marvin_convnet detect _service_mode:=1 _write_directory:="/home/andyz/apc/toolbox/data/tmp"`

`rosrun marvin_fcn detect _service_mode:=2 _read_directory:="/home/andyz/apc/toolbox/ros_packages/catkin_ws/src/marvin_fcn/data" _write_directory:="/home/andyz/apc/toolbox/ros_packages/catkin_ws/src/marvin_fcn/data"`
`rosrun marvin_convnet detect _service_mode:=2 _read_directory:="/home/andyz/apc/toolbox/data/tmp" _write_directory:="/home/andyz/apc/toolbox/data/tmp"`

`rosservice call /marvin_fcn ["elmers_washable_no_run_school_glue","expo_dry_erase_board_eraser"] 0 0`
`rosservice call /marvin_convnet ["elmers_washable_no_run_school_glue","expo_dry_erase_board_eraser"] 0 0`



Expand Down
23 changes: 0 additions & 23 deletions calibration/calibrate.m

This file was deleted.

75 changes: 0 additions & 75 deletions calibration/demo.m

This file was deleted.

43 changes: 0 additions & 43 deletions calibration/loadCalib.m

This file was deleted.

137 changes: 137 additions & 0 deletions evaluation/benchmark.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
% Test on MIT-Princeton APC 2016 Benchmark
%
% Start ROS services marvin_convnet and pose_estimation before running this
% script (and realsense_camera if necessary)
% Set marvin_convnet to mode 2 to read RGB-D data from disk
% Run in same Matlab instance as where ROS service pose_estimation was started
%
% ---------------------------------------------------------
% Copyright (c) 2016, Andy Zeng
%
% This file is part of the APC Vision Toolbox and is available
% under the terms of the Simplified BSD License provided in
% LICENSE. Please retain this notice and LICENSE if you use
% this file (or any portion of it) in your project.
% ---------------------------------------------------------

% User configurations (change me)
tmpDataPath = '/home/andyz/apc/toolbox/data/tmp'; % Temporary directory used by marvin_convnet, where all RGB-D images and detection masks are saved
benchmarkPath = '/home/andyz/apc/toolbox/data/benchmark'; % Benchmark directory
rgbdUtilsPath = '/home/andyz/apc/toolbox/rgbd-utils'; % Directory of RGB-D toolbox utilities
resultVisPath = 'results'; % Directory to save visualizations of pose estimation results

% Load benchmark scenes and labels
sceneList = {};
fid = fopen(fullfile(benchmarkPath,'info.txt'));
while ~feof(fid)
scenePath = fullfile(benchmarkPath,fscanf(fid,'%s,'));
if ~feof(fid)
sceneList{length(sceneList)+1} = scenePath(1:(end-1));
end
end
fclose(fid);

% Add paths and create directories
addpath(genpath(rgbdUtilsPath));
if ~exist(tmpDataPath,'file')
mkdir(tmpDataPath);
end
if ~exist(resultVisPath,'file')
mkdir(resultVisPath);
end

% Loop through benchmark scenes
for sceneIdx = 1:length(sceneList)
scenePath = sceneList{sceneIdx};
fprintf(sprintf('[Test] %s\n',scenePath));

% Remove all files in temporary folder used by marvin_convnet
delete(fullfile(tmpDataPath,'*'));

% Copy current scene to temporary folder used by marvin_convnet
copyfile(fullfile(scenePath,'*'),tmpDataPath);

% Load scene
sceneData = loadScene(scenePath);
numFrames = length(sceneData.colorFrames);

% Call marvin_convnet to do 2D object segmentation for each RGB-D frame
fprintf(' [Segmentation] Frame ');
binIds = 'ABCDEFGHIJKL';
binNum = strfind(binIds,sceneData.binId)-1;
for frameIdx = 0:(numFrames-1)
fprintf('%d ',frameIdx);
[client,reqMsg] = rossvcclient('/marvin_convnet');
reqMsg.BinId = binNum;
reqMsg.ObjectNames = sceneData.objects;
reqMsg.FrameId = frameIdx;
response = call(client,reqMsg);
end
fprintf('\n');

% Call apc_posest to do object pose estimation for the sequence
[client,reqMsg] = rossvcclient('/pose_estimation');
reqMsg.SceneFiles = tmpDataPath;
if ~isempty(strfind(scenePath,'office'))
reqMsg.CalibrationFiles = '/home/andyz/apc/toolbox/data/benchmark/office/calibration';
elseif ~isempty(strfind(scenePath,'warehouse'))
reqMsg.CalibrationFiles = '/home/andyz/apc/toolbox/data/benchmark/warehouse/calibration';
end
reqMsg.DoCalibration = true;
response = call(client,reqMsg);

% % Copy result and visualization files to results folder
% resultFiles = dir(fullfile(tmpDataPath,'*.result.txt'));
% resultImages = dir(fullfile(tmpDataPath,'*.result.png'));
% visFiles = dir('*.ply');
% visObjNames = {};
% visObjScores = {};
% for resultIdx = 1:length(resultFiles)
% currResultFile = resultFiles(resultIdx).name;
% currResultFilenameDotIdx = strfind(currResultFile,'.');
% currObjName = currResultFile(1:(currResultFilenameDotIdx(1)-1));
% currResultFileMatrix = dlmread(fullfile(tmpDataPath,currResultFile));
% currObjScore = currResultFileMatrix(length(currResultFileMatrix));
% visObjNames{length(visObjNames)+1} = currObjName;
% visObjScores{length(visObjScores)+1} = currObjScore;
% % copyfile(fullfile(tmpPath,resultFiles(resultIdx).name),fullfile(resultPath,[testDir(seqIdx).name,'.',resultFiles(resultIdx).name]));
% end
% for resultIdx = 1:length(resultImages)
% currResultFile = resultImages(resultIdx).name;
% visResultImage = imread(fullfile(tmpDataPath,currResultFile));
% [sortVals,sortIdx] = sortrows(cell2mat(visObjScores)',-1);
% visResultImage = insertText(visResultImage,[10 10],'Confidence : Object ID','TextColor','white','BoxColor','black');
% textY = 32;
% for objIdx = 1:length(visObjNames)
% if ~isempty(strfind(currResultFile,visObjNames{sortIdx(objIdx)}))%resultIdx == sortIdx(objIdx)
% visResultImage = insertText(visResultImage,[10 textY],sprintf('%f : %s',visObjScores{sortIdx(objIdx)},visObjNames{sortIdx(objIdx)}),'TextColor','black','BoxColor','green');
% else
% visResultImage = insertText(visResultImage,[10 textY],sprintf('%f : %s',visObjScores{sortIdx(objIdx)},visObjNames{sortIdx(objIdx)}),'TextColor','white','BoxColor','black');
% end
% textY = textY + 22;
% end
% imwrite(visResultImage,fullfile(resultPath,strcat(testDir(sceneIdx).name,'.',resultImages(resultIdx).name)));
% % copyfile(fullfile(tmpPath,resultImages(resultIdx).name),fullfile(resultPath,[testDir(seqIdx).name,'.',resultImages(resultIdx).name]));
% end
% % copyfile(fullfile(tmpPath,'frame-000007.color.png'),fullfile(resultPath,[testDir(seqIdx).name,'.','frame-000007.color.png']));
% for visFileIdx = 1:length(visFiles)
% movefile(visFiles(visFileIdx).name,fullfile(resultPath,[testDir(sceneIdx).name,'.',visFiles(visFileIdx).name]));
% end

end
















48 changes: 48 additions & 0 deletions evaluation/prepBenchmark.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@




seqList = {};
benchmarkPath = '/home/andyz/apc/toolbox/data/benchmark';
fid = fopen(fullfile(benchmarkPath,'info.txt'),'wb');

% otsDir = dir(fullfile(benchmarkPath,'office/test/shelf/scene-0*'));
% for seqIdx = 1:length(otsDir)
% fprintf(fid,'office/test/shelf/%s,\n',otsDir(seqIdx).name);
% end
%
% ottDir = dir(fullfile(benchmarkPath,'office/test/tote/scene-0*'));
% for seqIdx = 1:length(ottDir)
% fprintf(fid,'office/test/tote/%s,\n',ottDir(seqIdx).name);
% end
%
% wpsDir = dir(fullfile(benchmarkPath,'warehouse/practice/shelf/scene-0*'));
% for seqIdx = 1:length(wpsDir)
% fprintf(fid,'warehouse/practice/shelf/%s,\n',wpsDir(seqIdx).name);
% end
%
% wptDir = dir(fullfile(benchmarkPath,'warehouse/practice/tote/scene-0*'));
% for seqIdx = 1:length(wptDir)
% fprintf(fid,'warehouse/practice/tote/%s,\n',wptDir(seqIdx).name);
% end

wcsDir = dir(fullfile(benchmarkPath,'warehouse/competition/shelf/scene-0*'));
for seqIdx = 1:length(wcsDir)
fprintf(fid,'warehouse/competition/shelf/%s,\n',wcsDir(seqIdx).name);
end

wctDir = dir(fullfile(benchmarkPath,'warehouse/competition/tote/scene-0*'));
for seqIdx = 1:length(wctDir)
fprintf(fid,'warehouse/competition/tote/%s,\n',wctDir(seqIdx).name);
end

fclose(fid);









File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0137ec6

Please sign in to comment.