示例#1
0
func (d *FreenectDevice) RawRGBFrame(format VideoFormat) (unsafe.Pointer, uint32) {
	var data unsafe.Pointer
	var timestamp C.uint32_t
	out := C.freenect_sync_get_video(&data, &timestamp, d.DeviceIndexCType, C.freenect_video_format(format))
	if out > 0 {
		return nil, 0
	}
	return data, uint32(timestamp)
}
示例#2
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
}
示例#3
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
}
示例#4
0
//FREENECTAPI freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt);
func FindVideoMode(res Resolution, format VideoFormat) FrameMode {
	fm := C.freenect_find_video_mode(C.freenect_resolution(res), C.freenect_video_format(format))
	return *(*FrameMode)(unsafe.Pointer(&fm))
}