KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
kjb::Manhattan_world Class Reference

This class contains the three orthogonal vanishing points defining a Manhattan scene, where most or all planes are aligned with three main orthogonal directions. This class optionally contains a set of segments from the scene, assigned to the correct vanishing point. More...

#include <manhattan_world.h>

Public Member Functions

 Manhattan_world (double ifocal=MW_FOCAL_INIT_VALUE)
 
 Manhattan_world (const std::vector< Vanishing_point > &ivpts, double ifocal=MW_FOCAL_INIT_VALUE)
 
 Manhattan_world (const Edge_segment_set &isegments, const std::vector< Vanishing_point > &ivpts, double ifocal=MW_FOCAL_INIT_VALUE, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 
 Manhattan_world (const char *filename, const Edge_segment_set &isegments, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 
 Manhattan_world (const char *filename)
 
 Manhattan_world (std::istream &in, const Edge_segment_set &isegments, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 
 Manhattan_world (const Manhattan_world &src)
 
Manhattan_worldoperator= (const Manhattan_world &src)
 
double get_focal_length () const
 returns the focal length More...
 
void set_focal_length (double ifocal)
 returns the focal length More...
 
void reset_vanishing_points (const std::vector< Vanishing_point > &vpts)
 
void assign_segments_to_vpts (const Edge_segment_set &, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 Assigns each input segment to the vanishing point it converges to, or mark it as an outlier if it does not converge to any vanishing point. More...
 
const std::vector< std::vector
< Manhattan_segment > > & 
get_assignments () const
 returns the vector of the segments assigned to the correct vanishing point (outliers in the last vector) More...
 
unsigned num_lines_assigned_to_vp (unsigned vpindex) const
 returns the length of the vector of the segments assigned to the vanishing point More...
 
const std::vector
< Vanishing_point > & 
get_vanishing_points () const
 Returns the vanishing points. More...
 
const std::vector
< Vanishing_point
get_value_vanishing_points () const
 
void draw_segments_with_vp_assignments (kjb::Image &img, double width=1.0) const
 draws the line segments with different colors according to the vanishing point they are assigned to (green and red for horizontal, blue for vertical, black for outliers). More...
 
void draw_lines_from_segments_midpoint_to_vp (kjb::Image &img, double width=1.0) const
 Draws a line between the mid point of each segment (excluding outliers) and the vanishing point the segment converges to. Line segments are drawn with different colors according to the vanishing point they are assigned to (green and red for horizontal, blue for vertical, black for outliers). More...
 
void read (std::istream &in, const Edge_segment_set &isegments, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 Reads this Manhattan world from an input stream. More...
 
void read (const char *filename, const Edge_segment_set &isegments, double outlier_threshold=MW_OUTLIER_THRESHOLD)
 Reads this Manhattan world from an input file. More...
 
void read (const char *filename)
 
void read (std::istream &in)
 
void write (std::ostream &out) const
 Writes this Manhattan world to an output stream. More...
 
void write (const char *out_file) const
 Writes this Manhattan world to an output file. More...
 
const Manhattan_cornerget_corner_2 (unsigned int i) const
 Returns the ith corner consisting of the intersection of two line segments. More...
 
const Manhattan_cornerget_corner_3 (unsigned int i) const
 Returns the ith corner consisting of the intersection of three line segments. More...
 
const Manhattan_cornerget_extra_corner (unsigned int i) const
 
const Manhattan_segmentget_manhattan_segment (unsigned int vp_index, unsigned int segment_index) const
 
void write_manhattan_corner (const Manhattan_corner &corner, std::ostream &out) const
 
void read_manhattan_corner (Manhattan_corner &corner, std::istream &in) const
 
void write_corners (std::ostream &out) const
 
void read_corners (std::istream &in)
 
void draw_corners (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners2 (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners2up (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners3 (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners3up (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners2smart (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_corners3smart (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
void draw_extra_corners (kjb::Image &img, bool draw_full_segments=false, double width=1.0) const
 
bool create_corner3_from_incomplete (Manhattan_corner &corner, unsigned int index3, bool towards_vp, const kjb::Vector &position, bool check_consistency=true)
 
void create_corners2 ()
 Creates corners by checking all possible intersections of two line segments. More...
 
void create_corners3 ()
 Creates corners by checking all possible intersections of three line segments. More...
 
void create_corners ()
 Creates corners by checking all possible intersections of two and three line segments. More...
 
unsigned int get_num_corners2 () const
 
unsigned int get_num_corners3 () const
 
unsigned int get_num_extra_corners () const
 
void print_corners (std::ostream &out) const
 
void print_corners2 (std::ostream &out) const
 
void print_corners3 (std::ostream &out) const
 
void print_vanishing_points (std::ostream &out) const
 
void get_3D_corner (double z_distance, double princ_x, double princ_y, unsigned int index, bool usecorner3, kjb::Vector &corner3D_1, kjb::Vector &corner3D_2, kjb::Vector &corner3D_3, kjb::Vector &position_3D) const
 
const std::vector
< Manhattan_corner > & 
get_corners3 () const
 
const std::vector
< Manhattan_corner > & 
get_corners2 () const
 
const std::vector
< Manhattan_corner > & 
get_extra_corners () const
 
void set_extra_corners_from_vertical_pairs (const std::vector< Segment_pair > &vpairs)
 

Static Public Member Functions

static bool create_corner (Manhattan_corner &corner, const Manhattan_segment &seg1, const Manhattan_segment &seg2, unsigned int index1, unsigned int index2, double max_stretch=MAX_CORNER_SEGMENT_STRETCH)
 Creates a corner from two line segments. Returns false if the segments do not intersect. More...
 
static bool create_corner3 (Manhattan_corner &corner, const Manhattan_segment &seg3, unsigned int index3, double max_stretch=MAX_CORNER_SEGMENT_STRETCH, double max_perp_stretch=MAX_CORNER_PERP_SEGMENT_STRETCH)
 Creates a corner from an already existing corner and a line segment. Returns false if the segment does not intersect the corner position. More...
 

Detailed Description

This class contains the three orthogonal vanishing points defining a Manhattan scene, where most or all planes are aligned with three main orthogonal directions. This class optionally contains a set of segments from the scene, assigned to the correct vanishing point.

Constructor & Destructor Documentation

kjb::Manhattan_world::Manhattan_world ( double  ifocal = MW_FOCAL_INIT_VALUE)
inline
kjb::Manhattan_world::Manhattan_world ( const std::vector< Vanishing_point > &  ivpts,
double  ifocal = MW_FOCAL_INIT_VALUE 
)
inline
Manhattan_world::Manhattan_world ( const Edge_segment_set isegments,
const std::vector< Vanishing_point > &  ivpts,
double  ifocal = MW_FOCAL_INIT_VALUE,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)
kjb::Manhattan_world::Manhattan_world ( const char *  filename,
const Edge_segment_set isegments,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)
inline
kjb::Manhattan_world::Manhattan_world ( const char *  filename)
inline
kjb::Manhattan_world::Manhattan_world ( std::istream &  in,
const Edge_segment_set isegments,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)
inline
kjb::Manhattan_world::Manhattan_world ( const Manhattan_world src)
inline

Member Function Documentation

void Manhattan_world::assign_segments_to_vpts ( const Edge_segment_set isegments,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)

Assigns each input segment to the vanishing point it converges to, or mark it as an outlier if it does not converge to any vanishing point.

bool Manhattan_world::create_corner ( Manhattan_corner corner,
const Manhattan_segment seg1,
const Manhattan_segment seg2,
unsigned int  index1,
unsigned int  index2,
double  max_stretch = MAX_CORNER_SEGMENT_STRETCH 
)
static

Creates a corner from two line segments. Returns false if the segments do not intersect.

Creates corners by checking all possible intersections of two line segments

Parameters
cornerWill contain the corner
seg1The first line segment
seg2The second line segment
index1The index of the vanishing point seg1 converges to
index2The index of the vanishing point seg2 converges to
max_stretchThe maximum stretch applicable to a line segment in order to consider the intersection as a corner
bool Manhattan_world::create_corner3 ( Manhattan_corner corner,
const Manhattan_segment seg3,
unsigned int  index3,
double  max_stretch = MAX_CORNER_SEGMENT_STRETCH,
double  max_perp_stretch = MAX_CORNER_PERP_SEGMENT_STRETCH 
)
static

Creates a corner from an already existing corner and a line segment. Returns false if the segment does not intersect the corner position.

Creates a corner from an already existing corner and a line segment. Returns false if the segment does not intersect the corner position

Parameters
cornerThe corner. It will be adapted if the third segment intersects it
seg3The line segment
index3The index of the vanishing point seg3 converges to
max_stretchThe maximum stretch applicable to a line segment in order to consider the intersection as a corner
max_perp_stretchThe maximum tolerated distance between the line seg3 lies on and the corner position
bool Manhattan_world::create_corner3_from_incomplete ( Manhattan_corner corner,
unsigned int  index3,
bool  towards_vp,
const kjb::Vector position,
bool  check_consistency = true 
)
void Manhattan_world::create_corners ( )

Creates corners by checking all possible intersections of two and three line segments.

void Manhattan_world::create_corners2 ( )

Creates corners by checking all possible intersections of two line segments.

void Manhattan_world::create_corners3 ( )

Creates corners by checking all possible intersections of three line segments.

void Manhattan_world::draw_corners ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners2 ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners2smart ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners2up ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners3 ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners3smart ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_corners3up ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_extra_corners ( kjb::Image img,
bool  draw_full_segments = false,
double  width = 1.0 
) const
void Manhattan_world::draw_lines_from_segments_midpoint_to_vp ( kjb::Image img,
double  width = 1.0 
) const

Draws a line between the mid point of each segment (excluding outliers) and the vanishing point the segment converges to. Line segments are drawn with different colors according to the vanishing point they are assigned to (green and red for horizontal, blue for vertical, black for outliers).

Parameters
imgthe image to draw the segments on
widththe width to use when drawing the line segments
void Manhattan_world::draw_segments_with_vp_assignments ( kjb::Image img,
double  width = 1.0 
) const

draws the line segments with different colors according to the vanishing point they are assigned to (green and red for horizontal, blue for vertical, black for outliers).

Draws the line segments with different colors according to the vanishing point they are assigned to (green and red for horizontal, blue for vertical, black for outliers).

Parameters
imgthe image to draw the segments on
widththe width to use when drawing the line segments
void Manhattan_world::get_3D_corner ( double  z_distance,
double  princ_x,
double  princ_y,
unsigned int  index,
bool  usecorner3,
kjb::Vector corner3D_1,
kjb::Vector corner3D_2,
kjb::Vector corner3D_3,
kjb::Vector position_3D 
) const
const std::vector< std::vector<Manhattan_segment> >& kjb::Manhattan_world::get_assignments ( ) const
inline

returns the vector of the segments assigned to the correct vanishing point (outliers in the last vector)

const Manhattan_corner& kjb::Manhattan_world::get_corner_2 ( unsigned int  i) const
inline

Returns the ith corner consisting of the intersection of two line segments.

const Manhattan_corner& kjb::Manhattan_world::get_corner_3 ( unsigned int  i) const
inline

Returns the ith corner consisting of the intersection of three line segments.

const std::vector<Manhattan_corner>& kjb::Manhattan_world::get_corners2 ( ) const
inline
const std::vector<Manhattan_corner>& kjb::Manhattan_world::get_corners3 ( ) const
inline
const Manhattan_corner& kjb::Manhattan_world::get_extra_corner ( unsigned int  i) const
inline
const std::vector<Manhattan_corner>& kjb::Manhattan_world::get_extra_corners ( ) const
inline
double kjb::Manhattan_world::get_focal_length ( ) const
inline

returns the focal length

const Manhattan_segment & Manhattan_world::get_manhattan_segment ( unsigned int  vp_index,
unsigned int  segment_index 
) const
unsigned int kjb::Manhattan_world::get_num_corners2 ( ) const
inline
unsigned int kjb::Manhattan_world::get_num_corners3 ( ) const
inline
unsigned int kjb::Manhattan_world::get_num_extra_corners ( ) const
inline
const std::vector<Vanishing_point> kjb::Manhattan_world::get_value_vanishing_points ( ) const
inline
const std::vector<Vanishing_point>& kjb::Manhattan_world::get_vanishing_points ( ) const
inline

Returns the vanishing points.

unsigned kjb::Manhattan_world::num_lines_assigned_to_vp ( unsigned  vpindex) const
inline

returns the length of the vector of the segments assigned to the vanishing point

Manhattan_world& kjb::Manhattan_world::operator= ( const Manhattan_world src)
inline
void kjb::Manhattan_world::print_corners ( std::ostream &  out) const
inline
void Manhattan_world::print_corners2 ( std::ostream &  out) const
void Manhattan_world::print_corners3 ( std::ostream &  out) const
void Manhattan_world::print_vanishing_points ( std::ostream &  out) const
void Manhattan_world::read ( std::istream &  in,
const Edge_segment_set isegments,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)

Reads this Manhattan world from an input stream.

Reads this Manhattan world from an input stream.

Parameters
inthe input stream to read this Manhattan world from
void Manhattan_world::read ( const char *  filename,
const Edge_segment_set isegments,
double  outlier_threshold = MW_OUTLIER_THRESHOLD 
)

Reads this Manhattan world from an input file.

Reads this Manhattan world from an input file.

Parameters
inthe input stream to read this Manhattan world from
void Manhattan_world::read ( const char *  filename)

Reads this Manhattan world from an input stream.

Parameters
inthe input stream to read this Manhattan world from
void Manhattan_world::read ( std::istream &  in)
void Manhattan_world::read_corners ( std::istream &  in)
void Manhattan_world::read_manhattan_corner ( Manhattan_corner corner,
std::istream &  in 
) const
void kjb::Manhattan_world::reset_vanishing_points ( const std::vector< Vanishing_point > &  vpts)
inline
void Manhattan_world::set_extra_corners_from_vertical_pairs ( const std::vector< Segment_pair > &  vpairs)
void kjb::Manhattan_world::set_focal_length ( double  ifocal)
inline

returns the focal length

void Manhattan_world::write ( std::ostream &  out) const

Writes this Manhattan world to an output stream.

Writes this Manhattan world to an input stream.

Parameters
outthe output stream to write this Manhattan world to
void kjb::Manhattan_world::write ( const char *  out_file) const
inline

Writes this Manhattan world to an output file.

void Manhattan_world::write_corners ( std::ostream &  out) const
void Manhattan_world::write_manhattan_corner ( const Manhattan_corner corner,
std::ostream &  out 
) const

The documentation for this class was generated from the following files: