Skip to content
Snippets Groups Projects
Commit a1704bb4 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

Merge branch 'master' of gitlab.utu.fi:nicolas.pope/ftl

parents 6901b94e fef5f737
No related branches found
No related tags found
No related merge requests found
Pipeline #20575 passed
...@@ -352,7 +352,10 @@ void ftl::gui::Camera::_draw(std::vector<ftl::rgbd::FrameSet*> &fss) { ...@@ -352,7 +352,10 @@ void ftl::gui::Camera::_draw(std::vector<ftl::rgbd::FrameSet*> &fss) {
void ftl::gui::Camera::_downloadFrames(ftl::rgbd::Frame *frame) { void ftl::gui::Camera::_downloadFrames(ftl::rgbd::Frame *frame) {
if (!frame) return; if (!frame) return;
auto &channel1 = frame->get<GpuMat>(Channel::Colour); // Use high res colour if available..
auto &channel1 = (frame->hasChannel(Channel::ColourHighRes)) ?
frame->get<GpuMat>(Channel::ColourHighRes) :
frame->get<GpuMat>(Channel::Colour);
im1_.create(channel1.size(), channel1.type()); im1_.create(channel1.size(), channel1.type());
channel1.download(im1_); channel1.download(im1_);
......
...@@ -139,7 +139,7 @@ Mat Calibrate::_getK(size_t idx) { ...@@ -139,7 +139,7 @@ Mat Calibrate::_getK(size_t idx) {
Mat Calibrate::getCameraMatrixLeft(const cv::Size res) { Mat Calibrate::getCameraMatrixLeft(const cv::Size res) {
if (rectify_) { if (rectify_) {
return Mat(P1_, cv::Rect(0, 0, 3, 3)); return scaleCameraIntrinsics(Mat(P1_, cv::Rect(0, 0, 3, 3)), res, img_size_);
} else { } else {
return scaleCameraIntrinsics(K_[0], res, calib_size_); return scaleCameraIntrinsics(K_[0], res, calib_size_);
} }
...@@ -147,7 +147,7 @@ Mat Calibrate::getCameraMatrixLeft(const cv::Size res) { ...@@ -147,7 +147,7 @@ Mat Calibrate::getCameraMatrixLeft(const cv::Size res) {
Mat Calibrate::getCameraMatrixRight(const cv::Size res) { Mat Calibrate::getCameraMatrixRight(const cv::Size res) {
if (rectify_) { if (rectify_) {
return Mat(P2_, cv::Rect(0, 0, 3, 3)); return scaleCameraIntrinsics(Mat(P2_, cv::Rect(0, 0, 3, 3)), res, img_size_);
} else { } else {
return scaleCameraIntrinsics(K_[1], res, calib_size_); return scaleCameraIntrinsics(K_[1], res, calib_size_);
} }
......
...@@ -45,6 +45,10 @@ bool File::post(const ftl::codecs::StreamPacket &s, const ftl::codecs::Packet &p ...@@ -45,6 +45,10 @@ bool File::post(const ftl::codecs::StreamPacket &s, const ftl::codecs::Packet &p
available(s.streamID) += s.channel; available(s.streamID) += s.channel;
// Discard all data channel packets for now
// TODO: Allow saving of data channels once formats have solidified.
if (static_cast<int>(s.channel) >= static_cast<int>(ftl::codecs::Channel::Data)) return true;
ftl::codecs::StreamPacket s2 = s; ftl::codecs::StreamPacket s2 = s;
// Adjust timestamp relative to start of file. // Adjust timestamp relative to start of file.
s2.timestamp -= timestart_; s2.timestamp -= timestart_;
......
...@@ -163,8 +163,8 @@ void Sender::post(ftl::rgbd::FrameSet &fs) { ...@@ -163,8 +163,8 @@ void Sender::post(ftl::rgbd::FrameSet &fs) {
for (auto c : frame.getChannels()) { for (auto c : frame.getChannels()) {
if (selected.has(c)) { if (selected.has(c)) {
// FIXME: Sends high res colour, but receive end currently broken // FIXME: Sends high res colour, but receive end currently broken
//auto cc = (c == Channel::Colour && frame.hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : Channel::Colour; auto cc = (c == Channel::Colour && frame.hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : c;
auto cc = c; //auto cc = c;
StreamPacket spkt; StreamPacket spkt;
spkt.version = 4; spkt.version = 4;
...@@ -230,6 +230,8 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) { ...@@ -230,6 +230,8 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
uint32_t offset = 0; uint32_t offset = 0;
while (offset < fs.frames.size()) { while (offset < fs.frames.size()) {
auto cc = (c == Channel::Colour && fs.frames[offset].hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : c;
StreamPacket spkt; StreamPacket spkt;
spkt.version = 4; spkt.version = 4;
spkt.timestamp = fs.timestamp; spkt.timestamp = fs.timestamp;
...@@ -237,7 +239,7 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) { ...@@ -237,7 +239,7 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
spkt.frame_number = offset; spkt.frame_number = offset;
spkt.channel = c; spkt.channel = c;
auto &tile = _getTile(fs.id, c); auto &tile = _getTile(fs.id, cc);
ftl::codecs::Encoder *enc = tile.encoder[(offset==0)?0:1]; ftl::codecs::Encoder *enc = tile.encoder[(offset==0)?0:1];
if (!enc) { if (!enc) {
...@@ -254,11 +256,11 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) { ...@@ -254,11 +256,11 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
// Upload if in host memory // Upload if in host memory
for (auto &f : fs.frames) { for (auto &f : fs.frames) {
if (f.isCPU(c)) { if (f.isCPU(c)) {
f.upload(Channels<0>(c), cv::cuda::StreamAccessor::getStream(enc->stream())); f.upload(Channels<0>(cc), cv::cuda::StreamAccessor::getStream(enc->stream()));
} }
} }
int count = _generateTiles(fs, offset, c, enc->stream(), lossless); int count = _generateTiles(fs, offset, cc, enc->stream(), lossless);
if (count <= 0) { if (count <= 0) {
LOG(ERROR) << "Could not generate tiles."; LOG(ERROR) << "Could not generate tiles.";
break; break;
...@@ -277,15 +279,15 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) { ...@@ -277,15 +279,15 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
pkt.frame_count = count; pkt.frame_count = count;
pkt.codec = codec; pkt.codec = codec;
pkt.definition = definition_t::Any; pkt.definition = definition_t::Any;
pkt.bitrate = (!lossless && ftl::codecs::isFloatChannel(c)) ? max_bitrate : max_bitrate/2; pkt.bitrate = (!lossless && ftl::codecs::isFloatChannel(cc)) ? max_bitrate : max_bitrate/2;
pkt.flags = 0; pkt.flags = 0;
if (!lossless && ftl::codecs::isFloatChannel(c)) pkt.flags = ftl::codecs::kFlagFloat | ftl::codecs::kFlagMappedDepth; if (!lossless && ftl::codecs::isFloatChannel(cc)) pkt.flags = ftl::codecs::kFlagFloat | ftl::codecs::kFlagMappedDepth;
else if (lossless && ftl::codecs::isFloatChannel(c)) pkt.flags = ftl::codecs::kFlagFloat; else if (lossless && ftl::codecs::isFloatChannel(cc)) pkt.flags = ftl::codecs::kFlagFloat;
else pkt.flags = ftl::codecs::kFlagFlipRGB; else pkt.flags = ftl::codecs::kFlagFlipRGB;
// Choose correct region of interest into the surface. // Choose correct region of interest into the surface.
cv::Rect roi = _generateROI(fs, c, offset); cv::Rect roi = _generateROI(fs, cc, offset);
cv::cuda::GpuMat sroi = tile.surface(roi); cv::cuda::GpuMat sroi = tile.surface(roi);
if (enc->encode(sroi, pkt)) { if (enc->encode(sroi, pkt)) {
...@@ -376,8 +378,10 @@ int Sender::_generateTiles(const ftl::rgbd::FrameSet &fs, int offset, Channel c, ...@@ -376,8 +378,10 @@ int Sender::_generateTiles(const ftl::rgbd::FrameSet &fs, int offset, Channel c,
} }
} else if (m.type() == CV_8UC4) { } else if (m.type() == CV_8UC4) {
cv::cuda::cvtColor(m, sroi, cv::COLOR_BGRA2RGBA, 0, stream); cv::cuda::cvtColor(m, sroi, cv::COLOR_BGRA2RGBA, 0, stream);
} else if (m.type() == CV_8UC3) {
cv::cuda::cvtColor(m, sroi, cv::COLOR_BGR2RGBA, 0, stream);
} else { } else {
LOG(ERROR) << "Unsupported colour format"; LOG(ERROR) << "Unsupported colour format: " << m.type();
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment