136 LogError(
"Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION");
176 LogError(
"Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION");
213 typedef std::map<OniDeviceInfo, oni::driver::DeviceBase*>
OniDeviceMap;
222 std::istringstream is(uri);
223 is.seekg(strlen(
"freenect://"));
243 DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie);
244 for (
int i = 0; i < Freenect::deviceCount(); i++)
246 std::string uri = devid_to_uri(i);
254 devices[info] = NULL;
255 deviceConnected(&info);
256 deviceStateChanged(&info, 0);
263 for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++)
265 if (strcmp(iter->first.uri, uri) == 0)
274 int id = uri_to_devid(iter->first.uri);
282 LogError(
"Could not find device " + std::string(uri));
288 for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++)
290 if (iter->second == pDevice)
292 WriteMessage(
"Closing device " + std::string(iter->first.uri));
293 int id = uri_to_devid(iter->first.uri);
300 LogError(
"Could not close unrecognized device");
314 for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++)
316 WriteMessage(
"Closing device " + std::string(iter->first.uri));
317 int id = uri_to_devid(iter->first.uri);
334 #define XN_NEW(type, arg...) new type(arg) 335 #define XN_DELETE(p) delete(p)
void DepthCallback(void *data, uint32_t timestamp)
void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs)
static void LogError(std::string error)
OniImageRegistrationMode getImageRegistrationMode() const
Driver(OniDriverServices *pDriverServices)
OniStatus tryDevice(const char *uri)
OniStatus getProperty(int propertyId, void *data, int *pDataSize)
Device(freenect_context *fn_ctx, int index)
OniStatus setProperty(int propertyId, const void *data, int dataSize)
void VideoCallback(void *data, uint32_t timestamp)
OniStatus invoke(int commandId, void *data, int dataSize)
OniStatus getSensorInfoList(OniSensorInfo **pSensors, int *numSensors)
OniBool isPropertySupported(int propertyId)
OniStatus setImageRegistrationMode(OniImageRegistrationMode mode)
ONI_EXPORT_DRIVER(FreenectDriver::Driver)
void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level)
OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode)
oni::driver::DeviceBase * deviceOpen(const char *uri, const char *mode=NULL)
std::map< OniDeviceInfo, oni::driver::DeviceBase * > OniDeviceMap
void destroyStream(oni::driver::StreamBase *pStream)
MyFreenectDevice * device
static int uri_to_devid(const std::string uri)
OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void *pCookie)
void buildFrame(void *data, uint32_t timestamp)
OniBool isCommandSupported(int commandId)
oni::driver::StreamBase * createStream(OniSensorType sensorType)
static std::string devid_to_uri(int id)
static OniSensorInfo getSensorInfo()
OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode)
static std::string to_string(const T &n)
static void WriteMessage(std::string info)
static oni::driver::DriverServices * DriverServices
void(ONI_CALLBACK_TYPE * DeviceStateChangedCallback)(const OniDeviceInfo *deviceId, int errorState, void *pCookie)
void deviceClose(oni::driver::DeviceBase *pDevice)
FreenectDevice(freenect_context *_ctx, int _index)
void(ONI_CALLBACK_TYPE * DeviceDisconnectedCallback)(const OniDeviceInfo *, void *pCookie)
static OniSensorInfo getSensorInfo()