-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCRPatch.h
60 lines (46 loc) · 2 KB
/
CRPatch.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
/*
// Author: Juergen Gall, BIWI, ETH Zurich
// Email: [email protected]
*/
#pragma once
#define _copysign copysign
#include <opencv2/opencv.hpp>
#include <vector>
#include <iostream>
#include "HoG.h"
// structure for image patch
struct PatchFeature {
PatchFeature() {}
cv::Rect roi;
std::vector<cv::Point> center;
std::vector<cv::Mat> vPatch;
void print() const {
std::cout << roi.x << " " << roi.y << " " << roi.width << " " << roi.height;
for(unsigned int i=0; i<center.size(); ++i) std::cout << " " << center[i].x << " " << center[i].y; std::cout << std::endl;
}
void show(int delay) const;
};
static HoG hog;
class CRPatch {
public:
CRPatch(cv::RNG* pRNG, int w, int h, int num_l) : cvRNG(pRNG), width(w), height(h) { vLPatches.resize(num_l);}
// Extract patches from image
void extractPatches(const cv::Mat& img, unsigned int n, int label, const cv::Rect* box = 0, const std::vector<cv::Point>* vCenter = 0);
// Extract features from image
static void extractFeatureChannels(const cv::Mat& img, std::vector<cv::Mat>& vImg);
// min/max filter
static void maxfilt(uchar* data, uchar* maxvalues, unsigned int step, unsigned int size, unsigned int width);
static void maxfilt(uchar* data, unsigned int step, unsigned int size, unsigned int width);
static void minfilt(uchar* data, uchar* minvalues, unsigned int step, unsigned int size, unsigned int width);
static void minfilt(uchar* data, unsigned int step, unsigned int size, unsigned int width);
static void maxminfilt(uchar* data, uchar* maxvalues, uchar* minvalues, unsigned int step, unsigned int size, unsigned int width);
static void maxfilt(cv::Mat &src, unsigned int width);
static void maxfilt(cv::Mat &src, cv::Mat &dst, unsigned int width);
static void minfilt(cv::Mat &src, unsigned int width);
static void minfilt(cv::Mat &src, cv::Mat &dst, unsigned int width);
std::vector<std::vector<PatchFeature> > vLPatches;
private:
cv::RNG *cvRNG;
int width;
int height;
};