Skip to content
Snippets Groups Projects
Commit fef5f737 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge branch 'bug/270/fullhd' into 'master'

Resolve #270 full hd colour

Closes #270

See merge request nicolas.pope/ftl!247
parents 890e7ed6 b00a9624
No related branches found
No related tags found
1 merge request!247Resolve #270 full hd colour
Pipeline #20452 passed
......@@ -352,7 +352,10 @@ void ftl::gui::Camera::_draw(std::vector<ftl::rgbd::FrameSet*> &fss) {
void ftl::gui::Camera::_downloadFrames(ftl::rgbd::Frame *frame) {
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());
channel1.download(im1_);
......
......@@ -139,7 +139,7 @@ Mat Calibrate::_getK(size_t idx) {
Mat Calibrate::getCameraMatrixLeft(const cv::Size res) {
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 {
return scaleCameraIntrinsics(K_[0], res, calib_size_);
}
......@@ -147,7 +147,7 @@ Mat Calibrate::getCameraMatrixLeft(const cv::Size res) {
Mat Calibrate::getCameraMatrixRight(const cv::Size res) {
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 {
return scaleCameraIntrinsics(K_[1], res, calib_size_);
}
......
......@@ -163,8 +163,8 @@ void Sender::post(ftl::rgbd::FrameSet &fs) {
for (auto c : frame.getChannels()) {
if (selected.has(c)) {
// 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;
auto cc = (c == Channel::Colour && frame.hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : c;
//auto cc = c;
StreamPacket spkt;
spkt.version = 4;
......@@ -230,6 +230,8 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
uint32_t offset = 0;
while (offset < fs.frames.size()) {
auto cc = (c == Channel::Colour && fs.frames[offset].hasChannel(Channel::ColourHighRes)) ? Channel::ColourHighRes : c;
StreamPacket spkt;
spkt.version = 4;
spkt.timestamp = fs.timestamp;
......@@ -237,7 +239,7 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
spkt.frame_number = offset;
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];
if (!enc) {
......@@ -254,11 +256,11 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
// Upload if in host memory
for (auto &f : fs.frames) {
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) {
LOG(ERROR) << "Could not generate tiles.";
break;
......@@ -277,15 +279,15 @@ void Sender::_encodeChannel(ftl::rgbd::FrameSet &fs, Channel c, bool reset) {
pkt.frame_count = count;
pkt.codec = codec;
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;
if (!lossless && ftl::codecs::isFloatChannel(c)) pkt.flags = ftl::codecs::kFlagFloat | ftl::codecs::kFlagMappedDepth;
else if (lossless && ftl::codecs::isFloatChannel(c)) pkt.flags = ftl::codecs::kFlagFloat;
if (!lossless && ftl::codecs::isFloatChannel(cc)) pkt.flags = ftl::codecs::kFlagFloat | ftl::codecs::kFlagMappedDepth;
else if (lossless && ftl::codecs::isFloatChannel(cc)) pkt.flags = ftl::codecs::kFlagFloat;
else pkt.flags = ftl::codecs::kFlagFlipRGB;
// 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);
if (enc->encode(sroi, pkt)) {
......@@ -376,8 +378,10 @@ int Sender::_generateTiles(const ftl::rgbd::FrameSet &fs, int offset, Channel c,
}
} else if (m.type() == CV_8UC4) {
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 {
LOG(ERROR) << "Unsupported colour format";
LOG(ERROR) << "Unsupported colour format: " << m.type();
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