-
Notifications
You must be signed in to change notification settings - Fork 0
/
FeatureMapGenerator.h
42 lines (29 loc) · 1.11 KB
/
FeatureMapGenerator.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
#pragma once
#include <opencv2\opencv.hpp>
#include <caffe\caffe.hpp>
#include <caffe\proto\caffe.pb.h>
#include <caffe\data_transformer.hpp>
#include <vector>
#include <string>
#include <unordered_map>
class FeatureMapGenerator {
public:
FeatureMapGenerator(std::string modelFile, std::string trainedFile);
~FeatureMapGenerator();
void setMeanValue(std::vector<float> &meanValue);
void setScale(float scale);
std::vector<float> getMeanValue() const;
float getScale() const;
std::unordered_map<std::string, std::vector<cv::Mat>> getFeatureMaps() const;
std::unordered_map<std::string, std::vector<cv::Mat>> generateFeatureMaps(cv::Mat img, std::vector<std::string> &layerNames);
std::unordered_map<std::string, std::vector<cv::Mat>> generateFeatureMaps(std::string imgPath, std::vector<std::string> &layerNames);
private:
std::vector<cv::Mat> transToMat(float* feat, caffe::Blob<float> *layer);
private:
caffe::Net<float> *net;
caffe::Blob<float> *input_layer;
float scale;
std::vector<float> meanValue;
std::vector<std::string> layerNames;
std::unordered_map<std::string, std::vector<cv::Mat>> featureMaps;
};