22#include < regex>
33
44#define benchmark
5- #define min (a,b ) (((a) < (b)) ? (a) : (b))
6- YOLO_V8::YOLO_V8 () {
5+ #define min (a, b ) (((a) < (b)) ? (a) : (b))
76
7+ YOLO_V8::YOLO_V8 ()
8+ {
89}
910
10-
11- YOLO_V8::~YOLO_V8 () {
12- for (auto & name : inputNodeNames) {
13- delete[] name;
14- }
15- for (auto & name : outputNodeNames) {
16- delete[] name;
17- }
11+ YOLO_V8::~YOLO_V8 ()
12+ {
1813}
1914
2015#ifdef USE_CUDA
@@ -25,9 +20,14 @@ namespace Ort
2520}
2621#endif
2722
28-
29- // Definition: Flattened image to blob (and normalizaed) for deep learning inference. Also reorganize from HWC to CHW.
30- // Note: Not in the header file since it is not used outside of this file.
23+ /* *
24+ * @brief Flattened image to blob (and normalized) for deep learning inference. Also reorganize from HWC to CHW.
25+ *
26+ * @tparam T
27+ * @param iImg
28+ * @param iBlob
29+ * @return char*
30+ */
3131template <typename T>
3232char * BlobFromImage (const cv::Mat& iImg, T& iBlob) {
3333 int channels = iImg.channels ();
@@ -66,7 +66,7 @@ char* YOLO_V8::PreProcess(const cv::Mat& iImg, std::vector<int> iImgSize, cv::Ma
6666 case YOLO_DETECT_V8:
6767 case YOLO_POSE:
6868 case YOLO_DETECT_V8_HALF:
69- case YOLO_POSE_V8_HALF:// LetterBox
69+ case YOLO_POSE_V8_HALF: // LetterBox and Top Left Crop
7070 {
7171 if (iImg.cols >= iImg.rows )
7272 {
@@ -83,7 +83,7 @@ char* YOLO_V8::PreProcess(const cv::Mat& iImg, std::vector<int> iImgSize, cv::Ma
8383 oImg = tempImg;
8484 break ;
8585 }
86- case YOLO_CLS:// CenterCrop
86+ case YOLO_CLS: // CenterCrop
8787 {
8888 int h = iImg.rows ;
8989 int w = iImg.cols ;
@@ -100,9 +100,9 @@ char* YOLO_V8::PreProcess(const cv::Mat& iImg, std::vector<int> iImgSize, cv::Ma
100100
101101const char * YOLO_V8::CreateSession (DL_INIT_PARAM& iParams) {
102102 const char * Ret = RET_OK;
103- if (session) {
104-
105- // Clear node names
103+ if (session)
104+ {
105+ // Clear node names from previous declaration
106106 for (auto & name : inputNodeNames) {
107107 delete[] name;
108108 }
@@ -117,7 +117,7 @@ const char* YOLO_V8::CreateSession(DL_INIT_PARAM& iParams) {
117117 bool result = std::regex_search (iParams.modelPath , pattern);
118118 if (result)
119119 {
120- Ret = " [YOLO_V8]:Your model path is error.Change your model path without chinese characters." ;
120+ Ret = " [YOLO_V8]:Your model path is error. Change your model path without chinese characters." ;
121121 std::cout << Ret << std::endl;
122122 return Ret;
123123 }
@@ -140,16 +140,7 @@ const char* YOLO_V8::CreateSession(DL_INIT_PARAM& iParams) {
140140 sessionOption.SetIntraOpNumThreads (iParams.intraOpNumThreads );
141141 sessionOption.SetLogSeverityLevel (iParams.logSeverityLevel );
142142
143- #ifdef _WIN32
144- int ModelPathSize = MultiByteToWideChar (CP_UTF8, 0 , iParams.modelPath .c_str (), static_cast <int >(iParams.modelPath .length ()), nullptr , 0 );
145- wchar_t * wide_cstr = new wchar_t [ModelPathSize + 1 ];
146- MultiByteToWideChar (CP_UTF8, 0 , iParams.modelPath .c_str (), static_cast <int >(iParams.modelPath .length ()), wide_cstr, ModelPathSize);
147- wide_cstr[ModelPathSize] = L' \0 ' ;
148- const wchar_t * modelPath = wide_cstr;
149- #else
150- const char * modelPath = iParams.modelPath .c_str ();
151- #endif // _WIN32
152-
143+ const char *modelPath = iParams.modelPath .c_str ();
153144 session = std::make_unique<Ort::Session>(env, modelPath, sessionOption);
154145 Ort::AllocatorWithDefaultOptions allocator;
155146 size_t inputNodesNum = session->GetInputCount ();
0 commit comments