KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
kjb Namespace Reference

Classes and functions for dealing with trajectory files. More...

Namespaces

 bbb
 
 debug
 
 flandmark
 
 geometry
 
 gpu
 
 gui
 
 mcmcda
 
 opencv
 
 opengl
 
 psi
 
 pt
 
 qd
 support for the path algorithm I call the quasi-Dijkstra method.
 
 TopoFusion
 this namespace hold structures and code written by Scott Morris.
 
 tracking
 

Classes

class  Spot_detector
 A spot detector functor, comparable to a blob detector. More...
 
class  Palette
 Construct some colors, for visualizing grids of numbers. More...
 
class  Calibrated_camera
 
class  Back_projector
 
class  Ground_back_projector
 
class  Parametric_frustum
 
class  Perspective_camera
 
class  Turntable_camera
 
class  Deva_detection
 
class  Compare_box_distance
 Functor for comparing box distance. More...
 
class  Deva_facemark
 
class  Face_detection
 
class  Vector_adapter
 Default adapter for the hessian function. More...
 
class  Collinear_segment_chain
 Represent a collinear line segment, a collinear line segment is inherited from an Line_segment. More...
 
class  Comparable_omap
 
  • creates an omap from an image that can call compare_omap(compareto) to see how similar it is.
More...
 
class  Corner
 Class to manipulate a 2D corner. The corener is defined in terms of a set of line segments all intersecting at a point in the image, which is the corner position. No consistency controls are performed here. More...
 
class  Edge_point
 
class  Edge
 
class  Edge_set
 
class  Canny_edge_detector
 Implements the Canny edge detection algorithm. More...
 
class  Chamfer_transform
 
class  Edge_segment
 
class  Fh_type
 
class  Feature_histogram
 
class  Features_manager
 
class  Foreground_mask
 
class  Geometric_context
 
class  Hog_responses
 
class  Line_segment_set
 Class to manipulate a set of line segments. More...
 
class  Edge_segment_set
 Class to manipulate a set of edge segments. More...
 
class  Manhattan_segment
 A manhattan segment defined by a line segment and the vanishing point it converges to. More...
 
class  Manhattan_corner_segment
 
class  Manhattan_corner
 
class  Manhattan_world
 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...
 
class  Omap_segment
 
class  Omap_computer
 
class  Segment_pair
 
class  Vanishing_point
 A vanishing point for a set of parallel lines in an image. More...
 
class  Vanishing_point_detector
 This class computes the position of the three vanishing points from a set of line segments. The ass. More...
 
struct  Compare_flow_features
 Functor to compare two Feature_pair. More...
 
class  Integral_flow
 
class  Ransac_line_fitting
 
class  Rotation_axis
 
struct  Calibration_descriptor
 
class  Circle
 
class  Circle_in_3d
 
class  Cylinder
 
class  Cylinder_section
 Cylinder_section: a section of a cylinder, specified by angle and position. More...
 
class  Line
 Parametric representation of a 2D line in terms of three parameters (a,b,c) (as in ax+by+c = 0). More...
 
class  Vector_d
 
class  Quaternion
 
class  Transformable
 Abstract class to apply a linear transformation to this object. More...
 
class  Glut_parapiped
 
class  Glut_perspective_camera
 
class  Glut_polymesh
 
class  Axis_aligned_rectangle_2d
 Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center, its width and its height. More...
 
class  Base_gl_interface
 
class  Parametric_camera_gl_interface
 
struct  RenderableObject
 
class  Line_segment
 Class to manipulate a line segment The class is parametrized in terms the position of the centre, its length and orientation. This is thus compatible with the output of the Berkeley edge detector. We store also the start point, the end point and the line parameters describing this line segment (for more details on how the line parameters work, please see the class line). This is redundant information, but it is convenient to have all these parameters precomputed and at hand. More...
 
class  Offscreen_buffer
 Offscreen rendering buffer. More...
 
class  Matrix_d
 
class  Frustum
 frustum: a polyhedron of which each torso face is a trapezoid and the top and bottom surfaces are polygons. More...
 
class  Parapiped
 Parallelepiped: a hexahedron of which each face is a parallelegram. More...
 
class  Polygon
 
class  GL_Polygon_Renderer
 
class  Polymesh
 Abstract class of connected polygons (faces) forming a mesh. We assume that each edge is shared between exactly two faces, that is to say the mesh has to be fully connected. More...
 
class  Polymesh_Plane
 This class contains a Vector of plane parameters, a vector of the face indices that lie in the plane, and the polymesh that the faces are from. The plane parameters are the coefficients of a plane of the form ax + by + cz + d = 0. More...
 
class  GL_Polymesh_Renderer
 
class  Rectangle_2d
 Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center, its width and its height. More...
 
class  Renderable
 Abstract class to render this object with GL. More...
 
class  Wire_renderable
 Abstract class to render this object with GL as a wire-frame. More...
 
class  Solid_renderable
 Abstract class to render this object with GL. More...
 
class  Wire_occlude_renderable
 Abstract class to render this object with GL as an occluded wire-frame into the depth buffer, to hide unseen lines. More...
 
class  Abstract_renderable
 
class  Generic_renderable
 
class  Generic_renderer
 
class  Renderer
 
class  Wire_renderer
 
class  Wire_occlude_renderer
 
class  Solid_renderer
 
class  Renderer_renderable
 
class  Mv_renderable
 Abstract class to render an object that has many possible views. More...
 
class  Mv_generic_renderable
 
class  Mv_wire_occlude_render_wrapper
 
class  Mv_wire_render_wrapper
 
class  Mv_solid_render_wrapper
 
class  Renderable_model
 
class  Right_Triangle_Pair
 
class  Rigid_object
 
class  Sphere
 
class  Triangular_mesh
 Triangular_mesh: a polygonal mesh of which each face is a triangle. More...
 
class  Gsl_multifit_fdf
 
class  Gsl_Multimin_fdf
 Wrapper for GSL's multidimensional minimizer, when you have gradient. More...
 
class  Gsl_Multimin_f
 Wrapper for GSL's multidimensional minimizer, without using gradient. More...
 
class  Generic_multimin
 
class  Gsl_Qrng_basic
 Wrapper for one of GSL's quasi-random generators. More...
 
class  Gsl_Qrng_Niederreiter
 Quasi-random generator using the algorithm of Bratley et al. More...
 
class  Gsl_Qrng_Sobol
 Quasi-random generator using the algorithm of Antonov and Saleev. More...
 
class  Gsl_Qrng_Halton
 Quasi-random generator using the algorithm of Halton. More...
 
class  Gsl_Qrng_Rvs_Halton
 Quasi-random generator using the algorithm of Vandewoestyne et al. More...
 
class  Gsl_ran_discrete
 Randomly sample discrete events with an empirical distribution. More...
 
class  Gsl_rng_basic
 Basic RAII wrapper for GNU GSL random number generators. More...
 
class  Gsl_Vector
 RAII wrapper for GSL vector objects. More...
 
class  Color_histogram
 Class to compute an RGB colour histogram over an image or a rectangular portion of it. The histogram is normalized. We use the same number of bins for each of the channels (r,g,b). It is easy to extend this class so that it computes such histogram over a segment of a shape other than rectangular. More...
 
class  Colormap
 
class  Filter
 Filter class. More...
 
struct  PixelHSVA
 Alternative Pixel using hue, saturation, value, and opacity (alpha). More...
 
class  Image
 Wrapped version of the C struct KJB_image. More...
 
class  Fftw_image_convolution
 this is a simple adaptation of Fftw_convolution_2d to Image input. More...
 
class  Opengl_framebuffer_image
 
struct  PixelRGBA
 Wrapped version of the C struct Pixel, with Alpha (opacity). More...
 
class  Cloneable
 Abstract class to clone this object. More...
 
class  Exception
 Base class of all exceptions in the jwsc++ library. More...
 
class  KJB_error
 Exception often thrown when wrapped C functions return error codes. More...
 
class  Not_implemented
 Object thrown when attempting to use unimplemented functionality. More...
 
class  Runtime_error
 Object thrown when computation fails somehow during execution. More...
 
class  Cant_happen
 Object thrown when the program does something thought impossible. More...
 
class  Illegal_argument
 Object thrown when an argument to a function is not acceptable. More...
 
class  Index_out_of_bounds
 Object thrown when an index argument exceeds the size of a container. More...
 
class  Dimension_mismatch
 Object thrown when an argument is of the wrong size or dimensions. More...
 
class  Divide_by_zero
 Object thrown when an division is attempted with a zero divisor. More...
 
class  Serialization_error
 Object thrown when serialization or deserialization fails. More...
 
class  IO_error
 Object thrown when input or output fails. More...
 
class  Result_error
 Object thrown when a function cannot generate a valid result. More...
 
class  Missing_dependency
 Object thrown when a program lacks required resources or libraries. More...
 
class  Option_exception
 Object thrown for exceptions related to command-line options. More...
 
class  Missing_option
 Object thrown when an obligatory command-line option is absent. More...
 
class  Stack_overflow
 Object thrown if a finite size stack is full and pushed farther. More...
 
class  Stack_underflow
 Object thrown if stack is empty and popped. More...
 
class  Resource_exhaustion
 Object thrown if a resource allocation failed (memory, fp, etc.) More...
 
class  Increment
 Generator that increments (++) its state everytime it is called. Useful for creating sequences of contigous values. More...
 
class  Increase_by
 Generator that increases (using +=) itself by the given value everytime it is called. More...
 
class  Index_less_than
 Predicate that compares the kth element of a indexable type. More...
 
class  Select_coordinate
 Selects a coordinate from a vector type. More...
 
class  Identity
 Identity function. More...
 
class  Every_nth_element
 Predicate that returns true every nth call. More...
 
class  Compare_address
 Predicate that returns true if address of element equals given. More...
 
class  Get_address
 Functor that returns the address of a given object. More...
 
class  minimum
 
class  maximum
 
class  Heartbeat
 A class for for indicating the status of slow-moving loops. More...
 
class  Index_range
 
class  Int_matrix
 This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements. More...
 
class  Int_vector
 This class implements vectors, in the linear-algebra sense, restricted to integer-valued elements. More...
 
class  const_circular_iterator
 
class  circular_iterator
 
class  Readable
 Abstract class to read this object from an input stream. More...
 
struct  Scope_guard
 
struct  SerializableConcept
 
class  File_Ptr
 RAII wrapper on stdio.h FILE pointers (use a derived class though). More...
 
struct  File_Ptr_Read
 RAII wrapper on FILE* used to read a file. More...
 
struct  File_Ptr_Write
 RAII wrapper on a FILE* used to write to a file. More...
 
struct  File_Ptr_Append
 RAII wrapper on FILE* used to append a file (write only at the end). More...
 
struct  File_Ptr_Read_Plus
 RAII wrapper on FILE* opened with mode "r+" to read and write. More...
 
class  Temporary_File
 This class safely opens a temporary file in TEMP_DIR (usually /tmp). More...
 
class  Temporary_Directory
 this class creates a temporary directory under TEMP_DIR (usu. /tmp) More...
 
struct  Temporary_Recursively_Removing_Directory
 create a temp directory that destroys itself with "rm -rf" command. More...
 
class  File_Ptr_Smart_Read
 This class transparently opens gzipped or bzip2-ed files. More...
 
struct  to_ptr
 Convert to a pointer. More...
 
class  Word_list
 Wrapper for the libKJB type Word_list (useful for globs). More...
 
class  Writeable
 Abstract class to write this object to an output stream. More...
 
class  Pthread_mutex
 dynamically allocated mutex: unlock before you destroy it! More...
 
struct  Pthread_locked_mutex
 same as Pthread_mutex, but starts off in "locked" state. More...
 
class  Mutex_lock
 simple RAII class to grab and release a mutex More...
 
class  Pthread_attr
 RAII class to manage an object of type kjb_pthread_attr_t. More...
 
class  Color_likelihood
 Functor that computes the likelihood of a set of projected faces onto an image, using the color distribution of each projected face. More later... More...
 
struct  compare_point_x_location
 
class  Line_correspondence
 
class  Edge_lines_likelihood
 
class  Correspondence
 
class  Independent_edge_points_likelihood
 
class  Learned_discrete_prior
 This class creates a histogram of a list of points and stores the number of bins in num_bins, the maximum and minimum values allowed in histo_max and histo_min, respectively, and the count of the number of points in each bin in histo_bins, which is a Vector of size num_bins. More...
 
class  Model_edge
 
class  Spline_curve
 
class  Spline_surface
 
class  Nurbs_curve
 
class  Nurbs_surface
 
class  Bezier_curve
 
class  Polybezier_curve
 
struct  SimpleVector
 
class  FFTW_Plan2d
 RAII class to manage an FFTW plan. More...
 
class  Fftw_convolution_2d
 A class for performing 2d convolution using the FFTW library. More...
 
struct  Matrix_traits
 
struct  Matrix_traits< int >
 
struct  Matrix_traits< double >
 
class  Generic_matrix_view
 
struct  Generic_const_matrix_view
 
class  Matrix
 This class implements matrices, in the linear-algebra sense, with real-valued elements. More...
 
class  Matrix_stream_io
 static functions to read and write matrix classes with iostream. More...
 
class  Sequence
 
class  Interval_sequence
 
class  Generic_vector_view
 
struct  Generic_const_vector_view
 
class  Vector
 This class implements vectors, in the linear-algebra sense, with real-valued elements. More...
 
class  Vector_stream_io
 functions to read and write vector classes with streams. More...
 
struct  Svd
 a tuple that computes a singular value decomposition of a matrix More...
 
class  Conditional_distribution
 A conditional distribution. More...
 
class  Normal_on_normal_dependence
 Represents the dependence between X and Y in p(x | y), where (x,y) is a bivariate normal. More...
 
class  MV_normal_on_normal_dependence
 Represents the dependence between X and Y in p(x | y), where (x,y) is a multivariate normal. More...
 
class  Geometric_distribution
 
class  Beta_binomial_distribution
 
struct  Distribution_traits
 Generic traits struct for all distributions. More...
 
class  Categorical_distribution
 A categorical distribution. More...
 
struct  Distribution_traits< Categorical_distribution< T > >
 Traits for the categorical distro. More...
 
class  MV_gaussian_distribution
 Multivariate Gaussian (normal) distribution. More...
 
struct  Distribution_traits< MV_gaussian_distribution >
 Traits for the multivariate normal. Type is kjb::Vector. More...
 
class  Log_normal_distribution
 Log-normal distribution. More...
 
struct  Distribution_traits< Log_normal_distribution >
 
class  Mixture_distribution
 This class implements a mixture distribution. In other words, it is the sum of a finite number of fractions of distributions of the same type (with different parameters). More...
 
struct  Distribution_traits< Mixture_distribution< Distribution > >
 Traits for the mixture distro. Type is the type of the mixed distributions. More...
 
class  Uniform_sphere_distribution
 
struct  Distribution_traits< Uniform_sphere_distribution< D > >
 Traits for the Uniform_sphere_distribution. More...
 
class  Von_mises_fisher_distribution
 
struct  Distribution_traits< Von_mises_fisher_distribution< D > >
 Traits for the Von-mises-fisher distribution. More...
 
class  Chinese_restaurant_process
 
struct  Distribution_traits< Chinese_restaurant_process >
 
class  Histogram
 A class that represents a histogram of data. ATM, the data must be doubles. More...
 
class  Histogram_2d
 
class  Weight_array
 Forward declarations. More...
 
class  Abstract_dynamics
 
class  Parapiped_camera_dynamics
 
class  Parapiped_stretch_dynamics
 
class  Focal_scale_dynamics
 
class  Discrete_change_size
 
class  Likelihood_dynamics
 
class  Manhattan_hog
 
class  Parametric_parapiped
 
class  Parametric_sphere
 
class  Kriging_interpolator
 a class to interpolate elevation values using Gaussian processes More...
 
class  Ned13_one_degree_grid
 storage for a single NED13 grid tile, plus convenient access. More...
 
class  Ned13_grid_cache
 This caches a bunch (potentially) of one-degree grids for you. More...
 
struct  Ned13_caching_reader
 interface to an elevation-info object that caches its NED13 grids More...
 
struct  Ned13_nearest_se_neighbor_reader
 support NED 13 elevation queries by using nearest southeast neighbor More...
 
struct  Ned13_bilinear_reader
 support NED 13 elevation queries using bilinear interpolation More...
 
struct  Ned13_gp_reader
 
class  Video_frame
 
class  Abstract_video
 
class  Video
 
class  OpenSSL_EVP
 Generic OpenSSL hasher class, the base class for specific derivations. More...
 
class  MD5
 Message Digest 5 computation, using OpenSSL code. More...
 

Typedefs

typedef Axis_aligned_rectangle_2d Bbox
 
typedef boost::shared_ptr
< Edge_set
Edge_set_ptr
 
typedef boost::shared_ptr
< Chamfer_transform
Chamfer_transform_ptr
 
typedef std::pair< float, float > Feature
 
typedef std::pair< Vector, VectorFeature_pair
 
typedef std::set< Feature_pair,
Compare_flow_features
Flow_feature_set
 
typedef Vector_d< 3 > Vector3
 
typedef Axis_aligned_rectangle_2d Bounding_Box2D
 
typedef Vector_d< 2 > Vector2
 
typedef Vector_d< 4 > Vector4
 
typedef std::pair< kjb::Vector,
kjb::Vector
Line3d
 
typedef Wire_occlude_renderer Silhouette_renderer
 
typedef void gsl_qrng_type
 
typedef void gsl_qrng
 
typedef Gsl_rng_mt19937 Gsl_rng_default
 An all-around good, fast, simulation-quality random number generator. More...
 
typedef boost::shared_ptr< ImageImage_ptr
 
typedef Cant_happen Cant_happen_exception
 
typedef std::list< std::pair
< int, int > > 
Region
 Later... More...
 
typedef std::vector< RegionRegion_vector
 Later... More...
 
typedef void * FFTW_complex_vector
 
typedef void * FFTW_real_vector
 
typedef boost::multi_array_ref
< double, 2 > 
Matrix_stl_view
 
typedef Generic_matrix_view
< Matrix
Matrix_view
 
typedef const
Generic_matrix_view< const
Matrix
Const_matrix_view
 
typedef Generic_vector_view
< Matrix
Matrix_vector_view
 
typedef const
Generic_vector_view< const
Matrix
Const_matrix_vector_view
 
typedef Generic_vector_view
< Vector
Vector_view
 
typedef const
Generic_vector_view< const
Vector
Const_vector_view
 
typedef Normal_on_normal_dependence Gaussian_on_gaussian_dependence
 
typedef
Conditional_distribution
< Normal_distribution,
Normal_distribution,
Normal_on_normal_dependence
Normal_conditional_distribution
 
typedef
Normal_conditional_distribution 
Gaussian_conditional_distribution
 
typedef
MV_normal_on_normal_dependence 
MV_gaussian_on_gaussian_dependence
 
typedef
Conditional_distribution
< MV_normal_distribution,
MV_normal_distribution,
MV_normal_on_normal_dependence
MV_normal_conditional_distribution
 
typedef
MV_normal_conditional_distribution 
MV_gaussian_conditional_distribution
 
typedef boost::math::bernoulli Bernoulli_distribution
 
typedef
boost::math::beta_distribution 
Beta_distribution
 
typedef boost::math::binomial Binomial_distribution
 
typedef boost::math::chi_squared Chi_square_distribution
 
typedef boost::math::exponential Exponential_distribution
 
typedef
boost::math::gamma_distribution 
Gamma_distribution
 
typedef boost::math::normal Gaussian_distribution
 
typedef boost::math::laplace Laplace_distribution
 
typedef boost::math::normal Normal_distribution
 
typedef boost::math::poisson Poisson_distribution
 
typedef boost::math::uniform Uniform_distribution
 
typedef
boost::math::inverse_gamma_distribution 
Inverse_gamma_distribution
 
typedef MV_gaussian_distribution MV_normal_distribution
 
typedef Chinese_restaurant_process Crp
 
typedef boost::mt19937 Base_generator_type
 

Enumerations

enum  Detection_type {
  DEVA, CV_FRONTAL_DEFAULT, CV_FRONTAL_ALT, CV_FRONTAL_ALT2,
  CV_FRONTAL_ALT_TREE, CV_PROFILE, FACE_COM, NUM_DETECTION_TYPES
}
 
enum  MOVE_DIRECTION { COL_PLUS, COL_MINUS, ROW_PLUS, ROW_MINUS }
 Move direction of the 2D bounding box. More...
 
enum  { GSL_QRNG_NIEDER, GSL_QRNG_SOBOL, GSL_QRNG_HALTON, GSL_QRNG_RVSHALTON }
 
enum  {
  GSL_RNG_MT19937, GSL_RNG_RANLXS0, GSL_RNG_RANLXS1, GSL_RNG_RANLXS2,
  GSL_RNG_RANLXD1, GSL_RNG_RANLXD2, GSL_RNG_CMRG, GSL_RNG_MRG,
  GSL_RNG_TAUS2, GSL_RNG_GFSR4
}
 constants used to select random number generators More...
 
enum  Parapiped_camera_dynamics_params {
  PCD_PARAPIPED_X = 0, PCD_PARAPIPED_Y, PCD_PARAPIPED_Z, PCD_PARAPIPED_WIDTH,
  PCD_PARAPIPED_HEIGHT, PCD_PARAPIPED_LENGTH, PCD_PARAPIPED_YAW, PCD_CAMERA_FOCAL,
  PCD_CAMERA_PITCH, PCD_CAMERA_ROLL
}
 
enum  NED13_FLOAT_AUTODETECT { NED_AD_MSBFIRST, NED_AD_LSBFIRST, NED_AD_UNCERTAIN }
 

Functions

double get_3d_height (const Vector &bottom_2d, const Vector &top_2d, const Perspective_camera &camera)
 Back project the 2d points to find the height in 3D. Assume that the bottom is on the ground. More...
 
void swap (Perspective_camera &cam1, Perspective_camera &cam2)
 Swap two cameras. More...
 
std::ofstream & operator<< (std::ofstream &out, const Quaternion &q)
 
Turntable_camera regularize_turntable_cameras (const std::vector< Calibrated_camera > &cameras_)
 
std::vector< Deva_detectionparse_deva_detection (std::istream &is, const std::string &type=std::string("person"))
 Parse the output from Deva's part detector into a vector of Deva_detection. More...
 
std::vector< Deva_detectionparse_deva_detection (std::istream &is, double score_thresh, const std::string &type=std::string("person"))
 Parse the output from Deva's part detector and prune by the confidence score. More...
 
Deva_detection parse_deva_detection_line (const std::string &line, const std::string &type=std::string("person"))
 Parse the output from Deva's part detector. More...
 
std::vector< Deva_facemarkparse_deva_facemark (std::istream &is)
 Parse the output from Deva's face detector into a vector of Deva_facemark. More...
 
Deva_facemark parse_deva_facemark_line (const std::string &line)
 Parse the output from Deva's face detector. More...
 
void write_deva_facemark (const std::vector< Deva_facemark > &faces, std::ostream &os)
 Write the output from Deva's face detector into a vector of Deva_facemark. More...
 
void write_deva_facemark_line (const Deva_facemark &face, std::ostream &os)
 Write the output from Deva's face detector. More...
 
Vector gaze_direction (const Face_detection &face, const Perspective_camera &camera)
 Computes the direction of the gaze. More...
 
Vector face_location_3d (const Face_detection &face, const Perspective_camera &camera, const Bbox &body_box)
 Computes the 3D location of a face. More...
 
std::ostream & operator<< (std::ostream &ost, const Face_detection &face)
 Writes the face into ostream. More...
 
bool operator< (const Face_detection &f1, const Face_detection &f2)
 Compares to boxes using middle of box. Needed because we have associated containers of these. More...
 
Face_detection parse_face_line (const std::string &line)
 Parse a line of a file (in face.com format) into a Face_Detection. More...
 
std::vector< Face_detectionread_face_file (std::istream &is)
 Read set of faces from file (in face.com format). More...
 
std::vector< std::vector
< Face_detection > > 
read_face_files (const std::vector< std::string > &face_fps)
 Parse the output of the faces from multiple files into a vector of vector of Face_detection. More...
 
std::vector< std::string > get_all_detection_type_names ()
 Get all types. More...
 
const std::string & get_detection_type_name (Detection_type type)
 Get the name of a detection type. More...
 
Detection_type get_detection_type (const std::string &name)
 Get the type of a detection name. More...
 
std::ostream & operator<< (std::ostream &ost, Detection_type type)
 Stream out an detection. More...
 
std::istream & operator>> (std::istream &ist, Detection_type &type)
 Stream in an detection. More...
 
