libdart_openmvg/src/frame.h

117 lines
3.3 KiB
C++

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#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>
#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>
#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>
#include <iostream>
#include <map>
#include <utility>
#include "./base.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 *);
#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;
Frame(const _Frame *f) : mW(f->w), mH(f->h), mDepth(f->depth)
{
cFrame = f;
uint8_t *buffer_data = NULL;
size_t len = 0;
read_buffer(f->stream, &buffer_data, &len);
mStream = std::stringstream(std::string((char *)buffer_data));
}
openMVG::image::Image<u_char> getMvgImage();
void calculateFeatures();
};
typedef std::pair<const Frame &, const Frame &> FrameMatchKey;
typedef std::map<std::pair<size_t, size_t>, openMVG::matching::IndMatches> FrameFeatureMatch;
class Frames : protected std::vector<DartOpenMvg::Frame>
{
protected:
openMVG::matching::PairWiseMatches mFeatureMap;
openMVG::tracks::STLMAPTracks mTracks;
openMVG::sfm::SfM_Data mSfmData;
openMVG::sfm::Bundle_Adjustment_Ceres mAdjustment;
public:
Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &);
void computeMatches();
void buildTracks();
void adjust ();
void resection ();
void resectionAll ();
};
}
#endif
_FFI_PLUGIN
Frame *new_frame_from_handle(FILE *, int, int, int);
_FFI_PLUGIN
Frame *new_frame_from_data(const uint8_t *, const size_t, int, int, int);
void frame_cleanup(Frame *);
#endif // __FRAME_H