diff --git a/fastdeploy/vision/visualize/visualize.h b/fastdeploy/vision/visualize/visualize.h index 498944c23..3507c6499 100755 --- a/fastdeploy/vision/visualize/visualize.h +++ b/fastdeploy/vision/visualize/visualize.h @@ -161,9 +161,26 @@ FASTDEPLOY_DECL cv::Mat VisOcr(const cv::Mat& im, const OCRResult& ocr_result); FASTDEPLOY_DECL cv::Mat VisMOT(const cv::Mat& img, const MOTResult& results, float score_threshold = 0.0f, tracking::TrailRecorder* recorder = nullptr); -FASTDEPLOY_DECL cv::Mat SwapBackground( - const cv::Mat& im, const cv::Mat& background, const MattingResult& result, - bool remove_small_connected_area = false); +/** \brief Swap the image background with MattingResult + * + * \param[in] im the input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format + * \param[in] background the background image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format + * \param[in] result the MattingResult produced by model + * \param[in] remove_small_connected_area if remove_small_connected_area==true, the visualized result will not include the small connected areas + * \return cv::Mat type stores the visualized results + */ +FASTDEPLOY_DECL cv::Mat SwapBackground(const cv::Mat& im, + const cv::Mat& background, + const MattingResult& result, + bool remove_small_connected_area = false); +/** \brief Swap the image background with SegmentationResult + * + * \param[in] im the input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format + * \param[in] background the background image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format + * \param[in] result the SegmentationResult produced by model + * \param[in] background_label the background label number in SegmentationResult + * \return cv::Mat type stores the visualized results + */ FASTDEPLOY_DECL cv::Mat SwapBackground(const cv::Mat& im, const cv::Mat& background, const SegmentationResult& result, diff --git a/python/fastdeploy/vision/visualize/__init__.py b/python/fastdeploy/vision/visualize/__init__.py index 6ebd08c1c..e528c8804 100755 --- a/python/fastdeploy/vision/visualize/__init__.py +++ b/python/fastdeploy/vision/visualize/__init__.py @@ -138,6 +138,15 @@ def swap_background(im_data, result, remove_small_connected_area=False, background_label=0): + """Swap the image background with MattingResult or SegmentationResult + + :param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param background: (numpy.ndarray)The background image data, 3-D array with layout HWC, BGR format + :param result: The result produced by model, MattingResult or SegmentationResult + :param remove_small_connected_area: (bool) If remove_small_connected_area==True, the visualized result will not include the small connected areas + :param background_label: (int)The background label number in SegmentationResult + :return: (numpy.ndarray) image with visualized results + """ if isinstance(result, C.vision.MattingResult): return C.vision.swap_background(im_data, background, result, remove_small_connected_area)