// This function creates a new structure representing a fixed format and resolution depth stream. // Note the parameters will be validated and the corresponding depth mode will be set, but the stream // will not be started. // BUG(g): The depth mode is set here instead of on Start() which means we can't reset the camera... func (device *Device) DepthCamera(res Resolution, fmt DepthFormat, source DepthSource, sink DepthSink) (*DepthCamera, int) { mode := C.freenect_find_depth_mode(C.freenect_resolution(res), C.freenect_depth_format(fmt)) if mode.is_valid == 0 { return nil, -999 } rc := int(C.freenect_set_depth_mode(device.dev, mode)) if rc != 0 { return nil, rc } C.registerDepthCallback(device.dev) device.depth = &DepthCamera{device, false, int(mode.bytes), source, sink, nil} return device.depth, 0 }
// StartDepthStream begins the retrieval of depth information from the device. func (device *Device) StartDepthStream(resolution Resolution, format DepthFormat) error { errCode := C.freenect_set_depth_mode(device.device, C.freenect_find_depth_mode(C.freenect_resolution(resolution), C.freenect_depth_format(format))) if errCode != 0 { return errors.New("could not find depth mode") } errCode = C.freenect_start_depth(device.device) if errCode != 0 { return errors.New("could not start depth stream") } return nil }
//FREENECTAPI freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt); func FindDepthMode(res Resolution, format DepthFormat) FrameMode { fm := C.freenect_find_depth_mode(C.freenect_resolution(res), C.freenect_depth_format(format)) return *(*FrameMode)(unsafe.Pointer(&fm)) }