Fixes for loading images with new interface.

This commit is contained in:
Tadas Baltrusaitis 2017-11-18 21:08:43 +00:00
parent 5a483f7486
commit 974cee63b9
5 changed files with 22 additions and 39 deletions

View file

@ -88,8 +88,6 @@ namespace Utilities
std::string output_codec;
double fps_vid_out;
// For output location
std::string output_root = "";
};
}

View file

@ -241,11 +241,21 @@ bool ImageCapture::OpenDirectory(std::string directory, std::string bbox_directo
std::ifstream in_bbox(bbox_file.string().c_str(), std::ios_base::in);
std::vector<cv::Rect_<double> > bboxes_image;
// Keep reading bounding boxes from a file, stop if empty line or
while (!in_bbox.eof())
{
std::string bbox_string;
std::getline(in_bbox, bbox_string);
if (bbox_string.empty())
continue;
std::stringstream ss(bbox_string);
double min_x, min_y, max_x, max_y;
in_bbox >> min_x >> min_y >> max_x >> max_y;
ss >> min_x >> min_y >> max_x >> max_y;
bboxes_image.push_back(cv::Rect_<double>(min_x, min_y, max_x - min_x, max_y - min_y));
}
in_bbox.close();

View file

@ -189,13 +189,12 @@ void RecorderOpenFace::SetObservationVisualization(const cv::Mat &vis_track)
if (params.outputTracked())
{
// Initialize the video writer if it has not been opened yet
if(!video_writer.isOpened())
if(video_writer.isOpened())
{
std::string video_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
std::string output_codec = params.outputCodec();
try
{
video_writer.open(video_filename, CV_FOURCC(output_codec[0], output_codec[1], output_codec[2], output_codec[3]), params.outputFps(), vis_track.size(), true);
video_writer.open(media_filename, CV_FOURCC(output_codec[0], output_codec[1], output_codec[2], output_codec[3]), params.outputFps(), vis_track.size(), true);
}
catch (cv::Exception e)
{

View file

@ -49,21 +49,6 @@ RecorderOpenFaceParameters::RecorderOpenFaceParameters(std::vector<std::string>
// Default output code
this->output_codec = "DIVX";
// First check if there is a root argument (so that videos and outputs could be defined more easilly)
for (size_t i = 0; i < arguments.size(); ++i)
{
if (arguments[i].compare("-root") == 0)
{
output_root = arguments[i + 1] + separator;
i++;
}
if (arguments[i].compare("-outroot") == 0)
{
output_root = arguments[i + 1] + separator;
i++;
}
}
bool output_set = false;
output_2D_landmarks = false;

View file

@ -26,9 +26,9 @@ else
end
if(isunix)
command = '"../../build/bin/FaceLandmarkImg"';
executable = '"../../build/bin/FaceLandmarkImg"';
else
command = '"../../x64/Release/FaceLandmarkImg.exe"';
executable = '"../../x64/Release/FaceLandmarkImg.exe"';
end
if(any(strcmp(varargin, 'model')))
@ -44,24 +44,15 @@ else
multi_view = 0;
end
command = cat(2, command, [' -mloc ' model ' ']);
command = cat(2, command, [' -multi_view ' num2str(multi_view) ' ']);
command = sprintf("%s -mloc %s -multiview %s -2Dfp -tracked ", executable, model, num2str(multi_view));
% TODO just landmarks + BBoxes
tic
parfor i=1:numel(dataset_dirs)
for i=1:numel(dataset_dirs)
input_loc = ['-fdir "', dataset_dirs{i}, '" '];
command_c = cat(2, command, input_loc);
out_loc = ['-ofdir "', output_loc, '" '];
command_c = cat(2, command_c, out_loc);
if(verbose)
out_im_loc = ['-oidir "', output_loc, '" '];
command_c = cat(2, command_c, out_im_loc);
end
command_c = cat(2, command_c, ' -wild ');
command_c = sprintf('%s -fdir "%s" -bboxdir "%s" -out_dir "%s" -wild ',...
command, dataset_dirs{i}, dataset_dirs{i}, output_loc);
if(isunix)
unix(command_c, '-echo');