|
| 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 | +// Aria Gen2 camera DataLayouts for OSS pyvrs writer. |
| 18 | +// Vendored from arvr/libraries/visiontypes/vrs/data_layouts/ImageDataLayout.h |
| 19 | +// with namespace changed from visiontypes::detail to pyvrs. |
| 20 | + |
| 21 | +#pragma once |
| 22 | + |
| 23 | +#include <cstdint> |
| 24 | + |
| 25 | +#include <vrs/DataLayout.h> |
| 26 | +#include <vrs/DataLayoutConventions.h> |
| 27 | +#include <vrs/DataPieces.h> |
| 28 | + |
| 29 | +namespace pyvrs { |
| 30 | + |
| 31 | +using vrs::OptionalDataPieces; |
| 32 | +using vrs::datalayout_conventions::ImageSpecType; |
| 33 | + |
| 34 | +// Additional fields to enable in ImageSensorConfigurationLayout when data was |
| 35 | +// encoded as video before recording. |
| 36 | +struct VideoConfigurationFields { |
| 37 | + vrs::DataPieceString videoCodecName{vrs::datalayout_conventions::kImageCodecName}; |
| 38 | +}; |
| 39 | + |
| 40 | +struct ImageSensorConfigurationLayout : public vrs::AutoDataLayout { |
| 41 | + static constexpr uint32_t kVersion = 2; |
| 42 | + |
| 43 | + explicit ImageSensorConfigurationLayout(bool allocateVideoFields = false) |
| 44 | + : videoConfigurationFields(allocateVideoFields) {} |
| 45 | + |
| 46 | + vrs::DataPieceString deviceType{"device_type"}; |
| 47 | + vrs::DataPieceString deviceVersion{"device_version"}; |
| 48 | + vrs::DataPieceString deviceSerial{"device_serial"}; |
| 49 | + |
| 50 | + vrs::DataPieceValue<std::uint32_t> cameraId{"camera_id"}; |
| 51 | + vrs::DataPieceValue<std::uint32_t> streamType{"stream_type"}; |
| 52 | + vrs::DataPieceValue<std::uint32_t> streamIndex{"stream_index"}; |
| 53 | + |
| 54 | + vrs::DataPieceString sensorModel{"sensor_model"}; |
| 55 | + vrs::DataPieceString sensorSerial{"sensor_serial"}; |
| 56 | + |
| 57 | + vrs::DataPieceValue<double> nominalRateHz{"nominal_rate"}; |
| 58 | + |
| 59 | + vrs::DataPieceValue<ImageSpecType> imageWidth{vrs::datalayout_conventions::kImageWidth}; |
| 60 | + vrs::DataPieceValue<ImageSpecType> imageHeight{vrs::datalayout_conventions::kImageHeight}; |
| 61 | + vrs::DataPieceValue<ImageSpecType> imageStride{vrs::datalayout_conventions::kImageStride}; |
| 62 | + vrs::DataPieceValue<ImageSpecType> imageStride2{vrs::datalayout_conventions::kImageStride2}; |
| 63 | + vrs::DataPieceValue<ImageSpecType> pixelFormat{vrs::datalayout_conventions::kImagePixelFormat}; |
| 64 | + vrs::DataPieceValue<ImageSpecType> plane2OffsetRows{"image_plane_2_offset_rows"}; |
| 65 | + vrs::DataPieceValue<ImageSpecType> plane3OffsetRows{"image_plane_3_offset_rows"}; |
| 66 | + |
| 67 | + vrs::DataPieceValue<std::uint32_t> imageOrientation{"image_orientation"}; |
| 68 | + vrs::DataPieceValue<std::uint32_t> shutterDirection{"shutter_direction"}; |
| 69 | + |
| 70 | + vrs::DataPieceValue<double> exposureDurationMin{"exposure_duration.min"}; |
| 71 | + vrs::DataPieceValue<double> exposureDurationMax{"exposure_duration.max"}; |
| 72 | + |
| 73 | + vrs::DataPieceValue<double> gainMin{"gain.min"}; |
| 74 | + vrs::DataPieceValue<double> gainMax{"gain.max"}; |
| 75 | + |
| 76 | + vrs::DataPieceValue<double> gammaFactor{"gamma_factor"}; |
| 77 | + |
| 78 | + vrs::DataPieceString factoryCalibration{"factory_calibration"}; |
| 79 | + vrs::DataPieceString onlineCalibration{"online_calibration"}; |
| 80 | + |
| 81 | + vrs::DataPieceString description{"description"}; |
| 82 | + |
| 83 | + vrs::DataPieceString cameraMuxModeName{"camera_mux_mode_name"}; |
| 84 | + |
| 85 | + const OptionalDataPieces<VideoConfigurationFields> videoConfigurationFields; |
| 86 | + |
| 87 | + vrs::AutoDataLayoutEnd end; |
| 88 | +}; |
| 89 | + |
| 90 | +// Additional fields to enable in ImageDataLayout when data was encoded as video |
| 91 | +// before recording. |
| 92 | +struct VideoDataFields { |
| 93 | + vrs::DataPieceValue<double> keyFrameTimestamp{ |
| 94 | + vrs::datalayout_conventions::kImageKeyFrameTimeStamp}; |
| 95 | + vrs::DataPieceValue<ImageSpecType> keyFrameIndex{ |
| 96 | + vrs::datalayout_conventions::kImageKeyFrameIndex}; |
| 97 | +}; |
| 98 | + |
| 99 | +struct ImageDataLayout : public vrs::AutoDataLayout { |
| 100 | + static constexpr uint32_t kVersion = 2; |
| 101 | + |
| 102 | + explicit ImageDataLayout(bool allocateVideoFields = false) |
| 103 | + : videoDataFields(allocateVideoFields) {} |
| 104 | + |
| 105 | + vrs::DataPieceValue<std::uint64_t> groupId{"group_id"}; |
| 106 | + vrs::DataPieceValue<std::uint64_t> groupMask{"group_mask"}; |
| 107 | + vrs::DataPieceValue<std::uint64_t> streamIndexMask{"stream_index_mask"}; |
| 108 | + vrs::DataPieceValue<std::uint64_t> frameNumber{"frame_number"}; |
| 109 | + vrs::DataPieceValue<std::uint32_t> frameTag{"frame_tag"}; |
| 110 | + vrs::DataPieceValue<double> exposureDuration{"exposure_duration_s"}; |
| 111 | + vrs::DataPieceValue<double> gain{"gain"}; |
| 112 | + vrs::DataPieceValue<double> readoutDurationSeconds{"readout_duration_s"}; |
| 113 | + vrs::DataPieceValue<std::int64_t> captureTimestampNs{"capture_timestamp_ns"}; |
| 114 | + vrs::DataPieceValue<std::int64_t> captureTimestampInProcessingClockDomainNs{ |
| 115 | + "capture_timestamp_in_processing_clock_domain_ns"}; |
| 116 | + vrs::DataPieceValue<std::int64_t> arrivalTimestampNs{"arrival_timestamp_ns"}; |
| 117 | + vrs::DataPieceValue<std::int64_t> processingStartTimestampNs{"processing_start_timestamp_ns"}; |
| 118 | + vrs::DataPieceValue<double> temperature{"temperature_deg_c"}; |
| 119 | + vrs::DataPieceVector<uint8_t> imageMetadata{"image_metadata"}; |
| 120 | + |
| 121 | + const OptionalDataPieces<VideoDataFields> videoDataFields; |
| 122 | + |
| 123 | + vrs::DataPieceValue<double> focusDistanceMm{"focus_distance_mm", -1.0}; |
| 124 | + |
| 125 | + vrs::AutoDataLayoutEnd end; |
| 126 | +}; |
| 127 | + |
| 128 | +class PyStream; |
| 129 | + |
| 130 | +std::unique_ptr<PyStream> createAriaGen2ImageStream( |
| 131 | + const std::string& flavor, |
| 132 | + vrs::RecordableTypeId typeId, |
| 133 | + const std::string& codec = "H.265"); |
| 134 | + |
| 135 | +} // namespace pyvrs |
0 commit comments