Skip to content

Commit

Permalink
feat: read size from cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsaloka committed Jul 10, 2024
1 parent 440d272 commit adaf479
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/ninshiki_cpp/detector/dnn_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class DnnDetector : public Detector
bool myriad;

cv::dnn::Net net;

int width;
int height;
};

} // namespace ninshiki_cpp::detector
Expand Down
13 changes: 11 additions & 2 deletions src/ninshiki_cpp/detector/dnn_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ DnnDetector::DnnDetector()
classes.push_back(line);
}


std::ifstream ifs_cfg(config.c_str());
std::string cfg_line;
while (std::getline(ifs_cfg, cfg_line)) {
if (cfg_line.find("width") != std::string::npos) {
width = std::stoi(jitsuyo::split_string(cfg_line, "="));
} else if (cfg_line.find("height") != std::string::npos) {
height = std::stoi(jitsuyo::split_string(cfg_line, "="));
break;
}
}
}

void DnnDetector::set_computation_method(bool gpu, bool myriad)
Expand Down Expand Up @@ -82,7 +91,7 @@ void DnnDetector::detect_darknet(const cv::Mat & image, float conf_threshold, fl

// Create a 4D blob from a frame
static cv::Mat blob;
cv::Size input_size = cv::Size(320, 320);
cv::Size input_size = cv::Size(width, height);
cv::dnn::blobFromImage(image, blob, 1.0, input_size, cv::Scalar(), false, false, CV_8U);

net.setInput(blob, "", 0.00392, cv::Scalar(0, 0, 0, 0));
Expand Down

0 comments on commit adaf479

Please sign in to comment.