Example #1
0
// StartVideoStream starts the retrieval of video information from the device.
func (device *Device) StartVideoStream(resolution Resolution, format VideoFormat) error {

	errCode := C.freenect_set_video_mode(device.device,
		C.freenect_find_video_mode(C.freenect_resolution(resolution), C.freenect_video_format(format)))

	if errCode != 0 {
		return errors.New("could not find video mode")
	}

	errCode = C.freenect_start_video(device.device)

	if errCode != 0 {
		return errors.New("could not start video stream")
	}

	return nil
}
Example #2
0
// This function creates a new structure representing a fixed format and resolution video stream.
// Note the parameters will be validated and the corresponding video mode will be set, but the stream
// will not be started.
// BUG(g): The video mode is set here instead of on Start() which means we can't reset the camera...
func (device *Device) VideoCamera(res Resolution, fmt VideoFormat, source VideoSource, sink VideoSink) (*VideoCamera, int) {
	if source == nil || sink == nil {
		return nil, -998
	}

	mode := C.freenect_find_video_mode(C.freenect_resolution(res), C.freenect_video_format(fmt))
	if mode.is_valid == 0 {
		return nil, -999
	}

	rc := int(C.freenect_set_video_mode(device.dev, mode))
	if rc != 0 {
		return nil, rc
	}

	C.registerVideoCallback(device.dev)

	device.video = &VideoCamera{device, false, int(mode.bytes), source, sink, nil}
	return device.video, 0
}
Example #3
0
//FREENECTAPI int freenect_set_video_mode(freenect_device* dev, freenect_frame_mode mode);
func (dev *Device) SetVideoMode(mode FrameMode) int {
	return int(C.freenect_set_video_mode(dev.ptr(), *mode.ptr()))
}