未验证 提交 4d9c17c1 编写于 作者: W wangxinxin08 提交者: GitHub

modify MkDir function to fix bugs (#1591)

上级 2385ca75
...@@ -54,8 +54,7 @@ static bool PathExists(const std::string& path){ ...@@ -54,8 +54,7 @@ static bool PathExists(const std::string& path){
} }
static void MkDir(const std::string& path) { static void MkDir(const std::string& path) {
std::string path_error(path); if (PathExists(path)) return;
path_error += " mkdir failed!";
int ret = 0; int ret = 0;
#ifdef _WIN32 #ifdef _WIN32
ret = _mkdir(path.c_str()); ret = _mkdir(path.c_str());
...@@ -63,6 +62,8 @@ static void MkDir(const std::string& path) { ...@@ -63,6 +62,8 @@ static void MkDir(const std::string& path) {
ret = mkdir(path.c_str(), 0755); ret = mkdir(path.c_str(), 0755);
#endif // !_WIN32 #endif // !_WIN32
if (ret != 0) { if (ret != 0) {
std::string path_error(path);
path_error += " mkdir failed!";
throw std::runtime_error(path_error); throw std::runtime_error(path_error);
} }
} }
...@@ -169,8 +170,13 @@ void PredictImage(const std::string& image_path, ...@@ -169,8 +170,13 @@ void PredictImage(const std::string& image_path,
std::vector<int> compression_params; std::vector<int> compression_params;
compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
compression_params.push_back(95); compression_params.push_back(95);
cv::imwrite(output_dir + OS_PATH_SEP + "output.jpg", vis_img, compression_params); std::string output_path(output_dir);
printf("Visualized output saved as output.jpg\n"); if (output_dir.rfind(OS_PATH_SEP) != output_dir.size() - 1) {
output_path += OS_PATH_SEP;
}
output_path += "output.jpg";
cv::imwrite(output_path, vis_img, compression_params);
printf("Visualized output saved as %s\n", output_path.c_str());
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册