Skip to content

Commit

Permalink
[Model] Add move assignment for DetectionResult (#600)
Browse files Browse the repository at this point in the history
* add onnx_ort_runtime demo

* rm in requirements

* support batch eval

* fixed MattingResults bug

* move assignment for DetectionResult
  • Loading branch information
wjj19950828 authored Nov 17, 2022
1 parent 6ebe612 commit fe4192c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions fastdeploy/vision/common/result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ DetectionResult::DetectionResult(const DetectionResult& res) {
}
}

DetectionResult& DetectionResult::operator=(DetectionResult&& other) {
if (&other != this) {
boxes = std::move(other.boxes);
scores = std::move(other.scores);
label_ids = std::move(other.label_ids);
contain_masks = std::move(other.contain_masks);
if (contain_masks) {
masks.clear();
masks = std::move(other.masks);
}
}
return *this;
}

void DetectionResult::Clear() {
std::vector<std::array<float, 4>>().swap(boxes);
std::vector<float>().swap(scores);
Expand Down
5 changes: 4 additions & 1 deletion fastdeploy/vision/common/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct FASTDEPLOY_DECL Mask : public BaseResult {
/*! @brief Detection result structure for all the object detection models and instance segmentation models
*/
struct FASTDEPLOY_DECL DetectionResult : public BaseResult {
DetectionResult() = default;
/** \brief All the detected object boxes for an input image, the size of `boxes` is the number of detected objects, and the element of `boxes` is a array of 4 float values, means [xmin, ymin, xmax, ymax]
*/
std::vector<std::array<float, 4>> boxes;
Expand All @@ -111,8 +112,10 @@ struct FASTDEPLOY_DECL DetectionResult : public BaseResult {

ResultType type = ResultType::DETECTION;

DetectionResult() {}
/// Copy constructor
DetectionResult(const DetectionResult& res);
/// Move assignment
DetectionResult& operator=(DetectionResult&& other);

/// Clear detection result
void Clear();
Expand Down

0 comments on commit fe4192c

Please sign in to comment.