27 if (line.find(
"PathFileType\t4\t(X/Y/Z)") == std::string::npos) {
33 "DataRate\tCameraRate\tNumFrames\tNumMarkers\tUnits\tOrigDataRate\tOrigDataStartFrame\tOrigNumFrames") ==
39 auto tokens =
tokenize(line,
" \t\r\n");
40 if (tokens.size() != 8) {
43 const double frameRate = std::stod(tokens[0]);
44 const size_t numMarkers = std::stoi(tokens[3]);
45 const std::string unitStr = tokens[4];
46 res.
fps =
static_cast<float>(frameRate);
51 if (tokens.size() != numMarkers + 2) {
55 std::vector<std::string> markerNames;
56 for (
size_t i = 2; i < tokens.size(); i++) {
57 markerNames.push_back(tokens[i]);
64 tokens =
tokenize(line,
"\t",
false);
66 if (tokens.size() != numMarkers * 3 + 2) {
71 std::vector<Marker> markers(numMarkers);
74 for (
size_t i = 0; i < numMarkers; i++) {
75 const size_t pos = i * 3 + 2;
77 i >= markerNames.size() || pos + 2 >= tokens.size(),
"Marker index {} out of bounds", i);
78 markers[i].name = markerNames[i];
79 if (tokens[pos + 0].empty() || tokens[pos + 1].empty() || tokens[pos + 2].empty()) {
80 markers[i].occluded =
true;
82 markers[i].occluded =
false;
84 std::stod(tokens[pos + 0]), std::stod(tokens[pos + 1]), std::stod(tokens[pos + 2])};
91 res.
frames.push_back(markers);
98 std::ifstream infile(filename);
99 if (!infile.is_open()) {
102 return loadTrc(
static_cast<std::istream&
>(infile), up);
107 return loadTrc(
static_cast<std::istream&
>(stream), up);
#define MT_THROW_IF(Condition,...)
Conditionally throws a std::runtime_error with a formatted message if the condition is true.
Vector3< double > Vector3d
UpVector
This enumeration is used to define the primary up vector directions for various coordinate systems an...
MarkerSequence loadTrc(std::istream &stream, UpVector up)
Loads marker data from a TRC input stream into a MarkerSequence.
std::istream & GetLineCrossPlatform(std::istream &is, std::string &line)
Reads a line from the input stream, handling line endings for different platforms.
std::vector< std::string > tokenize(const std::string &inputString, const std::string &delimiters, const bool trim)
Tokenizes a string using the specified single-byte delimiter characters.
Vector3< T > toMomentumVector3(const Vector3< T > &vec, UpVector up, Unit unit)
This function converts a 3D vector in the mocap marker coordinate system to the Momentum coordinate s...
All frames from a single motion capture sequence for one subject (actor).
float fps
Frame rate of the capture, in frames per second.
std::vector< std::vector< Marker > > frames
All marker observations across the sequence. Layout: [numFrames][numMarkers].
istream that takes a span of const bytes as input.