func (c Theta) TakePicture() revel.Result { client, _ := theta_v2.NewClient("http://192.168.1.1") // camera.startSession revel.INFO.Println("camera.startSession:") startSessionCommand := new(command.StartSessionCommand) client.CommandExecute(startSessionCommand) revel.INFO.Println(" sessionId:", *startSessionCommand.Results.SessionId) sessionId := startSessionCommand.Results.SessionId // camera.takePicture revel.INFO.Println("camera.takePicture") takePictureCommand := new(command.TakePictureCommand) takePictureCommand.Parameters.SessionId = sessionId takePictureCommandResponse, _ := client.CommandExecute(takePictureCommand) // camera.closeSession revel.INFO.Println("camera.closeSession:") closeSessionCommand := new(command.CloseSessionCommand) closeSessionCommand.Parameters.SessionId = sessionId client.CommandExecute(closeSessionCommand) c.Response.Status = 202 return c.RenderJson(takePictureCommandResponse) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) command := new(command.ListImagesCommand) parameters := &command.Parameters entryCount, includeThumb := 10, false parameters.EntryCount = &entryCount parameters.IncludeThumb = &includeThumb _, error := client.CommandExecute(command) if error != nil { fmt.Println("Error:", error) return } results := command.Results fmt.Println("totalEntries:", *results.TotalEntries) if *results.TotalEntries > 0 { entries := *results.Entries for i := range entries { fmt.Printf("{name: %s, uri: %s, size: %d}\n", *entries[i].Name, *entries[i].Uri, *entries[i].Size) } } }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) command := new(command.ListAllCommand) parameters := &command.Parameters entryCount, detail := 10, false parameters.EntryCount = &entryCount parameters.Detail = &detail client.CommandExecute(command) results := command.Results fmt.Println("totalEntries:", *results.TotalEntries) if *results.TotalEntries > 0 { entries := *results.Entries for i := range entries { fmt.Printf("{name: %s, uri: %s, size: %d}\n", *entries[i].Name, *entries[i].Uri, *entries[i].Size) } } }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } fileUri := "1" if len(os.Args) > 2 { fileUri = os.Args[2] } client, _ := theta_v2.NewClient(host) getMetadataCommand := new(command.GetMetadataCommand) getMetadataCommand.Parameters.FileUri = &fileUri client.CommandExecute(getMetadataCommand) exif := getMetadataCommand.Results.Exif fmt.Println("Exif:") fmt.Println(" ExifVersion:", *exif.ExifVersion) fmt.Println(" ExposureTime:", *exif.ExposureTime) fmt.Println(" ISOSpeedRatings:", *exif.ISOSpeedRatings) xmp := getMetadataCommand.Results.Xmp fmt.Println("XMP:") fmt.Println(" ProjectionType:", *xmp.ProjectionType) fmt.Println(" CroppedAreaImageWidthPixels:", *xmp.CroppedAreaImageWidthPixels) fmt.Println(" CroppedAreaImageHeightPixels:", *xmp.CroppedAreaImageHeightPixels) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) // camera.startSession startSessionCommand := new(command.StartSessionCommand) client.CommandExecute(startSessionCommand) fmt.Println("camera.startSession:") fmt.Println(" sessionId:", *startSessionCommand.Results.SessionId) sessionId := startSessionCommand.Results.SessionId // camera.getOptions getOptionsCommand := new(command.GetOptionsCommand) getOptionsCommand.Parameters.SessionId = sessionId optionNames := &[]string{"fileFormat", "fileFormatSupport", "captureMode", "captureModeSupport", "exposureProgram", "exposureProgramSupport", "shutterSpeed", "iso"} getOptionsCommand.Parameters.OptionNames = optionNames client.CommandExecute(getOptionsCommand) options := getOptionsCommand.Results.Options fmt.Println("camera.getOptions:") fmt.Println(" exposureProgram:", *options.ExposureProgram) fmt.Printf(" fileFormat: {type: %s, width: %d, height: %d}\n", *options.FileFormat.Type, *options.FileFormat.Width, *options.FileFormat.Height) fmt.Println(" captureMode:", *options.CaptureMode) fmt.Println(" ISO:", *options.Iso) // camera.setOptions setOptionsCommand := new(command.SetOptionsCommand) setOptionsCommand.Parameters.SessionId = sessionId setOptions := new(command.Options) image_type, image_width, image_height := "jpeg", 5376, 2688 setOptions.FileFormat = &command.FileFormat{Type: &image_type, Width: &image_width, Height: &image_height} iso := 100 setOptions.Iso = &iso exposureProgram := 9 // ISO priority program setOptions.ExposureProgram = &exposureProgram setOptionsCommand.Parameters.Options = setOptions setOptionsResponse, _ := client.CommandExecute(setOptionsCommand) fmt.Println("camera.setOptions:") fmt.Println(" State:", *setOptionsResponse.State) // camera.closeSession closeSessionCommand := new(command.CloseSessionCommand) closeSessionCommand.Parameters.SessionId = sessionId closeSessionResponse, _ := client.CommandExecute(closeSessionCommand) fmt.Println("camera.closeSession:") fmt.Println(" State:", *closeSessionResponse.State) }
func main() { host := "http://dummy-host" client, _ := theta_v2.NewClient(host) _, error := client.Info() if error != nil { fmt.Println("Error:", error.Error()) } }
func (c Theta) ImageList() revel.Result { client, _ := theta_v2.NewClient("http://192.168.1.1") listImagesCommand := new(command.ListImagesCommand) entryCount, includeThumb := 10, false listImagesCommand.Parameters.EntryCount = &entryCount listImagesCommand.Parameters.IncludeThumb = &includeThumb client.CommandExecute(listImagesCommand) entries := *listImagesCommand.Results.Entries return c.Render(entries) }
func (c Theta) ImageThumbnail(uri string) revel.Result { client, _ := theta_v2.NewClient("http://192.168.1.1") getImageCommand := new(command.GetImageCommand) imageType := "thumb" getImageCommand.Parameters.Type = &imageType getImageCommand.Parameters.FileUri = &uri response, _ := client.CommandExecute(getImageCommand) revel.INFO.Println(" fileUri:", uri) http_body := response.Results.(io.ReadCloser) defer http_body.Close() body, _ := ioutil.ReadAll(http_body) return JpegResponse(body) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) res, _ := client.State() fmt.Println("fingerprint:", *res.Fingerprint) fmt.Println("state:") fmt.Println(" sessionId:", *res.State.SessionId) fmt.Println(" battelyLevel:", *res.State.BatteryLevel) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) info, _ := client.Info() fmt.Println("manufacturer:", *info.Manufacturer) fmt.Println("model:", *info.Model) fmt.Println("serialNumber:", *info.SerialNumber) fmt.Println("firmwareVersion:", *info.FirmwareVersion) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) // camera.startSession startSessionCommand := new(command.StartSessionCommand) client.CommandExecute(startSessionCommand) sessionId := startSessionCommand.Results.SessionId // camera.setOptions fmt.Println("camera.setOptions:") setOptionsCommand := new(command.SetOptionsCommand) setOptionsCommand.Parameters.SessionId = sessionId setOptions := new(command.Options) // RICOH THETA S is NOT supported 5000x2500 jpeg image_type, image_width, image_height := "jpeg", 5000, 2000 setOptions.FileFormat = &command.FileFormat{Type: &image_type, Width: &image_width, Height: &image_height} setOptionsCommand.Parameters.Options = setOptions setOptionsResponse, _ := client.CommandExecute(setOptionsCommand) // Error Handling state := *setOptionsResponse.State fmt.Println(" State:", state) switch state { case "error": fmt.Println(" HTTP Response:") fmt.Println(" Status:", client.Response.Status) fmt.Println(" StatusCode:", client.Response.StatusCode) fmt.Println(" Error:") fmt.Println(" Code:", *setOptionsResponse.Error.Code) fmt.Println(" Message:", *setOptionsResponse.Error.Message) } // camera.closeSession closeSessionCommand := new(command.CloseSessionCommand) closeSessionCommand.Parameters.SessionId = sessionId client.CommandExecute(closeSessionCommand) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) res, _ := client.CheckForUpdates("test", nil) if res.StateFingerprint != nil { fmt.Println("fingerprint:", *res.StateFingerprint) } if res.ThrottleTimeout != nil { fmt.Println("throttleTimout:", *res.ThrottleTimeout) } }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } fileUri := "1" if len(os.Args) > 2 { fileUri = os.Args[2] } client, _ := theta_v2.NewClient(host) deleteCommand := new(command.DeleteCommand) deleteCommand.Parameters.FileUri = &fileUri response, _ := client.CommandExecute(deleteCommand) fmt.Println("state:", *response.State) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } fileUri := "1" if len(os.Args) > 2 { fileUri = os.Args[2] } client, _ := theta_v2.NewClient(host) getImageCommand := new(command.GetImageCommand) getImageCommand.Parameters.FileUri = &fileUri response, _ := client.CommandExecute(getImageCommand) http_body := response.Results.(io.ReadCloser) defer http_body.Close() split_strings := strings.Split(fileUri, "/") out, _ := os.Create(split_strings[len(split_strings)-1]) defer out.Close() io.Copy(out, http_body) }
func main() { host := "http://192.168.1.1" if len(os.Args) > 1 { host = os.Args[1] } client, _ := theta_v2.NewClient(host) // camera.startSession fmt.Println("camera.startSession:") startSessionCommand := new(command.StartSessionCommand) client.CommandExecute(startSessionCommand) fmt.Println(" sessionId:", *startSessionCommand.Results.SessionId) sessionId := startSessionCommand.Results.SessionId // state state, _ := client.State() fingerprint := *state.Fingerprint // camera.takePicture fmt.Println("camera.takePicture") takePictureCommand := new(command.TakePictureCommand) takePictureCommand.Parameters.SessionId = sessionId takePictureResponse, _ := client.CommandExecute(takePictureCommand) fmt.Println(" state:", *takePictureResponse.State) fmt.Println(" commandId:", *takePictureResponse.Id) commandId := takePictureResponse.Id // Wait Saving File fmt.Print("Wait Saving File...") lastFingerprint := fingerprint for lastFingerprint == fingerprint { lastFingerprint = fingerprint checkForUpdates, _ := client.CheckForUpdates(lastFingerprint, nil) fingerprint = *checkForUpdates.StateFingerprint } fmt.Println("done.") // camera.updateSession fmt.Println("camera.updateaSession:") updateSessionCommand := new(command.UpdateSessionCommand) updateSessionCommand.Parameters.SessionId = sessionId updateSessionResponse, _ := client.CommandExecute(updateSessionCommand) fmt.Println(" state:", *updateSessionResponse.State) sessionId = updateSessionCommand.Results.SessionId // camera.closeSession closeSessionCommand := new(command.CloseSessionCommand) closeSessionCommand.Parameters.SessionId = sessionId closeSessionResponse, _ := client.CommandExecute(closeSessionCommand) fmt.Println("camera.closeSession:") fmt.Println(" state:", *closeSessionResponse.State) // CommandStatus fmt.Println("CommandStatus:") commandStatusResponse, _ := client.CommandStatus(*commandId, takePictureCommand) for *commandStatusResponse.State != "done" { time.Sleep(200 * time.Millisecond) commandStatusResponse, _ = client.CommandStatus(*commandId, takePictureCommand) } fmt.Println(" state:", *commandStatusResponse.State) fmt.Println(" fileUri:", *takePictureCommand.Results.FileUri) }