示例#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
}
示例#2
0
// Starts the acquisition of the video stream. The source function will be invoked to obtain the first frame buffer.
func (camera *VideoCamera) Start() int {
	if camera.on == true {
		return 1
	}

	buffer := camera.source(camera.bytes)
	rc := int(C.freenect_set_video_buffer(camera.device.dev, unsafe.Pointer(&buffer[0])))
	if rc != 0 {
		fmt.Printf("Failed to set video buffer: %d\n", rc)
		return rc
	}
	camera.current = buffer

	rc = int(C.freenect_start_video(camera.device.dev))
	if rc != 0 {
		fmt.Printf("Failed to start video stream: %d\n", rc)
		return rc
	}

	fmt.Printf("Video stream started\n")
	camera.on = true
	return 0
}
示例#3
0
//FREENECTAPI int freenect_start_video(freenect_device *dev);
func (dev *Device) StartVideo() int {
	return int(C.freenect_start_video(dev.ptr()))
}