Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyframe Selection: Rework and add new selection methods #1343

Merged
merged 28 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f91a8c0
[dataio] VideoFeed: Improve error handling when moving to specific fr…
cbentejac Jan 20, 2023
edfe4f4
KeyframeSelection: Remove previous methods and add a new regular one
cbentejac Jan 31, 2023
4546359
KeyframeSelection: Harmonize indentation across files
cbentejac Jan 20, 2023
ff48245
KeyframeSelection: Add OpenCV dependency and the support of Optical Flow
cbentejac Jan 24, 2023
90c7dd7
KeyframeSelection: Add smart selection based on sharpness and optical…
cbentejac Feb 7, 2023
70279a4
[keyframe] Support exporting scores to a CSV file
cbentejac Jan 27, 2023
a5ef84e
[utils] KeyframeSelection: Add debug options to export scores as CSV
cbentejac Jan 24, 2023
cfe8499
[utils] KeyframeSelection: Add a debug option to skip the selection
cbentejac Jan 25, 2023
ec7f0e5
[keyframe] Add export of motion vectors to HSV images for each frame
cbentejac Jan 31, 2023
df7b50e
[utils] KeyframeSelection: Add options to export optical flow visuali…
cbentejac Jan 25, 2023
0035664
[keyframe] Handle corner case when identifying subsequences
cbentejac Jan 27, 2023
abb4f52
[utils] KeyframeSelection: Update software version
cbentejac Jan 25, 2023
1e77494
KeyframeSelection: Add support for several output extension files
cbentejac Jan 31, 2023
0cccda7
KeyframeSelection: Split rescaling parameters for sharpness and flow …
cbentejac Feb 1, 2023
9701143
[keyframe] Add a README describing the Keyframe module
cbentejac Feb 7, 2023
56a1939
KeyframeSelection: Add an option to name output keyframes consecutively
cbentejac Feb 7, 2023
576dec2
[keyframe] Handle missing frames within an input video
cbentejac Feb 8, 2023
23cef09
[dataio] Clean-up trailing whitespaces
cbentejac Feb 16, 2023
fee37d8
[image] Simplify retrieving the extensions supported by OpenImageIO
cbentejac Feb 16, 2023
9de160f
[image] Add a function determining if the input extension is a video …
cbentejac Feb 16, 2023
f2db007
[dataio] Check if the input format is supported with the "image" module
cbentejac Feb 16, 2023
281907a
[keyframe] Propage the input's orientation info to the output
cbentejac Feb 16, 2023
9ad5f60
[keyframe] Propagate pixel aspect ratio when possible
cbentejac Feb 16, 2023
c2148b4
[keyframe] Specify the input's colorspace when it is sRGB
cbentejac Feb 17, 2023
4f1f4db
KeyframeSelection: Add debug option to skip sharpness score computation
cbentejac Feb 23, 2023
f02e829
[utils] KeyframeSelection: Update "pxDisplacement" default value to 10%
cbentejac Mar 13, 2023
99b4e43
[keyframe] Add some info logs and increase the level of some debug logs
cbentejac Mar 13, 2023
5cbbbd8
[keyframe] build fix: add missing include
fabiencastan Mar 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ set(ALICEVISION_HAVE_OPENCV_CONTRIB 0)

if(ALICEVISION_BUILD_SFM)
if(NOT ALICEVISION_USE_OPENCV STREQUAL "OFF")
find_package(OpenCV COMPONENTS core imgproc video imgcodecs videoio features2d photo)
find_package(OpenCV COMPONENTS core imgproc video imgcodecs videoio features2d optflow photo)

if(OpenCV_FOUND)
# We do not set the minimal version directly in find_package
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ if(ALICEVISION_BUILD_SFM)
add_subdirectory(graph)
add_subdirectory(gpu)
add_subdirectory(imageMatching)
add_subdirectory(keyframe)
add_subdirectory(linearProgramming)
add_subdirectory(localization)
add_subdirectory(matching)
Expand All @@ -35,6 +34,7 @@ if(ALICEVISION_BUILD_SFM)
add_subdirectory(calibration)
if(ALICEVISION_HAVE_OPENCV)
add_subdirectory(imageMasking)
add_subdirectory(keyframe)
endif()
endif()

