VRS
A file format for sensor data.
Loading...
Searching...
No Matches
SharedDefinitions.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <vrs/DataLayout.h>
20#include <vrs/DataLayoutConventions.h>
21#include <vrs/DataPieces.h>
22
23namespace vrs_sample_apps {
24
25using namespace vrs; // we should not do this in a header, but for readability, we do in this sample
26
27// This file contains definitions shared between our reader & writer code
28
29constexpr const char* kSampleFileName = "sample_file.vrs";
30
31// DataLayout definitions: these are groups of data fields that will store in different records.
32
34struct CameraStreamConfig : public AutoDataLayout {
35 using ImageSpecType = datalayout_conventions::ImageSpecType;
36
37 // Spec of a raw image, stored in data records (controlled by most recent config record)
40 // Prefer to specify a storage type when storing an enum, to make the storage format explicit.
42
43 // Additional configuration information for the camera
44 DataPieceVector<float> cameraCalibration{"camera_calibration"};
45
46 AutoDataLayoutEnd endLayout;
47
48 // Record format version number, describing the overall record format.
49 // Stored in the DataLayout for convenience, using the namespace the class provides for clarity.
50 // DataLayout field changes do *not* require changing the record format version.
51 // The version only needs to change when the RecordFormat structure changes
52 // (e.g., adding/removing content blocks).
53 constexpr static uint32_t kVersion = 1;
54};
55
57struct CameraStreamData : public AutoDataLayout {
58 // Additional data provided with each frame
59 DataPieceValue<uint64_t> exposureTime{"exposure_time"};
60 DataPieceValue<float> exposure{"exposure"};
61 DataPieceValue<uint64_t> frameCounter{"frame_counter"};
62 DataPieceValue<float> cameraTemperature{"camera_temperature"};
63
64 AutoDataLayoutEnd endLayout;
65
66 constexpr static uint32_t kVersion = 1;
67};
68
70struct MotionStreamConfig : public AutoDataLayout {
71 DataPieceValue<double> motionStreamParam{"some_motion_stream_param"};
72
73 AutoDataLayoutEnd endLayout;
74
75 constexpr static uint32_t kVersion = 1;
76};
77
79struct MotionStreamData : public AutoDataLayout {
80 DataPieceVector<Matrix3Dd> motionData{"motion_data"};
81
82 AutoDataLayoutEnd endLayout;
83
84 constexpr static uint32_t kVersion = 1;
85};
86
87// Some constants for our audio streams
88const uint8_t kNumChannels = 1;
89const uint32_t kSampleRate = 44100;
90const size_t kAudioBlockSize = 256;
91
92// Number of data records we will create in each of our test file streams
93const size_t kDataRecordCount = 100;
94
95// Definition of the Recordable Class flavors we will use for our sample streams
96constexpr const char* kCameraStreamFlavor = "sample/camera";
97constexpr const char* kAudioStreamFlavor = "sample/audio";
98constexpr const char* kMotionStreamFlavor = "sample/motion";
99
100// Some arbitrary definitions to play with
101#define CALIBRATION_VALUES {23, 53, 343, 3, 12, 8}
102constexpr double kMotionValue = 25;
103
104} // namespace vrs_sample_apps
For use within an AutoDataLayout class, to end the AutoDataLayout's construction.
Definition DataLayout.h:610
DataPieceValue specialization class to store enums more conveniently and safely.
Definition DataPieceValue.h:285
DataPiece for a single value of type T. The value is stored in DataLayout's fixed size buffer.
Definition DataPieceValue.h:37
Vector of type T and variable size.
Definition DataPieceVector.h:39
constexpr const char * kImageWidth
DataLayout convention name for the image width.
Definition DataLayoutConventions.h:31
uint32_t ImageSpecType
Data type to use for the kImageXXX fields above.
Definition DataLayoutConventions.h:50
constexpr const char * kImageHeight
DataLayout convention name for the image height.
Definition DataLayoutConventions.h:33
constexpr const char * kImagePixelFormat
DataLayout convention name for the pixel format specification (see vrs::ImageFormat).
Definition DataLayoutConventions.h:39
Sample metadata for configuration records of an image stream.
Definition SharedDefinitions.h:34
Sample metadata for data records of an image stream.
Definition SharedDefinitions.h:57
Sample metadata for configuration records of a metadata stream.
Definition SharedDefinitions.h:70
Sample metadata for data records of a metadata stream.
Definition SharedDefinitions.h:79