-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfhog.h
More file actions
74 lines (59 loc) · 1.79 KB
/
Copy pathfhog.h
File metadata and controls
74 lines (59 loc) · 1.79 KB
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
#ifndef FHOG_H
#define FHOG_H
#include <annotator/plugins/plugin.h>
#include "widget.h"
#include <dlib/data_io.h>
#include <dlib/image_processing.h>
#include <dlib/svm_threaded.h>
#include <QtCore/QObject>
#include <QtCore/QtPlugin>
#include <QtGui/QIcon>
#include <memory>
#include <opencv2/core/mat.hpp>
#include <vector>
using std::shared_ptr;
using namespace AnnotatorLib;
namespace AnnotatorLib {
class Session;
}
namespace Annotator {
namespace Plugins {
class FHOG : public Plugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "annotator.fhog" FILE "fhog.json")
Q_INTERFACES(Annotator::Plugin)
public:
FHOG();
~FHOG();
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 train();
void getImagesTrain();
void upsampleImages();
void loadSVM(std::string file);
void saveSVM(std::string file);
protected:
cv::Rect findObject();
QPixmap getImgCrop(shared_ptr<AnnotatorLib::Annotation> annotation,
int size) const;
cv::Mat getImg(shared_ptr<AnnotatorLib::Annotation> annotation) const;
void initScanner();
Widget widget;
cv::Mat frameImg;
shared_ptr<Object> object = nullptr;
shared_ptr<Frame> frame = nullptr;
shared_ptr<Frame> lastFrame = nullptr;
dlib::array<dlib::array2d<unsigned char>> images_train;
std::vector<std::vector<dlib::rectangle>> boxes_train;
typedef dlib::scan_fhog_pyramid<dlib::pyramid_down<6>> image_scanner_type;
image_scanner_type scanner;
dlib::object_detector<image_scanner_type> detector;
};
}
}
#endif // FHOG_H