Matrix fourier_basis (size_t D, size_t num_basis_funcs)
 Returns a matrix whose rows form a Fourier basis in R^D. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_cfd (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the gradient of a function, evaluated at a point, using central finite differences. More...
 
template<class Func , class Vec >
Vector gradient_cfd (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the gradient of a function, evaluated at a point, using central finite differences, for a vectory-style model. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_ffd (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the gradient of a function, evaluated at a point, using forward finite differences. More...
 
template<class Func , class Vec >
Vector gradient_ffd (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the gradient of a function, evaluated at a point, using forward finite differences, for a vectory-style model. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_ind_cfd (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the gradient of a function, evaluated at a point, using central finite differences. More...
 
template<class Func , class Vec >
Vector gradient_ind_cfd (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the gradient of a function, evaluated at a point, using central finite differences for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
void gradient_cfd_mt_worker (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t i_start, size_t i_end, Vector &v)
 Helper function for gradient_cfd_mt. More...
 
template<class Func , class Model , class Adapter >
void gradient_ffd_mt_worker (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, double fx, size_t i_start, size_t i_end, Vector &v)
 Helper function for gradient_ffd_mt. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_cfd_mt (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t nt)
 Computes the gradient of a function, evaluated at a point, using central finite differences. Multi-threaded version. More...
 
template<class Func , class Vec >
Vector gradient_cfd_mt (const Func &f, const Vec &x, const std::vector< double > &dx, size_t nt=0)
 Computes the gradient of a function, evaluated at a point, using central finite differences, for a vectory-style model. Multi-threaded version. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_ffd_mt (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t nt)
 Computes the gradient of a function, evaluated at a point, using forward finite differences. Multi-threaded version. More...
 
template<class Func , class Vec >
Vector gradient_ffd_mt (const Func &f, const Vec &x, const std::vector< double > &dx, size_t nt=0)
 Computes the gradient of a function, evaluated at a point, using forward finite differences, for a vectory-style model. Multi-threaded version. More...
 
template<class Func , class Model , class Adapter >
void gradient_ind_cfd_mt_worker (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t i_start, size_t i_end, Vector &v)
 Helper function for gradient_ind_cfd_mt. More...
 
template<class Func , class Model , class Adapter >
Vector gradient_ind_cfd_mt (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t nt)
 Computes the gradient of a function, evaluated at a point, using central finite differences. Multithreaded version. More...
 
template<class Func , class Vec >
Vector gradient_ind_cfd_mt (const Func &f, const Vec &x, const std::vector< double > &dx, size_t nt=0)
 Computes the gradient of a function, evaluated at a point, using central finite differences for a vector-style model. Multi-threaded version. More...
 
template<class Func , class Model , class Adapter >
Matrix hessian (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the Hessian of a function, evaluated at a point, using finite differences. More...
 
template<class Func , class Vec >
Matrix hessian (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the Hessian of a function, evaluated at a point, for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
Matrix hessian_symmetric (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the Hessian of a function, evaluated at a point, using finite differences. This function assumes that the Hessian is SYMMETRIC, and only computes the lower triangle of it. More...
 
template<class Func , class Vec >
Matrix hessian_symmetric (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the Hessian of a function, evaluated at a point, for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
Matrix hessian_diagonal (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the diagonal Hessian of a function, evaluated at a point, using finite differences. More...
 
template<class Func , class Vec >
Matrix hessian_diagonal (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the Hessian of a function, evaluated at a point, for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
Matrix hessian_ind (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the Hessian of a function, evaluated at a point, using finite differences. More...
 
template<class Func , class Vec >
Matrix hessian_ind (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the Hessian of a "independent" function, evaluated at a point, for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
Matrix hessian_symmetric_ind (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter)
 Computes the Hessian of an "independent" function, evaluated at a point, using finite differences. This function assumes that the Hessian is SYMMETRIC, and only computes the lower triangle of it. More...
 
template<class Func , class Vec >
Matrix hessian_symmetric_ind (const Func &f, const Vec &x, const std::vector< double > &dx)
 Computes the Hessian of an "independent" function, evaluated at a point, for a vector-style model. More...
 
template<class Func , class Model , class Adapter >
Vector hessian_ind_diagonal (const Func &f, const Model &x, const std::vector< double > &dx, const Adapter &adapter, size_t is, size_t ie)
 Computes the Hessian diagonal of a function, evaluated at a point, using finite differences. More...
 
template<class Func , class Vec >
Vector hessian_ind_diagonal (const Func &f, const Vec &x, const std::vector< double > &dx, size_t is, size_t ie)
 Computes the Hessian diagonal of a "independent" function, evaluated at a point, for a vector-style model. More...
 
template<class F , class M , class A >
double grid_maximize (const F &fcn, const std::vector< std::pair< double, double > > &bounds, size_t nbins, const A &adapter, M &mxm)
 Maximizes a function by evaluating at all points in a grid. More...
 
template<class F , class V >
double grid_maximize (const F &fcn, const std::vector< std::pair< double, double > > &bounds, size_t nbins, V &mxm)
 Maximizes a function by evaluating at all points in a grid. More...
 
template<class F , class M , class G , class A >
void gradient_ascent (const F &fcn, M &x, const std::vector< double > &steps, const G &grad, const A &adapter)
 Maximizes a function using a simple gradient ascent method. More...
 
template<class F , class V , class G >
void gradient_ascent (const F &fcn, V &x, const std::vector< double > &steps, const G &grad)
 Maximizes a function using a simple gradient ascent method. More...
 
template<class F , class M , class A >
void refine_max (const F &fcn, M &x, const std::vector< double > &steps, const A &adapter)
 Refine the maximum of a function. More...
 
template<class Model , class Adapter >
void move_param (Model &x, size_t i, double dv, const Adapter &aptr)
 Helper function that moves a parameter by an amount. More...
 
template<class Model , class Adapter >
void move_params (Model &x, size_t i, size_t j, double dv, double dw, const Adapter &aptr)
 Helper function that moves a pair of parameters by an amount. More...
 
template<class Model , class Vec , class Adapter >
void move_params (Model &x, const Vec &dx, const Adapter &aptr)
 Helper function that moves all parameters by specified vector. More...
 
template<class M , class A >
bool next_point (const std::vector< std::pair< double, double > > &bounds, const std::vector< double > &widths, size_t nbins, std::vector< size_t > &indices, M &x, const A &adapter)
 Gets the next point in a N-dimensional grid. More...
 
const Vectorget_bottom_y (const Line_segment &seg)
 Get end-point with lowest y-value. More...
 
const Vectorget_top_y (const Line_segment &seg)
 Get end-point with highest y-value. More...
 
template<class InputIterator >
std::vector
< Collinear_segment_chain
find_collinear_segment_chains (InputIterator first, InputIterator last, double distance_threshold, double orientation_threshold)
 Find a set of collinear_segments_chains. More...
 
Image edges_to_image (const Edge_set &edges, bool invert, size_t remove_borders)
 
Edge_set_ptr edge_image_to_edge_points (const Image &i, bool oriented)
 
void load (Edge_set &edges, const std::string &fname)
 
void save (const Edge_set &edges, const std::string &fname)
 
void swap (Chamfer_transform &op1, Chamfer_transform &op2)
 
std::ostream & operator<< (std::ostream &out, const Edge_segment &es)
 
Features_managerdetect_hoiem_features_manager (const std::string &img_path)
 
void compute_HOG_features (const Image &img, int bin_size)
 
void rotate_matrix_90_degrees (Matrix &m, int number_of_times)
 
void rotateMatrix (Matrix &m, double angle)
 
void detect_long_connected_segments (Line_segment_set &segments, const std::string &img_path, int max_length)
 
std::ostream & operator<< (std::ostream &out, const Manhattan_corner &mc)
 
std::ostream & operator<< (std::ostream &out, const Manhattan_corner_segment &mcs)
 
std::ostream & operator<< (std::ostream &out, const Manhattan_segment &ms)
 
Manhattan_worldcreate_manhattan_world_from_CMU_file (const std::string &file_name)
 
Manhattan_worldcreate_mw_from_CMU_file_and_compute_focal_length (const std::string &file_name, const kjb::Edge_segment_set &iset, unsigned int num_rows, unsigned int num_cols)
 
void read_CMU_vanishing_points (std::vector< Vanishing_point > &vpts, double &focal_length, std::string file_name)
 
void draw_mid_point_to_vanishing_point (kjb::Image &img, const Line_segment &segment, const Vanishing_point &vpt, double ir, double ig, double ib, double width)
 
bool find_vanishing_point_given_one_and_line (const kjb::Vanishing_point &vp1, double focal, unsigned int img_cols, unsigned int img_rows, const Line_segment &ls, Vanishing_point &vpt)
 
bool find_third_vanishing_point (const kjb::Vanishing_point &vp1, const kjb::Vanishing_point &vp2, double focal, unsigned int img_rows, unsigned int img_cols, Vanishing_point &vpt)
 
bool read_hedau_vanishing_points (std::vector< Vanishing_point > &vpts, double &focal, const std::string &file_path, unsigned int num_cols, unsigned int num_rows)
 
bool find_vertical_vanishing_point (Vanishing_point &vp1, Vanishing_point &vp2, Vanishing_point &estimated_vertical, unsigned int img_cols, unsigned int img_rows)
 
bool robustly_estimate_vanishing_points (std::vector< Vanishing_point > &vpts, double &focal_length, const kjb::Image &img, double success_probability=VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY, bool jointly_estimate=false, std::vector< Vanishing_point > right_ones=std::vector< Vanishing_point >(0))
 Estimates the vanishing points for the three orthogonal directions of a Manhattan world scene (where most of all planes are aligned with three main orthogonal directions). This function works ONLY under the Manhattan world assumption. More...
 
bool robustly_estimate_vertical_vanishing_point (Vanishing_point &vertical, const kjb::Image &img, double success_probability=VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY)
 
bool relaxed_vanishing_point_estimation (std::vector< Vanishing_point > &vpts, double &focal_length, const kjb::Image &img, double success_probability)
 This function uses less constraints coming from geometry and uses the data more, relying on the assumption that there is less noise. This is convenient with synthetic data. More...
 
unsigned int assign_to_vanishing_point (double outlier_threshold, const Line_segment *isegment, const std::vector< Vanishing_point > &ivpts)
 Assigns an edge segments to the vanishing point that minimizes the angle between the segment and the line between the midpoint of the segment and the vanishing point. If this angle is too big for all vanishing points, the segment is labeled as an outlier. This checks using different outlier thresholds and can be time consuming (ie 1-5 seconds). More...
 
double robustly_estimate_vanishing_points_Kovesi (std::vector< Vanishing_point > &vpts, double &focal_length, const Image &img, const Line_segment_set &kovesi, double start_threshold=0.05, double vpts_tolerance=VPD_MAX_PRINCIPAL_POINT_POSITION_TOLERANCE, double success_probability=VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY)
 
bool detect_vanishing_points (std::vector< Vanishing_point > &vpts, double &focal_length, const std::string &img_path)
 
Vector average_flow (const Matrix &x_flows, const Matrix &y_flows, const Axis_aligned_rectangle_2d &roi)
 Get the average optical flow inside a rectangle region. More...
 
Matrix flow_magnitude (const Matrix &x_flows, const Matrix &y_flows)
 Compute the flow magnitude. More...
 
Flow_feature_set read_flow_features (const std::string &fname)
 Read in the procomputed optical flow from files. More...
 
std::vector< Feature_pairlook_up_features (const Flow_feature_set &of_set, const Axis_aligned_rectangle_2d &box)
 Given the features and a bounding box at the same frame, find and return the detected features inside the bounding box. More...
 
std::vector< Feature_pairlook_up_bg_features (const Flow_feature_set &of_set, const std::vector< Axis_aligned_rectangle_2d > &model_boxes)
 Given the features and all the model boxes at cur_frame, find all the background features. More...
 
Vector average_flow (const std::vector< Vector > &flows)
 Calculate the average optical flow for a vector of flow Vectors. More...
 
bool compare_flow_magnitude (const Vector &f_p, const Vector &f_n)
 Compare the optical flow magnitude. More...
 
std::vector< Vectorvalid_flow (const std::vector< Feature_pair > &feature_pairs, double percentile=1.0)
 Get valid features. More...
 
std::vector< Vectorvalid_flow (const std::vector< Feature_pair > &feature_pairs, const std::vector< size_t > &angle_hist)
 Get valid flow features that with angle alpha in the rangle (min_angle, max_angle) More...
 
std::vector< size_t > angle_histogram (const std::vector< Feature_pair > &feature_pairs, size_t num_bins=36)
 Compute the histogram of the flow vector angles. More...
 
Vector update_average_velocity (const Flow_feature_set &of_set, const Axis_aligned_rectangle_2d &old_model_box, const Vector &old_velocity, MOVE_DIRECTION dir, size_t unit=1)
 Update the average flow velocity based on the moving direction. More...
 
Vector update_average_velocity (const Flow_feature_set &of_set, const Axis_aligned_rectangle_2d &old_box, const Axis_aligned_rectangle_2d &new_box, const Vector &old_velocity)
 Update the average model velocity. More...
 
Vector lookup_feature (const Flow_feature_set &of_set, size_t x, size_t y, size_t subsample_sz=1)
 Looks up a feature in a feature set; deals with subsampling. More...
 
Vector total_flow (const Flow_feature_set &of_set, const Axis_aligned_rectangle_2d &box)
 Compute the average flow vector inside the bounding box. More...
 
void draw_features (Image &img, const std::vector< Feature_pair > &features, const Vector &average_flow, Image::Pixel_type feature_pixel=fpix, Image::Pixel_type ave_flow_pixel=apix)
 Draw the optical flow features and the average flow. More...
 
template<class VectorType , class MatrixType , class M_MatrixType >
VectorType backproject_dispatch_ (const VectorType &homo_screen_coord, const MatrixType &camera_matrix)
 
Vector3 backproject (const Vector3 &homo_camera_coord, const Matrix_d< 3, 4 > &camera_matrix)
 Same as backproject(), but using Vector3. More...
 
Vector backproject (const Vector &homo_screen_coord, const Matrix &camera_matrix)
 
template<class VectorType , class MatrixType >
VectorType backproject_with_m_inv_dispatch_ (const VectorType &homo_screen_coord, const MatrixType &M_inv)
 
Vector backproject_with_m_inv (const Vector &homo_screen_coord, const Matrix &M_inv)
 
Vector3 backproject_with_m_inv (const Vector3 &homo_screen_coord, const Matrix_d< 3, 3 > &M_inv)
 Same as backproject_with_m_inv(), but using Vector3. More...
 
Matrix lerp_extrinsic_camera_matrix (const Matrix &m1, const Matrix &m2, double t, bool use_slerp=false)
 Linearly-interpolate a two extrinsic camera matrices. More...
 
Matrix lerp_extrinsic_camera_matrix (const std::vector< Matrix > &extrinsic, const std::vector< double > &timestamps, double t, bool use_slerp=false)
 Linearly-interpolate a set of extrinsic camera matrix at given timestamps. More...
 
std::ostream & operator<< (std::ostream &ost, const Calibration_descriptor::Coord_convention &mode)
 
std::istream & operator>> (std::istream &ist, Calibration_descriptor::Coord_convention &mode)
 
void standardize_camera_matrices (Matrix &intrinsic, Matrix &rotation, Vector &translation, const Calibration_descriptor &cal)
 
void decompose_camera_matrix (const Matrix &camera_matrix, Matrix &intrinsic, Matrix &rotation, Vector &translation)
 
int get_convex_hull (const Matrix &points, Matrix &hull_vertices, std::vector< Matrix > &hull_facets)
 Get the convex hull of points hull_vertices stores the vertices of the convex hull hull_facets stores the facets of the hull. More...
 
bool intersect_hulls (const std::vector< Matrix > &pts, Matrix &hull_vertices, std::vector< Matrix > &hull_facets)
 Compute the intersections of the vector of points. More...
 
double get_convex_hull_volume (const kjb::Matrix &points)
 Get the volume of the convex hull of points. More...
 
bool intersect_3D_line_with_plane (kjb::Vector &intersection, double &t, const kjb::Vector &point, const kjb::Vector &direction, const kjb::Vector &plane)
 
template<class VectorType >
double intersect_line_with_plane_dispatch_ (const VectorType &line_point, const VectorType &line_direction, const VectorType &plane_point, const VectorType &plane_normal)
 
double intersect_line_with_plane (const kjb::Vector &line_point, const kjb::Vector &line_direction, const kjb::Vector &plane_point, const kjb::Vector &plane_normal)
 
template<std::size_t D>
double intersect_line_with_plane (const kjb::Vector_d< D > &line_point, const kjb::Vector_d< D > &line_direction, const kjb::Vector_d< D > &plane_point, const kjb::Vector_d< D > &plane_normal)
 intersect a D-dimensional line an plane, using point-vector representation. (static version) More...
 
Vector project_point_onto_line (const Vector &A, const Vector &B, const Vector &P)
 Project a point onto a line, in any dimension. More...
 
void get_3D_corner_orientation_from_2D_corner_lines (const kjb::Vector &corner2D_1, const kjb::Vector &corner2D_2, const kjb::Vector &corner2D_3, const kjb::Vector &position_2D, const kjb::Vector &position_3D, double focal_length, int epsilon, kjb::Vector &corner3D_1, kjb::Vector &corner3D_2, kjb::Vector &corner3D_3)
 
Quaternion slerp (const Quaternion &q1, const Quaternion &q2, double t)
 
Quaternion slerp2 (const Quaternion &q1, const Quaternion &q2, double t)
 
Quaternion nlerp (const Quaternion &q1, const Quaternion &q2, double t)
 
ostream & operator<< (ostream &out, const Quaternion &q)
 
double norm (const Quaternion &q, unsigned int l=2)
 
Quaternion difference (const Quaternion &q1, const Quaternion &q2)
 
void swap (Quaternion &q1, Quaternion &q2)
 Non-member swap function. More...
 
void scale (kjb::Axis_aligned_rectangle_2d &box, const kjb::Vector &s)
 
void get_projected_bbox_from_3Dpoints (Axis_aligned_rectangle_2d &bb, const std::vector< Vector > &points, const Base_gl_interface &camera, double img_width, double img_height)
 Projects a set of 3D points onto the image plane, and finds a bounding box (aligned with the image axes), such that it contains all the projected points. More...
 
std::ostream & operator<< (std::ostream &ost, const Axis_aligned_rectangle_2d &box)
 
std::istream & operator>> (std::istream &ist, Axis_aligned_rectangle_2d &box)
 
Bounding_Box2D intersect (const Bounding_Box2D &b1, const Bounding_Box2D &b2)
 
double get_rectangle_intersection (const kjb::Bounding_Box2D &b1, const kjb::Bounding_Box2D &b2)
 Compute area of intersection of two rectangles. More...
 
void translate (kjb::Axis_aligned_rectangle_2d &box, const kjb::Vector &t)
 
template<class Iterator >
Axis_aligned_rectangle_2d compute_bounding_box (Iterator first, Iterator last)
 Computes the 2D bounding box of a range of 2D points. More...
 
void swap (Axis_aligned_rectangle_2d &r1, Axis_aligned_rectangle_2d &r2)
 Swaps two rectangles. More...
 
void get_plane_parameters (const Vector &normal, const Vector &point_on_plane, Vector &plane_params)
 Finds the coefficients of the plane of the form ax + by + cz + d = 0 given the normal vector and a point on the plane. More...
 
void get_plane_parameters (const Vector &pt1, const Vector &pt2, const Vector &pt3, Vector &plane_params)
 Finds the coefficients of the plane of the form ax + by + cz + d = 0 given three points on the plane. More...
 
bool check_if_faces_are_coplanar (const Vector &plane1_params, const Vector &plane2_params, double tolerance, double distTolerance=1.0)
 Checks if two faces in a polymesh are coplanar. More...
 
bool check_if_4_points_are_coplanar (const Vector &p1, const Vector &p2, const Vector &p3, const Vector &p4, double tolerance)
 Checks if 4 points are coplanar. More...
 
double get_angle_between_two_vectors (const Vector &plane1_params, const Vector &plane2_params) throw (Illegal_argument, KJB_error)
 Calculates the smaller angle between the normal vectors of two planes. The angle returned is in radians. More...
 
void find_planes (const Polymesh &p, std::vector< Polymesh_Plane > &plane)
 Finds all of the planes in a polymesh and stores each set of coefficients along with the corresponding face indices in a Polymesh_Plane. More...
 
void render_planes (const Polymesh &p, const std::vector< Polymesh_Plane > &planes)
 Renders each plane in a polymesh with a different color. More...
 
void find_all_circles_in_polymesh (Polymesh &p, std::vector< Circle_in_3d > &circles, std::vector< std::vector< Vector > > &points)
 Finds all of the circles and the points that lie on them in the polymesh. More...
 
void find_right_triangles (const std::vector< kjb::Polygon > &faces, Int_vector &mask)
 Creates an Int_vector mask representing the faces in a polymesh that are right triangles. More...
 
void find_rectangles (const std::vector< kjb::Polygon > &faces, const Int_vector &mask, const Polymesh &p, std::vector< Right_Triangle_Pair > &rectangles)
 Finds all pairs of right triangles in a polymesh that are coplanar, adjacent along their hypotenuses, and have the same vertices along the shared edge (i.e. the triangle pairs form a rectangle). More...
 
void create_rectangle_mask (const Polymesh &p, const std::vector< Right_Triangle_Pair > &rectangles, Int_vector &rectMask)
 Creates an Int_vector mask representing the faces in a polymesh that are part of a rectangle. More...
 
void find_adjacent_rectangles (const Polymesh &p, const Int_vector &cylMask, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, int startIndex, int rectIndex, int prevAdjFace, double width, double lengthTolerance, double &smallestAngle, double &largestAngle, double &sumAngles, std::vector< int > &cyl_indices, Vector &edge_pt1, Vector &edge_pt2, Vector &edge_pt1_adj, Vector &edge_pt_adj)
 Determines which rectangles are adjacent to eachother and if a group of adjacent rectangles form part of a cylinder. More...
 
void find_cylinders (const Polymesh &p, const std::vector< Right_Triangle_Pair > &rectangles, std::vector< std::vector< int > > &cyl_indices, std::vector< double > &cylSumAngles, std::vector< std::vector< Vector > > &cylEdgePoints)
 Determines which groups of faces in the polymesh form cylinders. More...
 
void find_top_and_bottom_points_of_cylinder (const Polymesh &p, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, const std::vector< int > &cyl_indices, std::vector< Vector > &top_points, std::vector< Vector > &bottom_points)
 Determines which points make up the 'top' and which points make up the 'bottom' of the cylinder specified by the provided polymesh face indices. More...
 
void find_centroid_of_3d_points (const std::vector< Vector > &points, Vector &centroid)
 Finds the center of a set of 3D points. More...
 
void fit_plane_to_3d_points (const std::vector< Vector > &points, const Vector &centroid, Vector &plane_params)
 Uses singular value decomposition (SVD) to fit a plane to a set of 3D points. More...
 
void project_points_onto_plane (std::vector< Vector > &points, const Vector &plane_params, const Vector &centroid, std::vector< Vector > &projected_points)
 Projects 3D points onto the best-fit 3D plane. More...
 
void translate_3d_plane_to_xy_plane (const std::vector< Vector > &points, const Vector &plane_params, std::vector< Vector > &translated_points, std::vector< Matrix > &transformMatrices)
 
void translate_xy_point_to_3d_plane (const Vector &point, const std::vector< Matrix > &transformMatrices, Vector &translated_point)
 
void fit_cylinder (const Polymesh &p, const Int_vector &rectMask, const std::vector< Right_Triangle_Pair > &rectangles, const std::vector< int > &cyl_indices, double cylAngle, const std::vector< Vector > &cylEdgePoints, Cylinder_section &cyl)
 Determines the parameters of the cylinder formed by a set of faces in the polymesh. More...
 
void find_cylinders_to_render_and_fit (char *faceFile, char *cylFile, const Polymesh &p, std::vector< Polymesh_Plane > &plane, std::vector< Cylinder_section > &cyl)
 
void find_cylinders_to_render (const Polymesh &p, std::vector< Polymesh_Plane > &plane)
 Renders each set of faces that forms a cylinder a different color. More...
 
void find_rectangles_to_render (const Polymesh &p, std::vector< Polymesh_Plane > &plane)
 Renders each pair of faces that forms a rectangle a different color. More...
 
void find_right_triangles_to_render (const Polymesh &p, std::vector< Polymesh_Plane > &plane)
 Renders each face that is a right triangle in a different color. More...
 
void find_adjacent_right_triangles_to_render (const Polymesh &p, std::vector< Polymesh_Plane > &plane)
 Renders each face that is a right triangle and adjacent to another face that is also a right triangle in a different color. More...
 
std::ostream & operator<< (std::ostream &out, const Line_segment &ls)
 
void rotate (Matrix &m, const Quaternion &r)
 
void translate (Matrix &m, const Vector &v_in)
 
void retrieve_offscreen_capabilities (bool *_has_gl, bool *_has_osmesa)
 Checks what offscreen rendering capabilities are available on the machine. More...
 
bool supports_pbuffers ()
 DEPRECATED Returns true if pbuffers are available. ONLY FOR DEBUG PURPOSES. More...
 
bool supports_pixmaps ()
 DEPRECATED Returns true if pixelmaps are available. ONLY FOR DEBUG PURPOSES. More...
 
void kjb_opengl_debug_display_buffer ()
 Pop up a window displaying the opengl color buffer. More...
 
int min_bipartite_match (const Matrix &weights, Int_vector *assignment, Matrix::Value_type *cost)
 solve a matching with minimum cost in a complete bipartite graph. More...
 
double gsl_evaluate_Nd_boost_function (const gsl_vector *v, void *params)
 
 Gsl_rng_template (Gsl_rng_mt19937, gsl_rng_mt19937, GSL_RNG_MT19937)
 
 Gsl_rng_template (Gsl_rng_ranlxs0, gsl_rng_ranlxs0, GSL_RNG_RANLXS0)
 
 Gsl_rng_template (Gsl_rng_ranlxs1, gsl_rng_ranlxs1, GSL_RNG_RANLXS1)
 
 Gsl_rng_template (Gsl_rng_ranlxs2, gsl_rng_ranlxs2, GSL_RNG_RANLXS2)
 
 Gsl_rng_template (Gsl_rng_ranlxd1, gsl_rng_ranlxd1, GSL_RNG_RANLXD1)
 
 Gsl_rng_template (Gsl_rng_ranlxd2, gsl_rng_ranlxd2, GSL_RNG_RANLXD2)
 
 Gsl_rng_template (Gsl_rng_cmrg, gsl_rng_cmrg, GSL_RNG_CMRG)
 
 Gsl_rng_template (Gsl_rng_mrg, gsl_rng_mrg, GSL_RNG_MRG)
 
 Gsl_rng_template (Gsl_rng_taus2, gsl_rng_taus2, GSL_RNG_TAUS2)
 
 Gsl_rng_template (Gsl_rng_gfsr4, gsl_rng_gfsr4, GSL_RNG_GFSR4)
 
void report_gsl_failure_and_throw_kjb_error (int gsl_code, const char *file, unsigned line_no)
 Implements the error-handling activities of Gsl_Etx_impl(). More...
 
void gsl_iterate_EPE (int gsl_error_code)
 On error, print a GSL iteration error message (like EPE) More...
 
void Gsl_Etx_impl (int gsl_code, const char *file, unsigned line_no)
 On GSL error of some kind, throw an KJB_error exception. More...
 
Gsl_Vector operator* (double scalar, const Gsl_Vector &vector)
 multiply scalar and vector, scalar written on the left side More...
 
Image make_collage (Image const *const *input_images, int num_horizontal, int num_vertical)
 wrapper for kjb_c::make_image_collage More...
 
Image make_collage (Image const *input_img_array, int num_horizontal, int num_vertical)
 also works for an array of Image objects More...
 
void write_histograms (const std::vector< Color_histogram > &chs, const std::string &file_name)
 
void read_histograms (std::vector< Color_histogram > &chs, const std::string &file_name)
 
Filter gaussian_filter (double sigma, int size)
 Create a Gaussian filter with given sigma and size. More...
 
Filter laplacian_of_gaussian_filter (int size, double sigma)
 Create a Laplacian of Gaussian filter. More...
 
Image operator* (const Image &image, const Filter &kernel)
 Convolve an image with a filter. More...
 
Image gauss_sample_image (const Image &in, int resolution, double sigma)
 this wraps C function kjb_c::gauss_sample_image (q.v.). More...
 
Matrix operator* (const Matrix &in, const Filter &mask)
 
Filter gaussian_filter (double sigma)
 Create a Gaussian filter with given sigma. More...
 
Vector hsluma_space (const kjb_c::Pixel &p)
 Compute the spatial coordinates of a pixel in HSY color space. More...
 
kjb_c::Pixel get_pixel_from_hsluma_space (const Vector &hsy)
 This clampfully transforms a point in HSY space to RGB. More...
 
int get_pixel_from_hsluma_space (const Vector &hsy, kjb_c::Pixel *p)
 This might transform a point in HSY space to RGB. More...
 
Matrix to_grayscale_matrix (const Image &i)
 
Image scale_image (const Image &i, double factor)
 Scale image size by factor, i.e., enlarge or shrink. More...
 
Image rgb_matrices_to_image (const Matrix &red_channel, const Matrix &green_channel, const Matrix &blue_channel)
 Contruct an image from three matrices representing red, green, blue channels. More...
 
Image get_inverted (const Image &)
 
Image operator* (const Image &op1, double op2)
 Scale an image in channel space, yielding a new image. More...
 
Image operator/ (const Image &op1, double op2)
 Scale an image in channel space, yielding a new image. More...
 
Image operator+ (const Image &op1, const Image &op2)
 Add two images. More...
 
Image operator- (const Image &im1, const Image &im2)
 Subtract two images. More...
 
void enable_transparency (Image &i)
 set Image flag, to indicate that the 'alpha' channel is meaningful. More...
 
void disable_transparency (Image &i)
 clear Image flag, to indicate that the 'alpha' channel is not meaningful. More...
 
bool is_transparency_enabled (const Image &i)
 test the Image flag, returning true if the 'alpha' channel is meaningful. More...
 
Image matrix_to_max_contrast_8bit_bw_image (const kjb::Matrix &m)
 convert a matrix to a black-and-white image, with enhanced contrast. More...
 
Image matrix_to_color_image (const kjb::Matrix &m, const kjb::Colormap &map="jet")
 Converts a matrix to a high-contrast color image, mapping values to colors using a kjb::Colormap. Equivalent to Matlab's imagesc() function. More...
 
Image imagesc (const kjb::Matrix &data, const kjb::Colormap &map="jet")
 Ported version of Matlab's "imagesc()" function; alias of matrix_to_color_image. More...
 
std::string pixel_as_hex_triplet_string (const kjb_c::Pixel *p)
 express color as HTML-style hex triplet, e.g., "#FFCC00," of pointer More...
 
PixelRGBA operator* (const PixelRGBA &p, const PixelRGBA &q)
 Multiply two pixels together. More...
 
PixelRGBA operator* (const PixelRGBA &p, double k)
 Scale a pixel by a floating point value on the right. More...
 
PixelRGBA operator* (double k, const PixelRGBA &p)
 Scale a pixel by a floating point value on the left. More...
 
kjb_c::Pixel abs (const kjb_c::Pixel &p)
 Take the channel-wise absolute value of a kjb_c::Pixel. More...
 
std::string pixel_as_hex_triplet_string (const kjb_c::Pixel &p)
 express color as HTML-style hex triplet, e.g., "#FFCC00," reference More...
 
template<class Iterator , class Real >
std::iterator_traits< Iterator >
::value_type 
lerp (Iterator begin, Iterator end, Real x)
 
template<class IIterator , class OIterator , class QueryType >
std::iterator_traits
< OIterator >::value_type 
lerp (IIterator ibegin, IIterator iend, OIterator obegin, const QueryType &query_point)
 
template<class IIterator , class OIterator , class I2Iterator , class O2Iterator >
void ordered_lerp (IIterator ibegin, IIterator iend, OIterator obegin, I2Iterator i2begin, I2Iterator i2end, O2Iterator o2begin)
 
template<class Key_type , class Value_type , class Query_type >
Value_type lerp (const std::map< Key_type, Value_type > &piecewise_function, const Query_type &query_point)
 
template<class ForwardIterator >
void linspace (double min, double max, size_t n, ForwardIterator begin, bool endpoint=true)
 
template<class ForwardIterator >
void logspace (double min, double max, size_t n, ForwardIterator begin)
 
template<class InType , class OutIterator , class UnaryOperator >
void linspace (const InType &lower, const InType &upper, size_t N, const OutIterator &out_begin, const UnaryOperator &f)
 
template<class InType , class OutIterator >
void linspace (InType min, InType max, size_t n, OutIterator begin)
 
template<int NUM_BYTES>
void swap_bytes_dispatch (void *)
 Swap the byte-order of a value. More...
 
template<>
void swap_bytes_dispatch< 2 > (void *value)
 swap the byte order of a 16-bit value (do not call directly). More...
 
template<>
void swap_bytes_dispatch< 4 > (void *value)
 swap the byte order of a 32-bit value (do not call directly). More...
 
template<>
void swap_bytes_dispatch< 8 > (void *value)
 swap the byte order of a 64-bit value (do not call directly). More...
 
template<class T >
void swap_bytes (T *value)
 
template<class T >
void swap_bytes (T &value)
 
template<class T >
void swap_array_bytes (T *array, size_t N)
 
template<typename T >
T & move (T &v)
 
template<typename T >
const T & move (const T &v)
 
template<class Indexable >
Indexable ew_multiply (const Indexable &I, const Indexable &J)
 Multiply the elements of two Indexable things. Must be indexed via operator() and assignable. More...
 
template<class Indexable >
void ew_abs_ow (Indexable &I)
 Element-wise abosulte value. More...
 
template<class Indexable >
void ew_square_ow (Indexable &I)
 Square the elements of an indexable class in place. I must be indexed via operator(). More...
 
template<class Indexable >
Indexable ew_square (const Indexable &I)
 Square the elements of an indexable class; the result is returned. I must be indexed via operator(). More...
 
template<class Indexable >
void ew_sqrt_ow (Indexable &I)
 Take the square root of the elements of an indexable class in place. I must be indexed via operator(). More...
 
template<class Indexable >
Indexable ew_sqrt (const Indexable &I)
 Take the square root the elements of an indexable class; the result is returned. I must be indexed via operator(). More...
 
std::string kjb_get_error ()
 similar to kjb_c::kjb_get_error(), but this returns std::string. More...
 
void throw_kjb_error (const char *msg, const char *file, unsigned line)
 
std::vector< std::string > file_names_from_format (const std::string &name_format, size_t first=1, size_t num_files=std::numeric_limits< size_t >::max())
 Expands the format into a set of (existing) file names. More...
 
std::vector< std::string > dir_names_from_format (const std::string &name_format, size_t first=1)
 Expands the format into a set of (existing) file names. More...
 
std::vector< std::string > strings_from_format (const std::string &str_format, size_t num_strings, size_t first=1)
 Expands the format into a set strings. More...
 
std::string realpath (const std::string &path)
 return a canonicalized path, by wrapping kjb_c::kjb_realpath(). More...
 
std::string get_extension (const std::string &fname)
 
void swap (Index_range &r1, Index_range &r2)
 
std::istream & operator>> (std::istream &ist, Index_range &ir)
 
Int_matrix create_row_matrix (const Int_matrix::Vec_type &)
 Construct a one-row matrix by deep-copying a vector. More...
 
Int_matrix create_diagonal_matrix (const Int_matrix::Vec_type &diagnoal)
 Construct a one-row matrix by deep-copying a vector. More...
 
Int_matrix create_column_matrix (const Int_matrix::Vec_type &)
 Construct a one-column matrix by deep-copying a vector. More...
 
bool operator== (const Int_matrix &op1, const Int_matrix::Impl_type &op2)
 Test for exact equality between two matrices. More...
 
std::ostream & operator<< (std::ostream &out, const Int_matrix &m)
 Display matrix contents in an ASCII format. More...
 
Int_matrix create_identity_int_matrix (int rank)
 Construct an identity matrix of specified rank. More...
 
Int_matrix create_zero_int_matrix (int rows, int columns)
 Construct a zero matrix of specified size. More...
 
Int_matrix create_zero_int_matrix (int rows)
 Construct a square zero matrix of specified size. More...
 
Int_matrix operator* (const Int_matrix &op1, const Int_matrix &op2)
 Compute product of this matrix (on the left) and another. More...
 
Int_matrix operator* (const Int_matrix &op1, Int_matrix::Value_type op2)
 Compute the product of this matrix and a scalar, yielding a new matrix. More...
 
Int_matrix operator* (Int_matrix::Value_type op1, const Int_matrix &op2)
 Compute product of scalar and matrix, returning a new matrix. More...
 
Int_matrix operator/ (const Int_matrix &op1, Int_matrix::Value_type op2)
 Compute new matrix equal to lefthand matrix with each entry divided by a scalar value. More...
 
Int_matrix operator+ (const Int_matrix &op1, const Int_matrix &op2)
 Compute matrix addition, returning a new matrix. More...
 
Int_matrix operator- (const Int_matrix &op1, const Int_matrix &op2)
 Compute matrix difference, returning a new matrix. More...
 
Int_matrix operator- (const Int_matrix &op1)
 Return the additive inverse of this matrix. More...
 
bool operator== (const Int_matrix &op1, const Int_matrix &op2)
 Test for exact equality between two matrices. More...
 
bool operator!= (const Int_matrix &op1, const Int_matrix::Impl_type &op2)
 Test for any difference between two matrices. More...
 
bool operator!= (const Int_matrix &op1, const Int_matrix &op2)
 Test for any difference between two matrices. More...
 
bool operator== (const Int_matrix::Impl_type &op1, const Int_matrix &op2)
 Test for exact equality between two matrices. More...
 
bool operator!= (const Int_matrix::Impl_type &op1, const Int_matrix &op2)
 Test for any difference between two matrices. More...
 
Int_matrix matrix_transpose (const Int_matrix &op1)
 Test for any difference between two matrices. More...
 
Int_matrix abs (const Int_matrix &mat)
 Compute the elementwise absolute value of a matrix. More...
 
Int_matrix::Value_type max_abs_difference (const Int_matrix &op1, const Int_matrix &op2)
 Find the largest difference between two matrices. More...
 
Int_matrix::Value_type min (const Int_matrix &mat)
 Return the minimum value in this matrix. More...
 
Int_matrix::Value_type max (const Int_matrix &mat)
 Return the maximum value in this matrix. More...
 
Int_vector operator* (const Int_vector &op1, const Int_matrix &op2)
 Return product of this (as a row-vec) times matrix on the right. More...
 
Int_vector operator* (const Int_matrix &op1, const Int_vector &op2)
 Compute product of this matrix (on the left) and a column vector (on the right). More...
 
bool operator== (const Int_vector &op1, const Int_vector::Impl_type &op2)
 Test for exact equality between vectors. More...
 
bool operator< (const Int_vector &op1, const Int_vector &op2)
 Test weak lexicographic ordering between vectors. More...
 
Int_vector cross (const Int_vector &op1, const Int_vector &op2)
 Compute cross product of op1 and op2. More...
 
std::ostream & operator<< (std::ostream &out, const Int_vector &m)
 Display vector contents in an ASCII format. More...
 
Int_vector create_random_int_vector (int length)
 Construct a vector with random contents. More...
 
Int_vector create_vector_from_vector_section (const Int_vector &iv, int begin, int length)
 Construct a vector by deep-copying a section of another vector. More...
 
Int_vector operator* (const Int_vector &op1, Int_vector::Value_type op2)
 Scalar multiply, resulting in a new vector, e.g., v * 6. More...
 
Int_vector operator* (Int_vector::Value_type op1, const Int_vector &op2)
 Scalar multiplication of a vector. More...
 
Int_vector operator/ (const Int_vector &op1, Int_vector::Value_type op2)
 Scalar integer division, yielding a new vector. More...
 
Int_vector operator+ (const Int_vector &op1, const Int_vector &op2)
 Add two vectors, creating a new vector, e.g., v + w. More...
 
Int_vector operator- (const Int_vector &op1, const Int_vector &op2)
 Subtract one vector from another, resulting in a new vector, e.g., v - w. More...
 
Int_vector operator- (const Int_vector &op1)
 Return the negation of a vector, as in (-v), resulting in a new vector. More...
 
bool operator== (const Int_vector::Impl_type &op1, const Int_vector &op2)
 Test for exact equality between vectors. More...
 
bool operator!= (const Int_vector &op1, const Int_vector::Impl_type &op2)
 Test for (any) inequality between vectors. More...
 
bool operator!= (const Int_vector::Impl_type &op1, const Int_vector &op2)
 Test for inequality between vectors. More...
 
bool operator== (const Int_vector &op1, const Int_vector &op2)
 Test for exact equality between vectors. More...
 
bool operator!= (const Int_vector &op1, const Int_vector &op2)
 Test for (any) inequality between vectors. More...
 
bool operator<= (const Int_vector &op1, const Int_vector &op2)
 Test lexicographic ordering between vectors. More...
 
bool operator> (const Int_vector &op1, const Int_vector &op2)
 Test lexicographic ordering between vectors. More...
 
bool operator>= (const Int_vector &op1, const Int_vector &op2)
 Test lexicographic ordering between vectors. More...
 
Int_vector::Value_type max_abs_difference (const Int_vector &op1, const Int_vector &op2)
 Return the maximum of the absolute values of the elementwise difference between two vectors, provided they have the same length. More...
 
long int dot (const Int_vector &op1, const Int_vector &op2)
 Returns dot product of this and op2. More...
 
double norm2 (const Int_vector &op1)
 Compute l2-norm of vector. More...
 
double vector_distance (const Int_vector &op1, const Int_vector &op2)
 Compute the Euclidian distance between two vectors. More...
 
double vector_distance_squared (const Int_vector &op1, const Int_vector &op2)
 Compute the square of the Euclidian distance between two vectors. More...
 
template<class const_iterator >
const_circular_iterator
< const_iterator > 
make_const_circular_iterator (const_iterator begin, const_iterator end)
 
template<class Container >
const_circular_iterator
< typename
Container::const_iterator > 
make_const_circular_iterator (const Container &container)
 
template<class iterator >
circular_iterator< iterator > make_circular_iterator (iterator begin, iterator end)
 
template<class Container >
circular_iterator< typename
Container::iterator > 
make_circular_iterator (Container &container)
 
template<class Archive , class KJB_readable_writable >
void kjb_serialize_default (Archive &ar, KJB_readable_writable &obj, const unsigned int)
 Implements boost serialization for any object that implements the KjbReadableWritable concept. More...
 
template<class Archive , class KJB_readable_writable >
void kjb_serialize (Archive &ar, KJB_readable_writable &obj, const unsigned int version)
 
template<class Serializable >
void load (Serializable &, const std::string &)
 
template<class SerializableOutputIterator >
void load_many (SerializableOutputIterator it, const std::string &fmt_str, const Index_range &indices)
 
template<class SerializableOutputIterator >
void load_many (SerializableOutputIterator it, const std::string &fmt_str, size_t num_files, size_t first_index=0, size_t modulo=0)
 
template<class Value_type , class SerializablePtrOutputIterator >
void load_many_dynamic_dispatch (Value_type *, SerializablePtrOutputIterator it, const std::string &fmt_str, const Index_range &indices)
 
template<class Value_type , class SerializablePtrOutputIterator >
void load_many_dynamic_dispatch (typename boost::shared_ptr< Value_type >, SerializablePtrOutputIterator it, const std::string &fmt_str, const Index_range &indices)
 
template<class SerializablePtrOutputIterator >
void load_many_to_ptr (SerializablePtrOutputIterator it, const std::string &fmt_str, size_t num_files, size_t first_index=0, size_t modulo=1)
 
template<class SerializablePtrOutputIterator , class Index_range_type >
boost::enable_if
< boost::is_convertible
< Index_range_type,
Index_range >, void >::type 
load_many_to_ptr (SerializablePtrOutputIterator it, const std::string &fmt_str, const Index_range_type &indices)
 
template<class Serializable >
void save (const Serializable &, const std::string &)
 
int getline (FILE *fp, std::string *line, char EOL= '\n')
 Like C's fgets but with std::string, or C++'s getline but with FILE*. More...
 
void alert_untested (int line, const char *file)
 
template<class C >
size_t length (const C &cner)
 Counts the total number of elements in a 2D STL-style container. More...
 
std::map< int, Region_vectorget_regions_from_mask (const Int_matrix &mask, int region_length)
 Later... More...
 
void prepare_model_map (Int_matrix &model_map, const Polymesh &p)
 Prepares a model map from a polymesh. More...
 
void prepare_model_edges (std::vector< Model_edge > &edges, const Polymesh &p, const Base_gl_interface &eye)
 Prepares a set of model edges from a polymesh. More...
 
void prepare_model_map (Int_matrix &model_map, const std::vector< const Polymesh * > &ps)
 Prepares a model map from a vector of polymeshes. More...
 
void prepare_model_edges (std::vector< Model_edge > &edges, const std::vector< const Polymesh * > &ps, const Base_gl_interface &eye)
 Prepares a set of model edges from a vector of polymeshes. More...
 
void prepare_model_edges (std::vector< Model_edge > &edges, const std::vector< const Polymesh * > &ps, const Base_gl_interface &eye, const Matrix &M, double width, double height, const std::vector< bool > &flagged)
 
void prepare_model_edges (std::vector< Model_edge > &edges, const std::vector< const Polymesh * > &ps, const Base_gl_interface &eye, const Matrix &M, double width, double height)
 
void prepare_model_edges (std::vector< Model_edge > &edges, const Polymesh &p, const Base_gl_interface &eye, const Matrix &M, double width, double height, bool flagged)
 
void prepare_model_edges (std::vector< Model_edge > &edges, const Polymesh &p, const Base_gl_interface &eye, const Matrix &M, double width, double height)
 
void prepare_solid_model_map (Int_matrix &model_map, const std::vector< const Polymesh * > &ps)
 Prepares a model map from a polymesh. More...
 
void prepare_solid_model_map (Int_matrix &model_map, const Polymesh &p)
 Prepares a model map from a vector of polymeshes. More...
 
void draw_model_edges (kjb::Image &img, const std::vector< Model_edge > &edges)
 
void prepare_rendered_model_edges (std::vector< Model_edge > &edges, const Int_matrix &model_map)
 Prepares a set of rendered model edges from the model_map. More...
 
bool operator== (const Polybezier_curve &op1, const Polybezier_curve &op2)
 
Polybezier_curve subdivide (const Polybezier_curve &c, double u)
 
template<class Assignable_array_type >
double reduce (const Assignable_array_type &array, size_t length)
 
template<class Array_type >
double reduce_in_place (Array_type &array, size_t length)
 
bool work_buffer_is_unique (const Fftw_convolution_2d::Work_buffer &b)
 test whether a Work_buffer object is the last handle to its memory More...
 
void flip_matrix_ud (Matrix &m)
 deprecated synonym for Matrix::ow_vertical_flip More...
 
void flip_matrix_lr (Matrix &m)
 deprecated synonym for Matrix::ow_horizontal_flip More...
 
Matrix derivative_matrix (int degree, int N)
 
kjb::Matrix create_integral_matrix (const std::vector< double > &deltas)
 
kjb::Matrix create_integral_matrix (size_t N)
 
Matrix create_derivative_matrix (int N, int degree=1)
 
Matrix_stl_view get_matrix_stl_view (kjb::Matrix &mat)
 
template<class Iterator >
Matrix_traits< typename
std::iterator_traits< Iterator >
::value_type::value_type >
::Matrix_type 
create_matrix_from_rows (Iterator begin, Iterator end)
 Build a matrix from a container of row vectors. More...
 
template<class Iterator >
Matrix_traits< typename
std::iterator_traits< Iterator >
::value_type::value_type >
::Matrix_type 
create_matrix_from_columns (const Iterator &begin, const Iterator &end)
 Build a matrix from a container of column vectors. More...
 
template<class Container_ >
Matrix_traits< typename
Container_::value_type::value_type >
::Matrix_type 
create_matrix_from_columns (const Container_ &cols)
 Build a matrix from a container of column vectors. More...
 
template<class Container_ >
Matrix_traits< typename
Container_::value_type::value_type >
::Matrix_type 
create_matrix_from_rows (const Container_ &rows)
 Build a matrix from a container of row vectors. More...
 
Matrix create_row_matrix (const Vector &)
 Construct a one-row matrix by deep-copying a vector. More...
 
Matrix create_column_matrix (const Vector &)
 Construct a one-column matrix by deep-copying a vector. More...
 
Matrix create_gauss_random_matrix (int num_rows, int num_cols)
 
Matrix create_diagonal_matrix (const Matrix::Vec_type &diagonal)
 Construct a diagonal matrix from the specified vector. More...
 
Matrix create_diagonal_matrix (const Matrix::Vec_type &diagonal, size_t n)
 Construct a "repeating" diagonal matrix from the specified vector. More...
 
bool operator== (const Matrix &op1, const Matrix::Impl_type &op2)
 Test for exact equality between two matrices. More...
 
Matrix matrix_inverse (const Matrix &op1)
 Invert this matrix. More...
 
Matrix::Value_type max_abs_difference (const Matrix &op1, const Matrix &op2)
 Find the largest difference between two matrices. More...
 
std::ostream & operator<< (std::ostream &out, const Matrix &m)
 Display matrix contents in an ASCII format. More...
 
double det (const Matrix &mat)
 
Matrix::Vec_type sum_matrix_cols (const Matrix &)
 Compute the matrix's sum across columns (a.k.a. row-wise sum) More...
 
Matrix::Vec_type sum_matrix_rows (const Matrix &)
 Compute the matrix's sum down (a.k.a. columnar sum), like MATLAB. More...
 
Int_matrix create_int_matrix_from_matrix_ceil (const Matrix &)
 Construct a matrix with elements equal to the ceiling, ceil() of a given floating-point Matrix. More...
 
Int_matrix create_int_matrix_from_matrix_floor (const Matrix &)
 Construct an Int_matrix with elements equal to the floor() of a given floating-point Matrix. More...
 
Int_matrix floor (const Matrix &m)
 
Matrix logical_or (Matrix a, Matrix b)
 returns a matrix with 1s and 0s. 1 if either has a non zero value in that position, 0 otherwise More...
 
Matrix logical_and (Matrix a, Matrix b)
 returns a matrix with 1s and 0s. 1 if both matricies have a non zero value in that position, 0 otherwise More...
 
Matrix logical_not (Matrix a)
 returns a matrix with 1s and 0s. 1 if the value is 0, and 0 otherwise. More...
 
Matrix tile_matrix (Matrix trixy, unsigned m, unsigned n)
 Construct a tiling of the given matrix. More...
 
Matrix tile_matrix (int tehnum, unsigned m, unsigned n)
 Construct a tiling of the given matrix, in this case, a matrix of the given number with the specified size. More...
 
Matrix create_identity_matrix (int rank)
 Construct an identity matrix of specified rank. More...
 
Matrix create_identity_matrix (int num_rows, int num_cols)
 Construct a rank-deficient identity matrix with the specified number of rows and columns. More...
 
Matrix create_zero_matrix (int rows, int columns)
 Construct a zero matrix of specified size. More...
 
Matrix create_zero_matrix (int size)
 Construct a square zero matrix of specified size. More...
 
Matrix create_random_matrix (int num_rows, int num_cols)
 
Matrix create_diagonal_matrix (int size, Matrix::Value_type a)
 Construct a diagonal matrix of the specified size, where the diagonal elements are set to the given value. More...
 
Matrix operator* (const Matrix &op1, const Matrix &op2)
 Compute product of this matrix (on the left) and another. More...
 
Matrix operator* (const Matrix &op1, Matrix::Value_type op2)
 Compute the product of this matrix and a scalar, yielding a new matrix. More...
 
Matrix operator* (Matrix::Value_type op1, const Matrix &op2)
 Compute product of scalar and matrix, returning a new matrix. More...
 
Matrix operator/ (const Matrix &op1, Matrix::Value_type op2)
 Compute new matrix equal to lefthand matrix with each entry divided by a scalar value. More...
 
Matrix operator+ (const Matrix &op1, const Matrix &op2)
 Compute matrix addition, returning a new matrix. More...
 
Matrix operator+ (const Matrix &op1, double op2)
 Compute matrix addition, returning a new matrix. More...
 
Matrix operator- (const Matrix &op1, const Matrix &op2)
 Compute matrix difference, returning a new matrix. More...
 
Matrix shift_rows_by (const Matrix &op1, const Vector &op2)
 Add the same vector to each row, return a new Matrix. More...
 
Matrix shift_columns_by (const Matrix &op1, const Vector &op2)
 Add the same vector to each column, return a new Matrix. More...
 
Matrix ew_multiply_rows_by (const Matrix &op1, const Vector &op2)
 Elementwise multiply each row of op1 by a op2, return a new Matrix. More...
 
Matrix ew_multiply (const Matrix &op1, const Matrix &op2)
 Elementwise product of two matrices. More...
 
Matrix operator- (const Matrix &op1, double op2)
 Compute matrix difference, returning a new matrix. More...
 
Matrix operator- (const Matrix &op1)
 Return the additive inverse of this matrix. More...
 
bool operator== (const Matrix &op1, const Matrix &op2)
 Test for exact equality between two matrices. More...
 
bool operator!= (const Matrix &op1, const Matrix::Impl_type &op2)
 Test for any difference between two matrices. More...
 
bool operator!= (const Matrix &op1, const Matrix &op2)
 Test for any difference between two matrices. More...
 
bool operator== (const Matrix::Impl_type &op1, const Matrix &op2)
 Test for exact equality between two matrices. More...
 
bool operator!= (const Matrix::Impl_type &op1, const Matrix &op2)
 Test for any difference between two matrices. More...
 
bool operator< (const Matrix &op1, const Matrix &op2)
 Returns true if a is lexicographically less-than b. More...
 
Matrix matrix_transpose (const Matrix &op1)
 Transpose this matrix. More...
 
Matrix abs (const Matrix &mat)
 Compute the elementwise absolute value of a matrix. More...
 
double sum_squared_elements (const Matrix &mat)
 Compute the sum of squared elements. More...
 
Matrix::Value_type min (const Matrix &mat)
 Return the minimum value in this matrix. More...
 
Matrix::Value_type max (const Matrix &mat)
 Return the maximum value in this matrix. More...
 
Matrix outer_product (const Vector &v1, const Vector &v2)
 
void swap (Matrix &m1, Matrix &m2)
 Non-member swap function. More...
 
 FREE_FUNCTION_LIST (2, 3, true)
 
 FREE_FUNCTION_LIST (2, 3, false)
 
 FREE_FUNCTION_LIST_NO_TRANSPOSE (2, 3)
 
 FREE_FUNCTION_LIST (3, 4, true)
 
 FREE_FUNCTION_LIST (3, 4, false)
 
 FREE_FUNCTION_LIST_NO_TRANSPOSE (3, 4)
 
 FREE_FUNCTION_LIST_3DIM (3, 3, 4)
 
 FREE_FUNCTION_LIST_3DIM (3, 4, 4)
 
 FREE_FUNCTION_LIST_3DIM (2, 2, 3)
 
 FREE_FUNCTION_LIST_3DIM (2, 3, 3)
 
double det (const Matrix_d< 1, 1 > &m)
 
double det (const Matrix_d< 2, 2 > &m)
 
double det (const Matrix_d< 3, 3 > &m)
 
template<class Matrix_1 , class Matrix_2 >
Matrix matrix_multiply_dynamic_dispatch_ (const Matrix_1 &m1, const Matrix_2 &m2)
 don't call me directly More...
 
void kjb_serialize (boost::archive::text_iarchive &ar, Matrix &obj, const unsigned int version)
 
void kjb_serialize (boost::archive::text_oarchive &ar, Matrix &obj, const unsigned int version)
 
void kjb_serialize (boost::archive::text_iarchive &ar, Vector &obj, const unsigned int version)
 
void kjb_serialize (boost::archive::text_oarchive &ar, Vector &obj, const unsigned int version)
 
double log_binomial_coefficient (size_t n, size_t k)
 
Vector create_gauss_random_vector (int length)
 Construct a vector with values drawn from a standard Gaussian distribution (mean 0, variance 1);. More...
 
Vector operator* (const Vector &op1, const Matrix &op2)
 Return product of op1 (as a row-vec) times matrix on the right. More...
 
Vector operator* (const Matrix &op1, const Vector &op2)
 Compute product of this matrix (on the left) and a column vector (on the right). More...
 
bool operator== (const Vector &op1, const Vector::Impl_type &op2)
 Test for exact equality between vectors. More...
 
bool operator< (const Vector &op1, const Vector &op2)
 Test weak lexicographic ordering between vectors. More...
 
Vector cross (const Vector &op1, const Vector &op2)
 Compute cross product of op1 and op2. More...
 
std::ostream & operator<< (std::ostream &out, const Vector &m)
 Display vector contents in an ASCII format. More...
 
std::ostream & stream_write_vector (std::ostream &ost, const Vector &m)
 Write vector to an output stream so it can be read with read_vector. More...
 
std::istream & stream_read_vector (std::istream &ist, Vector &m)
 Read vector from an input stream. More...
 
std::vector< Vectorget_transpose (const std::vector< Vector > &m)
 Treat a std::vector of kjb::Vectors as a matrix and get its 'transpose'. More...
 
Int_vector floor (const Vector &realv)
 Build an Int_vector that is the element-wise floor of a real Vector. More...
 
kjb::Vector create_uniformly_spaced_vector (double a, double b, unsigned n)
 
Vector create_random_vector (int length)
 Construct a vector with values drawn from a uniform distribution over [0,1]. More...
 
Vector create_zero_vector (int length)
 Construct a vector containing zeroes. More...
 
Vector create_vector_from_vector_section (const Vector &iv, int begin, int length)
 Construct a vector by deep-copying a section of another vector. More...
 
Vector operator* (const Vector &op1, Vector::Value_type op2)
 Scalar multiply, resulting in a new vector, e.g., v * 6. More...
 
Vector operator* (Vector::Value_type op1, const Vector &op2)
 Scalar multiplication of a vector. More...
 
Vector operator/ (const Vector &op1, Vector::Value_type op2)
 Scalar division, yielding a new vector. More...
 
Vector operator+ (const Vector &op1, const Vector &op2)
 Add two vectors, creating a new vector, e.g., v + w. More...
 
Vector operator- (const Vector &op1, const Vector &op2)
 Subtract one vector from another, resulting in a new vector, e.g., v - w. More...
 
Vector operator- (const Vector &op1)
 Return the negation of a vector, as in (-v), resulting in a new vector. More...
 
bool operator== (const Vector::Impl_type &op1, const Vector &op2)
 Test for exact equality between vectors. More...
 
bool operator!= (const Vector &op1, const Vector::Impl_type &op2)
 Test for (any) inequality between vectors. More...
 
bool operator!= (const Vector::Impl_type &op1, const Vector &op2)
 Test for inequality between vectors. More...
 
bool operator== (const Vector &op1, const Vector &op2)
 Test for exact equality between vectors. More...
 
bool operator!= (const Vector &op1, const Vector &op2)
 Test for (any) inequality between vectors. More...
 
bool operator<= (const Vector &op1, const Vector &op2)
 Test lexicographic ordering between vectors. More...
 
bool operator> (const Vector &op1, const Vector &op2)
 Test lexicographic ordering between vectors. More...
 
bool operator>= (const Vector &op1, const Vector &op2)
 Test lexicographic ordering between vectors. More...
 
Vector::Value_type max_abs_difference (const Vector &op1, const Vector &op2)
 Return the maximum of the absolute values of the elementwise difference between two vectors, provided they have the same length. More...
 
Vector::Value_type dot (const Vector &op1, const Vector &op2)
 Returns dot product of op1 and op2. More...
 
double norm1 (const Vector &op)
 Compute L1-norm of vector. More...
 
double norm2 (const Vector &op1)
 Compute L2-norm of vector. More...
 
double vector_distance (const Vector &op1, const Vector &op2)
 Compute the Euclidian distance between two vectors. More...
 
double vector_distance_squared (const Vector &op1, const Vector &op2)
 Compute the square of the Euclidian distance between two vectors. More...
 
Vector::Value_type max (const Vector &vec)
 Return the maximum element in the vector. More...
 
Vector::Value_type min (const Vector &vec)
 Return the minimum element in the vector. More...
 
Vector cat_vectors (const Vector &first, const Vector &second)
 Concatenate two vectors. More...
 
template<class InputIterator >
Vector cat_vectors (InputIterator first, InputIterator last)
 Concatenate the vectors in the given sequence of vectors. More...
 
template<class OutputIterator >
OutputIterator separate_vector (const Vector &vec, int sz, OutputIterator result)
 Separate the given vector into vectors of the give size; the vectors will be output into the output iterator. More...
 
void swap (Vector &v1, Vector &v2)
 Non-member swap. More...
 
Vector multiply_matrix_and_vector_d_dispatch_ (const Matrix &m, const double *v, size_t size)
 dispatch for operator*(Matrix, Vector_d). This deals with a circular dependency between matrix.h and vector_d.h by moving template code into a cpp file. DO NOT CALL DIRECTLY! More...
 
Vector2 make_vector2 (const Vector &v)
 
Vector3 make_vector3 (const Vector &v)
 
Vector4 make_vector4 (const Vector &v)
 
template<std::size_t D>
Vector operator* (const Matrix &m, const Vector_d< D > v)
 multiply by static vector More...
 
template<std::size_t D>
Vector_d< Doperator- (const Vector_d< D > &first, const Vector_d< D > &second)
 
template<std::size_t D>
Vector_d< Doperator- (const Vector_d< D > &first, double second)
 
template<std::size_t D>
Vector_d< Doperator- (double first, const Vector_d< D > &second)
 
template<std::size_t D>
Vector_d< Doperator- (const Vector_d< D > &first)
 
template<std::size_t D>
Vector_d< Doperator+ (const Vector_d< D > &first, const Vector_d< D > &second)
 
template<std::size_t D>
Vector_d< Doperator+ (const Vector_d< D > &first, double second)
 
template<std::size_t D>
Vector_d< Doperator+ (double first, const Vector_d< D > &second)
 
template<std::size_t D>
Vector_d< Doperator* (const Vector_d< D > &v, double s)
 
template<std::size_t D>
Vector_d< Doperator* (double s, const Vector_d< D > &v)
 
template<std::size_t D>
Vector_d< Doperator/ (const Vector_d< D > &v, double s)
 
template<std::size_t N>
void swap (Vector_d< N > &first, Vector_d< N > &second)
 
template<std::size_t N>
bool operator== (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<std::size_t N>
bool operator!= (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<std::size_t N>
bool operator< (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<std::size_t N>
bool operator> (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<std::size_t N>
bool operator<= (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<std::size_t N>
bool operator>= (const Vector_d< N > &first, const Vector_d< N > &second)
 
template<size_t D>
double norm1 (const kjb::Vector_d< D > &v)
 
template<size_t D>
double norm2 (const kjb::Vector_d< D > &v)
 
template<size_t D>
Vector_d< Dcreate_random_vector ()
 
template<size_t D>
Vector_d< Dcreate_gauss_random_vector ()
 
Vector2 create_random_vector2 ()
 
Vector3 create_random_vector3 ()
 
Vector4 create_random_vector4 ()
 
template<size_t D>
Vector_d< Dcreate_unit_vector (size_t d)
 
template<std::size_t D>
std::ostream & operator<< (std::ostream &out, const Vector_d< D > &v)
 
template<std::size_t D>
std::istream & operator>> (std::istream &ist, Vector_d< D > &v)
 
template<std::size_t D>
double dot (const Vector_d< D > &op1, const Vector_d< D > &op2)
 
template<std::size_t D>
double vector_distance (const Vector_d< D > &op1, const Vector_d< D > &op2)
 Compute the Euclidian distance between two vectors. More...
 
template<std::size_t D>
double vector_distance_squared (const Vector_d< D > &op1, const Vector_d< D > &op2)
 Compute the Euclidian distance between two vectors. More...
 
Vector3 cross (const Vector3 &op1, const Vector3 &op2)
 
Matrix cholesky_decomposition (const Matrix &M)
 
double log_det (const Matrix &M)
 
void diagonalize (const Matrix &M, Matrix &eig_vectors, Vector &eig_values, bool symmetric=false)
 KJB c-style syntax for eigenvalue decomposition. More...
 
Vector forward_substitution (const Matrix &L, const Vector &b)
 Perform forward substitution to solve the SLE Lx = b, where L is an lower triangular matrix and b is a vector. More...
 
Vector back_substitution (const Matrix &U, const Vector &b)
 Perform forward substitution to solve the SLE Ux = b, where. More...
 
template<class Target , class Given , class Func >
double conditional_pdf (const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Target >::type &x, const typename Distribution_traits< Given >::type &y)
 Gets the conditional pdf p(x | y) of the given ConditionalDistribution. More...
 
template<class Target , class Given , class Func >
double conditional_log_pdf (const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Target >::type &x, const typename Distribution_traits< Given >::type &y)
 Gets the conditional log-pdf log p(x | y) of the given ConditionalDistribution. More...
 
template<class Target , class Given , class Func >
Distribution_traits< Target >::type conditional_sample (const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Given >::type &y)
 Produces a sample from the given conditioanl distro, given a value for the given variable. More...
 
template<class InIter >
Normal_distribution mle_normal (InIter first, InIter last)
 
template<class InIter >
Beta_distribution mle_beta (InIter first, InIter last)
 
template<class InIter >
Gamma_distribution mle_gamma (InIter first, InIter last)
 
template<size_t D, class InIter >
Von_mises_fisher_distribution< Dmle_vmf (InIter first, InIter last)
 
std::pair< double, int > make_double_int_pair_ (double d, int i)
 
double chi_square (const Histogram_2d &hist_1, const Histogram_2d &hist_2)
 
double chi_square (const Matrix &h1, const Matrix &h2)
 
double pdf (const MV_gaussian_distribution &P, const Vector &x)
 Computes the joint PDF of a multivariate Gaussian at x. More...
 
double log_pdf (const MV_gaussian_distribution &P, const Vector &x)
 Computes the log PDF a multivariate normal distribution at x. More...
 
double pdf (const Chinese_restaurant_process &cpr, const Chinese_restaurant_process::Type &B)
 PDF of the CPR. More...
 
double log_pdf (const Chinese_restaurant_process &cpr, const Chinese_restaurant_process::Type &B)
 log-PDF of the CPR. More...
 
double pdf (const Geometric_distribution &dist, double x)
 Computes the PMF of a geometric distribution at x. More...
 
double pdf (const Log_normal_distribution &dist, double x)
 Computes the PDF of a log-normal distribution at x. More...
 
template<class T >
double pdf (const Categorical_distribution< T > &dist, const T &x)
 Computes the PMF of a categorical distribution at x. More...
 
template<class Distribution >
double pdf (const Mixture_distribution< Distribution > &dist, const typename Distribution_traits< Mixture_distribution< Distribution > >::type &x)
 Computes the PDF/PMF of a mixture distribution at x. More...
 
double pdf (const Gaussian_distribution &P, double x)
 Compute pdf of a Gaussian distribution. More...
 
double log_pdf (const Beta_binomial_distribution &dist, double k)
 Computes the log PDF of a Beta-binomial distribution at k. More...
 
double pdf (const Beta_binomial_distribution &dist, double k)
 Evaluate the probability density function of a Beta-binomial distribution. More...
 
template<size_t D>
double log_pdf (const Von_mises_fisher_distribution< D > &dist, const kjb::Vector_d< D > &v)
 
template<size_t D>
double pdf (const Von_mises_fisher_distribution< D > &dist, const kjb::Vector_d< D > &v)
 Evaluate the probability density function of a Von-mises Fisher distribtuion (x's magnitude is ignored/assumed 1.0) More...
 
template<size_t D>
double log_pdf (const Uniform_sphere_distribution< D > &, const kjb::Vector_d< D > &)
 Computes the log PDF of a uniform distribution over the surface of the unit sphere in D-dimensional Euclidean space. The density is given in D-1 dimensional euclidean units. More...
 
template<size_t D>
double pdf (const Uniform_sphere_distribution< D > &P, const kjb::Vector_d< D > &x)
 Evaluate the probability density function of a uniform sphere distribution (x's magnitude is ignored / assumed 1.0) More...
 
double cdf (const Log_normal_distribution &dist, double x)
 Computes the cdf of a log-normal distribution at x. More...
 
template<class T >
double cdf (const Categorical_distribution< T > &dist, const T &x)
 Computes the CDF of a categorical distribution at x. More...
 
template<class Distribution >
double cdf (const Mixture_distribution< Distribution > &dist, const typename Distribution_traits< Mixture_distribution< Distribution > >::type &x)
 Computes the CDF of a mixture distribution at x. More...
 
template<class Distribution >
double log_pdf (const Distribution &P, const typename Distribution_traits< Distribution >::type &x)
 Computes the log PDF of a distribution at x. More...
 
double log_pdf (const Gaussian_distribution &P, double x)
 Computes the log PDF a normal distribution at x. More...
 
double log_pdf (const Laplace_distribution &P, double x)
 Computes the log PDF a Laplace distribution at x. More...
 
double log_pdf (const Binomial_distribution &P, double k)
 Computes the log PDF a normal distribution at x. More...
 
Base_generator_type basic_rnd_gen (DEFAULT_SEED)
 
Vector sample (const MV_gaussian_distribution &dist)
 Sample from a multivariate normal distribution. More...
 
Chinese_restaurant_process::Type sample (const Chinese_restaurant_process &crp)
 Sample from a CRP. More...
 
size_t sample_occupied_tables (const Chinese_restaurant_process &crp)
 Sample the number of occupied tables from a CRP (don't store the actual partition). More...
 
void seed_sampling_rand (unsigned int x0)
 Seed random number generator. More...
 
double sample (const Uniform_distribution &dist)
 Sample from a uniform distribution. More...
 
template<class Distro >
double sample (const Distro &dist)
 Template sample function. More...
 
double sample (const Bernoulli_distribution &dist)
 Sample from a Bernoulli distribution. More...
 
double sample (const Binomial_distribution &dist)
 Sample from a Binomial distribution. More...
 
double sample (const Exponential_distribution &dist)
 Sample from a exponential distribution. More...
 
double sample (const Gaussian_distribution &dist)
 Sample from a Gaussian distribution. More...
 
double sample (const Poisson_distribution &dist)
 Sample from a Poisson distribution. More...
 
double sample (const Geometric_distribution &dist)
 
template<class T >
sample (const Categorical_distribution< T > &dist)
 Sample from a categorical distribution. More...
 
template<class Iterator , class distance_type >
Iterator element_uar (Iterator first, distance_type size)
 Pick an element uniformly at random (UAR) from a sequence, represented by a beginning iterator and a size. More...
 
double sample (const Log_normal_distribution &dist)
 
template<class Distribution >
Distribution_traits
< Mixture_distribution
< Distribution > >::type 
sample (const Mixture_distribution< Distribution > &dist)
 Sample from a mixture distribution. More...
 
template<size_t D>
kjb::Vector_d< Dsample (const Uniform_sphere_distribution< D > &)
 Sample uniformly from the surface of a unit-sphere in D-dimensional euclidean space. More...
 
template<size_t D, class Vector_d_iterator >
void sample (const Von_mises_fisher_distribution< D > &dist, size_t n, Vector_d_iterator it)
 
template<size_t D>
Vector_d< Dsample (const Von_mises_fisher_distribution< D > &dist)
 
template<class Iterator , class Value_type >
Value_type mean (Iterator begin, Iterator end, const Value_type &)
 
template<class Iterator >
std::iterator_traits< Iterator >
::value_type 
mean (Iterator begin, Iterator end=Iterator())
 
template<class InputIterator , class Distribution , class Statistic >
bool goodness_of_fit_test (InputIterator first, InputIterator last, const Distribution &dist, const Statistic &statistic, double alpha, int num_params, int num_bins)
 
template<class InputIterator , class Distribution , class Statistic >
bool goodness_of_fit_test (InputIterator first, InputIterator last, const Distribution &dist, const Statistic &statistic, double alpha, int dof_redux)
 
double chi2stat_helper (int O, int E)
 Compute the chi-square test value for a single element. More...
 
template<class InputIterator >
double chi_square_statistic (InputIterator first1, InputIterator last1, InputIterator first2)
 
double gstat_helper (int O, int E)
 Compute the G-test value for a single element. More...
 
template<class InputIterator >
double g_statistic (InputIterator first1, InputIterator last1, InputIterator first2)
 
template<class InputIterator , class Distribution >
bool chi_square_test (InputIterator first, InputIterator last, const Distribution &dist, double alpha, int num_params, int num_bins)
 
template<class InputIterator , class Distribution >
bool chi_square_test (InputIterator first, InputIterator last, const Distribution &dist, double alpha, int dof_redux)
 
template<class InputIterator , class Distribution >
bool g_test (InputIterator first, InputIterator last, const Distribution &dist, double alpha, int num_params, int num_bins)
 
template<class InputIterator , class Distribution >
bool g_test (InputIterator first, InputIterator last, const Distribution &dist, double alpha, int dof_redux)
 
Vector log_normalize (const Vector &vec)
 normalize a probability vector in log space More...
 
Vector exponentiate (const Vector &vec)
 elementwise exponentiate a vector without normalizing More...
 
Vector log_normalize_and_exponentiate (const Vector &vec)
 normalize and exponentiate a vector of unnormalized log probabilities More...
 
Matrix log_normalize_and_exponentiate (const Matrix &mat)
 row-wise normalize and exponentiate a matrix of log probabilities More...
 
Matrix log_normalize_rows (const Matrix &mat)
 normalize the rows of a stochastic matrix in log space More...
 
Vector log_marginalize_over_rows (const Matrix &mat)
 marginalize across the rows of a matrix of log probabilities More...
 
Vector log_marginalize_over_cols (const Matrix &mat)
 marginalize down the columns of a matrix of log probabilities More...
 
double log_sum (double n1, double n2)
 
double log_sum (double n1, double n2, double n3)
 
template<class Iterator >
double log_sum (Iterator first, Iterator last)
 
double log_diff (double n1, double n2)
 
template<size_t D>
bool operator== (const Weight_array< D > &left, const Weight_array< D > &right)
 
template<size_t D>
bool operator!= (const Weight_array< D > &left, const Weight_array< D > &right)
 
template<size_t D>
Weight_array< Doperator+ (const Weight_array< D > &left, const Weight_array< D > &right)
 Free function declarations. More...
 
template<size_t D>
Weight_array< Doperator* (const Weight_array< D > &left, const Weight_array< D > &right)
 
template<size_t D>
Weight_array< Doperator/ (const Weight_array< D > &left, const Weight_array< D > &right)
 
template<size_t D>
Weight_array< Doperator+ (const Weight_array< D > &w, const typename Weight_array< D >::Val_type &offset)
 
template<size_t D>
Weight_array< Doperator* (const Weight_array< D > &w, const typename Weight_array< D >::Val_type &scale)
 
template<size_t D>
Weight_array< Doperator/ (const Weight_array< D > &w, const typename Weight_array< D >::Val_type &right)
 
template<size_t D, size_t K>
Weight_array< Dconvex_combination (const Weight_array< K > &weights, const boost::array< Weight_array< D >, K > &components)
 
template<size_t D>
std::ostream & operator<< (std::ostream &os, const Weight_array< D > &wa)
 
template<typename T , size_t D>
std::ostream & operator<< (std::ostream &os, const boost::array< T, D > &arr)
 
int stochastic_dynamics (unsigned int iterations, const kjb::Vector &delta_t, double alpha, unsigned int kick, kjb::Vector &parameters, int(*compute_energy_gradient)(const Vector &parameters, Vector &out_gradient), int(*accept_sample)(const Vector &parameters), int(*log_sample)(const Vector &parameters, const Vector &momenta))
 Double precision leapfrog stochastic dynamics. More...
 
int draw_cylinder (GLUquadricObj *myQuadric, const Vector &p1, const Vector &p2, double r)
 Uses opengl to draw a cylinder with the given points as the centers of the top and bottom of the cylinder and with the given radius. More...
 
int draw_cylinder (Perspective_camera &c, GLUquadricObj *myQuadric, const Vector &p1, const Vector &p2, double r)
 
int draw_cylinder (GLUquadricObj *myQuadric, const Cylinder cyl)
 
int draw_cylinder (Perspective_camera &c, GLUquadricObj *myQuadric, const std::vector< Cylinder > cylinders)
 
int draw_cylinder_section (GLUquadricObj *myQuadric, const Vector &p1, const Vector &p2, double radius, double angle, const Vector &angle_startpt, const Vector &angle_endpt, GLuint &MY_CLIP_PLANE, GLuint &MY_CLIP_PLANE1)
 Uses opengl to draw a cylinder section. More...
 
int draw_cylinder_section (Perspective_camera &c, GLUquadricObj *myQuadric, const std::vector< Cylinder_section > cylinders)
 
void compute_cylinder_rotation_angles (const Vector &p1, const Vector &p2, Vector &top, Vector &bottom, double &magnitude, double &angle_y, double &angle_x)
 
void draw_translated_and_rotated_cylinder (GLUquadricObj *myQuadric, const Vector &bottom, const double angle_y, const double angle_x, const double radius, const double magnitude)
 
void build_cylinder (std::vector< Vector > &vlist, std::vector< Vector > &nlist, int facets, int ribs, float radius, float length)
 Creates a list of vertices for a cylinder with the given height and radius on the z-axis with the bottom face centered at the origin. Also creates a corresponding list containing the normal vector for each vertex. More...
 
void build_frustum (std::vector< Vector > &vlist, std::vector< Vector > &nlist, int facets, int ribs, float radius_bottom, float radius_top, float length)
 Creates a list of vertices for a frustum with the given height and radius of bottom and top faces on the z-axis with the bottom face centered at the origin. Also creates a corresponding list containing the normal vector for each vertex. More...
 
void untransform_points (std::vector< Vector > &vlist, const Vector &bottom, const double angle_y, const double angle_x, std::vector< Vector > &vlist_tr)
 
void draw_cylinder_edges (std::vector< Vector > &vlist, int facets, int ribs, const Vector &bottom, const double angle_y, const double angle_x, const Perspective_camera *camera)
 
void draw_cylinder_facets (std::vector< Vector > &vlist, int facets, int ribs)
 
void render_cylinder_silhouette (const Polymesh *polymesh, const Perspective_camera *camera)
 
void render_occlude_cylinder_silhouette (const Polymesh *polymesh, const Perspective_camera *camera)
 
void render_frustum_silhouette (const Polymesh *polymesh, Perspective_camera *camera)
 
void render_occlude_frustum_silhouette (const Polymesh *polymesh, Perspective_camera *camera)
 
double propose_parapiped_and_camera_from_orthogonal_corner_good (kjb::Parametric_parapiped &pp, kjb::Perspective_camera &camera, const kjb::Manhattan_corner &corner, double focal_length, unsigned int num_rows, unsigned int num_cols, double corner_3D_z_position, double p_width_ratio, double p_height_ratio, double p_length_ratio)
 
bool propose_parapiped_inside_parapiped_from_orthogonal_corner (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_room=true)
 
bool propose_frame_inside_parapiped_from_orthogonal_corner (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, unsigned int &face_number, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &idesired_dimensions, unsigned int num_rows, unsigned int num_cols)
 
bool propose_frame_inside_parapiped_from_orthogonal_corner_good (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, unsigned int &face_number, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &idesired_dimensions, unsigned int num_rows, unsigned int num_cols, bool wall_x, bool expand_to_the_ground)
 
bool propose_parapiped_at_different_depth_from_orthogonal_corner (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_room)
 
bool propose_parapiped_onside_parapiped_from_orthogonal_corner (kjb::Vector &centre, kjb::Vector &dimensions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_sp_obj, kjb::Vector &sp_obj_centre, kjb::Vector &sp_obj_dimensions)
 
bool propose_supported_parapiped_inside_parapiped_from_orthogonal_corner (kjb::Vector &centre, kjb::Vector &dimensions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_sp_obj, kjb::Vector &sp_obj_centre, kjb::Vector &sp_obj_dimensions)
 
bool propose_parapiped_inside_parapiped_from_orthogonal_corner_against_wall (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_room, bool expand_right, bool expand_z_up, bool expand_towards_camera)
 
bool propose_supported_parapiped_inside_parapiped_from_three_corners (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner1, const Manhattan_corner &corner2, const Manhattan_corner &corner3, double desired_height, unsigned int num_rows, unsigned int num_cols, double base_height)
 
bool propose_parapiped_inside_parapiped_from_three_corners_on_the_floor (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner1, const Manhattan_corner &corner2, const Manhattan_corner &corner3, double desired_height, unsigned int num_rows, unsigned int num_cols)
 
bool propose_parapiped_inside_parapiped_from_two_corners_on_the_floor (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner1, const Manhattan_corner &corner2, double desired_height, double desired_other_dimension_ratio, bool direction, bool &is_diagonal, bool &is_dx, unsigned int num_rows, unsigned int num_cols)
 
bool propose_parapiped_onside_parapiped_from_one_corner_in_the_center (kjb::Vector &centre, kjb::Vector &dimensions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, const kjb::Vector &imin_desired_dimensions, unsigned int num_rows, unsigned int num_cols, double distance_from_camera, bool expand_sp_obj, kjb::Vector &sp_obj_centre, kjb::Vector &sp_obj_dimensions)
 
bool propose_parapiped_inside_parapiped_from_one_corner_in_the_centre_on_the_floor (kjb::Vector &centre, kjb::Vector &dimensions, kjb::Vector &expansion_deltas, std::vector< bool > &expansion_directions, Parametric_parapiped &new_pp, const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, double desired_height, double desired_width, double desired_length, bool &is_dx, unsigned int num_rows, unsigned int num_cols)
 
void expand_towards_camera (const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &corner, unsigned int num_rows, unsigned int num_cols, bool &expand_tw_camera, bool &expand_right, bool &expand_z_up)
 
double propose_parapiped_and_camera_from_vanishing_points (kjb::Parametric_parapiped &pp, kjb::Perspective_camera &camera, const std::vector< Vanishing_point > &vpts, double focal_length, unsigned int num_rows, unsigned int num_cols)
 
bool find_height_from_two_corners (const Parametric_parapiped &pp, const Perspective_camera &camera, const Manhattan_corner &floor_corner, const Manhattan_corner &top_corner, double &desired_height, unsigned int num_rows, unsigned int num_cols)
 
bool shift_parapiped_to_match_corner (kjb::Parametric_parapiped &pp, kjb::Perspective_camera &camera, unsigned int num_rows, unsigned int num_cols, const kjb::Vector &corner)
 
bool propose_frame_inside_parapiped_from_three_corners_on_the_wall (kjb::Vector &centre, kjb::Vector &dimensions, const Parametric_parapiped &pp, const Perspective_camera &camera, unsigned int &face_number, const Manhattan_corner &corner1, const Manhattan_corner &corner2, const Manhattan_corner &corner3, unsigned int num_rows, unsigned int num_cols)
 
bool backproject_point_to_plane (kjb::Vector &intersection, kjb::Vector point2D, kjb::Vector plane, const Parametric_parapiped &pp, const Perspective_camera &camera, int num_rows, int num_cols)
 
void update_focal_with_position (Perspective_camera &cam, double ifocal, Parametric_parapiped &pp)
 
Vector set_camera_to_view_entire_model (Perspective_camera &c, Polymesh &p, int imageWidth, int imageHeight)
 
int get_ned_fdeq (const std::string &fn, std::deque< float > *odq, bool flip)
 read the floating-point values of a NED13 file into a deque. More...
 
int get_ned_fdeq (const std::string &fn, std::deque< float > *odq, enum NED13_FLOAT_AUTODETECT byteorder)
 read the floating-point values of a NED13 file into a deque. More...
 
int ned_fdeq_to_matrix (const std::deque< float > &ibuf, Matrix *omat)
 convert a deque of floats into a square kjb Matrix More...
 
int get_ned_matrix (const std::string &fn, Matrix *omat, bool flip)
 read the floating-point values of a NED13 file into a square matrix. More...
 
int get_ned_matrix (const std::string &fn, Matrix *omat, enum NED13_FLOAT_AUTODETECT byteorder)
 read the floating-point values of a NED13 file into a square matrix. More...
 
int autodetect_ned_byteorder (const std::string &fn, enum NED13_FLOAT_AUTODETECT *result)
 attempt to determine the byteorder of the input file. More...
 
TopoPt force_zone_to_this (const TopoPt &p, char use_this_zone)
 
int ned13_grid (const TopoFusion::pt &center, Matrix *elev_o, Matrix *elev_de_o, Matrix *elev_dn_o, int eastwest_size_meters=2000, int northsouth_size_meters=2000, int resolution_meters=1, Ned13_caching_reader *cache=0, const std::vector< std::string > &path=std::vector< std::string >())
 generate a grid describing an elevation model near some location More...
 
double delta_e_meters (const Ned13_one_degree_grid::IntegralLL &)
 distance, in meters, of the next grid point to the east More...
 
double delta_n_meters (const Ned13_one_degree_grid::IntegralLL &)
 distance, in meters, of the next grid point to the north More...
 
std::pair< double, double > delta_n_e_meters (const Ned13_one_degree_grid::IntegralLL &)
 distances, in meters, of next grid pt north (first), east (second) More...
 
TopoFusion::pt ned13_ill_to_utm (const Ned13_one_degree_grid::IntegralLL &)
 convert to UTM coordinates (no elevation) More...
 
GILL utm_to_se_ned13_ill (const TopoFusion::pt &p)
 convert from UTM coord to grid location, truncating to the southeast More...
 
GILL round_nw_to_whole_degrees (const GILL &ill)
 map an input location to the nearest location to northwest of whole degrees More...
 
TopoFusion::pt dem_to_doq_displacement (const TopoFusion::pt &dem_p)
 return correction factor between DEM and DOQ coordinate systems. More...
 
bool operator== (const Ned13_one_degree_grid::IntegralLL &p, const Ned13_one_degree_grid::IntegralLL &q)
 test two coordinate locations for equality More...
 
bool operator< (const kjb::Ned13_one_degree_grid::IntegralLL &p, const kjb::Ned13_one_degree_grid::IntegralLL &q)
 impose an order on coordinate locations (geographically silly). More...
 
Ned13_one_degree_grid::IntegralLL round_nw_to_whole_degrees (const Ned13_one_degree_grid::IntegralLL &)
 
Matrix ned13_grid (const TopoFusion::pt &center, int eastwest_size_meters=2000, int northsouth_size_meters=2000, int resolution_meters=1, Ned13_caching_reader *cache=0, const std::vector< std::string > &path=std::vector< std::string >())
 generate a grid of elevation values between points at a location More...
 
void set_spy_filename (const std::string &)
 
TopoFusion::pt force_zone_to_this (const TopoFusion::pt &, char use_this_zone)
 
Image ned_visualize_grid (const Matrix &elev_o, const Matrix &elev_de_o, const Matrix &elev_dn_o, int decimation=1, int bar_length=0)
 show NED grid output in visual form More...
 
void compute_median_background (const std::vector< std::string > &frames_fps, Matrix &r_mat, Matrix &g_mat, Matrix &s_mat, size_t sub_sampling_sz=1, size_t rate=1)
 Compute the background value by a median filter. More...
 

Variables

const Image::Pixel_type apix = {255.0, 0.0, 0.0}
 
const Image::Pixel_type fpix = {0.0, 0.0, 255.0}
 
gsl_qrng_typegsl_qrng_niederreiter_2
 
gsl_qrng_typegsl_qrng_sobol
 
gsl_qrng_typegsl_qrng_halton
 
gsl_qrng_typegsl_qrng_reversehalton
 
const Gaussian_distribution STD_NORMAL
 
const unsigned int DEFAULT_SEED = static_cast<unsigned int>(std::time(0)+getpid())
 Random seed used to initialize the random number generator. More...
 
Base_generator_type basic_rnd_gen
 
const float NED_MISSING = -9999.0
 sentinel for missing elevation data More...
 
const float NED_MIN = -100
 Death Valley is -86 meters elevation. More...
 
const float NED_MAX = 7000
 Mt. McKinley is 6194 meters elevation. More...
 
const int NED_ELLIPSOID = TopoFusion::ELLIPSOID_GRS_1980
 
typedef Matrix_d< 4, 4, false > Matrix4
 
typedef Matrix_d< 2, 2 > Matrix2
 
typedef Matrix_d< 3, 3 > Matrix3
 
Matrix_d< 2, 2 > matrix_inverse (const Matrix_d< 2, 2 > &m)
 
Matrix_d< 3, 3 > matrix_inverse (const Matrix_d< 3, 3 > &m)
 
void symmetric_eigs (const kjb::Matrix3 &A, double &eig1, double &eig2, double &eig3)
 get eigenvalues of symmetric matrix A in ascending order More...
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS,
TRANSPOSED > 
operator* (double scalar, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &mat)
 
template<class Matrix_type_1 , class Matrix_type_2 >
Matrix_d
< Matrix_type_1::num_rows,
Matrix_type_2::num_cols > 
matrix_multiply_dispatch_ (const Matrix_type_1 &m1, const Matrix_type_2 &m2)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix operator* (const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op1, const Matrix &op2)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix operator* (const kjb::Matrix &op1, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op2)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
bool operator== (const Matrix &op2, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op1)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
bool operator!= (const Matrix &op2, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op1)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS,
TRANSPOSED > 
operator- (const Matrix op1, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op2)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS,
TRANSPOSED > 
operator+ (const Matrix &second, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &op2)
 
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
std::ostream & operator<< (std::ostream &ost, const Matrix_d< NROWS, NCOLS, TRANSPOSED > &mat)
 
template<std::size_t D>
Matrix_d< D, Dcreate_identity_matrix ()
 
template<std::size_t D>
Matrix_d< D, Douter_product (const Vector_d< D > &v1, const Vector_d< D > &v2)
 
template<std::size_t NROWS, std::size_t NCOLS>
Matrix_d< NROWS, NCOLS > create_random_matrix ()
 
template<size_t D>
double trace (const Matrix_d< D, D > &m)
 
template<std::size_t R, std::size_t C, bool T>
double accumulate (const Matrix_d< R, C, T > &mat, double init)
 
template<std::size_t R, std::size_t C, bool T, class Binary_function >
double accumulate (const Matrix_d< R, C, T > &mat, double init, Binary_function binary_op)
 
template<std::size_t R, std::size_t C>
double max_abs_difference (const Matrix_d< R, C, false > &op1, const Matrix_d< R, C, false > &op2)
 
template<std::size_t R, std::size_t C, bool T>
double max (const Matrix_d< R, C, T > &mat)
 
template<std::size_t R, std::size_t C, bool T>
double min (const Matrix_d< R, C, T > &mat)
 

Detailed Description

Classes and functions for dealing with trajectory files.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

http://creativecommons.org/licenses/by-nc-sa/3.0/us/

You are free:

to Share - to copy, distribute, display, and perform the work to Remix - to make derivative works

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Noncommercial. You may not use this work for commercial purposes.

Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

Any of the above conditions can be waived if you get permission from the copyright holder.

Apart from the remix rights granted under this license, nothing in this license impairs or restricts the author's moral rights.

This file includes explicit template instantiation for Vector_D<N> for N up to 10. This allows m_vector_d.h to remain lightweight by containing no template implementations.

Note: If you need a larger than 10-dimensional Vector_d, you must also #include <m_cpp/m_vector_d.impl.h>

This header contains no implementations; those are in m_vector_d.impl.h.

If you need a vector_d of dimension less than 11, you can skip including m_vector_d.impl.h and benefit from fast compile times. This is because m_vector_d.cpp explicitly instantiates the Vector_d<D> template for D up to 10.

For dimensions greater than 10, both this file and m_vector_d.impl.h must be included by your code.

Typedef Documentation

typedef boost::mt19937 kjb::Base_generator_type
typedef boost::math::bernoulli kjb::Bernoulli_distribution
typedef boost::math::beta_distribution kjb::Beta_distribution
typedef boost::math::binomial kjb::Binomial_distribution
Deprecated:
Use Cant_happen instead.
typedef boost::shared_ptr<Chamfer_transform> kjb::Chamfer_transform_ptr
typedef boost::math::chi_squared kjb::Chi_square_distribution
typedef boost::shared_ptr<Edge_set> kjb::Edge_set_ptr
typedef boost::math::exponential kjb::Exponential_distribution
typedef std::pair<float, float> kjb::Feature
typedef std::pair<Vector, Vector> kjb::Feature_pair
typedef void* kjb::FFTW_complex_vector
typedef void* kjb::FFTW_real_vector
typedef boost::math::gamma_distribution kjb::Gamma_distribution
typedef boost::math::normal kjb::Gaussian_distribution
typedef void kjb::gsl_qrng
typedef void kjb::gsl_qrng_type

An all-around good, fast, simulation-quality random number generator.

If you don't know which random number generator to pick, I recommend this one, the "Mersenne Twister." It is what standard Python uses, it is fast, and has a period of ~ 10^6000. It is competitive with the faster _TAU and _GFSR4 algorithms.

If we discover flaws in the Mersenne Twister or if a faster algorithm emerges in the future, then this "default" typedef will be changed to a better selection. Application code that uses this default type definition should be written to be robust against such changes.

typedef boost::math::inverse_gamma_distribution kjb::Inverse_gamma_distribution
typedef boost::math::laplace kjb::Laplace_distribution
typedef std::pair<kjb::Vector, kjb::Vector> kjb::Line3d
typedef Matrix_d<2,2> kjb::Matrix2
typedef Matrix_d<3,3> kjb::Matrix3
typedef Matrix_d< 4, 4 > kjb::Matrix4
typedef boost::math::normal kjb::Normal_distribution
typedef boost::math::poisson kjb::Poisson_distribution
typedef std::list<std::pair<int, int> > kjb::Region

Later...

typedef std::vector<Region> kjb::Region_vector

Later...

typedef boost::math::uniform kjb::Uniform_distribution

Enumeration Type Documentation

anonymous enum
Enumerator
GSL_QRNG_NIEDER 
GSL_QRNG_SOBOL 
GSL_QRNG_HALTON 
GSL_QRNG_RVSHALTON 
anonymous enum

constants used to select random number generators

See Also
http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html

GSL supports many other legacy algorithms that I have not bothered to add.

Enumerator
GSL_RNG_MT19937 

Matsumoto's & Nishimura's "Mersenne Twister".

GSL_RNG_RANLXS0 

RANLUX single-precision level 0.

GSL_RNG_RANLXS1 

RANLUX single-precision level 1.

GSL_RNG_RANLXS2 

RANLUX single-precision level 2.

GSL_RNG_RANLXD1 

RANLUX double-precision level 1.

GSL_RNG_RANLXD2 

RANLUX double-precision level 2.

GSL_RNG_CMRG 

L'Ecuyer's '96 generator, period ~ 10^56.

GSL_RNG_MRG 

L'Ecuyer et al. '93 generator, period ~ 10^46.

GSL_RNG_TAUS2 

Tausworthe generator version 2.

GSL_RNG_GFSR4 

Four-tap-XOR shift generator.

Enumerator
DEVA 
CV_FRONTAL_DEFAULT 
CV_FRONTAL_ALT 
CV_FRONTAL_ALT2 
CV_FRONTAL_ALT_TREE 
CV_PROFILE 
FACE_COM 
NUM_DETECTION_TYPES 

Move direction of the 2D bounding box.

Enumerator
COL_PLUS 
COL_MINUS 
ROW_PLUS 
ROW_MINUS 
Enumerator
NED_AD_MSBFIRST 

byteorder is MSB-first, network order

NED_AD_LSBFIRST 

byteorder is LSB-first, like Intel

NED_AD_UNCERTAIN 

byteorder is not known

Enumerator
PCD_PARAPIPED_X 
PCD_PARAPIPED_Y 
PCD_PARAPIPED_Z 
PCD_PARAPIPED_WIDTH 
PCD_PARAPIPED_HEIGHT 
PCD_PARAPIPED_LENGTH 
PCD_PARAPIPED_YAW 
PCD_CAMERA_FOCAL 
PCD_CAMERA_PITCH 
PCD_CAMERA_ROLL 

Function Documentation

template<std::size_t R, std::size_t C, bool T>
double kjb::accumulate ( const Matrix_d< R, C, T > &  mat,
double  init 
)

Add elements of a matrix

template<std::size_t R, std::size_t C, bool T, class Binary_function >
double kjb::accumulate ( const Matrix_d< R, C, T > &  mat,
double  init,
Binary_function  binary_op 
)

apply binary function to all elements of a matrix (same as std::accumulate, treating matrix like a long vector)

void kjb::alert_untested ( int  line,
const char *  file 
)
std::vector< size_t > kjb::angle_histogram ( const std::vector< Feature_pair > &  feature_pairs,
size_t  num_bins = 36 
)

Compute the histogram of the flow vector angles.

unsigned int kjb::assign_to_vanishing_point ( double  outlier_threshold,
const Line_segment isegment,
const std::vector< Vanishing_point > &  ivpts 
)

Assigns an edge segments to the vanishing point that minimizes the angle between the segment and the line between the midpoint of the segment and the vanishing point. If this angle is too big for all vanishing points, the segment is labeled as an outlier. This checks using different outlier thresholds and can be time consuming (ie 1-5 seconds).

If you want a faster estimation you can simply use the find_vpts_with_ransac function of class Vanishing_point_detector that looks for vanishing point only with once using the input edges and the specified number of outliers

int kjb::autodetect_ned_byteorder ( const std::string &  fn,
enum NED13_FLOAT_AUTODETECT *  result 
)

attempt to determine the byteorder of the input file.

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate problems with the file.
Parameters
[in]fnFilename of the float file to read
[out]resultOutput parameter containing a sentinel value indicating either the byteorder (if the evidence is clear) or a value indicating that the test was unsuccessful. This pointer must not equal null.

If the file IO fails, if number of floats in the file is not a square, or if neither byte order yields plausible data, this returns ERROR.

Vector kjb::average_flow ( const Matrix x_flows,
const Matrix y_flows,
const Axis_aligned_rectangle_2d roi 
)

Get the average optical flow inside a rectangle region.

Vector kjb::average_flow ( const std::vector< Vector > &  flows)
inline

Calculate the average optical flow for a vector of flow Vectors.

Vector kjb::back_substitution ( const Matrix &  U,
const Vector &  b 
)

Perform forward substitution to solve the SLE Ux = b, where.

Note
U MUST be upper triangular; if it is not, behavior is undefined
This is a very dumb – and, therefore, slow – algorithm.
Vector3 kjb::backproject ( const Vector3 &  homo_screen_coord,
const Matrix_d< 3, 4 > &  camera_matrix 
)

Same as backproject(), but using Vector3.

Vector kjb::backproject ( const Vector &  homo_camerascreen_coord,
const Matrix &  camera_matrix 
)

Receives a point in homogeneous screen coordinates and back-projects it onto its location on the plane at infinity. This can be interpreted as a 3D direction vector, d, which together with the camera center, c, defines the 3D back-projection line, l:

l = c + d * t ; for all t

Parameters
homo_camera_coordCamera coordinate to be backprojected. Specified in 2D homogeneous coordinates (size must be 3).
camera_matrixA 3x4 camera matrix for projecting 3d points to 2d.
Returns
The back-projected coordinate on the plane at infinity. Alternatively, this is the 3D direction vector that defines the backprojection line (see above).
template<class VectorType , class MatrixType , class M_MatrixType >
VectorType kjb::backproject_dispatch_ ( const VectorType &  homo_screen_coord,
const MatrixType &  camera_matrix 
)
bool kjb::backproject_point_to_plane ( kjb::Vector intersection,
kjb::Vector  point2D,
kjb::Vector  plane,
const Parametric_parapiped pp,
const Perspective_camera camera,
int  num_rows,
int  num_cols 
)
Vector kjb::backproject_with_m_inv ( const Vector &  homo_screen_coord,
const Matrix &  M_inv 
)

Same as backproject(), but the matrix passed-in is the inverse of the left 3x3 submatrix of the camera matrix. This saves time when you've already computed the inverse matrix and you want to backproject a large number of points.

Parameters
homo_screen_coordScreen coordinate to be backprojected. Specified in 2D homogeneous coordinates (size must be 3).
M_invLet P be a 3x4 camera matrix P. M_inv is the inverse of the left 3x3 submatrix of P, i.e. M_inv = P(0:2, 0:2)^-1
See Also
backproject
Vector3 kjb::backproject_with_m_inv ( const Vector3 &  homo_screen_coord,
const Matrix_d< 3, 3 > &  M_inv 
)

Same as backproject_with_m_inv(), but using Vector3.

template<class VectorType , class MatrixType >
VectorType kjb::backproject_with_m_inv_dispatch_ ( const VectorType &  homo_screen_coord,
const MatrixType &  M_inv 
)
Base_generator_type kjb::basic_rnd_gen ( DEFAULT_SEED  )
void kjb::build_cylinder ( std::vector< Vector > &  vlist,
std::vector< Vector > &  nlist,
int  facets,
int  ribs,
float  radius,
float  length 
)

Creates a list of vertices for a cylinder with the given height and radius on the z-axis with the bottom face centered at the origin. Also creates a corresponding list containing the normal vector for each vertex.

void kjb::build_frustum ( std::vector< Vector > &  vlist,
std::vector< Vector > &  nlist,
int  facets,
int  ribs,
float  radius_bottom,
float  radius_top,
float  length 
)

Creates a list of vertices for a frustum with the given height and radius of bottom and top faces on the z-axis with the bottom face centered at the origin. Also creates a corresponding list containing the normal vector for each vertex.

double kjb::cdf ( const Log_normal_distribution &  dist,
double  x 
)
inline

Computes the cdf of a log-normal distribution at x.

template<class T >
double kjb::cdf ( const Categorical_distribution< T > &  dist,
const T &  x 
)

Computes the CDF of a categorical distribution at x.

template<class Distribution >
double kjb::cdf ( const Mixture_distribution< Distribution > &  dist,
const typename Distribution_traits< Mixture_distribution< Distribution > >::type &  x 
)

Computes the CDF of a mixture distribution at x.

bool kjb::check_if_4_points_are_coplanar ( const Vector p1,
const Vector p2,
const Vector p3,
const Vector p4,
double  tolerance 
)

Checks if 4 points are coplanar.

bool kjb::check_if_faces_are_coplanar ( const Vector plane1_params,
const Vector plane2_params,
double  tolerance,
double  distTolerance = 1.0 
)

Checks if two faces in a polymesh are coplanar.

double kjb::chi2stat_helper ( int  O,
int  E 
)
inline

Compute the chi-square test value for a single element.

double kjb::chi_square ( const Histogram_2d hist_1,
const Histogram_2d hist_2 
)
double kjb::chi_square ( const Matrix h1,
const Matrix h2 
)
template<class InputIterator >
double kjb::chi_square_statistic ( InputIterator  first1,
InputIterator  last1,
InputIterator  first2 
)
inline

Compute the Chi-square statistic for two histograms, given by the two ranges. The second range is taken as the true frequencies.

Note
All values of both histograms must be positive.
template<class InputIterator , class Distribution >
bool kjb::chi_square_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
double  alpha,
int  num_params,
int  num_bins 
)
inline

Compute the goodness of fit test (using the Chi-square statistic) of a sample with respect to the given continuous distribution.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
alphaThreshold for passing the test.
num_paramsnumber of parameters of this distribution.
num_binsNumber of bins to use to compute histograms.
template<class InputIterator , class Distribution >
bool kjb::chi_square_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
double  alpha,
int  dof_redux 
)

Compute the goodness of fit test (using the Chi-square statistic) of a sample with respect to the given discrete distribution.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
alphaThreshold for passing the test.
dof_reduxDegrees of freedom reduction.
Matrix kjb::cholesky_decomposition ( const Matrix &  M)
inline

For any symmetric positive-definite matrix M, returns a lower-triangular triangular matrix L such that M = LL'

bool kjb::compare_flow_magnitude ( const Vector &  f_p,
const Vector &  f_n 
)
inline

Compare the optical flow magnitude.

template<class Iterator >
Axis_aligned_rectangle_2d kjb::compute_bounding_box ( Iterator  first,
Iterator  last 
)
inline

Computes the 2D bounding box of a range of 2D points.

This is implemented in the most straight-forward way possible; it's linear in the number of points.

Parameters
firstPoints to the first kjb::Vector in the range.
firstPast-the-end iterator in the range.
void kjb::compute_cylinder_rotation_angles ( const Vector p1,
const Vector p2,
Vector top,
Vector bottom,
double &  magnitude,
double &  angle_y,
double &  angle_x 
)
Parameters
p1The center point of one of the bases of the cylinder.
p2The center point of the other base of the cylinder.
topThe larger center point (i.e. MAX(p1, p2) ).
bottomThe smaller center point (i.e. MIN(p1, p2) ).
magnitudeThe computed height of the cylinder.
angle_yThe angle to rotate the cylinder vector (given by top - bottom) around the y-axis to move it into the yz-plane.
angle_xThe angle to rotate the cylinder vector (given by top - bottom) around the x-axis to move it from the yz-plane onto the z-axis.
void kjb::compute_HOG_features ( const Image &  img,
int  bin_size 
)
void kjb::compute_median_background ( const std::vector< std::string > &  frames_fps,
Matrix r_mat,
Matrix g_mat,
Matrix s_mat,
size_t  sub_sampling_sz = 1,
size_t  rate = 1 
)

Compute the background value by a median filter.

template<class Target , class Given , class Func >
double kjb::conditional_log_pdf ( const Conditional_distribution< Target, Given, Func > &  cd,
const typename Distribution_traits< Target >::type &  x,
const typename Distribution_traits< Given >::type &  y 
)
inline

Gets the conditional log-pdf log p(x | y) of the given ConditionalDistribution.

template<class Target , class Given , class Func >
double kjb::conditional_pdf ( const Conditional_distribution< Target, Given, Func > &  cd,
const typename Distribution_traits< Target >::type &  x,
const typename Distribution_traits< Given >::type &  y 
)
inline

Gets the conditional pdf p(x | y) of the given ConditionalDistribution.

template<class Target , class Given , class Func >
Distribution_traits<Target>::type kjb::conditional_sample ( const Conditional_distribution< Target, Given, Func > &  cd,
const typename Distribution_traits< Given >::type &  y 
)
inline

Produces a sample from the given conditioanl distro, given a value for the given variable.

template<size_t D, size_t K>
Weight_array< D > kjb::convex_combination ( const Weight_array< K > &  weights,
const boost::array< Weight_array< D >, K > &  components 
)
Matrix kjb::create_derivative_matrix ( int  N,
int  degree = 1 
)
inline
template<std::size_t D>
Matrix_d< D, D > kjb::create_identity_matrix ( )
Matrix kjb::create_integral_matrix ( const std::vector< double > &  deltas)
Matrix kjb::create_integral_matrix ( size_t  N)

Returns a lower-triangular matrix with all 1's.

Manhattan_world * kjb::create_manhattan_world_from_CMU_file ( const std::string &  file_name)
Manhattan_world * kjb::create_mw_from_CMU_file_and_compute_focal_length ( const std::string &  file_name,
const kjb::Edge_segment_set iset,
unsigned int  num_rows,
unsigned int  num_cols 
)
template<std::size_t NROWS, std::size_t NCOLS>
Matrix_d< NROWS, NCOLS > kjb::create_random_matrix ( )
void kjb::create_rectangle_mask ( const Polymesh p,
const std::vector< Right_Triangle_Pair > &  rectangles,
Int_vector rectMask 
)

Creates an Int_vector mask representing the faces in a polymesh that are part of a rectangle.

void kjb::decompose_camera_matrix ( const Matrix &  camera_matrix,
Matrix &  intrinsic,
Matrix &  rotation,
Vector &  translation 
)

Some camera conventions have the camera looking down the positive z-axis, while others look down the negative z-axis (e.g. OPenGL). This is admittedly a bit arcane, but a necessary operation, nonetheless.

Use LU decomposition to decompose the camera matrix into its intrinsic and extrinsic parts. Ambiguity in the decomposition is resolved by forcing the diagonal elements of the intrinsic matrix to be positive.

Parameters
camera_matrix[in] The 3x4 camera matrix to be decomposed
intrinsic[out] The output intrinsic camera matrix
rotation[out] The camera's extrinsic rotation
translation[out] The world origin relative to the camera coordinate frame. The camera center in world coordinate frame can be found by (- rotation.transpose() * translation).
Postcondition
M = K [R | t] , where M is the input matrix, K is the intrinsic matrix, R is the rotation matrix, and t is the translation vector
Author
Kyle Simek
double kjb::delta_e_meters ( const Ned13_one_degree_grid::IntegralLL &  ill)

distance, in meters, of the next grid point to the east

std::pair< double, double > kjb::delta_n_e_meters ( const Ned13_one_degree_grid::IntegralLL &  ill)

distances, in meters, of next grid pt north (first), east (second)

double kjb::delta_n_meters ( const Ned13_one_degree_grid::IntegralLL &  ill)

distance, in meters, of the next grid point to the north

TopoFusion::pt kjb::dem_to_doq_displacement ( const TopoFusion::pt &  dem_p)

return correction factor between DEM and DOQ coordinate systems.

Parameters
dem_pUTM reference point from a DEM (digital elevation model)
Returns
approximate coordinates of the corresponding location in DOQ imagery

The DEM and DOQ datasets do not share precisely the same coordinate system.

In other words, the UTM triple (e=222222, n=3333333, z=12) indicates two different (nearby) geographic locations in the DEM dataset and the DOQ dataset. If we try to use the same coordinate notation for both, we will have misregistered data; when the terrain includes cliffs or rivers, the misregistration is obvious. The displacement is in the neighborhood of 100 to 200 meters.

I do not understand the source of this displacement. It might be a systemic error – maybe MSR uses the Clarke-1866 ellipsoid (the historical basis for UTM coordinates) somehow with the NAD-83 reference positioning. That does not entirely make sense, but I'm reduced to guessing. The funny business below is basically an empirical solution to a poorly-understood problem.

Matrix kjb::derivative_matrix ( int  degree,
int  N 
)
double kjb::det ( const Matrix_d< 1, 1 > &  m)
inline
double kjb::det ( const Matrix_d< 2, 2 > &  m)
double kjb::det ( const Matrix_d< 3, 3 > &  m)
kjb::Features_manager * kjb::detect_hoiem_features_manager ( const std::string &  img_path)
void kjb::detect_long_connected_segments ( Line_segment_set segments,
const std::string &  img_path,
int  max_length 
)
bool kjb::detect_vanishing_points ( std::vector< Vanishing_point > &  vpts,
double &  focal_length,
const std::string &  img_path 
)
void kjb::diagonalize ( const Matrix &  M,
Matrix &  eig_vectors,
Vector &  eig_values,
bool  symmetric = false 
)
inline

KJB c-style syntax for eigenvalue decomposition.

Quaternion kjb::difference ( const Quaternion &  q1,
const Quaternion &  q2 
)
inline

Returns the "rotational difference" between q1 and q2. In other words, this returns the rotation through which q2 must rotate to become q1.

diff = difference(q1, q2); assert(q1 == q2 * diff);

std::vector< std::string > kjb::dir_names_from_format ( const std::string &  name_format,
size_t  first 
)

Expands the format into a set of (existing) file names.

int kjb::draw_cylinder ( GLUquadricObj myQuadric,
const Vector p1,
const Vector p2,
double  radius 
)

Uses opengl to draw a cylinder with the given points as the centers of the top and bottom of the cylinder and with the given radius.

Parameters
p1A vector representing the center point of the top of the cylinder
p2A vector representing the center point of the bottom of the cylinder
radiusA double representing the radius of the cylinder to be drawn
int kjb::draw_cylinder ( Perspective_camera c,
GLUquadricObj myQuadric,
const Vector p1,
const Vector p2,
double  radius 
)
Parameters
cA Perspective_camera
p1A vector representing the center point of the top of the cylinder
p2A vector representing the center point of the bottom of the cylinder
radiusA double representing the radius of the cylinder to be drawn
int kjb::draw_cylinder ( GLUquadricObj myQuadric,
const Cylinder  cyl 
)
int kjb::draw_cylinder ( Perspective_camera c,
GLUquadricObj myQuadric,
const std::vector< Cylinder cylinders 
)
void kjb::draw_cylinder_edges ( std::vector< Vector > &  vlist,
int  facets,
int  ribs,
const Vector bottom,
const double  angle_y,
const double  angle_x,
const Perspective_camera camera 
)
void kjb::draw_cylinder_facets ( std::vector< Vector > &  vlist,
int  facets,
int  ribs 
)
int kjb::draw_cylinder_section ( GLUquadricObj myQuadric,
const Vector p1,
const Vector p2,
double  radius,
double  angle,
const Vector angleStartpt,
const Vector angleEndpt,
GLuint MY_CLIP_PLANE,
GLuint MY_CLIP_PLANE1 
)

Uses opengl to draw a cylinder section.

Parameters
p1A vector representing the center point of the top of the cylinder
p2A vector representing the center point of the bottom of the cylinder
radiusA double representing the radius of the cylinder to be drawn
angle
angleStartpt
angleEndpt
MY_CLIP_PLANE
MY_CLIP_PLANE1
int kjb::draw_cylinder_section ( Perspective_camera c,
GLUquadricObj myQuadric,
const std::vector< Cylinder_section cylinders 
)
void kjb::draw_features ( Image img,
const std::vector< Feature_pair > &  features,
const Vector average_flow,
Image::Pixel_type  feature_pixel = fpix,
Image::Pixel_type  ave_flow_pixel = apix 
)

Draw the optical flow features and the average flow.

void kjb::draw_mid_point_to_vanishing_point ( kjb::Image img,
const Line_segment segment,
const Vanishing_point vpt,
double  ir,
double  ig,
double  ib,
double  width 
)
void kjb::draw_model_edges ( kjb::Image img,
const std::vector< Model_edge > &  edges 
)
void kjb::draw_translated_and_rotated_cylinder ( GLUquadricObj myQuadric,
const Vector bottom,
const double  angle_y,
const double  angle_x,
const double  radius,
const double  magnitude 
)
Parameters
myQuadricA GLUquadricObj needed for the gluCylinder() method.
bottomThe smaller center point (i.e. MIN(p1, p2) ).
angle_yThe angle to rotate the cylinder vector (given by top - bottom) around the y-axis to move it into the yz-plane.
angle_xThe angle to rotate the cylinder vector (given by top - bottom) around the x-axis to move it from the yz-plane onto the z-axis.
radiusThe radius of the cylinder to be drawn.
magnitudeThe height of the cylinder to be drawn.
Edge_set_ptr kjb::edge_image_to_edge_points ( const Image &  i,
bool  oriented = false 
)

Convert a binary image to an edge set.

Note
No attempt is made to group edge points into edges; if you need such funtionality, I suggest creating a group_edge_points method or global function that receives the output of this function.
Parameters
iThe image to convert. Any pixels not (0,0,0) are considered edge points.
orientedWhether or not to determine edge orientation (enabling is slower).
Returns
An edge set representing the image edges.
Note
calling edge_image_to_edges(img, b).color(white_image, 0.0,0.0,0.0) should result in white image == img. This has not been tested, though.
Author
Kyle Simek
Image kjb::edges_to_image ( const Edge_set &  edges,
bool  invert = false,
size_t  remove_borders = 0 
)

Create a black-and-white image from a set of edges. Background will be white, edges will be black.

Parameters
invertbackground is black, edges are white
remove_bordersfill an n-pixel frame around image with background color (useful for removing artifact edges)
Author
Kyle Simek
template<class Iterator , class distance_type >
Iterator kjb::element_uar ( Iterator  first,
distance_type  size 
)
inline

Pick an element uniformly at random (UAR) from a sequence, represented by a beginning iterator and a size.

Returns
An iterator to the randomly chosen element.
void kjb::expand_towards_camera ( const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
unsigned int  num_rows,
unsigned int  num_cols,
bool &  expand_tw_camera,
bool &  expand_right,
bool &  expand_z_up 
)
Vector kjb::exponentiate ( const Vector &  vec)

elementwise exponentiate a vector without normalizing

Author
Colin Dawson
Vector kjb::face_location_3d ( const Face_detection face,
const Perspective_camera camera,
const Bbox body_box 
)

Computes the 3D location of a face.

Returns
Vector representing the 3D location the given face detection using the given camera.
std::vector< std::string > kjb::file_names_from_format ( const std::string &  name_format,
size_t  first,
size_t  num_files 
)

Expands the format into a set of (existing) file names.

void kjb::find_adjacent_rectangles ( const Polymesh p,
const Int_vector cylMask,
const Int_vector rectMask,
const std::vector< Right_Triangle_Pair > &  rectangles,
int  startIndex,
int  rectIndex,
int  prevAdjFace,
double  width,
double  lengthTolerance,
double &  smallestAngle,
double &  largestAngle,
double &  sumAngles,
std::vector< int > &  cyl_indices,
Vector edge_pt1,
Vector edge_pt2,
Vector edge_pt1_adj,
Vector edge_pt_adj 
)

Determines which rectangles are adjacent to eachother and if a group of adjacent rectangles form part of a cylinder.

void kjb::find_adjacent_right_triangles_to_render ( const Polymesh p,
std::vector< Polymesh_Plane > &  plane 
)

Renders each face that is a right triangle and adjacent to another face that is also a right triangle in a different color.

void kjb::find_all_circles_in_polymesh ( Polymesh p,
std::vector< Circle_in_3d > &  circles,
std::vector< std::vector< Vector > > &  points 
)

Finds all of the circles and the points that lie on them in the polymesh.

For each point, creates a list of the points within a sphere of radius 10% of length of longest bounding-box edge and centered at the point. Fits a circle to each set of 3 points in a list, then checks ALL points in polymesh to see if they lie on the circle.

Parameters
pthe polymesh that the faces are from.
circlesthe vector of Circle_in_3d objects which contain the parameters (circle, radius, normal) needed to define a circle in the 3d space of the polymesh.
pointsthe vector containing lists of points (one for each circle).
void kjb::find_centroid_of_3d_points ( const std::vector< Vector > &  points,
Vector centroid 
)

Finds the center of a set of 3D points.

template<class InputIterator >
std::vector<Collinear_segment_chain> kjb::find_collinear_segment_chains ( InputIterator  first,
InputIterator  last,
double  distance_threshold,
double  orientation_threshold 
)

Find a set of collinear_segments_chains.

void kjb::find_cylinders ( const Polymesh p,
const std::vector< Right_Triangle_Pair > &  rectangles,
std::vector< std::vector< int > > &  cyl_indices,
std::vector< double > &  cylSumAngles,
std::vector< std::vector< Vector > > &  cylEdgePoints 
)

Determines which groups of faces in the polymesh form cylinders.

void kjb::find_cylinders_to_render ( const Polymesh p,
std::vector< Polymesh_Plane > &  plane 
)

Renders each set of faces that forms a cylinder a different color.

void kjb::find_cylinders_to_render_and_fit ( char *  faceFile,
char *  cylFile,
const Polymesh p,
std::vector< Polymesh_Plane > &  plane,
std::vector< Cylinder_section > &  cyl 
)
bool kjb::find_height_from_two_corners ( const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner floor_corner,
const Manhattan_corner top_corner,
double &  desired_height,
unsigned int  num_rows,
unsigned int  num_cols 
)
void kjb::find_planes ( const Polymesh p,
std::vector< Polymesh_Plane > &  plane 
)

Finds all of the planes in a polymesh and stores each set of coefficients along with the corresponding face indices in a Polymesh_Plane.

Finds all of the planes which contain at least one face in the polymesh. Does not include planes for which the total area of the faces lying in it is less than a threshold value.

Parameters
pthe polymesh that the faces are from.
planethe vector of Polymesh_Planes in which the plane parameters and the corresponding face indices are stored.
void kjb::find_rectangles ( const std::vector< kjb::Polygon > &  faces,
const Int_vector mask,
const Polymesh p,
std::vector< Right_Triangle_Pair > &  triangles 
)

Finds all pairs of right triangles in a polymesh that are coplanar, adjacent along their hypotenuses, and have the same vertices along the shared edge (i.e. the triangle pairs form a rectangle).

Parameters
facesthe vector of polygons
maskthe Int_vector mask representing which polygons are right triangles
pthe polymesh that the faces are from
trianglesthe vector of triangle pairs that form rectangles
void kjb::find_rectangles_to_render ( const Polymesh p,
std::vector< Polymesh_Plane > &  plane 
)

Renders each pair of faces that forms a rectangle a different color.

void kjb::find_right_triangles ( const std::vector< kjb::Polygon > &  faces,
Int_vector mask 
)

Creates an Int_vector mask representing the faces in a polymesh that are right triangles.

Searches through a vector of Polygons representing the faces in a polymesh and checks each polygon to see if it is a right triangle. If it is, the corresponding element in the Int_vector mask is set to 1. If the polygon is not a right triangle, the mask element is 0.

Parameters
facesthe vector of polygons
maskthe Int_vector mask representing which polygons are right triangles
void kjb::find_right_triangles_to_render ( const Polymesh p,
std::vector< Polymesh_Plane > &  plane 
)

Renders each face that is a right triangle in a different color.

bool kjb::find_third_vanishing_point ( const kjb::Vanishing_point vp1,
const kjb::Vanishing_point vp2,
double  focal,
unsigned int  img_rows,
unsigned int  img_cols,
Vanishing_point vpt 
)
void kjb::find_top_and_bottom_points_of_cylinder ( const Polymesh p,
const Int_vector rectMask,
const std::vector< Right_Triangle_Pair > &  rectangles,
const std::vector< int > &  cyl_indices,
std::vector< Vector > &  top_points,
std::vector< Vector > &  bottom_points 
)

Determines which points make up the 'top' and which points make up the 'bottom' of the cylinder specified by the provided polymesh face indices.

bool kjb::find_vanishing_point_given_one_and_line ( const kjb::Vanishing_point vp1,
double  focal,
unsigned int  img_cols,
unsigned int  img_rows,
const Line_segment ls,
Vanishing_point vpt 
)
bool kjb::find_vertical_vanishing_point ( Vanishing_point vp1,
Vanishing_point vp2,
Vanishing_point estimated_vertical,
unsigned int  img_cols,
unsigned int  img_rows 
)
void kjb::fit_cylinder ( const Polymesh p,
const Int_vector rectMask,
const std::vector< Right_Triangle_Pair > &  rectangles,
const std::vector< int > &  cyl_indices,
double  cylAngle,
const std::vector< Vector > &  cylEdgePoints,
Cylinder_section cyl 
)

Determines the parameters of the cylinder formed by a set of faces in the polymesh.

void kjb::fit_plane_to_3d_points ( const std::vector< Vector > &  points,
const Vector centroid,
Vector plane_params 
)

Uses singular value decomposition (SVD) to fit a plane to a set of 3D points.

void kjb::flip_matrix_lr ( Matrix &  m)
inline

deprecated synonym for Matrix::ow_horizontal_flip

void kjb::flip_matrix_ud ( Matrix &  m)
inline

deprecated synonym for Matrix::ow_vertical_flip

Matrix kjb::flow_magnitude ( const Matrix x_flows,
const Matrix y_flows 
)

Compute the flow magnitude.

TopoFusion::pt kjb::force_zone_to_this ( const TopoFusion::pt &  ,
char  use_this_zone 
)
TopoPt kjb::force_zone_to_this ( const TopoPt &  p,
char  use_this_zone 
)
Vector kjb::forward_substitution ( const Matrix &  L,
const Vector &  b 
)

Perform forward substitution to solve the SLE Lx = b, where L is an lower triangular matrix and b is a vector.

Note
L MUST be lower triangular; if it is not, behavior is undefined
This is a very dumb – and, therefore, slow – algorithm.
Matrix kjb::fourier_basis ( size_t  D,
size_t  num_basis_funcs 
)

Returns a matrix whose rows form a Fourier basis in R^D.

This function returns a set of basis vectors that form a Fourier basis in D-dimensional space. If num_basis_funcs is specified, only the first num_basis_funcs are included.

kjb::FREE_FUNCTION_LIST ( ,
,
true   
)
kjb::FREE_FUNCTION_LIST ( ,
,
false   
)
kjb::FREE_FUNCTION_LIST ( ,
,
true   
)
kjb::FREE_FUNCTION_LIST ( ,
,
false   
)
kjb::FREE_FUNCTION_LIST_3DIM ( ,
,
 
)
kjb::FREE_FUNCTION_LIST_3DIM ( ,
,
 
)
kjb::FREE_FUNCTION_LIST_3DIM ( ,
,
 
)
kjb::FREE_FUNCTION_LIST_3DIM ( ,
,
 
)
kjb::FREE_FUNCTION_LIST_NO_TRANSPOSE ( ,
 
)
kjb::FREE_FUNCTION_LIST_NO_TRANSPOSE ( ,
 
)
template<class InputIterator >
double kjb::g_statistic ( InputIterator  first1,
InputIterator  last1,
InputIterator  first2 
)
inline

Compute the G statistic (used in the G-test) for two histograms, given by the two ranges. The second range is taken as the true frequencies.

Note
All values of both histograms must be positive.
template<class InputIterator , class Distribution >
bool kjb::g_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
double  alpha,
int  num_params,
int  num_bins 
)
inline

Compute the goodness of fit test (using the G-test) of a sample with respect to the given continuous distribution.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
alphaThreshold for passing the test.
num_paramsnumber of parameters of this distribution.
num_binsNumber of bins to use to compute histograms.
template<class InputIterator , class Distribution >
bool kjb::g_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
double  alpha,
int  dof_redux 
)

Compute the goodness of fit test (using the G-test) of a sample with respect to the given discrete distribution.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
alphaThreshold for passing the test.
dof_reduxDegrees of freedom reduction.
Vector kjb::gaze_direction ( const Face_detection face,
const Perspective_camera camera 
)

Computes the direction of the gaze.

Returns
Vector representing the gaze direction of the given face detection using the given camera.
void kjb::get_3D_corner_orientation_from_2D_corner_lines ( const kjb::Vector corner2D_1,
const kjb::Vector corner2D_2,
const kjb::Vector corner2D_3,
const kjb::Vector position_2D,
const kjb::Vector position_3D,
double  focal_length,
int  epsilon,
kjb::Vector corner3D_1,
kjb::Vector corner3D_2,
kjb::Vector corner3D_3 
)
double kjb::get_3d_height ( const Vector &  bottom_2d,
const Vector &  top_2d,
const Perspective_camera &  camera 
)
inline

Back project the 2d points to find the height in 3D. Assume that the bottom is on the ground.

std::vector< std::string > kjb::get_all_detection_type_names ( )

Get all types.

double kjb::get_angle_between_two_vectors ( const Vector plane1_params,
const Vector plane2_params 
)
throw (Illegal_argument,
KJB_error
)

Calculates the smaller angle between the normal vectors of two planes. The angle returned is in radians.

const Vector& kjb::get_bottom_y ( const Line_segment &  seg)
inline

Get end-point with lowest y-value.

int kjb::get_convex_hull ( const kjb::Matrix points,
Matrix &  hull_vertices,
std::vector< Matrix > &  hull_facets 
)

Get the convex hull of points hull_vertices stores the vertices of the convex hull hull_facets stores the facets of the hull.

/\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\

double kjb::get_convex_hull_volume ( const kjb::Matrix points)
inline

Get the volume of the convex hull of points.

Detection_type kjb::get_detection_type ( const std::string &  name)

Get the type of a detection name.

const std::string & kjb::get_detection_type_name ( Detection_type  type)

Get the name of a detection type.

std::string kjb::get_extension ( const std::string &  fname)
inline

Return the extension of a filename, with the '.' removed

int kjb::get_ned_fdeq ( const std::string &  fn,
std::deque< float > *  odq,
bool  flip 
)

read the floating-point values of a NED13 file into a deque.

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate failure or success
Parameters
[in]fnFilename (possibly with path) of local file, which is assumed to contain nothing except binary-format float data, IEEE 754 single-precision. The byte order is assumed to be "network byte order," i.e., MSB-first.
[out]odqPointer to std::deque<float> into which to store the data. It must not equal null.
[in]flipFlag to indicate when input is in "network byte order," which on Intel-style architectures requires the order to be reversed. To repeat, TRUE indicates "network byte order," also known as MSB-first, common on Motorola-style machines.

In case it is not clear, the purpose of this function is to handle the low-level file input and byte-order conversion.

int kjb::get_ned_fdeq ( const std::string &  fn,
std::deque< float > *  odq,
enum NED13_FLOAT_AUTODETECT  byteorder 
)

read the floating-point values of a NED13 file into a deque.

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate failure or success
Parameters
[in]fnFilename, same as 'fn' in sibling function (q.v.).
[out]odqPointer to std::deque<float> into which to store the data. It must not equal null.
[in]byteorderIf NED_AD_MSBFIRST or NED_AD_LSBFIRST, we read the input under that assumption. If NED_AD_UNCERTAIN, we try to autodetect the byte order.
See Also
autodetect_ned_byteorder

This is the same as get_ned_fdeq( const std::string&, std::deque< float >*, bool ) except that this function tries to autodetect the byteorder of the data if byteorder is set to NED_AD_UNCERTAIN.

int kjb::get_ned_matrix ( const std::string &  fn,
Matrix *  omat,
bool  flip 
)

read the floating-point values of a NED13 file into a square matrix.

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate failure or success
Parameters
[in]fnFilename (possibly with path) of local file, which is assumed to contain nothing except binary-format float data, IEEE 754 single-precision. The byte order is assumed to be "network byte order," i.e., MSB-first. The total number is assumed to be a perfect square.
[out]omatPointer to matrix into which to store the data. It must not equal null.
[in]flipFlag used to indicate input in MSB-first order – see description of flip parameter of get_ned_fdeq().

This function is implemented by calling get_ned_fdeq() and ned_fdeq_to_matrix(), which is a little less efficient that possible – we read the file into memory (in the deque) and then copy it into another part of memory (in the Matrix). But I doubt the penalty is significant, and it's a natural way to factor the computation.

int kjb::get_ned_matrix ( const std::string &  fn,
Matrix *  omat,
enum NED13_FLOAT_AUTODETECT  byteorder 
)

read the floating-point values of a NED13 file into a square matrix.

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate failure or success
Parameters
[in]fnsame as 'fn' for get_ned_matrix( const std::string&, Matrix*, bool ).
[out]omatPointer to matrix into which to store the data. It must not equal null.
[in]adIf NED_AD_MSBFIRST or NED_AD_LSBFIRST, we read the input under that assumption. If NED_AD_UNCERTAIN, we try to autodetect the byte order.
See Also
autodetect_ned_byteorder
void kjb::get_plane_parameters ( const Vector normal,
const Vector point_on_plane,
Vector plane_params 
)

Finds the coefficients of the plane of the form ax + by + cz + d = 0 given the normal vector and a point on the plane.

void kjb::get_plane_parameters ( const Vector pt1,
const Vector pt2,
const Vector pt3,
Vector plane_params 
)

Finds the coefficients of the plane of the form ax + by + cz + d = 0 given three points on the plane.

void kjb::get_projected_bbox_from_3Dpoints ( Bounding_Box2D &  bb,
const std::vector< Vector > &  points,
const Base_gl_interface &  camera,
double  img_width,
double  img_height 
)

Projects a set of 3D points onto the image plane, and finds a bounding box (aligned with the image axes), such that it contains all the projected points.

Projects a set of 3D points onto the image plane, and finds a bounding box (aligned with the image axes), such that it contains all the projected points

Parameters
bbwill contain the computed bounding box
pointsthe set of 3D points to project. They can be in homogeneous coordinates
camerathe camera to use when projecting
img_widththe width of the image plane in pixels
img_heightthe height of the image plane in pixels
double kjb::get_rectangle_intersection ( const kjb::Bounding_Box2D b1,
const kjb::Bounding_Box2D b2 
)

Compute area of intersection of two rectangles.

std::map< int, Region_vector > kjb::get_regions_from_mask ( const Int_matrix &  mask,
int  region_length 
)

Later...

const Vector& kjb::get_top_y ( const Line_segment &  seg)
inline

Get end-point with highest y-value.

int kjb::getline ( FILE *  fp,
std::string *  line,
char  EOL = '\n' 
)

Like C's fgets but with std::string, or C++'s getline but with FILE*.

C has the fgets(3) function, but requires that you know the maximum length of an input line. C++ has the getline function for a string, but requires that you use streams. This function lets you read a line from a FILE* into a string, giving the best of both libraries.

A "line" is defined as a string of characters read from the FILE* until we hit EOF or we read the EOL character you specified (unless EOL was allowed to default to newline). Just as fgets does, if an EOL character is read, we include it in the string as the last character.

Parameters
[in]fpFile from which to read
[out]lineInput is appended onto the back of this string. If this pointer equals NULL, that is considered an error and the return value will be EOF.
[in]EOLCharacter that delimits the line of input (we presume such a value must exist). As is conventional, the default value is '
'
Returns
kjb_c::ERROR if there is an error or if we reach EOF before any characters are read; but if successful, return kjb_c::NO_ERROR.
template<class InputIterator , class Distribution , class Statistic >
bool kjb::goodness_of_fit_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
const Statistic &  statistic,
double  alpha,
int  num_params,
int  num_bins 
)

Performs a goodness-of-fit test based on the given continuous distribution. The statistic used must follow a chi-square distribution.

TODO: make more generic: the statistic should not be chi-square-distributed.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
statisticReturns a chi-square distributed statistic given two histograms.
testTest used; must follow chi-square distribution.
alphaThreshold for passing the test.
num_paramsnumber of parameters of this distribution.
num_binsNumber of bins to use to compute histograms.
Note
The range of samples must contain at least 10 elements.
template<class InputIterator , class Distribution , class Statistic >
bool kjb::goodness_of_fit_test ( InputIterator  first,
InputIterator  last,
const Distribution &  dist,
const Statistic &  statistic,
double  alpha,
int  dof_redux 
)

Performs a goodness-of-fit test based on the given discrete distribution. The statistic used must follow a chi-square distribution.

TODO: make more generic: the statistic should not be chi-square-distributed.

Parameters
firstFirst element of sample set.
lastLast element of sample set.
distDistribution of interest.
statisticReturns a chi-square distributed statistic given two histograms.
alphaThreshold for passing the test.
dof_reduxDegrees of freedom reduction.
template<class F , class M , class G , class A >
void kjb::gradient_ascent ( const F &  fcn,
M &  x,
const std::vector< double > &  steps,
const G &  grad,
const A &  adapter 
)

Maximizes a function using a simple gradient ascent method.

Parameters
xCurrent value of model.
fcnFunction of interest. Must receive a const Model& and return a double. Its type can be anything that is callablle with the correct signature.
stepsStep sizes in each dimension.
gradGradient operator. Takes a const Model& and returns a kjb::Vector.
adapterAllows us to treat our model as a vector. Must have A::get, A::set, and A::size implemented. See kjb::Vector_adapter for an example.
template<class F , class V , class G >
void kjb::gradient_ascent ( const F &  fcn,
V &  x,
const std::vector< double > &  steps,
const G &  grad 
)
inline

Maximizes a function using a simple gradient ascent method.

Parameters
xCurrent value of variable.
fcnFunction of interest. Must receive a const kjb::Vector& and return a double. Its type can be anything that is callablle with the correct signature.
stepsStep sizes in each dimension.
gradGradient operator. Takes a const kjb::Vector& and returns a kjb::Vector.
template<class Func , class Model , class Adapter >
Vector kjb::gradient_cfd ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the gradient of a function, evaluated at a point, using central finite differences.

Parameters
fThe function whose gradient is desired. It must receive a Model const-ref and return a double.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::gradient_cfd ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the gradient of a function, evaluated at a point, using central finite differences, for a vectory-style model.

Parameters
fThe function whose gradient is desired. It must receive a vector-style object const-ref and return a double.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Vector kjb::gradient_cfd_mt ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  nt 
)

Computes the gradient of a function, evaluated at a point, using central finite differences. Multi-threaded version.

Parameters
fThe function whose gradient is desired. It must receive a Model const-ref and return a double. This function is responsible for handling its own rewritable state; i.e., make sure f is thread-safe.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
ntThe number of threads. If not set, use the number of hardware threads available on the current system
template<class Func , class Vec >
Vector kjb::gradient_cfd_mt ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx,
size_t  nt = 0 
)
inline

Computes the gradient of a function, evaluated at a point, using central finite differences, for a vectory-style model. Multi-threaded version.

Parameters
fThe function whose gradient is desired. It must receive a vector-style object const-ref and return a double.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
void kjb::gradient_cfd_mt_worker ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  i_start,
size_t  i_end,
Vector &  v 
)

Helper function for gradient_cfd_mt.

template<class Func , class Model , class Adapter >
Vector kjb::gradient_ffd ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the gradient of a function, evaluated at a point, using forward finite differences.

Parameters
fThe function whose gradient is desired. It must receive a Model const-ref and return a double.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::gradient_ffd ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the gradient of a function, evaluated at a point, using forward finite differences, for a vectory-style model.

Parameters
fThe function whose gradient is desired. It must receive a vector-style object const-ref and return a double.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Vector kjb::gradient_ffd_mt ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  nt 
)

Computes the gradient of a function, evaluated at a point, using forward finite differences. Multi-threaded version.

Parameters
fThe function whose gradient is desired. It must receive a Model const-ref and return a double.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::gradient_ffd_mt ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx,
size_t  nt = 0 
)
inline

Computes the gradient of a function, evaluated at a point, using forward finite differences, for a vectory-style model. Multi-threaded version.

Parameters
fThe function whose gradient is desired. It must receive a vector-style object const-ref and return a double.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
void kjb::gradient_ffd_mt_worker ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
double  fx,
size_t  i_start,
size_t  i_end,
Vector &  v 
)

Helper function for gradient_ffd_mt.

template<class Func , class Model , class Adapter >
Vector kjb::gradient_ind_cfd ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the gradient of a function, evaluated at a point, using central finite differences.

Parameters
fA function f(x,i) that recieves a Model const-ref and an index and returns a double. f(x, i) may be any function that differs from f(x) by constant offset for any value of x_i. This permits terms not involving x_i to be ignored, saving computation.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::gradient_ind_cfd ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the gradient of a function, evaluated at a point, using central finite differences for a vector-style model.

Parameters
fA function f(x,i) that recieves a Model const-ref and an index and returns a double. f(x, i) may be any function that differs from f(x) by constant offset for any value of x_i. This permits terms not involving x_i to be ignored, saving computation.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Vector kjb::gradient_ind_cfd_mt ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  nt 
)

Computes the gradient of a function, evaluated at a point, using central finite differences. Multithreaded version.

Parameters
fA function that recieves a Model const-ref and an index and returns a double. Semantically, f(x, i) returns the result of evaluating the true function on a model that only differs from x in dimension i.
xThe point at which the gradient is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default kjb::Vector_adapter. Otherwise, provide a class which implements get(), set(), and size() for your model type. See kjb::Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::gradient_ind_cfd_mt ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx,
size_t  nt = 0 
)
inline

Computes the gradient of a function, evaluated at a point, using central finite differences for a vector-style model. Multi-threaded version.

Parameters
fA function that recieves a Model const-ref and an index and returns a double. Semantically, f(x, i) returns the result of evaluating the true function on a model that only differs from x in dimension i.
xThe point at which the gradient is to be evaluated. Class Vec must have size() and operator[] defined.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
void kjb::gradient_ind_cfd_mt_worker ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  i_start,
size_t  i_end,
Vector &  v 
)

Helper function for gradient_ind_cfd_mt.

template<class F , class M , class A >
double kjb::grid_maximize ( const F &  fcn,
const std::vector< std::pair< double, double > > &  bounds,
size_t  nbins,
const A &  adapter,
M &  mxm 
)

Maximizes a function by evaluating at all points in a grid.

Parameters
fcnThe function. Must recieve a const-ref to type M, and return a double.
boundsBounds (one pair of upper and lower bounds per dimension) of region of integration.
nbinsNumber of bins in grid.
adapterAllows us to treat our model as a vector. Must have A::get, A::set, and A::size implemented. See kjb::Vector_adapter for an example.
def_modelAn initialized model. Must be ready for getting and setting.

The runtime of this function grows exponentially with the number of dimensions. Please only use for proof-of-concept or testing.

template<class F , class V >
double kjb::grid_maximize ( const F &  fcn,
const std::vector< std::pair< double, double > > &  bounds,
size_t  nbins,
V &  mxm 
)
inline

Maximizes a function by evaluating at all points in a grid.

Parameters
fcnFunction of interest. Must receive a kjb::Vector and return a double. Its type can be anything that is callablle with the correct signature.
boundsBounds (one pair of upper and lower bounds per dimension) of region of integration.
nbinsNumber of bins in grid.

The runtime of this function grows exponentially with the number of dimensions. Please only use for proof-of-concept or testing.

void kjb::Gsl_Etx_impl ( int  gsl_code,
const char *  file,
unsigned  line_no 
)
inline

On GSL error of some kind, throw an KJB_error exception.

Exceptions
KJB_errorif the gsl_code is not equal to GSL_SUCCESS

Please consider using the GSL_ETX macro instead of calling this directly.

GSL is the GNU Scientific Library. GSL routines usually return a status code that is either GSL_SUCCESS or some sort of coded value describing the lack of success. GSL error codes are describe at the link below: http://www.gnu.org/software/gsl/manual/html_node/Error-Codes.html

The design goal of this function is to be as efficient as possible to inline, and therefore to defer as much as possible to the helper function report_gsl_failure_and_throw_kjb_error, which implements the error action. That's why there are no local variables.

double kjb::gsl_evaluate_Nd_boost_function ( const gsl_vector v,
void *  params 
)
inline
void kjb::gsl_iterate_EPE ( int  gsl_error_code)

On error, print a GSL iteration error message (like EPE)

kjb::Gsl_rng_template ( Gsl_rng_mt19937  ,
gsl_rng_mt19937  ,
GSL_RNG_MT19937   
)
kjb::Gsl_rng_template ( Gsl_rng_ranlxs0  ,
gsl_rng_ranlxs0  ,
GSL_RNG_RANLXS0   
)
kjb::Gsl_rng_template ( Gsl_rng_ranlxs1  ,
gsl_rng_ranlxs1  ,
GSL_RNG_RANLXS1   
)
kjb::Gsl_rng_template ( Gsl_rng_ranlxs2  ,
gsl_rng_ranlxs2  ,
GSL_RNG_RANLXS2   
)
kjb::Gsl_rng_template ( Gsl_rng_ranlxd1  ,
gsl_rng_ranlxd1  ,
GSL_RNG_RANLXD1   
)
kjb::Gsl_rng_template ( Gsl_rng_ranlxd2  ,
gsl_rng_ranlxd2  ,
GSL_RNG_RANLXD2   
)
kjb::Gsl_rng_template ( Gsl_rng_cmrg  ,
gsl_rng_cmrg  ,
GSL_RNG_CMRG   
)
kjb::Gsl_rng_template ( Gsl_rng_mrg  ,
gsl_rng_mrg  ,
GSL_RNG_MRG   
)
kjb::Gsl_rng_template ( Gsl_rng_taus2  ,
gsl_rng_taus2  ,
GSL_RNG_TAUS2   
)
kjb::Gsl_rng_template ( Gsl_rng_gfsr4  ,
gsl_rng_gfsr4  ,
GSL_RNG_GFSR4   
)
double kjb::gstat_helper ( int  O,
int  E 
)
inline

Compute the G-test value for a single element.

template<class Func , class Model , class Adapter >
Matrix kjb::hessian ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the Hessian of a function, evaluated at a point, using finite differences.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Matrix kjb::hessian ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the Hessian of a function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Matrix kjb::hessian_diagonal ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the diagonal Hessian of a function, evaluated at a point, using finite differences.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Matrix kjb::hessian_diagonal ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the Hessian of a function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Matrix kjb::hessian_ind ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the Hessian of a function, evaluated at a point, using finite differences.

Parameters
fA function that recieves a Model const-ref and two indices and returns a double. f(x, i, j) may be any function that differs from f(x) by constant offset for any values of x_i and x_j. This permits terms not involving x_i and x_j to be ignored, saving computation time.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Matrix kjb::hessian_ind ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the Hessian of a "independent" function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Vector kjb::hessian_ind_diagonal ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter,
size_t  is,
size_t  ie 
)

Computes the Hessian diagonal of a function, evaluated at a point, using finite differences.

Parameters
fA function that recieves a Model const-ref and two indices and returns a double. f(x, i) may be any function that differs from f(x) by constant offset for any values of x_i. This permits terms not involving x_i to be ignored, saving computation time.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Vector kjb::hessian_ind_diagonal ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx,
size_t  is,
size_t  ie 
)
inline

Computes the Hessian diagonal of a "independent" function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Matrix kjb::hessian_symmetric ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the Hessian of a function, evaluated at a point, using finite differences. This function assumes that the Hessian is SYMMETRIC, and only computes the lower triangle of it.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Matrix kjb::hessian_symmetric ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the Hessian of a function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
template<class Func , class Model , class Adapter >
Matrix kjb::hessian_symmetric_ind ( const Func &  f,
const Model &  x,
const std::vector< double > &  dx,
const Adapter &  adapter 
)

Computes the Hessian of an "independent" function, evaluated at a point, using finite differences. This function assumes that the Hessian is SYMMETRIC, and only computes the lower triangle of it.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
adapterAdapts a model type to behave as a vector. If the model type has operator[] and size() implemented, then use the default. Otherwise, provide a class which implements get(), set(), and size() for your model type. See Vector_adapater for more information.
template<class Func , class Vec >
Matrix kjb::hessian_symmetric_ind ( const Func &  f,
const Vec &  x,
const std::vector< double > &  dx 
)
inline

Computes the Hessian of an "independent" function, evaluated at a point, for a vector-style model.

Parameters
fA function that recieves a Model const-ref and returns a double.
xThe point at which the Hessian is to be evaluated.
dxThe step sizes in each of the dimensions of x.
Bounding_Box2D kjb::intersect ( const Bounding_Box2D &  b1,
const Bounding_Box2D &  b2 
)

find the intersection between two bounding boxes

bool kjb::intersect_3D_line_with_plane ( kjb::Vector intersection,
double &  t,
const kjb::Vector point,
const kjb::Vector direction,
const kjb::Vector plane 
)

TODO: Document me!

bool kjb::intersect_hulls ( const std::vector< Matrix > &  pts,
Matrix &  hull_vertices,
std::vector< Matrix > &  hull_facets 
)

Compute the intersections of the vector of points.

/\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\

Parameters
ptsis a vector points on the convex hulls
double kjb::intersect_line_with_plane ( const kjb::Vector line_point,
const kjb::Vector line_direction,
const kjb::Vector plane_point,
const kjb::Vector plane_normal 
)
inline

Intersection of a D-dimensional line and plane, using point-vector representation for both. No exceptions are thrown for degenerate cases; instead, mathematically sensible sentinal values are returned (see notes below for details).

Parameters
line_pointA point on the line
line_directionThe line's direction vector (not necessarilly unit-length)
plane_pointA point on the plane
plane_normalThe plane's normal (must be unit length (?))
Returns
The scalar t such that the intersection point p can be obtained by: p = line_point + t * line_direction;
Note
If no intersection occurs (line and plane are parallel), we say the intersection occurs at infinity, and std::numeric_limits<double>::infinity() is returned.
If plane and line are coincident, intersection occurs at all points along the line, and no single solution exists. In this case, std::numeric_limits<double>::quiet_NaN() is returned.
template<std::size_t D>
double kjb::intersect_line_with_plane ( const kjb::Vector_d< D > &  line_point,
const kjb::Vector_d< D > &  line_direction,
const kjb::Vector_d< D > &  plane_point,
const kjb::Vector_d< D > &  plane_normal 
)
inline

intersect a D-dimensional line an plane, using point-vector representation. (static version)

template<class VectorType >
double kjb::intersect_line_with_plane_dispatch_ ( const VectorType &  line_point,
const VectorType &  line_direction,
const VectorType &  plane_point,
const VectorType &  plane_normal 
)

Do not call directly.

std::string kjb::kjb_get_error ( )

similar to kjb_c::kjb_get_error(), but this returns std::string.

void kjb::kjb_opengl_debug_display_buffer ( )

Pop up a window displaying the opengl color buffer.

This pops up a window to display the contents of the opengl color buffer during debugging.

This is intentionally in the global namespace to make it callable inside gdb using "print kjb_opengl_debug_display_buffer()".

Since it's difficult to know exactly the format of the active buffer, this simply assumes it's grayscale and reads the red component only. This should be good enough for debugging.

void kjb::kjb_serialize ( boost::archive::text_iarchive &  ar,
Matrix &  obj,
const unsigned int  version 
)
void kjb::kjb_serialize ( boost::archive::text_oarchive &  ar,
Matrix &  obj,
const unsigned int  version 
)
void kjb::kjb_serialize ( boost::archive::text_iarchive &  ar,
Vector &  obj,
const unsigned int  version 
)
void kjb::kjb_serialize ( boost::archive::text_oarchive &  ar,
Vector &  obj,
const unsigned int  version 
)
template<class Archive , class KJB_readable_writable >
void kjb::kjb_serialize ( Archive &  ar,
KJB_readable_writable &  obj,
const unsigned int  version 
)
template<class Archive , class KJB_readable_writable >
void kjb::kjb_serialize_default ( Archive &  ar,
KJB_readable_writable &  obj,
const unsigned  int 
)

Implements boost serialization for any object that implements the KjbReadableWritable concept.

This function enables serialization for any Swappable class that can be constructed by receiving a filename, and implements a write(fname) method. In general serialization should be implemented manually, but for kjb_c wrapped structures, manual wrapping is ill-advised for maintainability reasons. This function makes those classes serializable.

Warning
This function is used by the boost library's serialization routines and should almost never be called directly.
Note
this function could have been called "serialize", which would allow boost to automatically serialize any classes modelling KjbReadableWritable. However, since this function is rather ineffecient and not preferred if there are more sensible alternatives, we chose this function name so class authors are forced to explicitly call this function from the class's serialize() method.
See Also
KjbReadableWritable_concept, Swappable_concept
template<class C >
size_t kjb::length ( const C &  cner)

Counts the total number of elements in a 2D STL-style container.

template<class Iterator , class Real >
std::iterator_traits<Iterator>::value_type kjb::lerp ( Iterator  begin,
Iterator  end,
Real  x 
)

Linearly interpolate a set of reference values.

Iterators represent a set of uniformly-spaced reference values, with the first element corresponding to 0.0, and the last element corresponding to 1.0. Iterators may refer to any value that is closed under self-addition and multiplication by scalar double.

Parameters
beginIterator to first element of reference set
endIterator to one-after-last element of reference set
xValue to interpolate; should be scaled to be within [0.0, 1.0]. Values outside this range will be clamped to [0.0, 1.0].

Tags: Linear interpolation

template<class IIterator , class OIterator , class QueryType >
std::iterator_traits<OIterator>::value_type kjb::lerp ( IIterator  ibegin,
IIterator  iend,
OIterator  obegin,
const QueryType &  query_point 
)

Evaluate a piecewise-linear function defined by a set of input/output samples.

Function is specified as two random-acess iterators: one containing function inputs, the other containing function outputs. Inputs must be partially ordered. The both types must be equality and less-than comparable.

Parameters
in_beginbegin iterator to function input values
in_endend itertor to function input values
out_beginbegin iterator to function output values
out_endend iterator to function output values
query_pointA point in the domain of this function to evaluate
Returns
The function value evaluated at query point, interpolated between the two nearest keypoints
Template Parameters
Query_typeInput point; must be convertible to Key_type
Exceptions
Index_out_of_boundsif query_point lies outside of the domain of the given function.
template<class Key_type , class Value_type , class Query_type >
Value_type kjb::lerp ( const std::map< Key_type, Value_type > &  piecewise_function,
const Query_type &  query_point 
)

Evaluate a piecewise-linear function defined by a set of input/output samples.

Function is specified as a key-value map containing function outputs for various sampled inputs. The key-values must be equality and less-than comparable.

Parameters
piecewise_functionA set of key-value pairs representing input/output samples/changepoints
query_pointA point in the domain of this function to evaluate
Returns
a key, value pair containing the interpolated input and output values.
Template Parameters
Query_typeInput point; must be convertible to Key_type
Exceptions
Index_out_of_boundsif query_point lies outside of the domain of the given function.
Matrix kjb::lerp_extrinsic_camera_matrix ( const Matrix &  m1,
const Matrix &  m2,
double  t,
bool  use_slerp = false 
)

Linearly-interpolate a two extrinsic camera matrices.

Linearly-interpolate a twp extrinsic camera matrices. "slerp" (quaternion spherical linear interpolation) is used for interpolation of orientations, while standard linear interpolation is used for translation.

r

Parameters
tlinear interpolation parameter, must be scaled to be in [0,1]
use_slerpUse spherical interpolation of angles instead of linear. Spherical exhibits constant rotational speed, while linear speeds up in the middle, but is more efficient to compute
Matrix kjb::lerp_extrinsic_camera_matrix ( const std::vector< Matrix > &  extrinsic,
const std::vector< double > &  timestamps,
double  t,
bool  use_slerp = false 
)

Linearly-interpolate a set of extrinsic camera matrix at given timestamps.

Linearly-interpolate a set of extrinsic camera matrix at given timestamps.

"slerp" (quaternion spherical linear interpolation) is used for interpolation of orientations, while standard linear interpolation is used for translation.

Precondition
timestamps is sorted ascending
t >= timestamps.front() && t <= timestamps.back()
template<class ForwardIterator >
void kjb::linspace ( double  min,
double  max,
size_t  n,
ForwardIterator  begin,
bool  endpoint = true 
)

A generator function that fills a range with linearly-spaced values between min and max, inclusive. The functionality is intended to match that of matlab's linspace built-in.

Parameters
beginiterator to output collection
endpointinclude endpoint in interval (closed interval)
Author
Kyle Simek
template<class InType , class OutIterator , class UnaryOperator >
void kjb::linspace ( const InType &  lower,
const InType &  upper,
size_t  N,
const OutIterator &  out_begin,
const UnaryOperator &  f 
)

Alternative version of linspace that recieves a transforms function which operates on the the linearly-spaced values.

Bounary points will be included in the output and passed to the provided function.

Input type must implement multiplication-by-scalar and addition.

The function will always be evaluated at the extrema, therefore N must be at least 2.

Parameters
lowerOne end of the input range (not necessarilly lower)
upper
Nnumer of positions along range to evaluate (must be >= 2)
out_beginIterator to output sequence. Must have size at least N
ffunction to evaluate. Must receive one argument of type InType, and return type must be the value_type of the output iterator. @
template<class InType , class OutIterator >
void kjb::linspace ( InType  min,
InType  max,
size_t  n,
OutIterator  begin 
)

A generic version of linspace that operates on a generic type, using linear interpolation. Input type must imlement addition and multiplication-by-scalar.

Parameters
minOne end of value range (not necessarilly lower than max)
maxOther end of value range
nnumber of values to output (min and max are always output, so n must be >= 2)
beginiterator to output collection
Note
min does not need to be less than max. if max < min, the sequence will simply be descending.
Template Parameters
InTypeType to be interpolated
OutIteratorpointer to output colleciton. InType must be convertible to OutIterator::value_type must be
Author
Kyle Simek
template<class Serializable >
void kjb::load ( Serializable &  ,
const std::string &   
)

Unserialize an object file.

This assumes that:

The object was serialized by value The object was saved to an ascii format using text_oarchive, The file contains only this object

All three of these criteria are satisfied by the kjb::save() function. Assuming the serialization routine and equality operator are implemented correctly, the test below should always pass:

My_obj o; My_obj o2 = o;

save(o, "filename"); load(o2, "filename"); assert(o == o2);

Author
Kyle Simek
void kjb::load ( Edge_set &  edges,
const std::string &  fname 
)
inline
template<class SerializableOutputIterator >
void kjb::load_many ( SerializableOutputIterator  it,
const std::string &  fmt_str,
const Index_range &  indices 
)

Load a sequence of files into a collection.

Template Parameters
SerializableOutputIteratorIterator whose value_type is Serializable
Parameters
iteratorto first element of collection that will receive the loaded files
fmt_strPrintf-formatted string representing the file sequence. Must include some form of "%d" string.
indicesAn Index_range describing which files in the sequence to load. As an alternative to passing an Index_range explicity, you may pass any of the common representations listed below.
Note
indices may be passed any of the following: std::vector of type convertible to size_t std::list of type convertible to size_t kjb::Int_vector Matlab-formatted string (i.e. "1:2:100") int or size_t
template<class SerializableOutputIterator >
void kjb::load_many ( SerializableOutputIterator  it,
const std::string &  fmt_str,
size_t  num_files,
size_t  first_index = 0,
size_t  modulo = 0 
)

Load a sequence of files into a collection.

Template Parameters
SerializableOutputIteratorIterator whose value_type is Serializable
Parameters
iteratorto first element of collection that will receive the loaded files
fmt_strPrintf-formatted string representing the file sequence. Must include some form of "%d" string.
num_filesNumber of files to read.
first_indexFirst index of file to read (usually 0 or 1).
template<class Value_type , class SerializablePtrOutputIterator >
void kjb::load_many_dynamic_dispatch ( Value_type *  ,
SerializablePtrOutputIterator  it,
const std::string &  fmt_str,
const Index_range &  indices 
)
template<class Value_type , class SerializablePtrOutputIterator >
void kjb::load_many_dynamic_dispatch ( typename boost::shared_ptr< Value_type >  ,
SerializablePtrOutputIterator  it,
const std::string &  fmt_str,
const Index_range &  indices 
)
template<class SerializablePtrOutputIterator >
void kjb::load_many_to_ptr ( SerializablePtrOutputIterator  it,
const std::string &  fmt_str,
size_t  num_files,
size_t  first_index = 0,
size_t  modulo = 1 
)
template<class SerializablePtrOutputIterator , class Index_range_type >
boost::enable_if<boost::is_convertible<Index_range_type, Index_range>,void>::type kjb::load_many_to_ptr ( SerializablePtrOutputIterator  it,
const std::string &  fmt_str,
const Index_range_type &  indices 
)
Note
indices may be any of the following: std::vector of type convertible to size_t std::list of type convertible to size_t kjb::Int_vector Matlab-formatted string (i.e. "1:2:100") int or size_t
double kjb::log_binomial_coefficient ( size_t  n,
size_t  k 
)
double kjb::log_det ( const Matrix M)

For any symmetric positive-definite matrix M, returns the log of the determinant of M. Uses Cholesky decomposition.

double kjb::log_diff ( double  n1,
double  n2 
)
inline

Take the difference of two probabilities represented in log-space without risk of underflow (copied from the analogous log_sum function; implemented separately to be able to apply over two arrays without needing to multiply everything in the array by -1

Author
Colin Dawson
Vector kjb::log_marginalize_over_cols ( const Matrix &  mat)

marginalize down the columns of a matrix of log probabilities

Author
Colin Dawson
Vector kjb::log_marginalize_over_rows ( const Matrix &  mat)

marginalize across the rows of a matrix of log probabilities

Author
Colin Dawson
Vector kjb::log_normalize ( const Vector &  vec)

normalize a probability vector in log space

Author
Colin Dawson
Vector kjb::log_normalize_and_exponentiate ( const Vector &  vec)

normalize and exponentiate a vector of unnormalized log probabilities

Author
Colin Dawson
Matrix kjb::log_normalize_and_exponentiate ( const Matrix &  mat)

row-wise normalize and exponentiate a matrix of log probabilities

Author
Colin Dawson
Matrix kjb::log_normalize_rows ( const Matrix &  mat)

normalize the rows of a stochastic matrix in log space

Author
Colin Dawson
double kjb::log_pdf ( const MV_gaussian_distribution &  P,
const Vector &  x 
)

Computes the log PDF a multivariate normal distribution at x.

This is a specialization of the generic joint_log_pdf function. It is specialized to avoid the computation of the log of the exponential.

double kjb::log_pdf ( const Beta_binomial_distribution &  dist,
double  k 
)
inline

Computes the log PDF of a Beta-binomial distribution at k.

template<size_t D>
double kjb::log_pdf ( const Von_mises_fisher_distribution< D > &  dist,
const kjb::Vector_d< D > &  v 
)
inline
double kjb::log_pdf ( const Chinese_restaurant_process &  cpr,
const Chinese_restaurant_process::Type &  B 
)

log-PDF of the CPR.

template<size_t D>
double kjb::log_pdf ( const Uniform_sphere_distribution< D > &  ,
const kjb::Vector_d< D > &   
)
inline

Computes the log PDF of a uniform distribution over the surface of the unit sphere in D-dimensional Euclidean space. The density is given in D-1 dimensional euclidean units.

It returns 1/S, where S is the surface area of a D-dimensional unit-sphere

template<class Distribution >
double kjb::log_pdf ( const Distribution &  P,
const typename Distribution_traits< Distribution >::type &  x 
)
inline

Computes the log PDF of a distribution at x.

This simply returns log(pdf(P, x)); please specialize for best results.

double kjb::log_pdf ( const Gaussian_distribution &  P,
double  x 
)
inline

Computes the log PDF a normal distribution at x.

This is a specialization of the generic log_pdf function. It is specialized to avoid the computation of the log of the exponential.

double kjb::log_pdf ( const Laplace_distribution &  P,
double  x 
)
inline

Computes the log PDF a Laplace distribution at x.

This is a specialization of the generic log_pdf function. It is specialized to avoid the computation of the log of the exponential.

double kjb::log_pdf ( const Binomial_distribution &  P,
double  k 
)
inline

Computes the log PDF a normal distribution at x.

This is a specialization of the generic log_pdf function. It is specialized to avoid the computation of the log of the exponential.

double kjb::log_sum ( double  n1,
double  n2 
)
inline

Take the sum of two probabilities represented in log-space without risk of underflow.

This is useful for marginalization and normalization of sets of very small numbers.

Author
Kyle Simek
double kjb::log_sum ( double  n1,
double  n2,
double  n3 
)
inline

Take the sum of three probabilities represented in log-space without risk of underflow.

In other words, return log(exp(n1) + exp(n2)), even if exponentiating any of the numbers would normally result in underflow.

This is useful for marginalization and normalization of sets of very small numbers.

Author
Kyle Simek
template<class Iterator >
double kjb::log_sum ( Iterator  first,
Iterator  last 
)

Take the log-sum of N probabilies represented in log-space without risk of underflow. In other words, return log(exp(n1) + exp(n2)), even if exponentiating any of the numbers would normally result in underflow.

This is useful for marginalization and normalization of sets of very small numbers.

Author
Kyle Simek
template<class ForwardIterator >
void kjb::logspace ( double  min,
double  max,
size_t  n,
ForwardIterator  begin 
)

Emulates matlab's logspace operator

std::vector< Feature_pair > kjb::look_up_bg_features ( const Flow_feature_set of_set,
const std::vector< Axis_aligned_rectangle_2d > &  model_boxes 
)

Given the features and all the model boxes at cur_frame, find all the background features.

std::vector< Feature_pair > kjb::look_up_features ( const Flow_feature_set of_set,
const Axis_aligned_rectangle_2d box 
)

Given the features and a bounding box at the same frame, find and return the detected features inside the bounding box.

Vector kjb::lookup_feature ( const Flow_feature_set of_set,
size_t  x,
size_t  y,
size_t  subsample_sz = 1 
)

Looks up a feature in a feature set; deals with subsampling.

template<class iterator >
circular_iterator<iterator> kjb::make_circular_iterator ( iterator  begin,
iterator  end 
)
inline
template<class Container >
circular_iterator<typename Container::iterator> kjb::make_circular_iterator ( Container &  container)
inline
template<class const_iterator >
const_circular_iterator<const_iterator> kjb::make_const_circular_iterator ( const_iterator  begin,
const_iterator  end 
)
inline
template<class Container >
const_circular_iterator<typename Container::const_iterator> kjb::make_const_circular_iterator ( const Container &  container)
inline
std::pair<double, int> kjb::make_double_int_pair_ ( double  d,
int  i 
)
inline
Matrix_d< 2, 2 > kjb::matrix_inverse ( const Matrix_d< 2, 2 > &  m)
Matrix_d< 3, 3 > kjb::matrix_inverse ( const Matrix_d< 3, 3 > &  m)
template<class Matrix_type_1 , class Matrix_type_2 >
Matrix_d< Matrix_type_1::num_rows, Matrix_type_2::num_cols > kjb::matrix_multiply_dispatch_ ( const Matrix_type_1 &  m1,
const Matrix_type_2 &  m2 
)

Utility dispatch for m1 * m2 operator. Assumes compile-time dimension checks have already occurred.

Don't call me directly!

template<class Matrix_1 , class Matrix_2 >
Matrix kjb::matrix_multiply_dynamic_dispatch_ ( const Matrix_1 &  m1,
const Matrix_2 &  m2 
)

don't call me directly

template<std::size_t R, std::size_t C, bool T>
double kjb::max ( const Matrix_d< R, C, T > &  mat)
inline

returns the maximum element of a matrix

template<std::size_t R, std::size_t C>
double kjb::max_abs_difference ( const Matrix_d< R, C, false > &  op1,
const Matrix_d< R, C, false > &  op2 
)
template<class Iterator , class Value_type >
Value_type kjb::mean ( Iterator  begin,
Iterator  end,
const Value_type &   
)

Compute the algebraic mean of a collection of elements. Note that since the Null-value in general is unknown, the collection must have at least one element.

This version of mean is called by the simpler version, mean(begin, end). This version receives a value-type as a third parameter, allowing users to overload this signature for specific Value_type's.

difference(begin, end) > 0

template<class Iterator >
std::iterator_traits<Iterator>::value_type kjb::mean ( Iterator  begin,
Iterator  end = Iterator() 
)

Compute the algebraic mean of a collection of elements. Note that since the Null-value in general is unknown, the collection must have at least one element.

This function simply dispatches to a more type-specific version mean(Iterator begin, Iterator end, Value_type dummy). Users wishing to specialize mean based on the value-type should overload the other version, since the value-type is in the signature.

difference(begin, end) > 0

template<std::size_t R, std::size_t C, bool T>
double kjb::min ( const Matrix_d< R, C, T > &  mat)
inline

returns the minimum element of a matrix

int kjb::min_bipartite_match ( const Matrix &  weights,
Int_vector *  assignment,
Matrix::Value_type *  cost 
)

solve a matching with minimum cost in a complete bipartite graph.

This does NOT use the Hungarian algorithm. It uses a dynamic programming approach, and it is slower but simple to understand. It might be too slow if the graph is large.

The input graph is implicitly a complete bipartite graph G=(L,R,E,w) where L = (l0, l1, . . . , lM) and R = (r0, r1, . . . , rN) are the disjoint sets of vertices, E is the edge set, and w : E –> R is the weight function. Every weight must be nonnegative, because it denotes a cost. Costs are additive, so the optimal assignment is the sum of the selected edges, and this routine computes an optimum in the sense that no other assignment has smaller total cost.

Parameters
[in]weightsMatrix of weights, where the value at row i and column j equals the weight of edge {li,rj}.
[out]assignmentPoints to vector into which the output will be written; it will be resized to length (M+1). If N==M, assignment->at(i) = j denotes that edge {li,rj} is in the optimal matching. However, entries of '-1' occur when N > M, and they indicate unassigned vertices of L. This pointer must not equal null.
[out]costOptional output pointer; if not equal to null, then *cost will contain the total cost of assignment.
Returns
ERROR or NO_ERROR depending on outcome.
template<class InIter >
Beta_distribution kjb::mle_beta ( InIter  first,
InIter  last 
)
template<class InIter >
Gamma_distribution kjb::mle_gamma ( InIter  first,
InIter  last 
)
template<class InIter >
Normal_distribution kjb::mle_normal ( InIter  first,
InIter  last 
)
inline
template<size_t D, class InIter >
Von_mises_fisher_distribution<D> kjb::mle_vmf ( InIter  first,
InIter  last 
)
template<typename T >
T& kjb::move ( T &  v)
inline
template<typename T >
const T& kjb::move ( const T &  v)
inline
template<class Model , class Adapter >
void kjb::move_param ( Model &  x,
size_t  i,
double  dv,
const Adapter &  aptr 
)
inline

Helper function that moves a parameter by an amount.

template<class Model , class Adapter >
void kjb::move_params ( Model &  x,
size_t  i,
size_t  j,
double  dv,
double  dw,
const Adapter &  aptr 
)
inline

Helper function that moves a pair of parameters by an amount.

template<class Model , class Vec , class Adapter >
void kjb::move_params ( Model &  x,
const Vec &  dx,
const Adapter &  aptr 
)

Helper function that moves all parameters by specified vector.

Matrix kjb::ned13_grid ( const TopoFusion::pt &  center,
int  eastwest_size_meters = 2000,
int  northsouth_size_meters = 2000,
int  resolution_meters = 1,
Ned13_caching_reader *  cache = 0,
const std::vector< std::string > &  path = std::vector< std::string >() 
)
inline

generate a grid of elevation values between points at a location

Parameters
centerUTM center point for grid
eastwest_size_meterssize of the grid, affecting column count
northsouth_size_meterssize of the grid, affecting row count
resolution_metersnumber of meters between pixel rows or columns
cacheoptional cache object possibly storing DEM tiles
pathoptional vector of directory names to search for tiles

Pixels are assumed square, as measured in meters.

The cache can be any of the reader classes, and as you know they offer polymorphic behavior to interpolate elevation at query points between known NED13 data. However, this function does not inherit that behavior. It interpolates its own way (at present, by using a Gaussian process/kriging).

Bug:
(August 2013) this returns bad results when the requested grid spans more than a single one-degree grid.
int kjb::ned13_grid ( const TopoFusion::pt &  center,
Matrix *  elev_o,
Matrix *  elev_de_o,
Matrix *  elev_dn_o,
int  eastwest_size_meters = 2000,
int  northsouth_size_meters = 2000,
int  resolution_meters = 1,
Ned13_caching_reader *  cache = 0,
const std::vector< std::string > &  path = std::vector< std::string >() 
)

generate a grid describing an elevation model near some location

Parameters
[in]centerUTM center point for grid
[out]elev_ooutput pointer: where to store elevation values
[out]elev_de_ooutput pointer for elevation eastern gradient
[out]elev_dn_ooutput pointer for elevation northern gradient
[in]eastwest_size_meterssize of the grid, affecting column count
[in]northsouth_size_meterssize of the grid, affecting row count
[in]resolution_metersnumber of meters between pixel rows or columns
[in]cacheoptional cache object possibly storing DEM tiles
[in]pathoptional vector of directory names to search for tiles
Returns
kjb_c::ERROR or kjb_c::NO_ERROR as appropriate

Pixels are assumed square, as measured in meters.

The cache can be any of the reader classes, and as you know they offer polymorphic behavior to interpolate elevation at query points between known NED13 data. However, this function does not inherit that behavior. It interpolates its own way (at present, by using a Gaussian process/kriging).

The cache input is not const because the cache might change as we read elevation points from it, since it remembers the grids it queries.

Any of the Matrix pointers elev_o, elev_de_o, elev_dn_o may be passed in with a value of NULL to indicate that the corresponding output is unneeded.

See Also
ned_visualize_grid for a nice visualization of the output
TopoFusion::pt kjb::ned13_ill_to_utm ( const Ned13_one_degree_grid::IntegralLL &  i)

convert to UTM coordinates (no elevation)

int kjb::ned_fdeq_to_matrix ( const std::deque< float > &  ibuf,
Matrix *  omat 
)

convert a deque of floats into a square kjb Matrix

Returns
kjb_c::ERROR or kjb_c::NO_ERROR to indicate failure or success
Parameters
[in]ibufDeque of floating point values, possibly derived from get_ned_fdeq(). The number of entries must be a positive square.
[out]omatPointer to matrix into which to store the data. It must not equal null. Previous contents (if any) will be clobbered. Data are copied in row-major order.
Image kjb::ned_visualize_grid ( const Matrix &  elev_o,
const Matrix &  elev_de_o,
const Matrix &  elev_dn_o,
int  decimation = 1,
int  bar_length = 0 
)

show NED grid output in visual form

Parameters
elev_oGrid of elevation values
elev_de_oGrid of east-west elevation gradient values
elev_dn_oGrid of north-south elevation gradient values
decimationOptional decimation factor, to shrink output size
bar_lengthOptional length of key color bars in top left
Returns
Image showing elevation, which looks sort of like a relief map.
Exceptions
KJB_errorif the input matrices are not all the same size

The first 3 parameters must all be the same size and are expected to be the outputs of an elevation grid such as a ned13_grid. The decimation factor can shrink the output image, which might be convenient. For example, if decimation==3 then the output will have only one-third the number of rows and columns as elev_o.

The bar_length parameter defaults to 0, which means "do not draw bars." If bar_length is positive, it sets the length, in pixels, of lines drawn at the top left corner, which remind the viewer of which color indicates which gradient: red shows incline uphill going west to east, green shows incline uphill going north to south. The latter is arguably backwards, but our human visual habits expect illumination from "above," and so these visualizations look like there is green light shining from "above," north, and also red light shining from the left (west) edge, like a sunset.

There is another tweak: on many display media, each unit of green is incrementally more salient than the same unit of red. In fact it is kind of obnoxious. So, the green channel is diminished from the value it would have in a perfectly equitable world. Thus, a low flat area will probably look brown, not olive. I call the less-than-unity-gain the "tone it down, green" factor.

The visualization normalizes all the inputs, so on very flat terrain, the output visualization might be dominated by kriging artifacts or noise.

template<class M , class A >
bool kjb::next_point ( const std::vector< std::pair< double, double > > &  bounds,
const std::vector< double > &  widths,
size_t  nbins,
std::vector< size_t > &  indices,
M &  x,
const A &  adapter 
)

Gets the next point in a N-dimensional grid.

Quaternion kjb::nlerp ( const Quaternion &  q1,
const Quaternion &  q2,
double  t 
)

Normalized linear interpolation of two quaternions. More efficient than slerp, but rotation rate is non-constant.

double kjb::norm ( const Quaternion &  q,
unsigned int  l = 2 
)
inline
template<size_t D>
bool kjb::operator!= ( const Weight_array< D > &  left,
const Weight_array< D > &  right 
)
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
bool kjb::operator!= ( const Matrix &  op2,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op1 
)
inline
Matrix kjb::operator* ( const Matrix &  in,
const Filter &  mask 
)
template<size_t D>
Weight_array< D > kjb::operator* ( const Weight_array< D > &  left,
const Weight_array< D > &  right 
)
template<size_t D>
Weight_array< D > kjb::operator* ( const Weight_array< D > &  w,
const typename Weight_array< D >::Val_type &  scale 
)
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS, TRANSPOSED > kjb::operator* ( double  scalar,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  mat 
)
inline
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix kjb::operator* ( const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op1,
const Matrix &  op2 
)
inline
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix kjb::operator* ( const kjb::Matrix op1,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op2 
)
inline
Gsl_Vector kjb::operator* ( double  scalar,
const Gsl_Vector &  vector 
)
inline

multiply scalar and vector, scalar written on the left side

template<size_t D>
Weight_array< D > kjb::operator+ ( const Weight_array< D > &  left,
const Weight_array< D > &  right 
)

Free function declarations.

template<size_t D>
Weight_array< D > kjb::operator+ ( const Weight_array< D > &  w,
const typename Weight_array< D >::Val_type &  offset 
)
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS, TRANSPOSED > kjb::operator+ ( const Matrix &  second,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op2 
)
inline
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
Matrix_d< NROWS, NCOLS, TRANSPOSED > kjb::operator- ( const Matrix  op1,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op2 
)
inline
template<size_t D>
Weight_array< D > kjb::operator/ ( const Weight_array< D > &  left,
const Weight_array< D > &  right 
)
template<size_t D>
Weight_array< D > kjb::operator/ ( const Weight_array< D > &  w,
const typename Weight_array< D >::Val_type &  right 
)
bool kjb::operator< ( const Face_detection f1,
const Face_detection f2 
)

Compares to boxes using middle of box. Needed because we have associated containers of these.

bool kjb::operator< ( const kjb::Ned13_one_degree_grid::IntegralLL p,
const kjb::Ned13_one_degree_grid::IntegralLL q 
)
inline

impose an order on coordinate locations (geographically silly).

std::ostream & kjb::operator<< ( std::ostream &  ost,
const Calibration_descriptor::Coord_convention &  mode 
)
std::ostream & kjb::operator<< ( std::ostream &  ost,
Detection_type  type 
)

Stream out an detection.

std::ofstream& kjb::operator<< ( std::ofstream &  out,
const Quaternion &  q 
)
std::ostream& kjb::operator<< ( std::ostream &  ost,
const Face_detection face 
)

Writes the face into ostream.

Note
Pitch, yaw, and roll are in degrees to be consistent with the input files
std::ostream & kjb::operator<< ( std::ostream &  out,
const Edge_segment es 
)
std::ostream & kjb::operator<< ( std::ostream &  ost,
const Axis_aligned_rectangle_2d &  box 
)
template<size_t D>
std::ostream& kjb::operator<< ( std::ostream &  os,
const Weight_array< D > &  wa 
)
template<typename T , size_t D>
std::ostream& kjb::operator<< ( std::ostream &  os,
const boost::array< T, D > &  arr 
)
template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
std::ostream & kjb::operator<< ( std::ostream &  ost,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  mat 
)
std::ostream & kjb::operator<< ( std::ostream &  out,
const Line_segment &  ls 
)
std::ostream & kjb::operator<< ( std::ostream &  out,
const Manhattan_corner mc 
)
std::ostream & kjb::operator<< ( std::ostream &  out,
const Manhattan_corner_segment mcs 
)
std::ostream & kjb::operator<< ( std::ostream &  out,
const Manhattan_segment ms 
)
ostream& kjb::operator<< ( ostream &  out,
const Quaternion &  q 
)
template<size_t D>
bool kjb::operator== ( const Weight_array< D > &  left,
const Weight_array< D > &  right 
)
bool kjb::operator== ( const Ned13_one_degree_grid::IntegralLL &  p,
const Ned13_one_degree_grid::IntegralLL &  q 
)
inline

test two coordinate locations for equality

template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
bool kjb::operator== ( const Matrix &  op2,
const Matrix_d< NROWS, NCOLS, TRANSPOSED > &  op1 
)
inline
bool kjb::operator== ( const Polybezier_curve &  op1,
const Polybezier_curve &  op2 
)
std::istream & kjb::operator>> ( std::istream &  ist,
Calibration_descriptor::Coord_convention &  mode 
)
std::istream & kjb::operator>> ( std::istream &  ist,
Detection_type type 
)

Stream in an detection.

std::istream & kjb::operator>> ( std::istream &  ist,
Axis_aligned_rectangle_2d &  box 
)
template<class IIterator , class OIterator , class I2Iterator , class O2Iterator >
void kjb::ordered_lerp ( IIterator  ibegin,
IIterator  iend,
OIterator  obegin,
I2Iterator  i2begin,
I2Iterator  i2end,
O2Iterator  o2begin 
)

Evaluate a piecewise-linear function defined by a set of input/output samples. This version is optimized to perform multiple evaluations in a single pass, assuming the query points are ordered. If query points aren't ordered, behavior is undefined.

Parameters
ibeginbegin iterator to function input values
iendend itertor to function input values
obeginbegin iterator to function output values (an inputIterator)
i2beginbegin iterator to set of ordered query points
i2endend iterator to set of ordered query points
o2beginoutput iterator for set of linearly interpolated output values.
template<std::size_t D>
Matrix_d< D, D > kjb::outer_product ( const Vector_d< D > &  v1,
const Vector_d< D > &  v2 
)
inline

compute the outer produce of two vectors (v1' * v2)

std::vector< Deva_detection > kjb::parse_deva_detection ( std::istream &  is,
const std::string &  type = std::string("person") 
)

Parse the output from Deva's part detector into a vector of Deva_detection.

std::vector< Deva_detection > kjb::parse_deva_detection ( std::istream &  is,
double  score_thresh,
const std::string &  type = std::string("person") 
)

Parse the output from Deva's part detector and prune by the confidence score.

Deva_detection kjb::parse_deva_detection_line ( const std::string &  line,
const std::string &  type = std::string("person") 
)

Parse the output from Deva's part detector.

std::vector< Deva_facemark > kjb::parse_deva_facemark ( std::istream &  is)

Parse the output from Deva's face detector into a vector of Deva_facemark.

Deva_facemark kjb::parse_deva_facemark_line ( const std::string &  line)

Parse the output from Deva's face detector.

Face_detection kjb::parse_face_line ( const std::string &  line)

Parse a line of a file (in face.com format) into a Face_Detection.

double kjb::pdf ( const MV_gaussian_distribution &  P,
const Vector &  x 
)

Computes the joint PDF of a multivariate Gaussian at x.

double kjb::pdf ( const Geometric_distribution &  dist,
double  x 
)
inline

Computes the PMF of a geometric distribution at x.

double kjb::pdf ( const Log_normal_distribution &  dist,
double  x 
)
inline

Computes the PDF of a log-normal distribution at x.

template<class T >
double kjb::pdf ( const Categorical_distribution< T > &  dist,
const T &  x 
)
inline

Computes the PMF of a categorical distribution at x.

template<class Distribution >
double kjb::pdf ( const Mixture_distribution< Distribution > &  dist,
const typename Distribution_traits< Mixture_distribution< Distribution > >::type &  x 
)

Computes the PDF/PMF of a mixture distribution at x.

double kjb::pdf ( const Chinese_restaurant_process &  cpr,
const Chinese_restaurant_process::Type &  B 
)

PDF of the CPR.

double kjb::pdf ( const Gaussian_distribution &  P,
double  x 
)
inline

Compute pdf of a Gaussian distribution.

double kjb::pdf ( const Beta_binomial_distribution &  dist,
double  k 
)
inline

Evaluate the probability density function of a Beta-binomial distribution.

template<size_t D>
double kjb::pdf ( const Von_mises_fisher_distribution< D > &  dist,
const kjb::Vector_d< D > &  v 
)
inline

Evaluate the probability density function of a Von-mises Fisher distribtuion (x's magnitude is ignored/assumed 1.0)

template<size_t D>
double kjb::pdf ( const Uniform_sphere_distribution< D > &  P,
const kjb::Vector_d< D > &  x 
)
inline

Evaluate the probability density function of a uniform sphere distribution (x's magnitude is ignored / assumed 1.0)

void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const Polymesh p,
const Base_gl_interface eye 
)

Prepares a set of model edges from a polymesh.

The extrema of each edge are projected onto the image plane using the current gl projection and modelview matrices. Each projected edge is stored as a line segment having as extrema the projections of the extrema of the 3D polymesh edge. We also check for each edge whether it is part of the silhoutte of the polymesh or if it is an inner edge (we need the camera to do this test).

Prepares a set of model edges from a polymesh. The extrema of each edge are projected onto the image plane using the current gl projection and modelview matrices. Each projected edge is stored as a line segment having as extrema the projections of the extrema of the 3D polymesh edge. We also check for each edge whether it is part of the silhoutte of the polymesh or if it is an inner edge (we need the camera to do this test)

Parameters
edgesWill containt the projected edges
pThe input polymesh
eyeThe camera used to render this mesh
void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const std::vector< const Polymesh * > &  ps,
const Base_gl_interface eye 
)

Prepares a set of model edges from a vector of polymeshes.

The extrema of each edge are projected onto the image plane using the current gl projection and modelview matrices. Each projected edge is stored as a line segment having as extrema the projections of the extrema of the 3D polymesh edge. We also check for each edge whether it is part of the silhoutte of the polymesh or if it is an inner edge (we need the camera to do this test).

void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const std::vector< const Polymesh * > &  ps,
const Base_gl_interface eye,
const Matrix M,
double  width,
double  height,
const std::vector< bool > &  flagged 
)
void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const std::vector< const Polymesh * > &  ps,
const Base_gl_interface eye,
const Matrix M,
double  width,
double  height 
)
void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const Polymesh p,
const Base_gl_interface eye,
const Matrix M,
double  width,
double  height,
bool  flagged 
)

Prepares a set of model edges from a polymesh. The extrema of each edge are projected onto the image plane using the current gl projection and modelview matrices. Each projected edge is stored as a line segment having as extrema the projections of the extrema of the 3D polymesh edge. We also check for each edge whether it is part of the silhoutte of the polymesh or if it is an inner edge (we need the camera to do this test)

Parameters
edgesWill containt the projected edges
pThe input polymesh
eyeThe camera used to render this mesh
void kjb::prepare_model_edges ( std::vector< Model_edge > &  edges,
const Polymesh p,
const Base_gl_interface eye,
const Matrix M,
double  width,
double  height 
)

Prepares a set of model edges from a polymesh. The extrema of each edge are projected onto the image plane using the current gl projection and modelview matrices. Each projected edge is stored as a line segment having as extrema the projections of the extrema of the 3D polymesh edge. We also check for each edge whether it is part of the silhoutte of the polymesh or if it is an inner edge (we need the camera to do this test)

Parameters
edgesWill containt the projected edges
pThe input polymesh
eyeThe camera used to render this mesh
void kjb::prepare_model_map ( Int_matrix model_map,
const Polymesh p 
)

Prepares a model map from a polymesh.

Prepares a model map from a polymesh. Each edge of the polymesh is rendered using its id as a color. The id is obtained by assigning id = 1 to the first edge, and sequentially increasing ids to the following edges.

Each edge of the polymesh is rendered using its id as a color. The id is obtained by assigning id = 1 to the first edge, and sequentially increasing ids to the following edges

Parameters
model_mapWill prepare the model map from the input mesh
pThe mesh that will be rendered onto the map
void kjb::prepare_model_map ( Int_matrix model_map,
const std::vector< const Polymesh * > &  ps 
)

Prepares a model map from a vector of polymeshes.

Each edge of the polymesh is rendered using its id as a color. The id is obtained by assigning id = 1 to the first edge, and sequentially increasing ids to the following edges.

void kjb::prepare_rendered_model_edges ( std::vector< Model_edge > &  edges,
const Int_matrix model_map 
)

Prepares a set of rendered model edges from the model_map.

Prepares a set of renderend model edges from the model_map. TODO: here, we assume each rendered model is a silhoutte edge, which is not true. Will think a better way to determine the silhouette after CVPR.

void kjb::prepare_solid_model_map ( Int_matrix model_map,
const std::vector< const Polymesh * > &  ps 
)

Prepares a model map from a polymesh.

Each face of the polymesh is rendered using its id as a color. The id is obtained by assigning id = 1 to the first face, and sequentially increasing ids to the following faces.

void kjb::prepare_solid_model_map ( Int_matrix model_map,
const Polymesh p 
)

Prepares a model map from a vector of polymeshes.

Each face of the polymesh is rendered using its id as a color. The id is obtained by assigning id = 1 to the first face, and sequentially increasing ids to the following faces.

Vector kjb::project_point_onto_line ( const Vector &  A,
const Vector &  B,
const Vector &  P 
)
inline

Project a point onto a line, in any dimension.

Parameters
AEnd-point of the line.
BEnd-point of the line.
XPoint to project.
void kjb::project_points_onto_plane ( std::vector< Vector > &  points,
const Vector plane_params,
const Vector centroid,
std::vector< Vector > &  projected_points 
)

Projects 3D points onto the best-fit 3D plane.

bool kjb::propose_frame_inside_parapiped_from_orthogonal_corner ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
unsigned int &  face_number,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector idesired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols 
)
bool kjb::propose_frame_inside_parapiped_from_orthogonal_corner_good ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
unsigned int &  face_number,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector idesired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
bool  wall_x,
bool  expand_to_the_ground 
)
bool kjb::propose_frame_inside_parapiped_from_three_corners_on_the_wall ( kjb::Vector centre,
kjb::Vector dimensions,
const Parametric_parapiped pp,
const Perspective_camera camera,
unsigned int &  face_number,
const Manhattan_corner corner1,
const Manhattan_corner corner2,
const Manhattan_corner corner3,
unsigned int  num_rows,
unsigned int  num_cols 
)
double kjb::propose_parapiped_and_camera_from_orthogonal_corner_good ( kjb::Parametric_parapiped pp,
kjb::Perspective_camera camera,
const kjb::Manhattan_corner corner,
double  focal_length,
unsigned int  num_rows,
unsigned int  num_cols,
double  corner_3D_z_position,
double  p_width_ratio,
double  p_height_ratio,
double  p_length_ratio 
)
double kjb::propose_parapiped_and_camera_from_vanishing_points ( kjb::Parametric_parapiped pp,
kjb::Perspective_camera camera,
const std::vector< Vanishing_point > &  vpts,
double  focal_length,
unsigned int  num_rows,
unsigned int  num_cols 
)
bool kjb::propose_parapiped_at_different_depth_from_orthogonal_corner ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_room 
)

Propose supported parapiped inside parapiped from orthogonal_corner The height of the support planes are chosen from feasible ranges

bool kjb::propose_parapiped_inside_parapiped_from_one_corner_in_the_centre_on_the_floor ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
double  desired_height,
double  desired_width,
double  desired_length,
bool &  is_dx,
unsigned int  num_rows,
unsigned int  num_cols 
)
bool kjb::propose_parapiped_inside_parapiped_from_orthogonal_corner ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_room = true 
)
bool kjb::propose_parapiped_inside_parapiped_from_orthogonal_corner_against_wall ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_room,
bool  expand_right,
bool  expand_z_up,
bool  expand_towards_camera 
)
bool kjb::propose_parapiped_inside_parapiped_from_three_corners_on_the_floor ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner1,
const Manhattan_corner corner2,
const Manhattan_corner corner3,
double  desired_height,
unsigned int  num_rows,
unsigned int  num_cols 
)
bool kjb::propose_parapiped_inside_parapiped_from_two_corners_on_the_floor ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner1,
const Manhattan_corner corner2,
double  desired_height,
double  desired_other_dimension_ratio,
bool  direction,
bool &  is_diagonal,
bool &  is_dx,
unsigned int  num_rows,
unsigned int  num_cols 
)
bool kjb::propose_parapiped_onside_parapiped_from_one_corner_in_the_center ( kjb::Vector centre,
kjb::Vector dimensions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_sp_obj,
kjb::Vector sp_obj_centre,
kjb::Vector sp_obj_dimensions 
)
bool kjb::propose_parapiped_onside_parapiped_from_orthogonal_corner ( kjb::Vector centre,
kjb::Vector dimensions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_sp_obj,
kjb::Vector sp_obj_centre,
kjb::Vector sp_obj_dimensions 
)
bool kjb::propose_supported_parapiped_inside_parapiped_from_orthogonal_corner ( kjb::Vector centre,
kjb::Vector dimensions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner,
const kjb::Vector imin_desired_dimensions,
unsigned int  num_rows,
unsigned int  num_cols,
double  distance_from_camera,
bool  expand_sp_obj,
kjb::Vector sp_obj_centre,
kjb::Vector sp_obj_dimensions 
)
bool kjb::propose_supported_parapiped_inside_parapiped_from_three_corners ( kjb::Vector centre,
kjb::Vector dimensions,
kjb::Vector expansion_deltas,
std::vector< bool > &  expansion_directions,
Parametric_parapiped new_pp,
const Parametric_parapiped pp,
const Perspective_camera camera,
const Manhattan_corner corner1,
const Manhattan_corner corner2,
const Manhattan_corner corner3,
double  desired_height,
unsigned int  num_rows,
unsigned int  num_cols,
double  base_height 
)
void kjb::read_CMU_vanishing_points ( std::vector< Vanishing_point > &  vpts,
double &  focal_length,
std::string  file_name 
)
std::vector< Face_detection > kjb::read_face_file ( std::istream &  is)

