syyxsxx пре 5 година
родитељ
комит
860ee1619a
2 измењених фајлова са 4 додато и 4 уклоњено
  1. 2 2
      deploy/cpp/src/paddlex.cpp
  2. 2 2
      deploy/cpp/src/visualize.cpp

+ 2 - 2
deploy/cpp/src/paddlex.cpp

@@ -362,7 +362,7 @@ bool Model::predict(const cv::Mat& im, DetResult* result) {
                bin_mask,
                cv::Size(box->mask.shape[0], box->mask.shape[1]));
       cv::threshold(bin_mask, bin_mask, 0.5, 1, cv::THRESH_BINARY);
-      auto mask_int_begin = reinterpret_cast<int*>(bin_mask.data);
+      auto mask_int_begin = reinterpret_cast<float*>(bin_mask.data);
       auto mask_int_end =
         mask_int_begin + box->mask.shape[0] * box->mask.shape[1];
       box->mask.data.assign(mask_int_begin, mask_int_end);
@@ -546,7 +546,7 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
                 bin_mask,
                 cv::Size(box->mask.shape[0], box->mask.shape[1]));
         cv::threshold(bin_mask, bin_mask, 0.5, 1, cv::THRESH_BINARY);
-        auto mask_int_begin = reinterpret_cast<int*>(bin_mask.data);
+        auto mask_int_begin = reinterpret_cast<float*>(bin_mask.data);
         auto mask_int_end =
           mask_int_begin + box->mask.shape[0] * box->mask.shape[1];
         box->mask.data.assign(mask_int_begin, mask_int_end);

+ 2 - 2
deploy/cpp/src/visualize.cpp

@@ -84,8 +84,8 @@ cv::Mat Visualize(const cv::Mat& img,
     if (boxes[i].mask.data.size() == 0) {
       continue;
     }
-    cv::Mat bin_mask(boxes[i].mask.shape[0],
-                     boxes[i].mask.shape[1],
+    cv::Mat bin_mask(boxes[i].mask.shape[1],
+                     boxes[i].mask.shape[0],
                      CV_8UC1,
                      boxes[i].mask.data.data());
     cv::Mat full_mask = cv::Mat::zeros(vis_img.size(), CV_8UC1);