-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample.c
54 lines (39 loc) · 1.23 KB
/
example.c
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
/**
* A example usage demo for LBP, based on OpenCV.
*
* !note: un-tested
*/
#include "lbp.h"
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
static void _test() {
IplImage *img = NULL;
int sz = 0;
double *feat_vec = NULL;
unsigned char *lbp_img = NULL;
if (!img) return ;
struct lbp_setting s;
img = = cvLoadImage("foo.jpg", 0);
if (img == NULL) return ;
lbp_init(&s, 16, 16, 16, 16);
sz = lbp_length(&s, img->width, img->height);
feat_vec = (double*)malloc(sizeof(double) * sz);
assert( feat_vec != NULL );
lbp_img = (unsigned char *)malloc(sizeof(unsigned char) *
img->widthStep *
img->height);
assert( lbp_img != NULL );
/* perform LBP and store result image into lbp_img */
lbp_process(img->imageData, img->width,
img->widthStep, img->height,
lbp_img);
/* extratc dense lbp feature, normalizaed using L2 */
lbp_extract(&s, lbp_img, img->width, img->widthStep,
img->height, feat_vec, LBP_L2NORM);
/* do something with the feat vec */
}
int main(int argc, char *argv[]) {
_test();
return 0;
}