提交 352c9446 authored 作者: blu's avatar blu

object detection

上级 03ed183c
...@@ -6,7 +6,7 @@ using namespace clipp; ...@@ -6,7 +6,7 @@ using namespace clipp;
using namespace std; using namespace std;
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
bool bHumanOnly = true; string bHumanOnly = "true";
float fConfident = 0.1; float fConfident = 0.1;
bool bVerbose = false; bool bVerbose = false;
bool help = false; bool help = false;
...@@ -16,12 +16,12 @@ int main(int argc, char *argv[]){ ...@@ -16,12 +16,12 @@ int main(int argc, char *argv[]){
auto cli = ( auto cli = (
value("input path", sInput), value("input path", sInput),
option("-cl").set(fConfident).doc("confidence level of detection, default: 0.1"), option("-cl") & value("confidence level of detection, default: 0.1", fConfident),
option("-vv", "--debug").set(bVerbose).doc("verbose prints"), option("-vv", "--debug").set(bVerbose).doc("verbose prints"),
option("-human", "--human-only").set(bHumanOnly).doc("detect only human object"), option("-human", "--human-only") & value("detect only human object, default: true", bHumanOnly),
option("-c", "--config-path").set(modelPath).doc("model and configuration path"), option("-c", "--config-path") & value("model and configuration path", modelPath),
option("-h", "--help").set(help).doc("print this help info"), option("-h", "--help").set(help).doc("print this help info"),
option("-o", "--output").set(sOutput).doc("output, eg: a.jpg; b.avi"), option("-o", "--output") & value("output, eg: a.jpg; b.avi. default: detect.jpg", sOutput),
option("-r", "--continue").set(bCont).doc("continue detection, default: false") option("-r", "--continue").set(bCont).doc("continue detection, default: false")
); );
...@@ -31,10 +31,12 @@ int main(int argc, char *argv[]){ ...@@ -31,10 +31,12 @@ int main(int argc, char *argv[]){
spdlog::info(s.str()); spdlog::info(s.str());
exit(0); exit(0);
} }
spdlog::info("{} {}", bHumanOnly, fConfident);
if(bVerbose) { if(bVerbose) {
spdlog::set_level(spdlog::level::debug); spdlog::set_level(spdlog::level::debug);
} }
YoloDectect detector(modelPath, bHumanOnly, fConfident, bCont); YoloDectect detector(modelPath, bHumanOnly == "true"?true:false, fConfident, bCont);
detector.process(sInput, sOutput); detector.process(sInput, sOutput);
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
unsigned long numFrameProcessed = 0; unsigned long numFrameProcessed = 0;
private: private:
// Initialize the parameters // Initialize the parameters
const string selfId = "YoloDetector"; const string selfId = "ObjectDetector";
float confThreshold = 0.1; // Confidence threshold float confThreshold = 0.1; // Confidence threshold
float nmsThreshold = 0.2; // Non-maximum suppression threshold float nmsThreshold = 0.2; // Non-maximum suppression threshold
int inpWidth = 416; // Width of network's input image int inpWidth = 416; // Width of network's input image
...@@ -229,7 +229,7 @@ public: ...@@ -229,7 +229,7 @@ public:
if(inVideoUri.substr(inVideoUri.find_last_of(".") + 1) == "mp4"||(cameNo = stoi(inVideoUri)) >= 0) { if(inVideoUri.substr(inVideoUri.find_last_of(".") + 1) == "mp4"||(cameNo = stoi(inVideoUri)) >= 0) {
bInputIsImage = false; bInputIsImage = false;
} }
}catch(Exception &e) { }catch(...) {
} }
...@@ -319,7 +319,7 @@ public: ...@@ -319,7 +319,7 @@ public:
auto ms = chrono::duration_cast<chrono::milliseconds >(chrono::system_clock::now().time_since_epoch()).count(); auto ms = chrono::duration_cast<chrono::milliseconds >(chrono::system_clock::now().time_since_epoch()).count();
string ofname = outFileBase + "_person_" + to_string(ms) + ".jpg"; string ofname = outFileBase + "_person_" + to_string(ms) + ".jpg";
imwrite(ofname, outFrame); imwrite(ofname, outFrame);
spdlog::info("found human {} x: {}, y: {}, w: {}, h: {}", c, r.x, r.y, r.width, r.height); spdlog::info("{} found human {} x: {}, y: {}, w: {}, h: {}; written image: {}", selfId, c, r.x, r.y, r.width, r.height, ofname);
if(!bContinue){ if(!bContinue){
cmdStop = true; cmdStop = true;
break; break;
...@@ -330,8 +330,14 @@ public: ...@@ -330,8 +330,14 @@ public:
if(wrapNum > 0) { if(wrapNum > 0) {
detCnt = detCnt % wrapNum; detCnt = detCnt % wrapNum;
} }
string ofname = outFileBase + to_string(detCnt) + ".jpg"; string ofname = outFileBase + to_string(detCnt) + ".jpg";
imwrite(ofname, outFrame); imwrite(ofname, outFrame);
string msg = fmt::format("{} found {} {}:\n", selfId, ret.size(), ofname);
for(auto &[s, c, r]:ret) {
msg += fmt::format("\t{} {} x: {}, y: {}, w: {}, h: {}\n",s, c, r.x, r.y, r.width, r.height);
}
spdlog::info(msg);
detCnt++; detCnt++;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论