libdart_openmvg/src/frame.h

126 lines
3.6 KiB
C
Raw Permalink Normal View History

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
2024-03-20 17:42:18 +01:00
#include <string>
#include <openMVG/matching/cascade_hasher.hpp>
#include <openMVG/matching/regions_matcher.hpp>
#include <openMVG/matching_image_collection/Matcher.hpp>
#include <openMVG/matching_image_collection/Matcher_Regions.hpp>
#include <openMVG/matching_image_collection/Pair_Builder.hpp>
#include <openMVG/sfm/pipelines/sfm_regions_provider.hpp>
#include <openMVG/sfm/pipelines/sfm_engine.hpp>
#include <openMVG/sfm/sfm_data_BA_ceres.hpp>
2024-03-20 17:42:18 +01:00
#include <openMVG/features/feature.hpp>
#include <openMVG/features/sift/octaver.hpp>
#include <openMVG/features/sift/SIFT_Anatomy_Image_Describer.hpp>
#include <openMVG/features/sift/sift_DescriptorExtractor.hpp>
#include <openMVG/features/sift/sift_KeypointExtractor.hpp>
#include <openMVG/features/akaze/AKAZE.hpp>
#include <openMVG/image/image_container.hpp>
#include <openMVG/image/image_io.hpp>
#include <openMVG/numeric/numeric.h>
#include <openMVG/tracks/tracks.hpp>
2024-04-03 16:39:37 +02:00
#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include <memory>
#include <openMVG/matching/indMatch.hpp>
#include <openMVG/matching_image_collection/Matcher_Regions.hpp>
#include <openMVG/matching_image_collection/Matcher.hpp>
#include <openMVG/matching/regions_matcher.hpp>
#include <openMVG/sfm/pipelines/sfm_regions_provider.hpp>
#include <openMVG/system/progressinterface.hpp>
#include <openMVG/system/logger.hpp>
2024-03-20 17:42:18 +01:00
#include <iostream>
#include <map>
#include <utility>
#include "./base.hpp"
2024-04-03 16:39:37 +02:00
#include "./mvg_override/describer/akaze.hpp"
#ifndef __FRAME_H
#define __FRAME_H
typedef struct _Frame
{
FILE *stream;
int w;
int h;
int depth;
} Frame;
FILE *make_buffer(const uint8_t *, const size_t);
int read_buffer(FILE *, uint8_t **, size_t *);
2024-03-20 17:42:18 +01:00
#ifdef __cplusplus
typedef Frame CFrame;
namespace DartOpenMvg
{
openMVG::image::Image<uint8_t> imageFromFrame(const Frame *);
class Frame
{
protected:
std::stringstream mStream;
int mW;
int mH;
int mDepth;
public:
// TODO make this private
const CFrame *cFrame;
// TODO make this private
std::unique_ptr<openMVG::features::Regions> mRegions;
2024-03-27 19:05:48 +01:00
Frame(const CFrame *f) : mW(f->w), mH(f->h), mDepth(f->depth)
2024-03-20 17:42:18 +01:00
{
cFrame = f;
uint8_t *buffer_data = NULL;
size_t len = 0;
2024-03-27 19:05:48 +01:00
rewind(f->stream);
2024-03-20 17:42:18 +01:00
read_buffer(f->stream, &buffer_data, &len);
mStream = std::stringstream(std::string((char *)buffer_data));
}
2024-03-23 18:44:50 +01:00
Frame(const Frame &);
openMVG::image::Image<u_char> getMvgImage();
2024-03-20 17:42:18 +01:00
void calculateFeatures();
};
typedef std::pair<const Frame &, const Frame &> FrameMatchKey;
typedef std::map<std::pair<size_t, size_t>, openMVG::matching::IndMatches> FrameFeatureMatch;
2024-03-20 17:42:18 +01:00
2024-03-23 18:44:50 +01:00
class Frames
2024-03-20 17:42:18 +01:00
{
protected:
2024-03-27 19:05:48 +01:00
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;
2024-03-23 18:44:50 +01:00
std::vector<Frame> mFrames;
Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &);
2024-03-27 19:05:48 +01:00
void add_frame(FILE *, int, int, int);
2024-03-20 17:42:18 +01:00
void computeMatches();
void buildTracks();
2024-03-23 18:44:50 +01:00
void adjust();
void resection();
void resectionAll();
2024-03-20 17:42:18 +01:00
};
}
#endif
_FFI_PLUGIN
Frame *new_frame_from_handle(FILE *, int, int, int);
2024-03-13 18:26:37 +01:00
_FFI_PLUGIN
Frame *new_frame_from_data(const uint8_t *, const size_t, int, int, int);
2024-03-23 01:27:54 +01:00
void frame_cleanup(Frame *);
#endif // __FRAME_H