Read set of faces from file (in face.com format).

std::vector< std::vector< Face_detection > > kjb::read_face_files ( const std::vector< std::string > &  face_fps)

Parse the output of the faces from multiple files into a vector of vector of Face_detection.

Flow_feature_set kjb::read_flow_features ( const std::string &  fname)

Read in the procomputed optical flow from files.

bool kjb::read_hedau_vanishing_points ( std::vector< Vanishing_point > &  vpts,
double &  focal,
const std::string &  file_path,
unsigned int  num_cols,
unsigned int  num_rows 
)
std::string kjb::realpath ( const std::string &  path)

return a canonicalized path, by wrapping kjb_c::kjb_realpath().

template<class Assignable_array_type >
double kjb::reduce ( const Assignable_array_type &  array,
size_t  length 
)

Sum elements in array by recursive pairwise merging. This is less prone to precision loss than a sequential sum, a problem that is quite drastic when summing large arrays of small numbers.

Template Parameters
Array_typeAny type that implements deep-copy semantics with operator= and implements operator[] (this includes kjb::Matrix, but not c-style arrays)
template<class Array_type >
double kjb::reduce_in_place ( Array_type &  array,
size_t  length 
)

Sum elements in array by recursive pairwise merging. This is less prone to precision loss than a sequential sum, a problem that is quite drastic when summing large arrays of small numbers.

