Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b84d40fd14 | |||
| e1137844ac | |||
| 301fc2ca75 |
|
After Width: | Height: | Size: 466 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 473 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 473 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 467 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 466 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 467 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 487 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 473 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 465 KiB |
|
After Width: | Height: | Size: 461 KiB |
|
After Width: | Height: | Size: 457 KiB |
|
After Width: | Height: | Size: 455 KiB |
|
After Width: | Height: | Size: 453 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 453 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 458 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 462 KiB |
|
After Width: | Height: | Size: 463 KiB |
|
After Width: | Height: | Size: 465 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 465 KiB |
|
After Width: | Height: | Size: 463 KiB |
|
After Width: | Height: | Size: 462 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 459 KiB |
|
After Width: | Height: | Size: 457 KiB |
|
After Width: | Height: | Size: 456 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 453 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 456 KiB |
|
After Width: | Height: | Size: 458 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 464 KiB |
|
After Width: | Height: | Size: 467 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 489 KiB |
|
After Width: | Height: | Size: 489 KiB |
|
After Width: | Height: | Size: 490 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 493 KiB |
|
After Width: | Height: | Size: 494 KiB |
|
After Width: | Height: | Size: 495 KiB |
|
After Width: | Height: | Size: 495 KiB |
|
After Width: | Height: | Size: 493 KiB |
|
After Width: | Height: | Size: 491 KiB |
|
After Width: | Height: | Size: 490 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 482 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 476 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 466 KiB |
|
After Width: | Height: | Size: 465 KiB |
|
After Width: | Height: | Size: 465 KiB |
@@ -39,6 +39,7 @@ set (LIBDART_OPENMVG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(TIFF REQUIRED)
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extlib/cwalk)
|
||||
|
||||
@@ -59,6 +60,7 @@ set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE) # we only want lib
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
|
||||
add_library(${LIBDART_OPENMVG} SHARED
|
||||
"mvg_override/describer/akaze.hpp"
|
||||
"frame.cxx"
|
||||
"streamingview.cxx"
|
||||
"image.cxx"
|
||||
@@ -67,6 +69,8 @@ add_library(${LIBDART_OPENMVG} SHARED
|
||||
|
||||
set(CEREAL_INCLUDE_DIR ${OpenMVG_DIR}/../../../include/openMVG_dependencies/cereal/include/cereal/)
|
||||
|
||||
dump_cmake_variables("^opencv")
|
||||
|
||||
target_include_directories(
|
||||
${LIBDART_OPENMVG}
|
||||
PRIVATE
|
||||
@@ -74,6 +78,7 @@ target_include_directories(
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${ARCHIMEDES_INCLUDE_DIRS}
|
||||
${CEREAL_INCLUDE_DIR}
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
@@ -82,6 +87,7 @@ target_link_libraries(
|
||||
jpeg
|
||||
tiff
|
||||
png
|
||||
${OpenCV_LIBS}
|
||||
OpenMVG::openMVG_image
|
||||
OpenMVG::openMVG_numeric
|
||||
OpenMVG::openMVG_features
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "frame.h"
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <stdlib.h>
|
||||
|
||||
FILE *make_buffer(const uint8_t *data, const size_t data_len)
|
||||
{
|
||||
@@ -70,16 +72,18 @@ Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
|
||||
return f;
|
||||
}
|
||||
|
||||
void clean_frame(Frame *f) {
|
||||
void clean_frame(Frame *f)
|
||||
{
|
||||
fclose(f->stream);
|
||||
free(f);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
DartOpenMvg::Frame::Frame(const DartOpenMvg::Frame &frame) {
|
||||
DartOpenMvg::Frame::Frame(const DartOpenMvg::Frame &frame)
|
||||
{
|
||||
cFrame = frame.cFrame;
|
||||
mRegions = std::unique_ptr<openMVG::features::Regions>(frame.mRegions.get());
|
||||
// mRegions = std::unique_ptr<openMVG::features::Regions>(frame.mRegions.get());
|
||||
}
|
||||
|
||||
openMVG::image::Image<u_char> DartOpenMvg::imageFromFrame(const CFrame *frame)
|
||||
@@ -105,13 +109,15 @@ DartOpenMvg::Frames::Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_opti
|
||||
mAdjustment = openMVG::sfm::Bundle_Adjustment_Ceres(options);
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frames::add_frame(FILE *handle, int w, int h, int depth)
|
||||
{
|
||||
CFrame *f = new_frame_from_handle(handle, w, h, depth);
|
||||
mFrames.push_back(
|
||||
Frame(f));
|
||||
}
|
||||
|
||||
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
|
||||
@@ -119,20 +125,28 @@ void DartOpenMvg::Frames::computeMatches()
|
||||
// image sequences (video frames), we'll stick to the sequence order.
|
||||
for (size_t i = 0; i < mFrames.size() - 1; ++i)
|
||||
{
|
||||
const Frame &frame1 = mFrames[i];
|
||||
const Frame &frame2 = mFrames[i+1];
|
||||
auto *regions1 = frame1.mRegions.get();
|
||||
auto *regions2 = frame2.mRegions.get();
|
||||
Frame &frame1 = mFrames[i];
|
||||
Frame &frame2 = mFrames[i + 1];
|
||||
frame1.calculateFeatures();
|
||||
frame2.calculateFeatures();
|
||||
auto regions1 = frame1.mRegions.get();
|
||||
auto regions2 = frame2.mRegions.get();
|
||||
if (!regions1)
|
||||
{
|
||||
std::string msg = std::string("No frame. Did you remember to calculate regions for frame ") + std::to_string(i) + "?";
|
||||
throw std::out_of_range(msg);
|
||||
}
|
||||
|
||||
// regions1->Load();
|
||||
std::cerr << "Loading " << std::to_string(regions1->RegionCount()) << " regions" << std::endl;
|
||||
|
||||
auto is_binary = regions1->IsBinary();
|
||||
|
||||
// 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())
|
||||
@@ -168,12 +182,17 @@ void DartOpenMvg::Frame::calculateFeatures()
|
||||
{
|
||||
using namespace openMVG::image;
|
||||
using namespace openMVG::features;
|
||||
auto desc = SIFT_Anatomy_Image_describer(SIFT_Anatomy_Image_describer::Params());
|
||||
auto image = imageFromFrame(cFrame);
|
||||
mRegions = desc.Describe(image);
|
||||
MvgOverride::AKAZE_OCV_Image_describer desc;
|
||||
auto im = imageFromFrame(cFrame);
|
||||
mRegions = desc.Describe(im);
|
||||
|
||||
if (!mRegions.get()) {
|
||||
throw std::range_error("Could not set regions member.");
|
||||
}
|
||||
}
|
||||
|
||||
void DartOpenMvg::Frames::resection() {
|
||||
void DartOpenMvg::Frames::resection()
|
||||
{
|
||||
// openMVG::tracks::TracksUtilsMap::GetFeatIndexPerViewAndTrackId(
|
||||
// mTracks;
|
||||
// )
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <openMVG/image/image_io.hpp>
|
||||
#include <openMVG/numeric/numeric.h>
|
||||
#include <openMVG/tracks/tracks.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -36,6 +37,7 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include "./base.hpp"
|
||||
#include "./mvg_override/describer/akaze.hpp"
|
||||
|
||||
#ifndef __FRAME_H
|
||||
#define __FRAME_H
|
||||
@@ -72,11 +74,12 @@ namespace DartOpenMvg
|
||||
const CFrame *cFrame;
|
||||
// TODO make this private
|
||||
std::unique_ptr<openMVG::features::Regions> mRegions;
|
||||
Frame(const _Frame *f) : mW(f->w), mH(f->h), mDepth(f->depth)
|
||||
Frame(const CFrame *f) : mW(f->w), mH(f->h), mDepth(f->depth)
|
||||
{
|
||||
cFrame = f;
|
||||
uint8_t *buffer_data = NULL;
|
||||
size_t len = 0;
|
||||
rewind(f->stream);
|
||||
read_buffer(f->stream, &buffer_data, &len);
|
||||
mStream = std::stringstream(std::string((char *)buffer_data));
|
||||
}
|
||||
@@ -92,17 +95,17 @@ namespace DartOpenMvg
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
// TODO: make private with accessors
|
||||
openMVG::matching::PairWiseMatches mFeatureMap;
|
||||
openMVG::tracks::STLMAPTracks mTracks;
|
||||
openMVG::sfm::SfM_Data mSfmData;
|
||||
openMVG::sfm::Bundle_Adjustment_Ceres mAdjustment;
|
||||
|
||||
public:
|
||||
|
||||
// TODO: make private with accessors
|
||||
std::vector<Frame> mFrames;
|
||||
|
||||
Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &);
|
||||
void add_frame(FILE *, int, int, int);
|
||||
void computeMatches();
|
||||
void buildTracks();
|
||||
void adjust();
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
// This file is part of OpenMVG, an Open Multiple View Geometry C++ library.
|
||||
|
||||
// Copyright (c) 2012, 2013 Pierre MOULON.
|
||||
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The <cereal/archives> headers are special and must be included first.
|
||||
#include <cereal/archives/json.hpp>
|
||||
|
||||
#include "openMVG/image/image_io.hpp"
|
||||
#include "openMVG/features/regions_factory_io.hpp"
|
||||
#include "openMVG/sfm/sfm.hpp"
|
||||
#include "openMVG/system/timer.hpp"
|
||||
|
||||
/// OpenCV Includes
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/core/eigen.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
||||
#ifndef __MVG_OVERRIDE_DESCRIBER_AKAZE_H
|
||||
#define __MVG_OVERRIDE_DESCRIBER_AKAZE_H
|
||||
|
||||
|
||||
namespace MvgOverride
|
||||
{
|
||||
|
||||
using namespace openMVG;
|
||||
using namespace openMVG::image;
|
||||
using namespace openMVG::features;
|
||||
using namespace openMVG::sfm;
|
||||
|
||||
enum eGeometricModel
|
||||
{
|
||||
FUNDAMENTAL_MATRIX = 0,
|
||||
ESSENTIAL_MATRIX = 1,
|
||||
HOMOGRAPHY_MATRIX = 2
|
||||
};
|
||||
|
||||
enum ePairMode
|
||||
{
|
||||
PAIR_EXHAUSTIVE = 0,
|
||||
PAIR_CONTIGUOUS = 1,
|
||||
PAIR_FROM_FILE = 2
|
||||
};
|
||||
|
||||
///
|
||||
//- Create an Image_describer interface that use an OpenCV feature extraction method
|
||||
// i.e. with the AKAZE detector+descriptor
|
||||
//--/!\ If you use a new Regions type you define and register it in
|
||||
// "openMVG/features/regions_factory.hpp" file.
|
||||
///
|
||||
// Reuse the existing AKAZE floating point Keypoint.
|
||||
typedef features::AKAZE_Float_Regions AKAZE_OpenCV_Regions;
|
||||
// Define the Interface
|
||||
class AKAZE_OCV_Image_describer : public Image_describer
|
||||
{
|
||||
public:
|
||||
using Regions_type = AKAZE_OpenCV_Regions;
|
||||
|
||||
cv::Ptr<cv::Feature2D> extractor;
|
||||
|
||||
AKAZE_OCV_Image_describer() : Image_describer()
|
||||
{
|
||||
extractor = cv::AKAZE::create(cv::AKAZE::DESCRIPTOR_KAZE);
|
||||
}
|
||||
|
||||
bool Set_configuration_preset(EDESCRIBER_PRESET preset) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
@brief Detect regions on the image and compute their attributes (description)
|
||||
@param image Image.
|
||||
@param mask 8-bit gray image for keypoint filtering (optional).
|
||||
Non-zero values depict the region of interest.
|
||||
@return regions The detected regions and attributes (the caller must delete the allocated data)
|
||||
*/
|
||||
std::unique_ptr<Regions> Describe(
|
||||
const Image<unsigned char> &image,
|
||||
const Image<unsigned char> *mask = nullptr) override
|
||||
{
|
||||
return Describe_AKAZE_OCV(image, mask);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Detect regions on the image and compute their attributes (description)
|
||||
@param image Image.
|
||||
@param mask 8-bit gray image for keypoint filtering (optional).
|
||||
Non-zero values depict the region of interest.
|
||||
@return regions The detected regions and attributes (the caller must delete the allocated data)
|
||||
*/
|
||||
std::unique_ptr<Regions_type> Describe_AKAZE_OCV(
|
||||
const Image<unsigned char> &image,
|
||||
const Image<unsigned char> *mask = nullptr)
|
||||
{
|
||||
auto regions = std::unique_ptr<Regions_type>(new Regions_type);
|
||||
|
||||
cv::Mat img;
|
||||
cv::eigen2cv(image.GetMat(), img);
|
||||
|
||||
cv::Mat m_mask;
|
||||
if (mask != nullptr)
|
||||
{
|
||||
cv::eigen2cv(mask->GetMat(), m_mask);
|
||||
}
|
||||
|
||||
std::vector<cv::KeyPoint> vec_keypoints;
|
||||
cv::Mat m_desc;
|
||||
|
||||
extractor->detectAndCompute(img, m_mask, vec_keypoints, m_desc);
|
||||
|
||||
if (!vec_keypoints.empty())
|
||||
{
|
||||
// reserve some memory for faster keypoint saving
|
||||
regions->Features().reserve(vec_keypoints.size());
|
||||
regions->Descriptors().reserve(vec_keypoints.size());
|
||||
|
||||
using DescriptorT = Descriptor<float, 64>;
|
||||
DescriptorT descriptor;
|
||||
int cpt = 0;
|
||||
for (auto i_keypoint = vec_keypoints.begin(); i_keypoint != vec_keypoints.end(); ++i_keypoint, ++cpt)
|
||||
{
|
||||
const SIOPointFeature feat((*i_keypoint).pt.x, (*i_keypoint).pt.y, (*i_keypoint).size, (*i_keypoint).angle);
|
||||
regions->Features().push_back(feat);
|
||||
|
||||
memcpy(descriptor.data(),
|
||||
m_desc.ptr<typename DescriptorT::bin_type>(cpt),
|
||||
DescriptorT::static_size * sizeof(DescriptorT::bin_type));
|
||||
regions->Descriptors().push_back(descriptor);
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
};
|
||||
|
||||
/// Allocate Regions type depending of the Image_describer
|
||||
std::unique_ptr<Regions> Allocate() const override
|
||||
{
|
||||
return std::unique_ptr<Regions_type>(new Regions_type);
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive &ar)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __MVG_OVERRIDE_DESCRIBER_AKAZE_H
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <archives/binary.hpp>
|
||||
#include <CUnit/Basic.h>
|
||||
#include <errno.h>
|
||||
#include <ios>
|
||||
#include "../image.h"
|
||||
#include "../streamingview.hpp"
|
||||
#include "../util.h"
|
||||
@@ -9,12 +12,11 @@
|
||||
#endif // __cplusplus
|
||||
|
||||
#define STRLEN 2048
|
||||
#define FRAME_COUNT 200
|
||||
|
||||
typedef Frame CFrame;
|
||||
|
||||
FILE *imageHandle = NULL;
|
||||
char frame1Path[STRLEN];
|
||||
char frame2Path[STRLEN];
|
||||
char *framePaths[FRAME_COUNT];
|
||||
|
||||
#define HERE __FILE__
|
||||
|
||||
@@ -22,60 +24,78 @@ int setUp(void)
|
||||
{
|
||||
char framesDir[STRLEN];
|
||||
size_t length;
|
||||
char framePathTpl[STRLEN];
|
||||
cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests
|
||||
cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN);
|
||||
cwk_path_join(framesDir, "0001.png", frame1Path, STRLEN);
|
||||
cwk_path_join(framesDir, "0002.png", frame2Path, STRLEN);
|
||||
printf("Opening file %s\n", frame1Path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFrame *get_first_frame() {
|
||||
imageHandle = fopen(frame1Path, "rw+");
|
||||
CFrame *f = new_frame_from_handle(
|
||||
imageHandle,
|
||||
768,
|
||||
768,
|
||||
64);
|
||||
return f;
|
||||
}
|
||||
|
||||
CFrame *get_second_frame() {
|
||||
imageHandle = fopen(frame2Path, "rw+");
|
||||
CFrame *f = new_frame_from_handle(
|
||||
imageHandle,
|
||||
768,
|
||||
768,
|
||||
64);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
int tearDown(void)
|
||||
{
|
||||
if (imageHandle)
|
||||
cwk_path_join(framesDir, "%04d.png", framePathTpl, STRLEN);
|
||||
// Set the length to be the length of the "template" plus enough room
|
||||
// for the sequence number.
|
||||
size_t pathLen = strlen(framePathTpl) + 5;
|
||||
for (size_t i = 0; i < FRAME_COUNT; ++i)
|
||||
{
|
||||
fclose(imageHandle);
|
||||
framePaths[i] = (char *)calloc(pathLen, sizeof(char *));
|
||||
snprintf(framePaths[i], pathLen, framePathTpl, i+1, 4);
|
||||
printf("Load frame %s\n", framePaths[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_calculate_fetures(void) {
|
||||
Frame *f = get_first_frame();
|
||||
CFrame *get_nth_frame(size_t frame_num)
|
||||
{
|
||||
struct stat statbuf;
|
||||
if (stat(framePaths[frame_num], &statbuf) < 0)
|
||||
{
|
||||
// std::cerr << "ERROR reading \"" << framePaths << "\"" << std::endl;
|
||||
std::cerr << std::string("Reading \"") << std::string(framePaths[frame_num]) << std::string("\"") << std::endl;
|
||||
throw new std::ios_base::failure(std::string(strerror(errno)));
|
||||
}
|
||||
FILE *handle = fopen(framePaths[frame_num], "r");
|
||||
|
||||
CFrame *f = new_frame_from_handle(
|
||||
handle,
|
||||
768,
|
||||
768,
|
||||
64);
|
||||
return f;
|
||||
}
|
||||
|
||||
int tearDown(void)
|
||||
{
|
||||
for (int i = 0; i < FRAME_COUNT; ++i)
|
||||
{
|
||||
free(framePaths[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_calculate_fetures(void)
|
||||
{
|
||||
Frame *f = get_nth_frame(0);
|
||||
DartOpenMvg::Frame frame(f);
|
||||
|
||||
frame.calculateFeatures();
|
||||
CU_ASSERT_TRUE(frame.mRegions.get()->RegionCount() > 0);
|
||||
}
|
||||
|
||||
void test_compute_matches(void) {
|
||||
Frame *f1 = get_first_frame();
|
||||
Frame *f2 = get_second_frame();
|
||||
const DartOpenMvg::Frame frame1(f1), frame2(f2);
|
||||
void test_compute_matches(void)
|
||||
{
|
||||
Frame *f1 = get_nth_frame(0);
|
||||
Frame *f2 = get_nth_frame(1);
|
||||
DartOpenMvg::Frame frame1(f1), frame2(f2);
|
||||
openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options opts;
|
||||
DartOpenMvg::Frames frames(opts);
|
||||
|
||||
frame1.calculateFeatures();
|
||||
frame2.calculateFeatures();
|
||||
|
||||
frames.mFrames.push_back(frame1);
|
||||
frames.mFrames.push_back(frame2);
|
||||
|
||||
CU_ASSERT_EQUAL(frames.mFeatureMap.size(), 0)
|
||||
|
||||
frames.computeMatches();
|
||||
|
||||
CU_ASSERT_TRUE(frames.mFeatureMap.size() > 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -95,7 +115,8 @@ int main()
|
||||
}
|
||||
|
||||
/* add the tests to the suite */
|
||||
if ((NULL == CU_add_test(pSuite, "frame features can be calculated", test_calculate_fetures)))
|
||||
if ((NULL == CU_add_test(pSuite, "frame features can be calculated", test_calculate_fetures)) ||
|
||||
(NULL == CU_add_test(pSuite, "matches can be computed", test_compute_matches)))
|
||||
{
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
|
||||