-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathWebCam.h
55 lines (44 loc) · 1.08 KB
/
WebCam.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
//
// WebCam.h for Camera enumeration
//
#include <opencv2/highgui/highgui.hpp>
#include <string.h>
#ifdef _MSC_VER
#include <windows.h>
#include <dshow.h>
#define HAVE_MSMF
#define HAVE_VFW
#pragma warning(disable: 4996)
#endif
using namespace cv;
typedef bool (*PENUMDEVICE)(void *pItem, char *pDeviceName);
class WebCam: public VideoCapture
{
public:
// pCallbackがNULLの場合、カメラの台数だけを返す
// pCallbackが設定されていたらコールバックでカメラ名を返す
// pItemはコールバック関数で渡される
static int EnumDevices(PENUMDEVICE pCallback, void *pItem);
/*
Usage:
// enum callback function
static int enumCamera(void* pItem, char *pName)
{
printf("%s\n", pName);
return 0;
}
int main()
{
int cameraCount;
cameraCount = Camera::EnumDevices((PENUMDEVICE)&enumCamera, NULL);
}
*/
//bool open(const string& filename, int mode);
public:
WebCam();
WebCam(const string& filename);
void SetName(const char *name) {strncpy(this->name, name, 80);}
char *GetName() {return name; }
protected:
char name[80];
};