Template Parameters
Array_typeAny type that implements operator[] (this includes kjb::Matrix and c-style arrays)
Warning
input array will be modified and should not be used after calling
template<class F , class M , class A >
void kjb::refine_max ( const F &  fcn,
M &  x,
const std::vector< double > &  steps,
const A &  adapter 
)

Refine the maximum of a function.

Parameters
xCurrent value of model.
fcnFunction of interest. Must receive a const Model& and return a double. Its type can be anything that is callablle with the correct signature.
stepsStep sizes in each dimension.
adapterAllows us to treat our model as a vector. Must have A::get, A::set, and A::size implemented. See kjb::Vector_adapter for an example.
Turntable_camera kjb::regularize_turntable_cameras ( const std::vector< Calibrated_camera > &  cameras_)

Take a set of individually calibrated cameras arranged in a turntable configuration and return the "best fit" Turntable camera.

In reality, we don't minimize any metric, do it heuristically by finding mean camara parameters.

Note
Position of the cameras is assumed to be evenly spaced around the circle, that is, angle increment is 360 / camreas_.size()

detect angles too. for now, it assumes clockwise rotation.

Receives a collection of calibrated cameras that are assumed to be in a turntable configuration, but due to noise, don't strictly comply with the Turntable_camera assumptions (e.g. coplanarity, pure rotation, etc. ). This function returns a Turntable_camera that tries to minimize the distance between its cameras and the original cameras.

