27 #ifndef INCLUDED_directx_camera_server_h_GUID_9322F126_0DA4_4DB9_11F3_DDBF76A6D9D9
28 #define INCLUDED_directx_camera_server_h_GUID_9322F126_0DA4_4DB9_11F3_DDBF76A6D9D9
34 #include "comutils/ComInit.h"
35 #include "comutils/ComPtr.h"
47 #define NO_DSHOW_STRSAFE
63 struct ConstructionError : std::runtime_error {
64 ConstructionError(
const char objName[])
66 std::string(
"directx_camera_server: Can't create ") + objName) {}
90 using FilterOperation = std::function<void(IBaseFilter &)>;
94 using BufferType = std::vector<unsigned char>;
97 directx_camera_server(
int which,
unsigned width = 0,
unsigned height = 0);
99 directx_camera_server(std::string
const &pathPrefix,
unsigned width = 0,
100 unsigned height = 0);
104 directx_camera_server(std::string
const &pathPrefix,
105 FilterOperation
const &sourceConfig);
107 virtual ~directx_camera_server(
void);
114 unsigned minY = 255,
unsigned maxY = 0,
115 double exposure_millisecs = 250.0);
124 BufferType
const &get_pixel_buffer()
const {
return _buffer; }
127 BufferType &get_pixel_buffer() {
return _buffer; }
136 bool isOpened(
void)
const {
return _started_graph; }
138 std::string
const &getPath()
const {
return devicePath_; }
141 bool start_com_and_graphbuilder();
142 bool open_moniker_and_finish_setup(comutils::Ptr<IMoniker> pMoniker,
143 FilterOperation
const &sourceConfig,
144 unsigned width,
unsigned height);
145 virtual void close_device(
void);
148 directx_camera_server();
150 comutils::ComInstance _com;
153 comutils::Ptr<IGraphBuilder>
156 comutils::Ptr<IMediaControl>
159 comutils::Ptr<ICaptureGraphBuilder2> _pBuilder;
163 std::unique_ptr<SampleGrabberWrapper> _pSampleGrabberWrapper;
167 bool _started_graph =
false;
174 MediaSampleExchangePtr sampleExchange_;
176 virtual bool open_and_find_parameters(
const int which,
unsigned width,
178 bool open_and_find_parameters(std::string
const &pathPrefix,
179 FilterOperation
const &sourceConfig,
180 unsigned width = 0,
unsigned height = 0);
181 virtual bool read_one_frame(
unsigned minX,
unsigned maxX,
unsigned minY,
182 unsigned maxY,
unsigned exposure_millisecs);
185 void allocate_buffer();
186 std::string devicePath_;
190 #endif // INCLUDED_directx_camera_server_h_GUID_9322F126_0DA4_4DB9_11F3_DDBF76A6D9D9
virtual unsigned get_num_colors() const =0
Return the number of colors that the image has.
virtual bool get_pixel_from_memory(unsigned X, unsigned Y, vrpn_uint8 &val, int RGB=0) const =0
Get pixels out of the memory buffer, RGB indexes the colors.
Header providing a C++ wrapper around TimeValueC.h.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
virtual bool read_image_to_memory(unsigned minX=255, unsigned maxX=0, unsigned minY=255, unsigned maxY=0, double exposure_time=250.0)=0