-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathncs.h
84 lines (65 loc) · 1.89 KB
/
ncs.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
80
81
82
83
84
#ifndef NCS_H
#define NCS_H
#include "widget.h"
#include <string>
#include <vector>
#include <annotator/plugins/plugin.h>
#include <mvnc.h>
#include <QtCore/QObject>
#include <QtCore/QtPlugin>
#include <QtGui/QIcon>
#include <opencv2/core/mat.hpp>
#include <opencv2/opencv.hpp>
using namespace AnnotatorLib;
using std::shared_ptr;
namespace AnnotatorLib {
class Session;
}
namespace Annotator {
namespace Plugins {
class NCS : public Plugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "annotator.ncs" FILE "ncs.json")
Q_INTERFACES(Annotator::Plugin)
public:
NCS();
~NCS();
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> annotation) override;
std::vector<shared_ptr<Commands::Command>> getCommands() override;
virtual bool requiresObject() const override { return false; }
void setAlexNet();
void setGoogLeNet();
void setSqueezeNet();
void setLabelmap(std::string filename);
void setGraph(std::string filename);
protected:
cv::Mat frameImg;
shared_ptr<Annotation> lastAnnotation = nullptr;
shared_ptr<Object> object = nullptr;
Widget widget;
shared_ptr<Frame> frame = 0;
shared_ptr<Frame> lastFrame = 0;
typedef unsigned short half;
int networkDim = 224;
float networkMean[3] = {0.40787054 * 255.0, 0.45752458 * 255.0,
0.48109378 * 255.0};
#define NAME_SIZE 100
mvncStatus retCode;
void *deviceHandle;
char devName[NAME_SIZE];
unsigned int graphFileLen;
void *graphFileBuf;
void *graphHandle;
bool graphLoaded = false;
static void *LoadFile(const char *path, unsigned int *length);
static half *LoadImage(cv::Mat resizedMat, int reqsize, float *mean);
std::vector<std::string> labels;
};
}
}
#endif // NCS_H