-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssd.h
79 lines (62 loc) · 1.88 KB
/
ssd.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef SSD_H
#define SSD_H
#include <annotator/plugins/plugin.h>
#include "detector.h"
#include "widget.h"
#include <QtCore/QObject>
#include <QtCore/QtPlugin>
#include <QtGui/QIcon>
#include <memory>
#include <opencv2/core/mat.hpp>
#include <thread>
#include <vector>
using std::shared_ptr;
using namespace AnnotatorLib;
namespace AnnotatorLib {
class Session;
}
namespace Annotator {
namespace Plugins {
class SSD : public Plugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "annotator.ssd" FILE "ssd.json")
Q_INTERFACES(Annotator::Plugin)
public:
SSD();
~SSD();
QString getName() override;
QWidget *getWidget() override;
bool setFrame(shared_ptr<Frame> frame, cv::Mat image) override;
void setObject(shared_ptr<Object> object) override;
shared_ptr<Object> getObject() const override;
void setLastAnnotation(shared_ptr<Annotation>) override;
std::vector<shared_ptr<Commands::Command>> getCommands() override;
void setPrototxt(std::string file);
void setCaffemodel(std::string file);
void setLabelmap(std::string file);
void setConfidenceThreshold(float threshold);
virtual bool requiresObject() const override { return false; }
protected:
bool modelLoaded = false;
std::string prototxt_file;
std::string caffemodel_file;
std::string labelmap_file;
float confidence_threshold = 0.01;
std::vector<std::string> labels;
Detector *detector = nullptr;
void initDetector();
std::shared_ptr<AnnotatorLib::Class> getClass(int label);
QPixmap getImgCrop(shared_ptr<AnnotatorLib::Annotation> annotation,
int size) const;
cv::Mat getImg(shared_ptr<AnnotatorLib::Annotation> annotation) const;
cv::Mat frameImg;
shared_ptr<Annotation> lastAnnotation = nullptr;
shared_ptr<Object> object = nullptr;
Widget widget;
std::thread trainThread;
shared_ptr<Frame> frame = nullptr;
shared_ptr<Frame> lastFrame = nullptr;
};
}
}
#endif // SSD_H