paella/Code/src/Skeleton/Skeleton.hpp

61 lines
1.8 KiB
C++
Raw Normal View History

2015-02-05 11:38:30 +01:00
#ifndef SKELETON_HPP
#define SKELETON_HPP
#include <string>
#include <vector>
#include <sstream>
#include "opencv2/features2d/features2d.hpp"
2015-02-05 11:38:30 +01:00
#include "Box.hpp"
class Vertex
{
public:
float x;
float y;
float z;
2015-02-05 11:38:30 +01:00
};
class Edge
{
public:
unsigned int v1;
unsigned int v2;
};
class Junction
{
public:
Junction(unsigned int i) : center{i}, neighbourgs{} {};
unsigned int center;
std::vector<unsigned int> neighbourgs;
};
class Skeleton
{
public:
Skeleton();
void loadFromFile(std::string const& path);
void draw() const;
void loadFromVectors(std::vector<Vertex> const& vertices, std::vector<unsigned int> const& path);
void countNeighbourgs();
void computeJunctions();
std::vector<Skeleton> split();
friend std::ostream& operator<<(std::ostream& out, Skeleton const& s);
void computeBoundingBox();
friend std::vector<std::pair<unsigned int,unsigned int>> branchesMatching(std::vector<std::pair<cv::KeyPoint,cv::KeyPoint>> keypoints, std::vector<Skeleton> branches1, std::vector<Skeleton> branches2);
2015-02-05 11:38:30 +01:00
private:
void addNextPoint(std::vector<std::vector<bool>> const& connections, std::vector<unsigned int>& path) const;
std::vector<unsigned int> findOnes(std::vector<std::vector<bool>> const& connections, unsigned int lineNumber) const;
friend unsigned int searchNearestBrancheIndex(cv::KeyPoint const& keypoint, std::vector<Skeleton> branches);
2015-02-05 11:38:30 +01:00
std::vector<Vertex> m_vertices;
std::vector<Edge> m_edges;
std::vector<unsigned int> m_neighbourgs_counters;
std::vector<Junction> m_junctions;
Box m_bounding_box;
static std::stringstream stream;
};
#endif // SKELETON_HPP