fix onnx yolo race condition
This commit is contained in:
@@ -178,6 +178,23 @@ namespace ANSCENTER {
|
||||
// Cached model input shape
|
||||
cv::Size inputImageShape;
|
||||
bool isDynamicInputShape{ false };
|
||||
|
||||
// Per-call preprocess that writes into caller-provided buffer + dims
|
||||
// instead of the BasicOrtHandler members (input_values_handler /
|
||||
// input_node_dims). detect() / detectBatch() use these so multiple
|
||||
// threads sharing one ONNXYOLO instance can preprocess and infer
|
||||
// concurrently — the Ort input tensor's backing storage is unique
|
||||
// per call and lives on the caller's stack. Without this, thread B
|
||||
// could overwrite the shared buffer between thread A's transform()
|
||||
// and thread A's Run(), causing A's Run() to consume B's pixels and
|
||||
// return detections that belong to B's frame. Observed on
|
||||
// Intel/OpenVINO EP where nothing else serializes.
|
||||
Ort::Value transformInto(const cv::Mat& mat,
|
||||
std::vector<float>& outBuffer,
|
||||
std::vector<int64_t>& outDims);
|
||||
Ort::Value transformBatchInto(const std::vector<cv::Mat>& images,
|
||||
std::vector<float>& outBuffer,
|
||||
std::vector<int64_t>& outDims);
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
|
||||
Reference in New Issue
Block a user