Skip to content
Snippets Groups Projects
net.hpp 1.34 KiB
Newer Older
Nicolas Pope's avatar
Nicolas Pope committed
#pragma once
#ifndef _FTL_RGBD_NET_HPP_
#define _FTL_RGBD_NET_HPP_

#include <ftl/net/universe.hpp>
#include <ftl/rgbd/source.hpp>
Nicolas Pope's avatar
Nicolas Pope committed
#include <ftl/threads.hpp>
Nicolas Pope's avatar
Nicolas Pope committed
#include <string>

namespace ftl {
namespace rgbd {
namespace detail {
Nicolas Pope's avatar
Nicolas Pope committed

/**
 * RGBD source from either a stereo video file with left + right images, or
 * direct from two camera devices. A variety of algorithms are included for
 * calculating disparity, before converting to depth.  Calibration of the images
 * is also performed.
 */
class NetSource : public detail::Source {
Nicolas Pope's avatar
Nicolas Pope committed
	public:
	explicit NetSource(ftl::rgbd::Source *);
Nicolas Pope's avatar
Nicolas Pope committed
	~NetSource();

	bool grab(int n, int b);
Nicolas Pope's avatar
Nicolas Pope committed
	bool isReady();

Nicolas Pope's avatar
Nicolas Pope committed
	void setPose(const Eigen::Matrix4d &pose);
	void reset();

Nicolas Pope's avatar
Nicolas Pope committed
	private:
	bool has_calibration_;
	ftl::UUID peer_;
	int N_;
	bool active_;
	std::string uri_;
	ftl::net::callback_t h_;
Nicolas Pope's avatar
Nicolas Pope committed
	MUTEX mutex_;
	int chunks_dim_;
	int chunk_width_;
	int chunk_height_;
	cv::Mat idepth_;
	float gamma_;
	int temperature_;
	int minB_;
	int maxN_;
	bool _getCalibration(ftl::net::Universe &net, const ftl::UUID &peer, const std::string &src, ftl::rgbd::Camera &p);
	void _recv(const std::vector<unsigned char> &jpg, const std::vector<unsigned char> &d);
	void _recvChunk(int frame, int chunk, bool delta, const std::vector<unsigned char> &jpg, const std::vector<unsigned char> &d);
	void _updateURI();
Nicolas Pope's avatar
Nicolas Pope committed
};

Nicolas Pope's avatar
Nicolas Pope committed
}
}

#endif  // _FTL_RGBD_NET_HPP_