-
Notifications
You must be signed in to change notification settings - Fork 2
/
video.c
72 lines (67 loc) · 1.38 KB
/
video.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <pthread.h>
#include <netdb.h>
#include <pthread.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "video.h"
#define DBG 0
/*
* Handles video streaming data
*/
void handleVideo(unsigned char stream[])
{
CvCapture *capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture)
{
printf("ERROR: Capture is NULL\n");
exit(-1);
}
cvNamedWindow("iRis", CV_WINDOW_AUTOSIZE);
while(1)
{
IplImage *frame = cvQueryFrame(capture);
if(!frame)
{
printf("ERROR: Unable to capture frame\n");
break;
}
cvShowImage("iRis", frame);
}
cvDestroyWindow("iRis");
}
inline void showFrame(IplImage *frame[])
{
int i;
for(i = 0; i < FRAMEMAX; ++i) cvShowImage("iRis", frame[i]);
}
inline void grabFrames(IplImage *frame[], CvCapture *capture)
{
int i;
for(i = 0; i < FRAMEMAX; ++i) frame[i] = cvQueryFrame(capture);
}
void sendFrames(const int *cfd, IplImage *frame[])
{
int i;
IplImage f[FRAMEMAX];
for(i = 0; i < FRAMEMAX; ++i)
{
f[i] = *frame[i];
free(frame[i]);
}
send(*cfd, f, sizeof(IplImage)*FRAMEMAX, 0);
}
inline void recvFrames(const int *cfd, IplImage frame[])
{
recv(*cfd, frame, sizeof(IplImage)*FRAMEMAX, 0);
}
#ifdef DBG
#include "dbg.c"
#endif