11#include " utils.h"
22#include < opencv2/ximgproc/edge_filter.hpp> // for guided filter
3+ #define LOGGING
34
45// Constructor
56Utils::Utils ()
@@ -33,7 +34,8 @@ char *Utils::PreProcess(const cv::Mat &iImg, std::vector<int> iImgSize, cv::Mat
3334 resizeScales = iImg.rows / (float )iImgSize.at (1 );
3435 cv::resize (oImg, oImg, cv::Size (int (iImg.cols / resizeScales), iImgSize.at (1 )));
3536 }
36- cv::Mat tempImg = cv::Mat::zeros (iImgSize.at (0 ), iImgSize.at (1 ), CV_8UC3);
37+ // cv::Mat tempImg = cv::Mat::zeros(iImgSize.at(0), iImgSize.at(1), CV_8UC3);
38+ cv::Mat tempImg = cv::Mat::zeros (iImgSize.at (1 ), iImgSize.at (0 ), CV_8UC3);
3739 oImg.copyTo (tempImg (cv::Rect (0 , 0 , oImg.cols , oImg.rows )));
3840 oImg = tempImg;
3941
@@ -198,6 +200,7 @@ void Utils::PostProcess(std::vector<Ort::Value> &output_tensors, const cv::Mat &
198200 result.masks .push_back (finalMask);
199201
200202 // Overlay for display on a copy (iImg is const)
203+ #ifdef LOGGING
201204 cv::Mat overlay = iImg.clone ();
202205 std::vector<std::vector<cv::Point>> contours;
203206 cv::findContours (finalMask, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
@@ -210,6 +213,7 @@ void Utils::PostProcess(std::vector<Ort::Value> &output_tensors, const cv::Mat &
210213 cv::imshow (" SAM Segmentation" , overlay);
211214 cv::waitKey (0 );
212215 cv::destroyAllWindows ();
216+ #endif // LOGGING
213217 }
214218 else
215219 {
0 commit comments