Exemple #1
0
// This function inititalize the freenect library, selects the motor and camera subdevices and begins the event processing loop.
// Event processing occurs in a go routine that will be terminated upon a call to Shutdown()
func Initialize() (*Freenect, int) {
	if _freenect != nil {
		return nil, -999
	}

	var ctx *C.freenect_context
	rc := int(C.freenect_init(&ctx, nil))

	if rc != 0 {
		return nil, rc
	}

	C.freenect_select_subdevices(ctx, (C.freenect_device_flags)(C.FREENECT_DEVICE_MOTOR|C.FREENECT_DEVICE_CAMERA))

	d := int(C.freenect_num_devices(ctx))
	_freenect = &Freenect{ctx, nil, make([]Device, d)}

	for x := 0; x < d; x++ {
		_freenect.Devices[x].index = x
		_freenect.Devices[x].freenect = _freenect
	}

	go func() {
		var to C.struct_timeval
		to.tv_sec = 0
		to.tv_usec = 0
		rc := C.int(0)
		for _freenect != nil && rc >= 0 {
			rc = C.freenect_process_events_timeout(_freenect.ctx, &to)
		}
	}()

	return _freenect, 0
}
Exemple #2
0
//FREENECTAPI int freenect_num_devices(freenect_context *ctx);
func (ctx *Context) NumDevices() int {
	return int(C.freenect_num_devices(ctx.ptr()))
}
Exemple #3
0
func (d *FreenectDevice) GetNumDevices() uint {
	return uint(C.freenect_num_devices(d.DeviceContext))
}