88#include " adapters/openvino_adapter.h"
99#include " utils/config.h"
1010#include " utils/math.h"
11+ #include " utils/nms.h"
1112#include " utils/preprocessing.h"
1213#include " utils/tensor.h"
13- #include " utils/nms.h"
1414
1515constexpr char saliency_map_name[]{" saliency_map" };
1616constexpr char feature_vector_name[]{" feature_vector" };
@@ -232,7 +232,7 @@ InstanceSegmentationResult InstanceSegmentation::postprocess(InferenceResult& in
232232 std::cout << " resize mode: " << resize_mode << std::endl;
233233 int padLeft = 0 , padTop = 0 ;
234234 if (utils::RESIZE_KEEP_ASPECT == resize_mode || utils::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
235- std::cout << " using some other resize mode..." << std::endl;
235+ std::cout << " using some other resize mode..." << std::endl;
236236 invertedScaleX = invertedScaleY = std::max (invertedScaleX, invertedScaleY);
237237 if (utils::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
238238 padLeft = (input_shape.width - int (std::round (floatInputImgWidth / invertedScaleX))) / 2 ;
@@ -306,7 +306,8 @@ InstanceSegmentationResult InstanceSegmentation::postprocess(InferenceResult& in
306306 return result;
307307}
308308
309- InstanceSegmentationResult InstanceSegmentation::postprocess_tile (InstanceSegmentationResult result, const cv::Rect& coord) {
309+ InstanceSegmentationResult InstanceSegmentation::postprocess_tile (InstanceSegmentationResult result,
310+ const cv::Rect& coord) {
310311 for (auto & det : result.segmentedObjects ) {
311312 det.x += coord.x ;
312313 det.y += coord.y ;
@@ -322,11 +323,12 @@ InstanceSegmentationResult InstanceSegmentation::postprocess_tile(InstanceSegmen
322323 return result;
323324}
324325
325- InstanceSegmentationResult InstanceSegmentation::merge_tiling_results (const std::vector<InstanceSegmentationResult>& tiles_results,
326- const cv::Size& image_size,
327- const std::vector<cv::Rect>& tile_coords,
328- const utils::TilingInfo& tiling_info) {
329- size_t max_pred_number = 200 ; // TODO: Actually get this from config!
326+ InstanceSegmentationResult InstanceSegmentation::merge_tiling_results (
327+ const std::vector<InstanceSegmentationResult>& tiles_results,
328+ const cv::Size& image_size,
329+ const std::vector<cv::Rect>& tile_coords,
330+ const utils::TilingInfo& tiling_info) {
331+ size_t max_pred_number = 200 ; // TODO: Actually get this from config!
330332
331333 InstanceSegmentationResult output;
332334 std::vector<AnchorLabeled> all_detections;
@@ -346,15 +348,15 @@ InstanceSegmentationResult InstanceSegmentation::merge_tiling_results(const std:
346348 output.segmentedObjects .reserve (keep_idx.size ());
347349 for (auto idx : keep_idx) {
348350 if (postprocess_semantic_masks) {
349- // why does this happen again?
350- // all_detections_ptrs[idx].get().mask = ;
351- // SegmentedObject obj = all_detections_ptrs[idx]; //copy
352- // std::cout << "Mask size before: " << obj.mask.size() << std::endl;
353- // std::cout << static_cast<cv::Rect>(obj) << std::endl;
354- // obj.mask = segm_postprocess(all_detections_ptrs[idx],
355- // obj.mask,
356- // image_size.height,
357- // image_size.width);
351+ // why does this happen again?
352+ // all_detections_ptrs[idx].get().mask = ;
353+ // SegmentedObject obj = all_detections_ptrs[idx]; //copy
354+ // std::cout << "Mask size before: " << obj.mask.size() << std::endl;
355+ // std::cout << static_cast<cv::Rect>(obj) << std::endl;
356+ // obj.mask = segm_postprocess(all_detections_ptrs[idx],
357+ // obj.mask,
358+ // image_size.height,
359+ // image_size.width);
358360 }
359361
360362 output.segmentedObjects .push_back (all_detections_ptrs[idx]);
@@ -390,14 +392,13 @@ InstanceSegmentationResult InstanceSegmentation::merge_tiling_results(const std:
390392 output.saliency_map = merge_saliency_maps (tiles_results, image_size, tile_coords, tiling_info);
391393
392394 return output;
393-
394395}
395396
396-
397- std::vector<cv::Mat_<std:: uint8_t >> InstanceSegmentation::merge_saliency_maps ( const std::vector<InstanceSegmentationResult>& tiles_results,
398- const cv::Size& image_size,
399- const std::vector<cv::Rect>& tile_coords,
400- const utils::TilingInfo& tiling_info ) {
397+ std::vector<cv::Mat_<std:: uint8_t >> InstanceSegmentation::merge_saliency_maps (
398+ const std::vector<InstanceSegmentationResult>& tiles_results,
399+ const cv::Size& image_size,
400+ const std::vector<cv::Rect>& tile_coords,
401+ const utils::TilingInfo& tiling_info) {
401402 std::vector<std::vector<cv::Mat_<std::uint8_t >>> all_saliency_maps;
402403 all_saliency_maps.reserve (tiles_results.size ());
403404 for (const auto & result : tiles_results) {
@@ -435,7 +436,8 @@ std::vector<cv::Mat_<std::uint8_t>> InstanceSegmentation::merge_saliency_maps(co
435436 }
436437
437438 for (size_t class_idx = 0 ; class_idx < num_classes; ++class_idx) {
438- auto image_map_cls = tiling_info.tile_with_full_image ? image_saliency_map[class_idx] : cv::Mat_<std::uint8_t >();
439+ auto image_map_cls =
440+ tiling_info.tile_with_full_image ? image_saliency_map[class_idx] : cv::Mat_<std::uint8_t >();
439441 if (image_map_cls.empty ()) {
440442 if (cv::sum (merged_map[class_idx]) == cv::Scalar (0 .)) {
441443 merged_map[class_idx] = cv::Mat_<std::uint8_t >();
0 commit comments