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
73
74
75
76
77
78
79
80
81
82
|
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Capture Guide</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body bgcolor="#FFFFFF">
<h1>Capture Guide</h1>
<h3><a name="Using">Using</a></h3>
<p>You can list the installed capture devices using: </p>
<pre>int imVideoCaptureDeviceCount(void)
const char* imVideoCaptureDeviceDesc(int device)</pre>
<p>If a device was removed or added in run time, you must update the list
calling:</p>
<pre>int imVideoCaptureReloadDevices(void)</pre>
<p>To handle devices you must create a <b>imVideoCapture</b> structure
using the function <b>imVideoCaptureCreate</b>. With this handle you can
manage any of the available devices, but only one device. The handle must be
destroyed with <b>imVideoCaptureDestroy</b>.</p>
<p>If you want to access two or more devices at the same time you must create
two different structures, but be aware that this usually work for high quality
devices like Firewire and USB 2.0. Webcams that use USB1.x can be used if
connected to different USB 2.0 controllers.</p>
<p>The next thing is to connect to a specific device, because all the other
remaining functions depends on this connection. Just call <b>imVideoCaptureConnect</b> with one of the available capture device numbers.</p>
<p>You control when a device start processing frames using <b>imVideoCaptureLive</b>. Once live the frames can be captured using
<b>imVideoCaptureFrame</b>. Or you can use <b>imVideoCaptureOneFrame</b>,
it will start capturing, returns the captured frame and stop capturing.</p>
<p>But before capturing a frame you may want to configure the device. You can
do it using Attributes, or at least in Windows you can do it using the
configuration dialogs with a call to <b>imVideoCaptureShowDialog</b>.</p>
<p>A very simple sequence of operations to capture just one frame from the
first device available:</p>
<pre>imVideoCapture* vc = imVideoCaptureCreate();
if (!imVideoCaptureConnect(vc, 0))
return;
int width, height;
imVideoCaptureGetImageSize(vc, &width, &height);
// initializes the data pointer
void* data = malloc(width*height*3);
imVideoCaptureOneFrame(vc, data, IM_RGB);
imVideoCaptureDestroy(vc);</pre>
<p>The capture library is completely independent from the other libraries. It
just uses the same description of the data buffer used in <b>imFileReadImageData</b>.</p>
<h3><a name="Building">Building</a></h3>
<p>You should include the <im_capture.h> header and link with the
"im_capture.lib" library. This library is independent of all IM libraries.
In Lua call require"imlua_capture".</p>
<p>To link with the capture library in Windows using Visual C you will need
the file "<a href="../download/strmiids.zip">strmiids.lib</a>". To link it
using Dev-C++ or Mingw 3 you will need the "<b>im_capture.dll</b>".</p>
<p>To compile the capture source code you will need the Direct X 9 SDK. Notice
that since Direct X uses COM, CoInitialize(NULL) is called when the devices
are enumerated.</p>
<p>For more information on Direct X capture, i.e. Direct Show see:</p>
<p>
<a href="http://msdn.microsoft.com/library/en-us/directx9_c/directX/htm/directshow.asp">
http://msdn.microsoft.com/library/en-us/directx9_c/directX/htm/directshow.asp</a></p>
</body>
</html>
|