start developing unit tests for frames.
This commit is contained in:
@ -90,6 +90,70 @@ openMVG::image::Image<u_char> DartOpenMvg::imageFromFrame(const CFrame *frame)
|
||||
return openMVG::image::Image<uint8_t>(eigenMatrix);
|
||||
}
|
||||
|
||||
DartOpenMvg::Frames::Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &options)
|
||||
{
|
||||
mAdjustment = openMVG::sfm::Bundle_Adjustment_Ceres(options);
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frames::computeMatches()
|
||||
{
|
||||
#ifdef OPENMVG_USE_OPENMP
|
||||
OPENMVG_LOG_INFO << "Using the OPENMP thread interface";
|
||||
const bool b_multithreaded_pair_search = (eMatcherType_ == CASCADE_HASHING_L2);
|
||||
// -> set to true for CASCADE_HASHING_L2, since OpenMP instructions are not used in this matcher
|
||||
#endif
|
||||
|
||||
// Match the pairs as a sequence
|
||||
// Within openMvg::matching_image_collection::Matcher
|
||||
// they matcha gainst *ALL* images. However, since we know the order of the
|
||||
// image sequences (video frames), we'll stick to the sequence order.
|
||||
for (size_t i = 0; i < this->size() - 1; ++i)
|
||||
{
|
||||
const Frame &frame1 = this->at(i);
|
||||
const Frame &frame2 = this->at(i + 1);
|
||||
auto *regions1 = frame1.mRegions.get();
|
||||
auto *regions2 = frame2.mRegions.get();
|
||||
|
||||
// Initialize the matching interface
|
||||
const std::unique_ptr<openMVG::matching::RegionsMatcher> matcher =
|
||||
openMVG::matching::RegionMatcherFactory(openMVG::matching::EMatcherType::HNSW_L2, *regions1);
|
||||
if (!matcher)
|
||||
continue;
|
||||
|
||||
#ifdef OPENMVG_USE_OPENMP
|
||||
#pragma omp parallel for schedule(dynamic) if (b_multithreaded_pair_search)
|
||||
#endif
|
||||
openMVG::matching::IndMatches vec_putative_matches;
|
||||
matcher->MatchDistanceRatio(0.5, *regions2, vec_putative_matches);
|
||||
if (vec_putative_matches.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
mFeatureMap[std::make_pair(i, i + 1)] = vec_putative_matches;
|
||||
}
|
||||
};
|
||||
|
||||
void DartOpenMvg::Frames::buildTracks()
|
||||
{
|
||||
openMVG::tracks::TracksBuilder trackBuilder;
|
||||
|
||||
openMVG::matching::PairWiseMatches matches;
|
||||
|
||||
trackBuilder.Build(mFeatureMap);
|
||||
trackBuilder.Filter();
|
||||
trackBuilder.ExportToSTL(mTracks);
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frames::adjust()
|
||||
{
|
||||
const openMVG::sfm::Optimize_Options ba_refine_options(openMVG::cameras::Intrinsic_Parameter_Type::ADJUST_ALL,
|
||||
openMVG::sfm::Extrinsic_Parameter_Type::ADJUST_ALL, // Adjust camera motion
|
||||
openMVG::sfm::Structure_Parameter_Type::ADJUST_ALL, // Adjust scene structure
|
||||
openMVG::sfm::Control_Point_Parameter(),
|
||||
false);
|
||||
mAdjustment.Adjust(mSfmData, ba_refine_options);
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frame::calculateFeatures()
|
||||
{
|
||||
using namespace openMVG::image;
|
||||
@ -99,30 +163,15 @@ void DartOpenMvg::Frame::calculateFeatures()
|
||||
mRegions = desc.Describe(image);
|
||||
}
|
||||
|
||||
openMVG::image::Image<u_char> DartOpenMvg::Frame::getMvgImage() {
|
||||
void DartOpenMvg::Frames::resection() {
|
||||
// openMVG::tracks::TracksUtilsMap::GetFeatIndexPerViewAndTrackId(
|
||||
// mTracks;
|
||||
// )
|
||||
}
|
||||
|
||||
openMVG::image::Image<u_char> DartOpenMvg::Frame::getMvgImage()
|
||||
{
|
||||
return imageFromFrame(this->cFrame);
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frames::computeMatches()
|
||||
{
|
||||
using namespace openMVG::matching;
|
||||
using namespace openMVG::matching_image_collection;
|
||||
using namespace openMVG::sfm;
|
||||
using namespace openMVG::image;
|
||||
Matcher *matcher = nullptr;
|
||||
|
||||
Regions_Provider provider = Regions_Provider();
|
||||
|
||||
matcher = new Matcher_Regions(0.8f, CASCADE_HASHING_L2);
|
||||
|
||||
openMVG::Pair_Set pairs = openMVG::Pair_Set();
|
||||
Image im1 = this->at(0).getMvgImage();
|
||||
Image im2 = this->at(1).getMvgImage();
|
||||
auto pair = openMVG::Pair(0, 1);
|
||||
pairs.insert(pair);
|
||||
|
||||
PairWiseMatches map_punitive_matches;
|
||||
|
||||
// matcher->Match(provider, pairs, map_punitive_matches, NULL);
|
||||
|
||||
#endif // __cplusplus
|
Reference in New Issue
Block a user