Exemple #1
0
//export videoCallback
func videoCallback(dev unsafe.Pointer, frame unsafe.Pointer, timestamp C.uint32_t) {
	device := (*Device)(C.freenect_get_user((*C.freenect_device)(dev)))
	if device == nil || device.video == nil {
		panic("No video camera found")
	}

	camera := device.video

	if frame != unsafe.Pointer(&camera.current[0]) {
		panic("Unexpected video frame buffer pointer")
	}

	camera.sink(camera.current, int32(timestamp))

	// source can return nil to reuse same buffer
	buffer := camera.source(camera.bytes)
	if buffer != nil {
		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)
			panic("Failed to set video buffer")
		}
		camera.current = buffer
	}
}
Exemple #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
}
Exemple #3
0
//FREENECTAPI int freenect_set_video_buffer(freenect_device *dev, void *buf);
func (dev *Device) SetVideobuffer(buf unsafe.Pointer) int {
	return int(C.freenect_set_video_buffer(dev.ptr(), buf))
}