fix(api): add setDuplicate(enable)

This commit is contained in:
TinyOh 2019-03-14 09:51:42 +08:00
parent 0025a555ba
commit 5a6eabcc5f
8 changed files with 30 additions and 5 deletions

View File

@ -237,6 +237,11 @@ class MYNTEYE_API API {
void SetDisparityComputingMethodType( void SetDisparityComputingMethodType(
const DisparityComputingMethod &MethodType); const DisparityComputingMethod &MethodType);
/**
* Set if the duplicate frames is enable.
*/
void setDuplicate(bool isEnable);
/** /**
* Set the option value. * Set the option value.
*/ */

View File

@ -35,8 +35,6 @@ int main(int argc, char *argv[]) {
cv::namedWindow("frame"); cv::namedWindow("frame");
cv::namedWindow("depth"); cv::namedWindow("depth");
double t = 0;
double fps;
while (true) { while (true) {
api->WaitForStreams(); api->WaitForStreams();

View File

@ -26,6 +26,8 @@ int main(int argc, char *argv[]) {
if (!ok) return 1; if (!ok) return 1;
api->ConfigStreamRequest(request); api->ConfigStreamRequest(request);
api->setDuplicate(true);
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so"); api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
api->EnableStreamData(Stream::DISPARITY_NORMALIZED); api->EnableStreamData(Stream::DISPARITY_NORMALIZED);

View File

@ -560,6 +560,10 @@ void API::EnablePlugin(const std::string &path) {
synthetic_->SetPlugin(plugin); synthetic_->SetPlugin(plugin);
} }
void API::setDuplicate(bool isEnable) {
synthetic_->setDuplicate(isEnable);
}
void API::SetDisparityComputingMethodType( void API::SetDisparityComputingMethodType(
const DisparityComputingMethod &MethodType) { const DisparityComputingMethod &MethodType) {
synthetic_->SetDisparityComputingMethodType(MethodType); synthetic_->SetDisparityComputingMethodType(MethodType);

View File

@ -26,6 +26,7 @@ MYNTEYE_BEGIN_NAMESPACE
Processor::Processor(std::int32_t proc_period) Processor::Processor(std::int32_t proc_period)
: last_frame_id_cd(0), : last_frame_id_cd(0),
last_frame_id_cd_vice(0), last_frame_id_cd_vice(0),
is_enable_cd(false),
proc_period_(std::move(proc_period)), proc_period_(std::move(proc_period)),
activated_(false), activated_(false),
input_ready_(false), input_ready_(false),
@ -282,7 +283,8 @@ api::StreamData Processor::GetStreamData(const Stream &stream) {
if (out != nullptr) { if (out != nullptr) {
auto output = Object::Cast<ObjMat>(out); auto output = Object::Cast<ObjMat>(out);
if (output != nullptr) { if (output != nullptr) {
if (last_frame_id_cd == output->data->frame_id) { if (!is_enable_cd &&
last_frame_id_cd == output->data->frame_id) {
// cut the duplicate frame. // cut the duplicate frame.
return {}; return {};
} }
@ -302,7 +304,8 @@ api::StreamData Processor::GetStreamData(const Stream &stream) {
for (auto it : streams) { for (auto it : streams) {
if (it.stream == stream) { if (it.stream == stream) {
if (num == 1) { if (num == 1) {
if (last_frame_id_cd == output->first_data->frame_id) { if (!is_enable_cd &&
last_frame_id_cd == output->first_data->frame_id) {
// cut the duplicate frame. // cut the duplicate frame.
return {}; return {};
} }
@ -310,7 +313,8 @@ api::StreamData Processor::GetStreamData(const Stream &stream) {
return obj_data_first(output); return obj_data_first(output);
} else { } else {
// last_frame_id_cd = output->second_data->frame_id; // last_frame_id_cd = output->second_data->frame_id;
if (last_frame_id_cd_vice == output->second_data->frame_id) { if (!is_enable_cd &&
last_frame_id_cd_vice == output->second_data->frame_id) {
// cut the duplicate frame. // cut the duplicate frame.
return {}; return {};
} }

View File

@ -77,6 +77,9 @@ class Processor :
std::shared_ptr<Object> GetOutput(); std::shared_ptr<Object> GetOutput();
std::uint64_t GetDroppedCount(); std::uint64_t GetDroppedCount();
inline void setDupEnable(bool isEnable) {
is_enable_cd = isEnable;
}
protected: protected:
virtual Object *OnCreateOutput() = 0; virtual Object *OnCreateOutput() = 0;
@ -92,6 +95,7 @@ class Processor :
virtual process_type ProcessInputConnection(); virtual process_type ProcessInputConnection();
std::uint16_t last_frame_id_cd; std::uint16_t last_frame_id_cd;
std::uint16_t last_frame_id_cd_vice; std::uint16_t last_frame_id_cd_vice;
bool is_enable_cd;
private: private:
/** Run in standalone thread. */ /** Run in standalone thread. */
void Run(); void Run();

View File

@ -174,6 +174,12 @@ bool Synthetic::Supports(const Stream &stream) const {
return checkControlDateWithStream(stream); return checkControlDateWithStream(stream);
} }
void Synthetic::setDuplicate(bool isEnable) {
for (auto it : processors_) {
it->setDupEnable(isEnable);
}
}
void Synthetic::EnableStreamData( void Synthetic::EnableStreamData(
const Stream &stream, stream_switch_callback_t callback, const Stream &stream, stream_switch_callback_t callback,
bool try_tag) { bool try_tag) {

View File

@ -83,6 +83,8 @@ class Synthetic {
void SetPlugin(std::shared_ptr<Plugin> plugin); void SetPlugin(std::shared_ptr<Plugin> plugin);
bool HasPlugin() const; bool HasPlugin() const;
void setDuplicate(bool isEnable);
const struct stream_control_t getControlDateWithStream( const struct stream_control_t getControlDateWithStream(
const Stream& stream) const; const Stream& stream) const;
void setControlDateCallbackWithStream( void setControlDateCallbackWithStream(