CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
metadata.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef METADATA_H
31 #define METADATA_H
32 
33 #include <vector>
34 
35 #include <QDir>
36 #include <QXmlStreamReader>
37 
38 #include "common.h"
39 #include "keyvaluecollection.h"
40 #include "sourcesettings.h"
41 
42 using cavapa::CalibrationPoint;
43 
44 namespace cavapa_gui
45 {
52 struct SourceInfo
53 {
58 
63 
68 
73 
77  std::vector<std::string> recordedVideos;
78 
82  std::vector<CalibrationPoint> calibrationPoints;
83 };
84 
92 {
93 private:
94  std::map<SourceID, SourceInfo> sources;
95  std::vector<std::string> ignoredKeys; //list of key names that are not saved
96  //to file
97  std::vector<GraphMarker> graphMarkers;
98 
99  CalibrationPoint readCalibrationPoint(QXmlStreamReader& xml);
100  void readMarker(QXmlStreamReader& xml);
101  void readSource(QXmlStreamReader& xml);
102 
103 public:
107  Metadata();
108 
117  void addSource(SourceID id, SourceType type,
118  const SourceSettings& settings, FrameTime startOffset = 0);
119 
125  void addVideo(SourceID id, const std::string& path);
126 
130  void clearSources();
131 
137  std::vector<CalibrationPoint> getCalibrationPoints(SourceID source);
138 
144  QDir getContainingDirectory() const;
145 
150  std::vector<GraphMarker> getMarkers() const;
151 
156  std::vector<SourceID> getSources() const;
157 
165 
171  FrameTime getStartOffset(SourceID source) const;
172 
177  int getVideoCount() const;
178 
184  std::vector<std::string> getVideos(SourceID id);
185 
191  bool readFromFile(const std::string& path);
192 
198  const std::vector<CalibrationPoint>& points);
199 
206  SourceID id,
207  const std::vector<CalibrationPoint>& points);
208 
213  void setMarkers(const std::vector<GraphMarker>& markers);
214 
220  bool writeToFile() const;
221 
228  bool writeToFile(const std::string& path) const;
229 
230 };
231 } //namespace cavapa_gui
232 
233 #endif // METADATA_H
std::vector< GraphMarker > getMarkers() const
Gets the markers associated with the metadata.
Definition: metadata.cpp:359
FrameTime getStartOffset(SourceID source) const
Gets the start offset for the specified source.
Definition: metadata.cpp:379
std::vector< std::string > getVideos(SourceID id)
Gets the recorded videos associated with the specified source.
Definition: metadata.cpp:244
unsigned int SourceID
Used to indicate unique source ID-numbers.
Definition: common.h:229
SourceSettings settings
The settings for the source.
Definition: metadata.h:67
QDir getContainingDirectory() const
Gets the path of the directory specifying where the metadata file is located.
Definition: metadata.cpp:235
Represents a collection of key-value pairs.
Definition: keyvaluecollection.h:51
SourceID id
The id number of the source.
Definition: metadata.h:57
Holds the information related to a source including id number, type, settings, a list of the recorded...
Definition: metadata.h:52
Represents the metadata associated with a measurement.
Definition: metadata.h:91
void addSource(SourceID id, SourceType type, const SourceSettings &settings, FrameTime startOffset=0)
Adds a new source to the metadata.
Definition: metadata.cpp:201
Metadata()
Constructs a new Metadata object with empty values.
Definition: metadata.cpp:183
Represents the settings for a video source.
Definition: sourcesettings.h:46
SourceType
Available source types are the following ones: CAMERA = hardware or network camera, NOTHING = not a working source, STREAM = network stream, VIDEO = video file and VIDEOSET = set of multiple files.
Definition: common.h:68
std::uint64_t FrameTime
Used to store milliseconds interval in frame times.
Definition: common.h:138
void setCalibrationPoints(const std::vector< CalibrationPoint > &points)
Sets the calibration points for the metadata.
Definition: metadata.cpp:328
bool writeToFile() const
Writes the metadata to the default file.
Definition: metadata.cpp:401
std::vector< CalibrationPoint > calibrationPoints
The set of the calibration points related to the source.
Definition: metadata.h:82
FrameTime startOffset
The start offset of the source used in analysis.
Definition: metadata.h:72
void addVideo(SourceID id, const std::string &path)
Adds a new recorded video file for the specified source.
Definition: metadata.cpp:216
void setMarkers(const std::vector< GraphMarker > &markers)
Sets the graph markers for the metadata.
Definition: metadata.cpp:396
SourceSettings getSourceSettings(SourceID source) const
Gets the source settings for the specified source from the metadata.
Definition: metadata.cpp:374
int getVideoCount() const
Gets the total video count of all sources.
Definition: metadata.cpp:386
std::vector< SourceID > getSources() const
Gets the ids of the sources associated with the metadata.
Definition: metadata.cpp:364
SourceType type
The type of the source.
Definition: metadata.h:62
bool readFromFile(const std::string &path)
Reads the metadata information from the specified XML file.
Definition: metadata.cpp:260
std::vector< std::string > recordedVideos
The set of the video files related to the source.
Definition: metadata.h:77
void clearSources()
Removes all sources from the Metadata object.
Definition: metadata.cpp:223
std::vector< CalibrationPoint > getCalibrationPoints(SourceID source)
Gets the calibration points of the specified source.
Definition: metadata.cpp:228