A set of cameras that have been individually calibrated from a turntable calibration set.

Returns
Turntable_camera A turntable camera representing the input cameras, with noise averaged out.
bool kjb::relaxed_vanishing_point_estimation ( std::vector< Vanishing_point > &  vpts,
double &  focal_length,
const kjb::Image img,
double  success_probability 
)

This function uses less constraints coming from geometry and uses the data more, relying on the assumption that there is less noise. This is convenient with synthetic data.

void kjb::render_cylinder_silhouette ( const Polymesh polymesh,
const Perspective_camera camera 
)
Parameters
polymeshPointer to a Parapiped.
cameraPointer to a Perspective_camera.
void kjb::render_frustum_silhouette ( const Polymesh polymesh,
Perspective_camera camera 
)
Parameters
polymeshPointer to a Frustum.
cameraPointer to a Perspective_camera.
void kjb::render_occlude_cylinder_silhouette ( const Polymesh polymesh,
const Perspective_camera camera 
)
Parameters
polymeshPointer to a Parapiped.
cameraPointer to a Perspective_camera.
void kjb::render_occlude_frustum_silhouette ( const Polymesh polymesh,
Perspective_camera camera 
)
Parameters
polymeshPointer to a Frustum.
cameraPointer to a Perspective_camera.
void kjb::render_planes ( const Polymesh p,
const std::vector< Polymesh_Plane > &  planes 
)