Expand Down
27 changes: 17 additions & 10 deletions src/aliceVision/dataio/FeedProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,39 @@
namespace aliceVision{
namespace dataio{

FeedProvider::FeedProvider(const std::string &feedPath, const std::string &calibPath)
FeedProvider::FeedProvider(const std::string &feedPath, const std::string &calibPath)
: _isVideo(false), _isLiveFeed(false)
{
namespace bf = boost::filesystem;
if(feedPath.empty())
{
throw std::invalid_argument("Empty filepath.");
}
if(bf::is_regular_file(bf::path(feedPath)))
if(bf::is_regular_file(bf::path(feedPath)))
{
// Image or video file
const std::string extension = bf::path(feedPath).extension().string();
if(ImageFeed::isSupported(extension))
{
_feeder.reset(new ImageFeed(feedPath, calibPath));
}
else
else
{
if(VideoFeed::isSupported(extension))
{
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OPENCV)
// let's try it with a video
_feeder.reset(new VideoFeed(feedPath, calibPath));
_isVideo = true;
// let's try it with a video
_feeder.reset(new VideoFeed(feedPath, calibPath));
_isVideo = true;
#else
throw std::invalid_argument("Unsupported mode! If you intended to use a video"
throw std::invalid_argument("Unsupported mode! If you intended to use a video"
" please add OpenCV support");
#endif
}
else
{
throw std::invalid_argument("Unsupported file format: " + feedPath);
}
}
}
// parent_path() returns "/foo/bar/" when input path equals to "/foo/bar/"
Expand Down Expand Up @@ -96,12 +103,12 @@ bool FeedProvider::readImage(image::Image<unsigned char> &imageGray,
{
return(_feeder->readImage(imageGray, camIntrinsics, mediaPath, hasIntrinsics));
}

std::size_t FeedProvider::nbFrames() const
{
if(_isLiveFeed)
return std::numeric_limits<std::size_t>::infinity();

return _feeder->nbFrames();
}

Expand All @@ -122,5 +129,5 @@ bool FeedProvider::isInit() const

FeedProvider::~FeedProvider( ) { }

}//namespace dataio
}//namespace dataio
}//namespace aliceVision
12 changes: 6 additions & 6 deletions src/aliceVision/dataio/FeedProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace dataio{
class FeedProvider
{
public:

FeedProvider(const std::string &feedPath, const std::string &calibPath = "");

/**
* @brief Provide a new RGB image from the feed.
*
Expand Down Expand Up @@ -51,7 +51,7 @@ class FeedProvider
camera::PinholeRadialK3 &camIntrinsics,
std::string &mediaPath,
bool &hasIntrinsics);

/**
* @brief Provide a new grayscale image from the feed.
*
Expand Down Expand Up @@ -101,7 +101,7 @@ class FeedProvider
* @return True if the feed is a video.
*/
bool isVideo() const {return _isVideo; }

/**
* @brief Return true if the feed is a live stream (e.g. a webcam).
*
Expand All @@ -110,14 +110,14 @@ class FeedProvider
bool isLiveFeed() const {return _isLiveFeed; }

virtual ~FeedProvider();

private:
std::unique_ptr<IFeed> _feeder;
bool _isVideo;
bool _isLiveFeed;

};

}//namespace dataio
}//namespace dataio
}//namespace aliceVision

8 changes: 4 additions & 4 deletions src/aliceVision/dataio/IFeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ void readCalibrationFromFile(const std::string &filename, camera::PinholeRadialK
int height = 0;
const size_t numParam = 6;
std::vector<double> params(numParam, 0);

fs >> width;
fs >> height;
for(size_t i = 0; i < numParam; ++i)
{
fs >> params[i];
}
camIntrinsics = camera::PinholeRadialK3(width, height,
camIntrinsics = camera::PinholeRadialK3(width, height,
params[0], params[1], params[2],
params[3], params[4], params[5]);

fs.close();
}

}//namespace dataio
}//namespace dataio
}//namespace aliceVision
16 changes: 8 additions & 8 deletions src/aliceVision/dataio/IFeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IFeed
* @return True if the feed is correctly initialized.
*/
virtual bool isInit() const = 0;

/**
* @brief Provide a new RGB image from the feed
* @param[out] imageRGB The new RGB image from the feed.
Expand Down Expand Up @@ -51,7 +51,7 @@ class IFeed
camera::PinholeRadialK3 &camIntrinsics,
std::string &mediaPath,
bool &hasIntrinsics) = 0;

/**
* @brief Provide a new grayscale image from the feed
* @param[out] imageGray The new image from the feed.
Expand All @@ -62,16 +62,16 @@ class IFeed
* @return True if there is a new image, false otherwise.
*/
virtual bool readImage(image::Image<unsigned char> &imageGray,
camera::PinholeRadialK3 &camIntrinsics,
camera::PinholeRadialK3 &camIntrinsics,
std::string &mediaPath,
bool &hasIntrinsics) = 0;
bool &hasIntrinsics) = 0;

virtual std::size_t nbFrames() const = 0;

virtual bool goToFrame(const unsigned int frame) = 0;

virtual bool goToNextFrame() = 0;

virtual ~IFeed( ) {}

};
Expand All @@ -84,6 +84,6 @@ class IFeed
*/
void readCalibrationFromFile(const std::string &filename, camera::PinholeRadialK3 &camIntrinsics);

}//namespace dataio
}//namespace dataio
}//namespace aliceVision

Loading