forked from krips89/opendetection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
od_faster_rcnn_cam.cpp
38 lines (34 loc) · 1.18 KB
/
od_faster_rcnn_cam.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <detectors/global2D/detection/ODConvDetector.h>
#include <common/pipeline/ODScene.h>
#include <common/pipeline/ODDetection.h>
#include <common/utils/ODFrameGenerator.h>
using std::string;
int main(int argc, char **argv){
od::g2d::ODConvDetector *faster_rcnn = new od::g2d::ODConvDetector();
string conf = "examples/objectdetector/faster_rcnn_models/config/voc_config.json";
faster_rcnn->setConfig(conf);
if (argc < 3){
std::cout << "usage: od_faster_rcnn_cam model_definition model_weights" << std::endl;
return 0;
}
else{
string model_def(argv[1]);
string model_weight(argv[2]);
faster_rcnn->initDetector(model_def, model_weight);
//get scenes
od::ODFrameGenerator<od::ODSceneImage, od::GENERATOR_TYPE_DEVICE> frameGenerator(0);
//GUI
cv::namedWindow("Overlay", cv::WINDOW_NORMAL);
while(frameGenerator.isValid() && cv::waitKey(30) != 27)
{
od::ODSceneImage * scene = frameGenerator.getNextFrame();
//Detect
od::ODDetections2D *detections = faster_rcnn->detectOmni(scene);
if(detections->size() > 0)
cv::imshow("Overlay", detections->renderMetainfo(*scene).getCVImage());
else
cv::imshow("Overlay", scene->getCVImage());
}
}
return 0;
}