コード例 #1
0
ファイル: freenect.go プロジェクト: buka/go-freenect
//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
	}
}
コード例 #2
0
ファイル: freenect.go プロジェクト: buka/go-freenect
// Starts the acquisition of the depth stream. The source function will be invoked to obtain the first frame buffer.
func (camera *DepthCamera) Start() int {
	if camera.on == true {
		return 1
	}

	buffer := camera.source(camera.bytes)
	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)
		return rc
	}
	camera.current = buffer

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

	fmt.Printf("Depth stream started\n")
	camera.on = true
	return 0
}
コード例 #3
0
ファイル: freenect.go プロジェクト: krux02/freenect-go
//FREENECTAPI int freenect_set_depth_buffer(freenect_device *dev, void *buf);
func (dev *Device) SetDepthBuffer(buf unsafe.Pointer) int {
	return int(C.freenect_set_depth_buffer(dev.ptr(), buf))
}