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(
const DisparityComputingMethod &MethodType);
/**
* Set if the duplicate frames is enable.
*/
void setDuplicate(bool isEnable);
/**
* Set the option value.
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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