@@ -45,13 +45,15 @@ namespace rerun_vrs {
45
45
46
46
rec_.set_time_seconds (" timestamp" , record.timestamp );
47
47
48
- if (record.recordType == vrs::Record::Type::CONFIGURATION)
48
+ if (record.recordType == vrs::Record::Type::CONFIGURATION) {
49
49
// NOTE this is meta data from the sensor that doesn't change over time and only comes
50
50
// in once in the beginning
51
51
rec_.log_timeless (
52
52
(entityPath_ + " /configuration" ).c_str (),
53
53
rerun::TextDocument (layout_str)
54
54
);
55
+ return false ;
56
+ }
55
57
56
58
if (record.recordType == vrs::Record::Type::DATA) {
57
59
auto & config = getExpectedLayout<FrameNumberDataLayout>(layout, blockIndex);
@@ -70,101 +72,29 @@ namespace rerun_vrs {
70
72
const vrs::CurrentRecord& record, size_t /* blockIndex*/ ,
71
73
const vrs::ContentBlock& contentBlock
72
74
) {
73
- /* std::cout << "onImageRead" << std::endl; */
74
- /* std::cout << "onImageRead" << std::endl; */
75
- const auto & spec = contentBlock.image ();
76
75
std::shared_ptr<vrs::utils::PixelFrame> frame;
77
- const auto & imageFormat = spec.getImageFormat ();
78
- const auto & imageFormatStr = spec.getImageFormatAsString ();
79
- bool frameValid = false ;
80
- /* std::cout << spec.getWidth() << "x" << spec.getHeight() << " " */
81
- /* << spec.getPixelFormatAsString() << " " << spec.getImageFormatAsString() */
82
- /* << std::endl; */
83
-
84
- if (imageFormat == vrs::ImageFormat::RAW) {
85
- frameValid = vrs::utils::PixelFrame::readRawFrame (frame, record.reader , spec);
86
- if (frameValid) {
87
- // Log image to Rerun
88
- // NOTE currently we need to construct a vector to log an image, this will
89
- // change in the future, see https://github.com/rerun-io/rerun/issues/3794
90
-
91
- rec_.log (
92
- add_quotes (id_.getName ()).c_str (),
93
- rerun::Image (
94
- {spec.getHeight (), spec.getWidth (), spec.getChannelCountPerPixel ()},
95
- std::move (frame->getBuffer ())
96
- )
97
- );
98
- } else {
99
- std::cout << " Failed reading raw frame." << std::endl;
100
- }
101
- /* if (!firstImage_ && frameValid) { */
102
- /* job = make_unique<ImageJob>(vrs::ImageFormat::RAW); */
103
- /* } */
76
+ bool frameValid = vrs::utils::PixelFrame::readFrame (frame, record.reader , contentBlock);
77
+
78
+ if (frameValid) {
79
+ // Log image to Rerun
80
+ // NOTE currently we need to construct a vector to log an image, this will
81
+ // change in the future, see https://github.com/rerun-io/rerun/issues/3794
82
+ rec_.log (
83
+ add_quotes (id_.getName ()).c_str (),
84
+ rerun::Image (
85
+ {frame->getHeight (),
86
+ frame->getWidth (),
87
+ frame->getSpec ().getChannelCountPerPixel ()},
88
+ std::move (frame->getBuffer ())
89
+ )
90
+ );
104
91
} else {
105
- std::cout << " Image format \" " << imageFormatStr
106
- << " \" not supported. Disabling player." << std::endl;
92
+ std::cout << " Failed reading image with format \" "
93
+ << contentBlock.image ().getImageFormatAsString () << " \" . Disabling player."
94
+ << std::endl;
107
95
enabled_ = false ;
108
96
}
109
97
return true ; // read next blocks, if any
110
-
111
- /* } else if (imageFormat_ == vrs::ImageFormat::VIDEO) { */
112
- /* // Video codec decompression happens here, but pixel format conversion is
113
- * asynchronous */
114
- /* PixelFrame::init(frame, contentBlock.image()); */
115
- /* frameValid = (tryToDecodeFrame(*frame, record, contentBlock) == 0); */
116
- /* if (!firstImage_ && frameValid) { */
117
- /* job = make_unique<ImageJob>(vrs::ImageFormat::VIDEO); */
118
- /* } */
119
- /* } else { */
120
- /* if (firstImage_) { */
121
- /* frameValid = PixelFrame::readFrame(frame, record.reader, contentBlock);
122
- */
123
- /* } else { */
124
- /* // decoding & pixel format conversion happen asynchronously */
125
- /* job = make_unique<ImageJob>(imageFormat_); */
126
- /* job->buffer.resize(contentBlock.getBlockSize()); */
127
- /* frameValid = (record.reader->read(job->buffer) == 0); */
128
- /* } */
129
- /* } */
130
- /* if (frameValid && job) { */
131
- /* job->frame = std::move(frame); */
132
- /* imageJobs_.startThreadIfNeeded(&FramePlayer::imageJobsThreadActivity,
133
- * this); */
134
- /* imageJobs_.sendJob(std::move(job)); */
135
- /* return true; */
136
- /* } */
137
- /* if (firstImage_) { */
138
- /* fmt::print( */
139
- /* "Found '{} - {}': {}, {}", */
140
- /* record.streamId.getNumericName(), */
141
- /* record.streamId.getTypeName(), */
142
- /* getCurrentRecordFormatReader()->recordFormat.asString(), */
143
- /* spec.asString()); */
144
- /* if (frameValid && spec.getImageFormat() != vrs::ImageFormat::RAW) { */
145
- /* fmt::print(" - {}", frame->getSpec().asString()); */
146
- /* } */
147
- /* blankMode_ = false; */
148
- /* } */
149
- /* if (frameValid) { */
150
- /* convertFrame(frame); */
151
- /* if (firstImage_) { */
152
- /* if (needsConvertedFrame_) { */
153
- /* fmt::print(" -> {}", frame->getSpec().asString()); */
154
- /* } */
155
- /* if (estimatedFps_ != 0) { */
156
- /* fmt::print(", {} fps", estimatedFps_); */
157
- /* } */
158
- /* frame->blankFrame(); */
159
- /* blankMode_ = true; */
160
- /* } */
161
- /* widget_->swapImage(frame); */
162
- /* } */
163
- /* recycle(frame, !needsConvertedFrame_); */
164
- /* if (firstImage_) { */
165
- /* fmt::print("\n"); */
166
- /* firstImage_ = false; */
167
- /* } */
168
98
}
169
99
170
100
void RerunFramePlayer::convertFrame (std::shared_ptr<vrs::utils::PixelFrame>& frame) {
0 commit comments