-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetforward.h
39 lines (35 loc) · 1.08 KB
/
netforward.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
#ifndef NETFORWARD_H
#define NETFORWARD_H
#ifdef USE_CAFFE_
#include <caffe/caffe.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <algorithm>
#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <opencv2/opencv.hpp>
class NetForward
{
public:
NetForward(std::string proto, std::string model);
NetForward(std::string proto, std::string model, std::string mean);
NetForward(std::string proto, std::string model, caffe::Phase phase);
NetForward(std::string proto, std::string model, std::string mean, caffe::Phase phase);
std::vector<float> forward(cv::Mat &img);
void printLayers();
~NetForward();
private:
cv::Mat SetMean(const std::string& mean_file);
void WrapInputLayer(std::vector<cv::Mat>* input_channels);
void Preprocess(const cv::Mat& img, std::vector<cv::Mat>* input_channels);
cv::Mat mean;
caffe::Net<float> *net;
caffe::Blob<float>* input_layer;
caffe::NetParameter *param;
};
#endif
#endif // NETFORWARD_H