-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcamera.hpp
More file actions
67 lines (55 loc) · 1.7 KB
/
camera.hpp
File metadata and controls
67 lines (55 loc) · 1.7 KB
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
#include <vector>
#include <functional>
#include <dshow.h>
#include <windows.h>
#include "qedit.h"
class Camera
{
private:
Camera();
Camera(const Camera &) = delete;
Camera& operator =(const Camera&) = delete;
~Camera();
bool mInitOK;
bool mIsVideoOpened;
int mVideoWidth, mVideoHeight, mBitDepth;
std::function<void(double, BYTE *, LONG)> mFrameCallBack;
private:
class SampleGrabberCallback : public ISampleGrabberCB
{
public:
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
HRESULT STDMETHODCALLTYPE SampleCB(double Time, IMediaSample *pSample);
HRESULT STDMETHODCALLTYPE BufferCB(double Time, BYTE *pBuffer, long BufferLen);
std::function<void(double, BYTE *, LONG)> mNewDataCallBack;
};
IGraphBuilder *mGraphBuilder;
ICaptureGraphBuilder2 *mCaptureGB;
IMediaControl *mMediaControl;
IBaseFilter *mDevFilter;
ISampleGrabber *mSampGrabber;
IMediaEventEx *mMediaEvent;
SampleGrabberCallback mSampleGrabberCB;
HRESULT InitializeEnv();
HRESULT BindFilter(int deviceID, IBaseFilter **pBaseFilter);
public:
static Camera *GetInstance(void)
{
static Camera instance;
return &instance;
}
std::vector<std::wstring> EnumAllCamera(void);
bool Open(std::wstring &camera_name);
bool Close(void);
/*!
* @param time : Starting time of the sample, in seconds.
* @param buff : Pointer to a buffer that contains the sample data.
* @param len : Length of the buffer pointed to by pBuffer, in bytes.
*/
void SetCallBack(std::function<void(double time, BYTE *buff, LONG len)>);
int GetHeight() { return mVideoHeight; }
int GetWidth() { return mVideoWidth; }
int GetBitDepth() { return mBitDepth; }
};