Renders each plane in a polymesh with a different color.

Renders all of the faces lying in the same plane the same color. Renders the faces lying in different planes different colors. All faces not included in a plane (because they consist of a minimal part of the mesh) are rendered the same color.

Parameters
pthe polymesh to be rendered.
planesthe vector of Polymesh_Planes containing the lists of indices which lie in the same planes.
void kjb::report_gsl_failure_and_throw_kjb_error ( int  gsl_code,
const char *  file,
unsigned  line_no 
)

Implements the error-handling activities of Gsl_Etx_impl().

Exceptions
KJB_errorif the gsl_code is not equal to GSL_SUCCESS

Please use the GSL_ETX macro instead of calling this directly.

void kjb::retrieve_offscreen_capabilities ( bool *  _has_gl,
bool *  _has_osmesa 
)

Checks what offscreen rendering capabilities are available on the machine.

Checks what offscreen rendering capabilities are available on the machine

Parameters
_has_glWill be true if open gl rendering is available
_has_osmesaWill be true if libosmesa is available
bool kjb::robustly_estimate_vanishing_points ( std::vector< Vanishing_point > &  vpts,
double &  focal_length,
const kjb::Image img,
double  success_probability = VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY,
bool  jointly_estimate = false,
std::vector< Vanishing_point right_ones = std::vector<Vanishing_point>(0) 
)

