-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface-capture.c
54 lines (43 loc) · 1.09 KB
/
face-capture.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
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "face-capture.h"
#include "errors.h"
#include "capture.h"
typedef struct FaceCapture {
Core_t core;
} FaceCapture;
void* faceCaptureThread(void *arg) {
FaceCapture *c = (FaceCapture*)arg;
Capture_t cap = captureInit();
CaptureResults results;
while (1) {
capture(cap, &results);
Event e;
e.whenOccurred = now();
e.type = E_FACE;
e.face.numFaces = results.numFaces;
for (int i=0; i<results.numFaces; i++) {
e.face.faces[i].x = results.faces[i].x;
e.face.faces[i].y = results.faces[i].y;
e.face.faces[i].width = results.faces[i].width;
e.face.faces[i].height = results.faces[i].height;
}
send(c->core, e);
}
return NULL;
}
FaceCapture* faceCaptureInit(Core_t core) {
FaceCapture *c = malloc(sizeof(FaceCapture));
if (c == NULL) {
explode("failed to malloc");
}
c->core = core;
return c;
}
void faceCaptureStart(FaceCapture *c) {
pthread_t threadId;
pthread_create(&threadId, NULL, faceCaptureThread, c);
}
void faceCaptureStop(FaceCapture *c) {
}