virtual void perform() = 0;
virtual void performAsync(T &t) = 0;
virtual V &getOutput() = 0;
+ virtual V &getOutputCache() = 0;
};
} // namespace
} // namespace
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
return _face_recognition->result();
}
+template<typename T, typename V> V &FaceRecognitionAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class FaceRecognitionAdapter<FaceRecognitionInput, FaceRecognitionResult>;
}
}
\ No newline at end of file
return _facenet->result();
}
+template<typename T, typename V> V &FacenetAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class FacenetAdapter<FacenetInput, FacenetOutput>;
}
}
\ No newline at end of file
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
return _image_classification->result();
}
+template<typename T, typename V> V &ImageClassificationAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>;
}
}
\ No newline at end of file
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
return _landmark_detection->result();
}
+template<typename T, typename V> V &FacialLandmarkAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class FacialLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>;
}
}
\ No newline at end of file
return _landmark_detection->result();
}
+template<typename T, typename V> V &PoseLandmarkAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class PoseLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>;
}
}
\ No newline at end of file
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
virtual void perform(mv_source_h &mv_src) = 0;
virtual void performAsync(ObjectDetectionInput &input) = 0;
virtual ObjectDetectionResult &getOutput() = 0;
+ virtual ObjectDetectionResult &getOutputCache() = 0;
};
} // machine_learning
void loadLabel();
void getEngineList();
void getDeviceList(const char *engine_type);
- void updateResult(ObjectDetectionResult &result);
template<typename T>
void preprocess(mv_source_h &mv_src, std::shared_ptr<MetaInfo> metaInfo, std::vector<T> &inputVector);
template<typename T> void pushToInput(ObjectDetectionQueue<T> &input);
void perform(mv_source_h &mv_src) override;
void performAsync(ObjectDetectionInput &input) override;
ObjectDetectionResult &getOutput() override;
+ ObjectDetectionResult &getOutputCache() override;
};
} // machine_learning
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
void perform(mv_source_h &mv_src) override;
void performAsync(ObjectDetectionInput &input) override;
ObjectDetectionResult &getOutput() override;
+ ObjectDetectionResult &getOutputCache() override;
};
} // machine_learning
* @details Contains object detection result.
*/
struct ObjectDetectionResult {
- bool is_valid {};
unsigned int number_of_objects {};
std::vector<unsigned int> indices;
std::vector<std::string> names;
return _object_detection->getOutput();
}
+template<typename T, typename V> V &FaceDetectionAdapter<T, V>::getOutputCache()
+{
+ return _object_detection->getOutputCache();
+}
+
template class FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;
}
}
\ No newline at end of file
auto context = static_cast<Context *>(handle);
auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
- ObjectDetectionResult &result = task->getOutput();
+ ObjectDetectionResult &result = task->getOutputCache();
if (result.number_of_objects <= index)
throw InvalidParameter("Invalid index range.");
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
- ObjectDetectionResult &result = task->getOutput();
+ ObjectDetectionResult &result = task->getOutputCache();
if (result.number_of_objects <= index)
throw InvalidParameter("Invalid index range.");
object->inference<T>(input.inputs);
ObjectDetectionResult &result = object->result();
- result.is_valid = false;
object->pushToOutput(result);
}
}
-void ObjectDetection::updateResult(ObjectDetectionResult &result)
-{
- _current_result = result;
- _current_result.is_valid = true;
-}
-
ObjectDetectionResult &ObjectDetection::getOutput()
{
if (_thread_handle) {
- // There may be two or more Native APIs which utilize getOutput() function.
- // Therefore, the current result should be kept until a new inference request is made for result consistency.
- if (_current_result.is_valid)
- return _current_result;
-
if (isOutputQueueEmpty())
- throw InvalidOperation("Output queue is empty.");
-
- ObjectDetectionResult result = popFromOutput();
- updateResult(result);
+ throw InvalidOperation("No inference result.");
- return _current_result;
+ _current_result = popFromOutput();
+ } else {
+ _current_result = result();
}
- return result();
+ return _current_result;
+}
+
+ObjectDetectionResult &ObjectDetection::getOutputCache()
+{
+ return _current_result;
}
void ObjectDetection::getOutputNames(vector<string> &names)
{
lock_guard<mutex> lock(_outgoing_queue_mutex);
ObjectDetectionResult output = _outgoing_queue.front();
+
_outgoing_queue.pop();
return output;
return _object_detection->getOutput();
}
+template<typename T, typename V> V &ObjectDetectionAdapter<T, V>::getOutputCache()
+{
+ return _object_detection->getOutputCache();
+}
+
template<typename T, typename V> void ObjectDetectionAdapter<T, V>::performAsync(T &t)
{
_object_detection->performAsync(t);
ObjectDetectionResult &ObjectDetectionExternal::getOutput()
{
- return _object_detection_plugin->getOutput();
+ _current_result = _object_detection_plugin->getOutput();
+
+ return _current_result;
+}
+
+ObjectDetectionResult &ObjectDetectionExternal::getOutputCache()
+{
+ return _current_result;
}
}
void perform() override;
void performAsync(T &t) override;
V &getOutput() override;
+ V &getOutputCache() override;
};
} // machine_learning
return _object_detection_3d->result();
}
+template<typename T, typename V> V &ObjectDetection3dAdapter<T, V>::getOutputCache()
+{
+ throw InvalidOperation("Not support yet.");
+}
+
template class ObjectDetection3dAdapter<ObjectDetection3dInput, ObjectDetection3dResult>;
}
}
\ No newline at end of file