Estimates the vanishing points for the three orthogonal directions of a Manhattan world scene (where most of all planes are aligned with three main orthogonal directions). This function works ONLY under the Manhattan world assumption.

double kjb::robustly_estimate_vanishing_points_Kovesi ( std::vector< Vanishing_point > &  vpts,
double &  focal_length,
const Image img,
const Line_segment_set kovesi,
double  start_threshold = 0.05,
double  vpts_tolerance = VPD_MAX_PRINCIPAL_POINT_POSITION_TOLERANCE,
double  success_probability = VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY 
)
bool kjb::robustly_estimate_vertical_vanishing_point ( Vanishing_point vertical,
const kjb::Image img,
double  success_probability = VPD_RANSAC_ROBUST_SUCCESS_PROBABILITY 
)
void kjb::rotate ( Matrix &  m,
const Quaternion &  r 
)

Apply translation v to homogeneous 3D transformation matrix m. This is designed to mimick opengl's glRotate() function.

Precondition
Matrix m is assumed to be homogeneous or non-homogeneous 3D rotation matrix (3x3 or 4x4).
Postcondition
Matrix m represents a new coordinate system after rotating by r.
void kjb::rotate_matrix_90_degrees ( Matrix m,
int  number_of_times 
)
void kjb::rotateMatrix ( Matrix &  m,
double  angle 
)

