Obtain raw frame in api stream data

This commit is contained in:
John Zhao 2018-06-07 17:39:51 +08:00
parent 22ea971407
commit 09fb4c04df
2 changed files with 23 additions and 13 deletions

View File

@ -30,6 +30,12 @@ MYNTEYE_BEGIN_NAMESPACE
class Device; class Device;
class Synthetic; class Synthetic;
namespace device {
class Frame;
} // namespace device
namespace api { namespace api {
/** /**
@ -41,6 +47,8 @@ struct MYNTEYE_API StreamData {
std::shared_ptr<ImgData> img; std::shared_ptr<ImgData> img;
/** Frame. */ /** Frame. */
cv::Mat frame; cv::Mat frame;
/** Raw frame. */
std::shared_ptr<device::Frame> frame_raw;
bool operator==(const StreamData &other) const { bool operator==(const StreamData &other) const {
if (img && other.img) { if (img && other.img) {

View File

@ -46,7 +46,7 @@ cv::Mat frame2mat(const std::shared_ptr<device::Frame> &frame) {
} }
api::StreamData data2api(const device::StreamData &data) { api::StreamData data2api(const device::StreamData &data) {
return {data.img, frame2mat(data.frame)}; return {data.img, frame2mat(data.frame), data.frame};
} }
} // namespace } // namespace
@ -152,7 +152,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat2 *output = Object::Cast<ObjMat2>(out); ObjMat2 *output = Object::Cast<ObjMat2>(out);
return {nullptr, output->first}; return {nullptr, output->first, nullptr};
} }
VLOG(2) << "Rectify not ready now"; VLOG(2) << "Rectify not ready now";
} break; } break;
@ -161,7 +161,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat2 *output = Object::Cast<ObjMat2>(out); ObjMat2 *output = Object::Cast<ObjMat2>(out);
return {nullptr, output->second}; return {nullptr, output->second, nullptr};
} }
VLOG(2) << "Rectify not ready now"; VLOG(2) << "Rectify not ready now";
} break; } break;
@ -170,7 +170,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
return {nullptr, output->value}; return {nullptr, output->value, nullptr};
} }
VLOG(2) << "Disparity not ready now"; VLOG(2) << "Disparity not ready now";
} break; } break;
@ -180,7 +180,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
return {nullptr, output->value}; return {nullptr, output->value, nullptr};
} }
VLOG(2) << "Disparity normalized not ready now"; VLOG(2) << "Disparity normalized not ready now";
} break; } break;
@ -189,7 +189,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
return {nullptr, output->value}; return {nullptr, output->value, nullptr};
} }
VLOG(2) << "Points not ready now"; VLOG(2) << "Points not ready now";
} break; } break;
@ -198,7 +198,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
Object *out = processor->GetOutput(); Object *out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
return {nullptr, output->value}; return {nullptr, output->value, nullptr};
} }
VLOG(2) << "Depth not ready now"; VLOG(2) << "Depth not ready now";
} break; } break;
@ -546,17 +546,19 @@ bool Synthetic::OnDepthProcess(
void Synthetic::OnRectifyPostProcess(Object *const out) { void Synthetic::OnRectifyPostProcess(Object *const out) {
const ObjMat2 *output = Object::Cast<ObjMat2>(out); const ObjMat2 *output = Object::Cast<ObjMat2>(out);
if (HasStreamCallback(Stream::LEFT_RECTIFIED)) { if (HasStreamCallback(Stream::LEFT_RECTIFIED)) {
stream_callbacks_.at(Stream::LEFT_RECTIFIED)({nullptr, output->first}); stream_callbacks_.at(Stream::LEFT_RECTIFIED)(
{nullptr, output->first, nullptr});
} }
if (HasStreamCallback(Stream::RIGHT_RECTIFIED)) { if (HasStreamCallback(Stream::RIGHT_RECTIFIED)) {
stream_callbacks_.at(Stream::RIGHT_RECTIFIED)({nullptr, output->second}); stream_callbacks_.at(Stream::RIGHT_RECTIFIED)(
{nullptr, output->second, nullptr});
} }
} }
void Synthetic::OnDisparityPostProcess(Object *const out) { void Synthetic::OnDisparityPostProcess(Object *const out) {
const ObjMat *output = Object::Cast<ObjMat>(out); const ObjMat *output = Object::Cast<ObjMat>(out);
if (HasStreamCallback(Stream::DISPARITY)) { if (HasStreamCallback(Stream::DISPARITY)) {
stream_callbacks_.at(Stream::DISPARITY)({nullptr, output->value}); stream_callbacks_.at(Stream::DISPARITY)({nullptr, output->value, nullptr});
} }
} }
@ -564,21 +566,21 @@ void Synthetic::OnDisparityNormalizedPostProcess(Object *const out) {
const ObjMat *output = Object::Cast<ObjMat>(out); const ObjMat *output = Object::Cast<ObjMat>(out);
if (HasStreamCallback(Stream::DISPARITY_NORMALIZED)) { if (HasStreamCallback(Stream::DISPARITY_NORMALIZED)) {
stream_callbacks_.at(Stream::DISPARITY_NORMALIZED)( stream_callbacks_.at(Stream::DISPARITY_NORMALIZED)(
{nullptr, output->value}); {nullptr, output->value, nullptr});
} }
} }
void Synthetic::OnPointsPostProcess(Object *const out) { void Synthetic::OnPointsPostProcess(Object *const out) {
const ObjMat *output = Object::Cast<ObjMat>(out); const ObjMat *output = Object::Cast<ObjMat>(out);
if (HasStreamCallback(Stream::POINTS)) { if (HasStreamCallback(Stream::POINTS)) {
stream_callbacks_.at(Stream::POINTS)({nullptr, output->value}); stream_callbacks_.at(Stream::POINTS)({nullptr, output->value, nullptr});
} }
} }
void Synthetic::OnDepthPostProcess(Object *const out) { void Synthetic::OnDepthPostProcess(Object *const out) {
const ObjMat *output = Object::Cast<ObjMat>(out); const ObjMat *output = Object::Cast<ObjMat>(out);
if (HasStreamCallback(Stream::DEPTH)) { if (HasStreamCallback(Stream::DEPTH)) {
stream_callbacks_.at(Stream::DEPTH)({nullptr, output->value}); stream_callbacks_.at(Stream::DEPTH)({nullptr, output->value, nullptr});
} }
} }