Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/phg/mvs/model_min_cut/min_cut_cgal_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ vector3d from_cgal_point(cgal_point_t p) { return vector3d(p.x(), p.y(), p.z());

cgal_point_t to_cgal_point(vector3d p) { return cgal_point_t(p[0], p[1], p[2]); }

vertex_info_t::vertex_info_t(unsigned int camera_id, const cv::Vec3b& color)
vertex_info_t::vertex_info_t(unsigned int camera_id, const vector3d& point, const cv::Vec3b& color, double radius)
: color(color)
, radius(radius)
, position_sum(point)
, color_sum(color[0], color[1], color[2])
, observations_count(1)
{
camera_ids.push_back(camera_id);
}
Expand All @@ -29,7 +33,32 @@ void vertex_info_t::merge(const vertex_info_t& that)
}

std::sort(camera_ids.begin(), camera_ids.end());
radius = std::max(radius, that.radius);
position_sum += that.position_sum;
color_sum += that.color_sum;
observations_count += that.observations_count;
if (observations_count > 0) {
color = averageColor();
}
for (int i = 1; i < camera_ids.size(); ++i) {
rassert(camera_ids[i - 1] < camera_ids[i], 23781274121024);
}
}

vector3d vertex_info_t::averagePoint(const vector3d& fallback_point) const
{
if (observations_count == 0)
return fallback_point;
return position_sum / (double)observations_count;
}

cv::Vec3b vertex_info_t::averageColor() const
{
if (observations_count == 0)
return color;
cv::Vec3b avg;
for (int c = 0; c < 3; ++c) {
avg[c] = cv::saturate_cast<unsigned char>(color_sum[c] / (double)observations_count);
}
return avg;
}
12 changes: 11 additions & 1 deletion src/phg/mvs/model_min_cut/min_cut_cgal_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@
struct vertex_info_t {
std::vector<unsigned int> camera_ids;
cv::Vec3b color;
double radius;
vector3d position_sum;
cv::Vec3d color_sum;
size_t observations_count;
size_t vertex_on_surface_id;

vertex_info_t()
: color(0, 0, 255) // red color, BGR convention (OpenCV compatible)
, radius(0.0)
, position_sum(0.0, 0.0, 0.0)
, color_sum(0.0, 0.0, 255.0)
, observations_count(0)
{
}

vertex_info_t(unsigned int camera_id, const cv::Vec3b& color);
vertex_info_t(unsigned int camera_id, const vector3d& point, const cv::Vec3b& color, double radius);

void merge(const vertex_info_t& that);
vector3d averagePoint(const vector3d& fallback_point) const;
cv::Vec3b averageColor() const;
};

struct cell_info_t {
Expand Down
3 changes: 3 additions & 0 deletions src/phg/mvs/model_min_cut/min_cut_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

#define LAMBDA_OUT 1.0
#define LAMBDA_IN 1.0

#define WEAK_SUPPORT_LAMBDA 0.25
#define WEAK_SUPPORT_RADIUS_KOEF 2.0
Loading
Loading