angle is in degrees!!

Ned13_one_degree_grid::IntegralLL kjb::round_nw_to_whole_degrees ( const Ned13_one_degree_grid::IntegralLL &  )
GILL kjb::round_nw_to_whole_degrees ( const GILL &  ill)

map an input location to the nearest location to northwest of whole degrees

Vector kjb::sample ( const MV_gaussian_distribution &  dist)

Sample from a multivariate normal distribution.

double kjb::sample ( const Uniform_distribution &  dist)
inline

Sample from a uniform distribution.

Crp::Type kjb::sample ( const Chinese_restaurant_process &  crp)

Sample from a CRP.

template<class Distro >
double kjb::sample ( const Distro &  dist)
inline

Template sample function.

This uses the probability transform to sample from the given distribution. The only requirement for this function is that the quantile() function be defined for the distribution.

It is recommended to directly sample from a distribution in cases where it is more efficient to do so by specializing the sample function (as is already done for some distributions).

double kjb::sample ( const Bernoulli_distribution &  dist)
inline

Sample from a Bernoulli distribution.

double kjb::sample ( const Binomial_distribution &  dist)
inline

Sample from a Binomial distribution.

double kjb::sample ( const Exponential_distribution &  dist)
inline

Sample from a exponential distribution.

double kjb::sample ( const Gaussian_distribution &  dist)
inline

Sample from a Gaussian distribution.

double kjb::sample ( const Poisson_distribution &  dist)
inline

Sample from a Poisson distribution.

double kjb::sample ( const Geometric_distribution &  dist)
inline
template<class T >
T kjb::sample ( const Categorical_distribution< T > &  dist)

Sample from a categorical distribution.

double kjb::sample ( const Log_normal_distribution &  dist)
inline
template<class Distribution >
Distribution_traits<Mixture_distribution<Distribution> >::type kjb::sample ( const Mixture_distribution< Distribution > &  dist)
inline

Sample from a mixture distribution.

template<size_t D>
kjb::Vector_d<D> kjb::sample ( const Uniform_sphere_distribution< D > &  )
inline

Sample uniformly from the surface of a unit-sphere in D-dimensional euclidean space.

template<size_t D, class Vector_d_iterator >
void kjb::sample ( const Von_mises_fisher_distribution< D > &  dist,
size_t  n,
Vector_d_iterator  it 
)
inline

Sample n i.i.d. D-dimensional unit vectors from a Von-mises fisher distribution.

Parameters
itoutput iterator, stores a collection of kjb::Vector_d<D>
template<size_t D>
Vector_d<D> kjb::sample ( const Von_mises_fisher_distribution< D > &  dist)

Sample a D-dimensional unit vector from a Von-mises fisher distribution.

size_t kjb::sample_occupied_tables ( const Chinese_restaurant_process &  crp)

Sample the number of occupied tables from a CRP (don't store the actual partition).

Author
Colin Dawson
template<class Serializable >
void kjb::save ( const Serializable &  ,
const std::string &   
)

Write a serializable object to a file.

This function will serialize the object by value to an ascii format using text_oarchive. It can be loaded using the kjb::load() method, or by manually using a boost::serialization text_iarchive object.

Author
Kyle Simek
void kjb::save ( const Edge_set &  edges,
const std::string &  fname 
)
inline
void kjb::scale ( kjb::Axis_aligned_rectangle_2d box,
const kjb::Vector s 
)

Scale a bounding box by a 2d scale vector.

The effect is that the four corners are effectively multiplied by a scalar; i.e. boxes not centered at the origin will change position (similar to opengl). If this is undesirable, scale first, then translate.

void kjb::seed_sampling_rand ( unsigned int  x0)
inline

Seed random number generator.

Vector kjb::set_camera_to_view_entire_model ( Perspective_camera c,
Polymesh p,
int  imageWidth,
int  imageHeight 
)
void kjb::set_spy_filename ( const std::string &  )
bool kjb::shift_parapiped_to_match_corner ( kjb::Parametric_parapiped pp,
kjb::Perspective_camera camera,
unsigned int  num_rows,
unsigned int  num_cols,
const kjb::Vector corner 
)
Quaternion kjb::slerp ( const Quaternion &  q1,
const Quaternion &  q2,
double  t 
)

Spherical linear interpolation between two quaternions

Quaternion kjb::slerp2 ( const Quaternion &  q1,
const Quaternion &  q2,
double  t 
)

An alternative implementation of spherical linear interpolation

void kjb::standardize_camera_matrices ( Matrix &  intrinsic,
Matrix &  rotation,
Vector &  translation,
const Calibration_descriptor &  cal = Calibration_descriptor::STANDARD 
)

Standardize the intrinsic and extrinsic parameters :

  • Move the principal point offset relative to the center of the image, not the corner
  • Ensure the image y-axis points upward.
  • Flip camera's z axis if world origin appears on wrong side of camera
  • Force det(rotation) to be 1.

The resulting decomposition should give identical mappings to calibrations that used different conventions but are otherwise identical.

Note
The resulting intrinsic matrix might not have positive diagonal elements, indicating that the camera's internal reference frame differs from the calibration frame. Hartley and zisserman describe this in terms of the extrinsic matrix, but it is more natural to push this manipulation into the intrinsic matrix.
This assumes positive z-values are in front of the camera. For opengl, you'll need to correct for this, since negative z-values are in front of the camera. Negating the focal points should do it, but be aware that z-depths aren't represented in the intrinsic matrix, so you'll have to be smart with how you build the GL_PROJECTION matrix to get depth values correct.
Parameters
intrinsic[in/out] the intrinsic matrix to transform
rotation[in/out] the rotation matrix extrinsic parameter
translation[in/out] the translation extrinsic parameter
cal[in] The description of the calibration set-up, including image size, origin, and axis orientation.
int kjb::stochastic_dynamics ( unsigned int  iterations,
const Vector &  delta_t,
double  alpha,
unsigned int  kick,
Vector &  parameters,
int(*)(const Vector &parameters, Vector &out_gradient)  compute_energy_gradient,
int(*)(const Vector &parameters)  accept_sample,
int(*)(const Vector &parameters, const Vector &momenta)  log_sample 
)

Double precision leapfrog stochastic dynamics.

std::vector< std::string > kjb::strings_from_format ( const std::string &  str_format,
size_t  num_strings,
size_t  first 
)

Expands the format into a set strings.

Polybezier_curve kjb::subdivide ( const Polybezier_curve &  c,
double  u 
)
bool kjb::supports_pbuffers ( )

DEPRECATED Returns true if pbuffers are available. ONLY FOR DEBUG PURPOSES.

DEPRECATED Returns true if pbuffers are available. ONLY FOR DEBUG PURPOSES

bool kjb::supports_pixmaps ( )

DEPRECATED Returns true if pixelmaps are available. ONLY FOR DEBUG PURPOSES.

DEPRECATED Returns true if pixel maps are available. ONLY FOR DEBUG PURPOSES

void kjb::swap ( Chamfer_transform &  op1,
Chamfer_transform &  op2 
)
inline
void kjb::swap ( Axis_aligned_rectangle_2d &  r1,
Axis_aligned_rectangle_2d &  r2 
)
inline

Swaps two rectangles.

void kjb::swap ( Quaternion &  q1,
Quaternion &  q2 
)
inline

Non-member swap function.

void kjb::swap ( Perspective_camera &  cam1,
Perspective_camera &  cam2 
)
inline

Swap two cameras.

void kjb::swap ( Vector &  v1,
Vector &  v2 
)
inline

Non-member swap.

void kjb::swap ( Matrix &  m1,
Matrix &  m2 
)
inline

Non-member swap function.

template<class T >
void kjb::swap_array_bytes ( T *  array,
size_t  N 
)

Reverse the byte-order of an array of values. Useful when swapping endian-ness of an array of values. This should be used only with arrays of primitive types of 1 word or less.

Kyle Simek

template<class T >
void kjb::swap_bytes ( T *  value)
inline

Reverse a value's byte-order. Useful when swapping the endian-ness of a value.

This is written so that the compiler should convert this into a direct call to the high-performance C-version, bswap_u*().

This template version makes the byte swapping functionality usable in generic algorithms, as well as unifying the interface somewhat.

Parameters
valueThe value whose bytes to swap
Note
To be used only with primitive types of 2, 4, or 8 bytes size.
Warning
Not to be used with bool.
Author
Kyle Simek
template<class T >
void kjb::swap_bytes ( T &  value)
inline
template<int NUM_BYTES>
void kjb::swap_bytes_dispatch ( void *  )
inline

Swap the byte-order of a value.

Note
You shouldn't call this directly, you should call swap_bytes.
Template Parameters
NUM_BYTESnumber of bytes in the value.
template<>
void kjb::swap_bytes_dispatch< 2 > ( void *  value)
inline

swap the byte order of a 16-bit value (do not call directly).

template<>
void kjb::swap_bytes_dispatch< 4 > ( void *  value)
inline

swap the byte order of a 32-bit value (do not call directly).

template<>
void kjb::swap_bytes_dispatch< 8 > ( void *  value)
inline

swap the byte order of a 64-bit value (do not call directly).

void kjb::symmetric_eigs ( const kjb::Matrix3 A,
double &  eig1,
double &  eig2,
double &  eig3 
)

get eigenvalues of symmetric matrix A in ascending order

void kjb::throw_kjb_error ( const char *  msg,
const char *  file,
unsigned  line 
)
Vector kjb::total_flow ( const Flow_feature_set of_set,
const Axis_aligned_rectangle_2d box 
)

Compute the average flow vector inside the bounding box.

template<size_t D>
double kjb::trace ( const Matrix_d< D, D > &  m)
void kjb::translate ( Matrix &  m,
const Vector &  v_in 
)

Apply translation v to homogeneous 3D transformation matrix m. This mimicks opengl's glTranslate() function. Vector is assumed to be a column vector.

void kjb::translate ( kjb::Axis_aligned_rectangle_2d box,
const kjb::Vector t 
)
inline

Translate a bounding box by a 2d offset vector

void kjb::translate_3d_plane_to_xy_plane ( const std::vector< Vector > &  points,
const Vector plane_params,
std::vector< Vector > &  translated_points,
std::vector< Matrix > &  transformMatrices 
)
void kjb::translate_xy_point_to_3d_plane ( const Vector point,
const std::vector< Matrix > &  transformMatrices,
Vector translated_point 
)
void kjb::untransform_points ( std::vector< Vector > &  vlist,
const Vector bottom,
const double  angle_y,
const double  angle_x,
std::vector< Vector > &  vlist_tr 
)
Vector kjb::update_average_velocity ( const Flow_feature_set of_set,
const Axis_aligned_rectangle_2d old_model_box,
const Vector old_velocity,
MOVE_DIRECTION  dir,
size_t  unit = 1 
)

Update the average flow velocity based on the moving direction.

Vector kjb::update_average_velocity ( const Flow_feature_set of_set,
const Axis_aligned_rectangle_2d old_box,
const Axis_aligned_rectangle_2d new_box,
const Vector old_velocity 
)

Update the average model velocity.

void kjb::update_focal_with_position ( Perspective_camera cam,
double  ifocal,
Parametric_parapiped pp 
)
Ned13_one_degree_grid::IntegralLL kjb::utm_to_se_ned13_ill ( const TopoFusion::pt &  p)

convert from UTM coord to grid location, truncating to the southeast

Parameters
pUTM point of interest
Returns
NED13 grid location closest to p without going north or west at all.
Bug:
quantization error empirically appears not always to be strictly SE.

If possible, try to avoid this function. Better to work with UTM points. Truncation error is usually around a dozen meters or less.

std::vector< Vector > kjb::valid_flow ( const std::vector< Feature_pair > &  feature_pairs,
double  percentile = 1.0 
)

Get valid features.

std::vector< Vector > kjb::valid_flow ( const std::vector< Feature_pair > &  feature_pairs,
const std::vector< size_t > &  angle_hist 
)

Get valid flow features that with angle alpha in the rangle (min_angle, max_angle)

void kjb::write_deva_facemark ( const std::vector< Deva_facemark > &  faces,
std::ostream &  os 
)

Write the output from Deva's face detector into a vector of Deva_facemark.

void kjb::write_deva_facemark_line ( const Deva_facemark face,
std::ostream &  os 
)

Write the output from Deva's face detector.

Variable Documentation

const Image::Pixel_type kjb::apix = {255.0, 0.0, 0.0}
Base_generator_type kjb::basic_rnd_gen
const unsigned int kjb::DEFAULT_SEED = static_cast<unsigned int>(std::time(0)+getpid())

Random seed used to initialize the random number generator.

const Image::Pixel_type kjb::fpix = {0.0, 0.0, 255.0}
gsl_qrng_type * kjb::gsl_qrng_halton
gsl_qrng_type* kjb::gsl_qrng_niederreiter_2
gsl_qrng_type * kjb::gsl_qrng_reversehalton
gsl_qrng_type * kjb::gsl_qrng_sobol
const int kjb::NED_ELLIPSOID = TopoFusion::ELLIPSOID_GRS_1980
const float kjb::NED_MAX = 7000

Mt. McKinley is 6194 meters elevation.

const float kjb::NED_MIN = -100

Death Valley is -86 meters elevation.

const float kjb::NED_MISSING = -9999.0

sentinel for missing elevation data

const Gaussian_distribution kjb::STD_NORMAL