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

Missing streamer files

parent 49e884d3
No related branches found
No related tags found
No related merge requests found
Pipeline #9739 passed
#ifndef _FTL_STREAMER_HPP_
#define _FTL_STREAMER_HPP_
#include <ftl/net/universe.hpp>
#include <nlohmann/json.hpp>
#include <opencv2/opencv.hpp>
#include <string>
namespace ftl {
class Streamer {
public:
Streamer(ftl::net::Universe &net, nlohmann::json &config);
~Streamer();
void send(const cv::Mat &rgb, const cv::Mat &depth);
private:
ftl::net::Universe &net_;
nlohmann::json config_;
std::string uri_;
};
};
#endif // _FTL_STREAMER_HPP_
#include <glog/logging.h>
#include <ftl/streamer.hpp>
#include <vector>
using ftl::Streamer;
using ftl::net::Universe;
using cv::Mat;
using nlohmann::json;
using std::string;
using std::vector;
Streamer::Streamer(Universe &net, json &config) : net_(net), config_(config) {
uri_ = string("ftl://utu.fi/")+(string)config["name"]+string("/rgb-d");
net.createResource(uri_);
}
Streamer::~Streamer() {
}
void Streamer::send(const Mat &rgb, const Mat &depth) {
// Compress the rgb as jpeg.
vector<unsigned char> rgb_buf;
cv::imencode(".jpg", rgb, rgb_buf);
net_.publish(uri_, rgb_buf);
LOG(INFO) << "JPG Size = " << ((float)rgb_buf.size() / (1024.0f*1024.0f)) << "Mb";
}
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