KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_complete_trajectory.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 by Kobus Barnard (author)
4  |
5  | Personal and educational use of this code is granted, provided that this
6  | header is kept intact, and that the authorship is not misrepresented, that
7  | its use is acknowledged in publications, and relevant papers are cited.
8  |
9  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10  |
11  | Please note that the code in this file has not necessarily been adequately
12  | tested. Naturally, there is no guarantee of performance, support, or fitness
13  | for any particular task. Nonetheless, I am interested in hearing about
14  | problems that you encounter.
15  |
16  | Author: Kyle Simek, Ernesto Brau, Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: pt_complete_trajectory.h 18707 2015-03-25 08:04:38Z jguan1 $ */
20 
21 #ifndef PT_COMPLETE_TRAJECTORY_H
22 #define PT_COMPLETE_TRAJECTORY_H
23 
27 #include <l_cpp/l_exception.h>
28 #include <m_cpp/m_vector.h>
29 #include <vector>
30 #include <limits>
31 #include <fstream>
32 #include <string>
33 #include <ios>
34 #include <iomanip>
35 
38 namespace kjb {
39 namespace pt {
40 
44 
46 double get_initial_direction(Trajectory& traj, size_t frame);
47 
49 void update_direction(Trajectory& traj, size_t frame, bool ow);
50 
52 void initialize_directions(Trajectory& traj, size_t st = 0, size_t et = 0, bool ow = false);
53 
55 //std::vector<Visibility> get_visibilities(const Trajectory& traj);
56 
57 }} //namespace kjb::pt
58 
59 namespace kjb {
60 namespace tracking {
62 template <>
63 bool kjb::pt::Trajectory_element::parse(const std::string& line);
64 
66 template <>
67 inline
68 void kjb::pt::Trajectory_element::write(std::ofstream& ofs) const
69 {
70  IFT(value.body_dir != std::numeric_limits<double>::max()
71  && value.face_dir[0] != std::numeric_limits<double>::max()
72  && value.face_dir[1] != std::numeric_limits<double>::max(),
73  Illegal_argument, "Cannot write trajectory: body or face"
74  " direction never initialized.");
75 
76  ofs << std::scientific;
77  ofs << value.position
78  << " " << std::setw(16) << std::setprecision(8) << value.body_dir
79  << " " << value.face_dir
80  << " 1.0" << std::endl;
81 }
82 
84 template <>
85 inline
86 void kjb::pt::Trajectory_element::write_invalid(std::ofstream& ofs)
87 {
88  ofs << Vector(6, -1.0) << " " << 0.0 << std::endl;
89 }
90 
92 template <>
93 bool kjb::pt::Trajectory::parse_header(const std::string& line);
94 
96 template <>
97 inline
98 void kjb::pt::Trajectory::write_header(std::ofstream& ofs) const
99 {
100  ofs << height << " " << width << " " << girth << std::endl;
101 }
102 
103 }}
104 #endif /*PT_COMPLETE_TRAJECTORY_H */
105 
double get_initial_direction(Trajectory &traj, size_t frame)
Gets default body direction at frame.
Definition: pt_complete_trajectory.cpp:118
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
Represents an element of a trajectory of a particular entity.
Definition: tracking_trajectory.h:61
Generic_trajectory_element< Complete_state > Trajectory_element
Definition: pt_complete_trajectory.h:41
void update_direction(Trajectory &traj, size_t frame, bool ow)
Set non-initialized direction in frame to default value.
Definition: pt_complete_trajectory.cpp:137
height
Definition: APPgetLargeConnectedEdges.m:33
void write(std::ofstream &ofs) const
Writes this element to a stream.
Definition: tracking_trajectory.h:79
#define IFT(a, ex, msg)
Definition: l_exception.h:101
Represents a set of trajectories; it is a map from entity to trajectory.
Definition: tracking_trajectory.h:53
Generic_trajectory< Complete_state > Trajectory
Definition: pt_complete_trajectory.h:42
bool parse(const std::string &line)
Reads an element from a line of a file.
Definition: tracking_trajectory.h:70
static void write_invalid(std::ofstream &ofs)
Writes this element to a stream.
Definition: tracking_trajectory.h:88
bool parse_header(const std::string &)
Parses the header information from a header line.
Definition: tracking_trajectory.h:145
void write_header(std::ofstream &) const
Writes the header of a trajectory. Does nothing by default. Please specialize.
Definition: tracking_trajectory.h:154
Generic_trajectory_map< Complete_state > Trajectory_map
Definition: pt_complete_trajectory.h:43
Support for error handling exception classes in libKJB.
void initialize_directions(Trajectory &traj, size_t st=0, size_t et=0, bool ow=false)
Set non-initialized directions to default values.
Definition: pt_complete_trajectory.cpp:187
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...