mirror of https://github.com/CGAL/cgal
Image Sequence + Feature points files are converted into a Soup of 3D triangles using 2D constrained Delaunay triangulations.
In this version we use the insert_constraint function on a couple of vertex_handle. One issue : (TODO) A point appears in 3d when we draw the soup of triangles. This might be an error due to the intersection of constraints in the 2D triangulation.
This commit is contained in:
parent
e572d6e9d2
commit
5da23b3631
|
|
@ -13,6 +13,8 @@ using namespace cimg_library;
|
|||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
|
@ -265,7 +267,7 @@ bool CGyrovizDoc_4::read_sequence(const std::string& first_image,
|
|||
|
||||
int image_index = atoi(image_name.substr(image_base_length, image_number_of_digits).c_str());
|
||||
std::ostringstream out;
|
||||
out << setfill('0') << std::setw(feature_file_number_of_digits) << image_index;
|
||||
out << std::setfill('0') << std::setw(feature_file_number_of_digits) << image_index;
|
||||
std::string feature_index = out.str();
|
||||
std::string feature_file_name = feature_file_base + feature_index + feature_file_extension;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
//#include "Gyroviz_vertex_segment_2.h"
|
||||
#include "Gyroviz_vertex_segment_2.h"
|
||||
#include <CGAL/Delaunay_triangulation_2.h>
|
||||
|
||||
template < class Gt, class Tds >
|
||||
template < class Gt, class Tds, class Cdt2VertexHandle >
|
||||
class Gyroviz_border_points_dt2 : public CGAL::Delaunay_triangulation_2<Gt, Tds>
|
||||
{
|
||||
// Private types
|
||||
|
|
@ -30,15 +30,16 @@ public:
|
|||
typedef typename Geom_traits::Segment_2 Segment_2;
|
||||
typedef typename Base::Face_handle Face_handle;
|
||||
typedef typename Base::Vertex_handle Vertex_handle;
|
||||
typedef typename Base::Vertex Vertex;
|
||||
typedef typename Base::Edge Edge;
|
||||
typedef typename Base::Finite_edges_iterator Finite_edges_iterator;
|
||||
typedef typename Base::Finite_faces_iterator Finite_faces_iterator;
|
||||
typedef typename Base::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
//typedef typename Gyroviz_vertex_segment_2<Base> Gyroviz_vertex_segment_2;
|
||||
typedef typename Gyroviz_vertex_segment_2<Cdt2VertexHandle> Gyroviz_vertex_segment_2;
|
||||
|
||||
// Data members
|
||||
private:
|
||||
std::vector<Vertex_handle> input;
|
||||
// // Data members
|
||||
//private:
|
||||
// std::vector<Vertex_handle> input;
|
||||
|
||||
// Public methods
|
||||
public:
|
||||
|
|
@ -46,11 +47,13 @@ public:
|
|||
|
||||
// Constructors
|
||||
Gyroviz_border_points_dt2(){}
|
||||
Gyroviz_border_points_dt2(std::vector<Vertex_handle> in)
|
||||
Gyroviz_border_points_dt2(std::vector<Cdt2VertexHandle> original_vertices)
|
||||
{
|
||||
for(int i=0; i<in.size(); ++i)
|
||||
for(int i=0; i<original_vertices.size(); ++i)
|
||||
{
|
||||
this->insert(in[i]->point());
|
||||
Vertex_handle vh = this->insert(original_vertices[i]->point());
|
||||
//vh->info().set_ptr(&*original_vertices[i]);
|
||||
vh->info() = original_vertices[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,19 +62,22 @@ public:
|
|||
|
||||
// this function will store as a vector of Gyroviz_vertex_segment_2
|
||||
// the entire 2D Delaunay triangulation
|
||||
std::vector<Segment_2> segments_out_of_dt2()
|
||||
std::vector<Gyroviz_vertex_segment_2> segments_out_of_dt2()
|
||||
{
|
||||
std::vector<Segment_2> result;
|
||||
std::vector<Gyroviz_vertex_segment_2> result;
|
||||
|
||||
Finite_edges_iterator fe = this->finite_edges_begin();
|
||||
for(; fe != this->finite_edges_end(); ++fe)
|
||||
{
|
||||
//Vertex_handle first_vertex(fe->first->vertex(ccw(fe->second)));
|
||||
Vertex_handle first_vertex(fe->first->vertex(ccw(fe->second)));
|
||||
//result.push_back(first_vertex);
|
||||
//Vertex_handle second_vertex(fe->first->vertex(cw(fe->second)));
|
||||
Vertex_handle second_vertex(fe->first->vertex(cw(fe->second)));
|
||||
//result.push_back(second_vertex);
|
||||
Segment_2 curr_segment(fe->first->vertex(ccw(fe->second))->point(),
|
||||
fe->first->vertex(cw(fe->second))->point());
|
||||
//Vertex_handle original_first_vertex = (Vertex*) first_vertex->info().get_ptr();
|
||||
//Vertex_handle original_second_vertex = (Vertex*) second_vertex->info().get_ptr();
|
||||
Cdt2VertexHandle original_first_vertex = first_vertex->info();
|
||||
Cdt2VertexHandle original_second_vertex = second_vertex->info();
|
||||
Gyroviz_vertex_segment_2 curr_segment(original_first_vertex, original_second_vertex);
|
||||
result.push_back(curr_segment);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include <CGAL/origin.h>
|
||||
|
||||
#include "Gyroviz_info_for_cdt2.h"
|
||||
//#include "Gyroviz_vertex_segment_2.h"
|
||||
#include "Gyroviz_border_points_dt2.h"
|
||||
#include "Gyroviz_triangle_with_cam.h"
|
||||
#include "Gyroviz_constrained_triangle_soup.h"
|
||||
|
|
@ -66,7 +65,7 @@ public:
|
|||
typedef typename Base::Finite_edges_iterator Finite_edges_iterator;
|
||||
typedef typename Base::Finite_faces_iterator Finite_faces_iterator;
|
||||
typedef typename Base::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
//typedef typename Gyroviz_vertex_segment_2<Gyroviz_cdt2> Gyroviz_vertex_segment_2;
|
||||
typedef typename Gyroviz_vertex_segment_2<Vertex_handle> Gyroviz_vertex_segment_2;
|
||||
typedef typename Gyroviz_triangle_with_cam<Gyroviz_cdt2> Gyroviz_triangle_with_cam;
|
||||
typedef typename Gyroviz_constrained_triangle_soup<Gyroviz_cdt2> Gyroviz_constrained_triangle_soup;
|
||||
|
||||
|
|
@ -127,6 +126,8 @@ public:
|
|||
|
||||
Vertex_handle vh = this->insert(point_2);
|
||||
vh->info() = Gyroviz_info_for_cdt2(point_3,image_number,false);
|
||||
//vh->info().set_point3(point_3);
|
||||
//vh->info().set_camera_number(image_number);
|
||||
number_of_vertices_pnt++;
|
||||
}
|
||||
}
|
||||
|
|
@ -332,9 +333,12 @@ public:
|
|||
|
||||
std::vector<Vertex_handle> vector_of_border_points = set_on_border_2D_vertices(image);
|
||||
|
||||
Gyroviz_border_points_dt2<Gt, Tds> border_dt2(vector_of_border_points);
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<Vertex_handle,Gt> Gyroviz_border_points_Vb;
|
||||
typedef CGAL::Constrained_triangulation_face_base_2<Gt> Gyroviz_border_points_Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Gyroviz_border_points_Vb,Gyroviz_border_points_Fb> Gyroviz_border_points_Tds;
|
||||
Gyroviz_border_points_dt2<Gt, Gyroviz_border_points_Tds,Vertex_handle> border_dt2(vector_of_border_points);
|
||||
|
||||
std::vector<Segment_2/*Vertex_handle*/> vector_of_vertex_segments = border_dt2.segments_out_of_dt2();
|
||||
std::vector<Gyroviz_vertex_segment_2> vector_of_vertex_segments = border_dt2.segments_out_of_dt2();
|
||||
|
||||
Point_2 source_vertex;
|
||||
Point_2 end_vertex;
|
||||
|
|
@ -351,18 +355,19 @@ public:
|
|||
// S(Border/Segment) = +1
|
||||
// S(Gap/Segment) = gap_score (default : -2)
|
||||
|
||||
for(int i = 0; i</*vector_of_vertex_segments*/vector_of_vertex_segments.size()/*-1*/; ++i)
|
||||
for(int i = 0; i</*vector_of_vertex_segments*/vector_of_vertex_segments.size(); ++i)
|
||||
{
|
||||
|
||||
//source_handle = vector_of_vertex_segments[i];
|
||||
//end_handle = vector_of_vertex_segments[++i];
|
||||
//source_vertex = source_handle->point();
|
||||
//end_vertex = end_handle->point();
|
||||
//Segment_2 s = (source_vertex, end_vertex);
|
||||
source_handle = vector_of_vertex_segments[i].get_source();
|
||||
end_handle = vector_of_vertex_segments[i].get_target();
|
||||
|
||||
source_vertex = vector_of_vertex_segments[i].source();
|
||||
source_vertex = source_handle->point();
|
||||
end_vertex = end_handle->point();
|
||||
Segment_2 s (source_vertex, end_vertex);
|
||||
|
||||
/*source_vertex = vector_of_vertex_segments[i].source();
|
||||
end_vertex = vector_of_vertex_segments[i].target();
|
||||
Segment_2 s = vector_of_vertex_segments[i];
|
||||
Segment_2 s = vector_of_vertex_segments[i];*/
|
||||
v = end_vertex - source_vertex;
|
||||
|
||||
length_curr_segment = (int)ceil(sqrt(s.squared_length()));
|
||||
|
|
@ -390,7 +395,7 @@ public:
|
|||
|
||||
if(global_score >= 0)
|
||||
{
|
||||
this->insert_constraint(source_vertex,end_vertex/*source_handle,end_handle*/);
|
||||
this->insert_constraint(/*source_vertex,end_vertex*/source_handle,end_handle);
|
||||
vector_of_constraints.push_back(s);
|
||||
global_score = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,19 +20,26 @@ protected:
|
|||
// Flag := on border or not
|
||||
bool flag;
|
||||
|
||||
//void* ptr;
|
||||
|
||||
public:
|
||||
Gyroviz_info_for_cdt2(){}
|
||||
Gyroviz_info_for_cdt2(Point_3 p, int cam_num, bool f):point(p),camera_number(cam_num),flag(f){}
|
||||
Gyroviz_info_for_cdt2() : flag(false)/*, ptr(NULL)*/ {}
|
||||
Gyroviz_info_for_cdt2(Point_3 p, int cam_num, bool f)
|
||||
: point(p),camera_number(cam_num),flag(f) {}
|
||||
//Gyroviz_info_for_cdt2(Point_3 p, int cam_num, bool f, void* pr)
|
||||
// : point(p),camera_number(cam_num),flag(f),ptr(pr) {}
|
||||
|
||||
// accessors
|
||||
const Point_3 get_point3() const { return point; }
|
||||
const int get_camera_number() const { return camera_number; }
|
||||
const bool get_flag() const { return flag; }
|
||||
//const void* get_ptr() const { return ptr; }
|
||||
|
||||
// modificators
|
||||
void set_point3(Point_3 point3) { point = point3; }
|
||||
void set_camera_number(int cam_num) { camera_number = cam_num; }
|
||||
void set_flag(bool f) { flag = f; }
|
||||
//void set_ptr(void* pr) { ptr = pr; }
|
||||
|
||||
};
|
||||
#endif // _Gyroviz_info_for_cdt2_
|
||||
|
|
@ -11,15 +11,15 @@
|
|||
#ifndef _Gyroviz_vertex_segment_2_
|
||||
#define _Gyroviz_vertex_segment_2_
|
||||
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
|
||||
template < class Triangulation >
|
||||
template < class Cdt2VertexHandle >
|
||||
class Gyroviz_vertex_segment_2
|
||||
{
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||
typedef Cdt2VertexHandle Vertex_handle;
|
||||
|
||||
protected:
|
||||
|
||||
// Vertex_handles
|
||||
Vertex_handle source;
|
||||
|
|
|
|||
Loading…
Reference in New Issue