55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#ifndef WebCamera_h__
|
|||
|
|
#define WebCamera_h__
|
||
|
|
|
||
|
|
#include "../ICamera.h"
|
||
|
|
#include "../IImage.h"
|
||
|
|
#include <mfapi.h>
|
||
|
|
#include <mfidl.h>
|
||
|
|
#include <mferror.h>
|
||
|
|
#include <mfcaptureengine.h>
|
||
|
|
#include "WinMfImageGrabber.h"
|
||
|
|
#include <shlwapi.h>
|
||
|
|
#pragma comment(lib, "mf.lib")
|
||
|
|
#pragma comment(lib, "mfplat.lib")
|
||
|
|
#pragma comment(lib, "mfuuid.lib")
|
||
|
|
#pragma comment(lib, "shlwapi.lib")
|
||
|
|
|
||
|
|
|
||
|
|
#include <memory>
|
||
|
|
#include <vector>
|
||
|
|
#include "../Delegate.h"
|
||
|
|
|
||
|
|
namespace LifeCore {
|
||
|
|
class WebCameraDescription {
|
||
|
|
public:
|
||
|
|
virtual ~WebCameraDescription() {}
|
||
|
|
virtual std::wstring GetName() = 0;
|
||
|
|
};
|
||
|
|
|
||
|
|
typedef std::shared_ptr<WebCameraDescription> webcam_desc_ptr;
|
||
|
|
|
||
|
|
class WebCamera : public ICamera, public IImage
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
Delegate<WebCamera*, RawBuffer<uint8>*> Event_ImageCapture;
|
||
|
|
WebCamera(webcam_desc_ptr desc);
|
||
|
|
int2 GetSize();
|
||
|
|
int32 GetBpp();
|
||
|
|
bool Read(int2 size, uint8* buffer);
|
||
|
|
static std::vector<webcam_desc_ptr> GetConnectedDevices();
|
||
|
|
bool Open();
|
||
|
|
void Close();
|
||
|
|
void OnImageGrabbed(WinMfImageGrabber* grabber, RawBuffer<uint8>* image);
|
||
|
|
void OnCaptureEvent(IMFMediaEvent* pEvent);
|
||
|
|
void Update();
|
||
|
|
RawBuffer<uint8>* GetImage();
|
||
|
|
int FrameNumber;
|
||
|
|
private:
|
||
|
|
webcam_desc_ptr description;
|
||
|
|
WinMfImageGrabber* grabber;
|
||
|
|
IMFMediaSource *pSource;
|
||
|
|
void* callback;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
#endif // WebCamera_h__
|