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

	camera := device.depth

	if frame != unsafe.Pointer(&camera.current[0]) {
		panic("Unexpected depth 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_depth_buffer(camera.device.dev, unsafe.Pointer(&buffer[0])))
		if rc != 0 {
			fmt.Printf("Failed to set depth buffer: %d\n", rc)
			panic("Failed to set depth buffer")
		}
		camera.current = buffer
	}
}
Beispiel #2
0
//FREENECTAPI void *freenect_get_user(freenect_device *dev);
func (dev *Device) GetUser() unsafe.Pointer {
	return C.freenect_get_user(dev.ptr())
}