-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcapture.c
54 lines (41 loc) · 897 Bytes
/
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
//Developed By Yash Shah
//capture.c
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
#include "capture.h"
// File-level variables
CvCapture * pCapture = 0;
//////////////////////////////////
// initCapture()
//
int initCapture()
{
// Initialize video capture
pCapture = cvCaptureFromCAM( CV_CAP_ANY );
if( !pCapture )
{
fprintf(stderr, "failed to initialize video capture\n");
return 0;
}
return 1;
}
//////////////////////////////////
// closeCapture()
//
void closeCapture()
{
// Terminate video capture and free capture resources
cvReleaseCapture( &pCapture );
return;
}
//////////////////////////////////
// nextVideoFrame()
//
IplImage * nextVideoFrame()
{
IplImage * pVideoFrame = cvQueryFrame( pCapture );
if( !pVideoFrame )
fprintf(stderr, "failed to get a video frame\n");
return pVideoFrame;
}