KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
psi_util.h
Go to the documentation of this file.
1 /* $Id: psi_util.h 18278 2014-11-25 01:42:10Z ksimek $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2011 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 #ifndef PSI_V1_UTIL
22 #define PSI_V1_UTIL
23 
24 #include <m_cpp/m_vector.h>
27 #include <g_cpp/g_quaternion.h>
30 
31 #include <l/l_word_list.h>
32 #include <l/l_sys_io.h> /* for kjb_glob */
33 
34 #ifdef KJB_HAVE_UA_CARTWHEEL
35 #include <MathLib/Point3d.h>
36 #include <MathLib/Vector3d.h>
37 #include <Core/Visualization.h>
38 #endif
39 
40 namespace kjb
41 {
42 namespace psi
43 {
44 
46 
47 #ifdef KJB_HAVE_UA_CARTWHEEL
48 inline kjb::Vector to_kjb(const CartWheel::Math::Point3d& pt)
49 {
50  return kjb::Vector(pt.x, pt.y, pt.z);
51 }
52 
53 inline kjb::Vector to_kjb(const CartWheel::Math::Vector3d& vec)
54 {
55  return kjb::Vector(vec.x, vec.y, vec.z);
56 }
57 
58 inline kjb::Quaternion to_kjb(const CartWheel::Math::Quaternion& q)
59 {
60  CartWheel::Math::Vector3d imag = q.getV();
61  double real = q.getS();
62  return kjb::Quaternion(imag.x, imag.y, imag.z, real);
63 }
64 #endif
65 
66 #ifdef KJB_HAVE_UA_CARTWHEEL
67 inline CartWheel::Math::Point3d to_cw_pt_3d(const kjb::Vector& pt)
68 {
69  assert(pt.size() == 3);
70  return CartWheel::Math::Point3d(pt[0], pt[1], pt[2]);
71 
72 }
73 #endif
74 
75 #ifdef KJB_HAVE_UA_CARTWHEEL
76 inline CartWheel::Math::Vector3d to_cw_vec_3d(const kjb::Vector& vec)
77 {
78  assert(vec.size() == 3);
79  return CartWheel::Math::Vector3d(vec[0], vec[1], vec[2]);
80 
81 }
82 #endif
83 
84 #ifdef KJB_HAVE_UA_CARTWHEEL
85 
91 void set_camera(CartWheel::Visualization& vis, const kjb::Perspective_camera& cam, double WIDTH, double HEIGHT);
92 #endif
93 
96  double height,
97  double tilt,
98  double focal_length)
99 {
100  kjb::Perspective_camera cam(0.1, 100);
101  cam.set_camera_centre(kjb::Vector(0.0,height,0.0));
103  cam.set_focal_length(focal_length);
104 
105  return cam;
106 }
107 
112 inline
113 Vector project_and_unstandarize(const Vector& x, const Matrix& P, double w, double h)
114 {
115  using namespace geometry;
117  pt::unstandardize(x2, w, h);
118  return x2;
119 }
120 
121 
123 
124 const std::string& get_name(Simulator_type type);
125 
126 std::istream& operator>>(std::istream& ist, Simulator_type& type);
127 std::ostream& operator<<(std::ostream& ost, Simulator_type type);
128 
130 void standardize(Deva_detection& boxes, double cam_width, double cam_height);
131 
135 void prune_by_height
136 (
137  std::vector<Deva_detection>& deva_boxes,
138  double screen_width,
139  double screen_height,
140  const Perspective_camera& camera,
141  double avereage_height
142 );
143 
144 } // namespace psi
145 } // namespace kjb
146 #endif
Simulator_type
Definition: psi_util.h:122
virtual void set_camera_centre(const kjb::Vector &icentre)
sets the camera centre
Definition: perspective_camera.cpp:695
std::ostream & operator<<(std::ostream &ost, const Action &action)
serialize an action
Definition: psi_action.cpp:333
size_type size() const
Alias to get_length(). Required to comply with stl Container concept.
Definition: m_vector.h:510
Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center...
Definition: gr_2D_bounding_box.h:51
Definition: psi_util.h:122
std::istream & operator>>(std::istream &ist, Action &action)
unserialize an action
Definition: psi_action.cpp:346
virtual void set_focal_length(double ifocal)
sets the focal length
Definition: perspective_camera.cpp:872
Vector project_and_unstandarize(const Vector &x, const Matrix &P, double w, double h)
Project the 3D point x to image coordinate using camera matrix P and make the top left as the origin...
Definition: psi_util.h:113
height
Definition: APPgetLargeConnectedEdges.m:33
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Definition: g_quaternion.h:79
Definition: d_deva_detection.h:41
Vector projective_to_euclidean_2d(const Vector &v)
Converts coordinates in (2D) projective space to coordinates in (2D) euclidean space.
Definition: g_util.cpp:109
St_perspective_camera for modeling a perspective camera using the classic Forsyth and Ponce parametri...
Definition: psi_util.h:122
Definition: g_quaternion.h:40
Definition: perspective_camera.h:93
x
Definition: APPgetLargeConnectedEdges.m:100
Vector euclidean_to_projective(const Vector &v)
Converts coordinates in euclidean space to coordinates in projective space.
Definition: g_util.cpp:122
const std::string & get_name(Action_type t)
Convert Action_type to string.
Definition: psi_action.cpp:198
x2
Definition: APPgetLargeConnectedEdges.m:123
void prune_by_height(std::vector< Deva_detection > &deva_boxes, double screen_width, double screen_height, const Perspective_camera &camera, double average_height)
Prune the deva boxes based on the average entity height.
Definition: psi_util.cpp:140
virtual void set_orientation(const kjb::Quaternion &q)
Alias of set_angles_from_quaternion()
Definition: perspective_camera.h:401
kjb::Perspective_camera make_camera(double height, double tilt, double focal_length)
Definition: psi_util.h:95
void unstandardize(Vector &v, double cam_width, double cam_height)
Changes vector to unstandard (image) coordinate system.
Definition: pt_util.h:83
Class representing an axis-aligned, 2D rectangle.
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
void standardize(Deva_skeleton_boxes &boxes, double cam_width, double cam_height)
move coordinate ssystem origin to center of image
Definition: psi_deva_skeleton.cpp:156
Axis_aligned_rectangle_2d Bbox
Definition: psi_deva_skeleton.h:32
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...