Skip to content

Commit

Permalink
[apps] Feature masking openMVG#513
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoulon committed Apr 15, 2016
1 parent 4d8bf09 commit 2afeb14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
8 changes: 4 additions & 4 deletions docs/sphinx/rst/software/SfM/ComputeFeatures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ Arguments description:

- NORMAL,
- HIGH,
- ULTRA: !!Can be time consumming!!
- ULTRA: !!Can be time consuming!!


**Use mask to filter keypoints/regions**

Sometime you may want to compute features/regions only on some parts of your images. It could include the folowing cases:
Sometime you may want to compute features/regions only on some parts of your images. It could include the following cases:

- You know that in your acquistion some areas may disturb the SfM pipeline (even if OpenMVG is known to be robust to a fair amount of outliers)
and lower the quality of the subsequent reconstruction. For exemple, in some close range configurations, you may prefer to move the object itself
- You know that in your acquisition some areas may disturb the SfM pipeline (even if OpenMVG is known to be robust to a fair amount of outliers)
and lower the quality of the subsequent reconstruction. For example, in some close range configurations, you may prefer to move the object itself
instead of moving the camera. Masks can also help you to deal with hemispherical fish-eyes, by masking useless zone of the sensor.
- You want to speed up the computation by reducing the number features/regions and thus the number of tie points.

Expand Down
22 changes: 10 additions & 12 deletions src/software/SfM/main_ComputeFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,9 @@ int main(int argc, char **argv)
// - if no file, compute features
{
system::Timer timer;
Image<unsigned char> imageGray;
Image<unsigned char> globalMask;
Image<unsigned char> imageMask;
Image<unsigned char> imageGray, globalMask, imageMask;

const std::string sGlobalMask_filename = stlplus::create_filespec(sfm_data.s_root_path, "mask.png");
const std::string sGlobalMask_filename = stlplus::create_filespec(sOutDir, "mask.png");
if(stlplus::file_exists(sGlobalMask_filename))
ReadImage(sGlobalMask_filename.c_str(), &globalMask);

Expand All @@ -225,12 +223,10 @@ int main(int argc, char **argv)
++iterViews, ++my_progress_bar)
{
const View * view = iterViews->second.get();
const std::string sView_filename = stlplus::create_filespec(sfm_data.s_root_path,
view->s_Img_path);
const std::string sFeat = stlplus::create_filespec(sOutDir,
stlplus::basename_part(sView_filename), "feat");
const std::string sDesc = stlplus::create_filespec(sOutDir,
stlplus::basename_part(sView_filename), "desc");
const std::string
sView_filename = stlplus::create_filespec(sfm_data.s_root_path, view->s_Img_path),
sFeat = stlplus::create_filespec(sOutDir, stlplus::basename_part(sView_filename), "feat"),
sDesc = stlplus::create_filespec(sOutDir, stlplus::basename_part(sView_filename), "desc");

//If features or descriptors file are missing, compute them
if (bForce || !stlplus::file_exists(sFeat) || !stlplus::file_exists(sDesc))
Expand All @@ -240,8 +236,10 @@ int main(int argc, char **argv)

Image<unsigned char> * mask = nullptr; // The mask is null by default

const std::string sImageMask_filename = stlplus::create_filespec(sfm_data.s_root_path,
stlplus::basename_part(sView_filename) + "_mask", "png");
const std::string sImageMask_filename =
stlplus::create_filespec(sfm_data.s_root_path,
stlplus::basename_part(sView_filename) + "_mask", "png");

if(stlplus::file_exists(sImageMask_filename))
ReadImage(sImageMask_filename.c_str(), &imageMask);

Expand Down
22 changes: 10 additions & 12 deletions src/software/SfM/main_ComputeFeatures_OpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,9 @@ int main(int argc, char **argv)
// - if no file, compute features
{
system::Timer timer;
Image<unsigned char> imageGray;
Image<unsigned char> globalMask;
Image<unsigned char> imageMask;
Image<unsigned char> imageGray, globalMask, imageMask;

const std::string sGlobalMask_filename = stlplus::create_filespec(sfm_data.s_root_path, "mask.png");
const std::string sGlobalMask_filename = stlplus::create_filespec(sOutDir, "mask.png");
if(stlplus::file_exists(sGlobalMask_filename))
ReadImage(sGlobalMask_filename.c_str(), &globalMask);

Expand All @@ -385,12 +383,10 @@ int main(int argc, char **argv)
++iterViews, ++my_progress_bar)
{
const View * view = iterViews->second.get();
const std::string sView_filename = stlplus::create_filespec(sfm_data.s_root_path,
view->s_Img_path);
const std::string sFeat = stlplus::create_filespec(sOutDir,
stlplus::basename_part(sView_filename), "feat");
const std::string sDesc = stlplus::create_filespec(sOutDir,
stlplus::basename_part(sView_filename), "desc");
const std::string
sView_filename = stlplus::create_filespec(sfm_data.s_root_path, view->s_Img_path),
sFeat = stlplus::create_filespec(sOutDir, stlplus::basename_part(sView_filename), "feat"),
sDesc = stlplus::create_filespec(sOutDir, stlplus::basename_part(sView_filename), "desc");

//If features or descriptors file are missing, compute them
if (bForce || !stlplus::file_exists(sFeat) || !stlplus::file_exists(sDesc))
Expand All @@ -400,8 +396,10 @@ int main(int argc, char **argv)

Image<unsigned char> * mask = nullptr; // The mask is null by default

const std::string sImageMask_filename = stlplus::create_filespec(sfm_data.s_root_path,
stlplus::basename_part(sView_filename) + "_mask", "png");
const std::string sImageMask_filename =
stlplus::create_filespec(sfm_data.s_root_path,
stlplus::basename_part(sView_filename) + "_mask", "png");

if(stlplus::file_exists(sImageMask_filename))
ReadImage(sImageMask_filename.c_str(), &imageMask);

Expand Down

0 comments on commit 2afeb14

Please sign in to comment.