Exemplo n.º 1
0
func getVideoSource(videoFile string) (camera *C.CvCapture, err error) {
	if videoFile != "" {
		file := C.CString(videoFile)
		camera = C.cvCaptureFromFile(file)
		C.free(unsafe.Pointer(file))
		if camera == nil {
			return camera, errors.New("Unable to open a video file. Shutting down scout.")
		}

		return camera, nil
	} else {
		camera = C.cvCreateCameraCapture(0)
		if camera == nil {
			return camera, errors.New("Unable to open webcam. Shutting down scout.")
		}

		// Make sure the webcam is set to 1080p.
		C.cvSetCaptureProperty(camera, C.CV_CAP_PROP_FRAME_WIDTH, 1920)
		C.cvSetCaptureProperty(camera, C.CV_CAP_PROP_FRAME_HEIGHT, 1080)
		C.cvSetCaptureProperty(camera, C.CV_CAP_PROP_BUFFERSIZE, 1)

		return camera, nil
	}
}
Exemplo n.º 2
0
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
func NewCameraCapture(index int) *Capture {
	cap := C.cvCreateCameraCapture(C.int(index))
	return (*Capture)(cap)
}