diff --git a/applications/vision/src/main.cpp b/applications/vision/src/main.cpp index 82da61dcfc7d780f7624e9e4ac051ceef973a117..d6c8e3eb03aef69a256e752597cc878fbe81bd8a 100644 --- a/applications/vision/src/main.cpp +++ b/applications/vision/src/main.cpp @@ -163,7 +163,12 @@ static void run(ftl::Configurable *root) { // Send channels on flush auto flushhandle = pool.onFlushSet([sender](ftl::data::FrameSet &fs, ftl::codecs::Channel c) { // TODO: Check the channel to see if it should be sent or not - sender->post(fs, c); + switch (c) { + case Channel::Colour : + case Channel::Colour2 : + case Channel::Depth : sender->post(fs, c); break; + default: break; + } return true; }); diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp index b8155489ed9f1a32aa1e7abbc297357398da2070..7bec885a7d6276faaf92a0094a598845b82a1cf7 100644 --- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp @@ -182,7 +182,7 @@ bool PylonDevice::get(cv::cuda::GpuMat &l_out, cv::cuda::GpuMat &r_out, cv::cuda CV_8UC1, (uint8_t*)result_right->GetBuffer()); - cv::cvtColor(wrap_right, rfull, cv::COLOR_BayerBG2BGRA); + cv::cvtColor(wrap_right, rfull, cv::COLOR_BayerRG2BGRA); if (isStereo()) { c->rectifyRight(rfull); @@ -218,7 +218,7 @@ bool PylonDevice::get(cv::cuda::GpuMat &l_out, cv::cuda::GpuMat &r_out, cv::cuda CV_8UC1, (uint8_t*)result_left->GetBuffer()); - cv::cvtColor(wrap_left, lfull, cv::COLOR_BayerBG2BGRA); + cv::cvtColor(wrap_left, lfull, cv::COLOR_BayerRG2BGRA); if (isStereo()) { c->rectifyLeft(lfull); diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp index 1fcd531101db4c4f4f525cbdf456c233ec07ecdd..191c5ed83e0d97d8b90683bca7336e74ea79148a 100644 --- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp @@ -329,12 +329,17 @@ bool StereoVideoSource::retrieve(ftl::rgbd::Frame &frame) { if (lsrc_->isStereo()) { cv::cuda::GpuMat &left = frame.create<cv::cuda::GpuMat>(Channel::Left); cv::cuda::GpuMat &right = frame.create<cv::cuda::GpuMat>(Channel::Right); - lsrc_->get(left, right, hres, hres_r, calib_, stream2_); + if (!lsrc_->get(left, right, hres, hres_r, calib_, stream2_)) { + frame.remove(Channel::Left); + frame.remove(Channel::Right); + } } else { cv::cuda::GpuMat &left = frame.create<cv::cuda::GpuMat>(Channel::Left); cv::cuda::GpuMat right; - lsrc_->get(left, right, hres, hres_r, calib_, stream2_); + if (!lsrc_->get(left, right, hres, hres_r, calib_, stream2_)) { + frame.remove(Channel::Left); + } } //LOG(INFO) << "Channel size: " << hres.size(); diff --git a/components/streams/src/sender.cpp b/components/streams/src/sender.cpp index 4a294c6976fdadc5da1103beaeb18588c788f0d4..6bf1a4fd35be8218b5a48e6187beee204ff5129c 100644 --- a/components/streams/src/sender.cpp +++ b/components/streams/src/sender.cpp @@ -397,6 +397,11 @@ void Sender::_encodeVideoChannel(ftl::data::FrameSet &fs, Channel c, bool reset) // fs.frames[offset].upload(cc); //} + if (!fs.frames[offset].hasChannel(cc)) { + offset++; + continue; + } + StreamPacket spkt; spkt.version = 4; spkt.timestamp = fs.timestamp(); @@ -464,7 +469,7 @@ void Sender::_encodeVideoChannel(ftl::data::FrameSet &fs, Channel c, bool reset) cv::imshow("Test", tmp); cv::waitKey(1);*/ } else { - LOG(ERROR) << "Encoding failed"; + LOG(ERROR) << "Encoding failed for channel " << (int)cc; } } catch (std::exception &e) { LOG(ERROR) << "Exception in encoder: " << e.what(); diff --git a/components/structures/src/new_frame.cpp b/components/structures/src/new_frame.cpp index 3ce0238b18e18998877c7e4f61078aeab53426bd..3181e31eef4e39d6965ba2ab2cd43f296bd1c96a 100644 --- a/components/structures/src/new_frame.cpp +++ b/components/structures/src/new_frame.cpp @@ -89,6 +89,14 @@ bool ftl::data::Frame::has(ftl::codecs::Channel c) const { } } +void ftl::data::Frame::remove(ftl::codecs::Channel c) { + const auto &i = data_.find(c); + if (i != data_.end()) { + i->second.status = ftl::data::ChannelStatus::INVALID; + changed_.erase(c); + } +} + Frame::ChannelData &Frame::_getData(ftl::codecs::Channel c) { if (status_ == FrameStatus::RELEASED) throw FTL_Error("Reading a released frame"); const auto &i = data_.find(c);