예제 #1
0
func handleCaptureEvent(camera *gphoto2go.Camera, folder string, fileName string) {
	path := path.Join(viper.GetString("photos.path"), fileName)
	reader := camera.FileReader(folder, fileName)
	fWriter, _ := os.Create(path)
	io.Copy(fWriter, reader)
	fWriter.Close()
	reader.Close()
	bus.Publish("photo:saved", path)
}
예제 #2
0
func initCameraEventSource(camera *gphoto2go.Camera) {
	go func() {
		for {
			eventChan := camera.AsyncWaitForEvent(1000)
			evt := <-eventChan
			if evt.Type == gphoto2go.EVENT_FILE_ADDED {
				bus.Publish("photo:capture", camera, evt.Folder, evt.File)
			}
		}
	}()
}
예제 #3
0
func initCamera() *gphoto2go.Camera {
	camera := new(gphoto2go.Camera)
	err := camera.Init()

	if err < 0 {
		log.Fatalf("No camera found. Exiting.\n")
	} else {
		bus.Publish("camera:init", camera)
	}

	return camera
}