GithubHelp home page GithubHelp logo

theta-web-api's Introduction

THETA Web API Client

Javadocs

Client implementation of RICOH THETA API v2.1.

Supported environments are Java, JVM languages, Android, and THETA Plug-in.

Tested on RICOH THETA V and THETA Z1. Some features for THETA S and SC are not tested.

Getting Started

Modify your build.gradle to include this library.

repositories {
    ...
    mavenCentral() // insert this line
}

dependencies {
    ...
    implementation 'org.theta4j:theta-web-api:1.6.0' // insert this line
}

Example Projects

Usage for Android and THETA Plug-in

This library takes network access, so your application needs android.permission.INTERNET permission.

Insert the following line into your AndroidManifest.xml.

<uses-permission android:name="android.permission.INTERNET"/>

Network access on UI thread causes an error on Android system. You need to call API on other thread.

For more details, see the official document.

// Invalid example written in Kotlin
class MyActivity : Activity() {
    override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
        // UI event is invoked on UI thread!!
        theta.takePicture() // this line causes error!!
        ...
    }
}
// Valid example written in Kotlin
class MyActivity : Activity() {
    private val executor = Executors.newSingleThreadExecutor()
    override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
        executor.submit {
            // The executor's thread is not an UI thread.
            theta.takePicture() // this is OK.
        }
        ...
    }
}

Example

These examples are written in Java.

Create Theta instance

org.theta4j.webapi.Theta is central object of this library.

When use from external device and THETA is Wi-Fi access point mode.

final Theta theta = Theta.create(); // endpoint is set to http://192.168.1.1

When use from external device and THETA is Wi-Fi client mode. Digest Authentication is required in this mode.

final String endpoint = "http://192.168.100.42"; // just an example
final String username = "THETAYL00000000";       // just an example
final String password = "p@55w0rd";              // just an example
final Theta theta = Theta.create(endpoint, username, password); // specify username and password

When use from THETA Plug-in.

final Theta theta = Theta.createForPlugin(); // endpoint is set to http://127.0.0.1:8080

Take a picture

theta.takePicture();

Take a picture and wait for done

import org.theta4j.osc.CommandResponse;
import org.theta4j.osc.CommandState;
import org.theta4j.webapi.TakePicture;
...
CommandResponse<TakePicture.Result> response = theta.takePicture();
while(response.getState() != CommandState.DONE) {
    response = theta.commandStatus(response);
    Thread.sleep(100);
}
System.out.println("fileUrl: " + response.getResults().getFileUrl());

Get option value

import static org.theta4j.webapi.Options.*;
...
final ISOSpeed iso = theta.getOption(ISO);
System.out.println("ISO: " + iso);

Get multiple option values in one HTTP request

import org.theta4j.osc.OptionSet;
import static org.theta4j.webapi.Options.*;
...
final OptionSet optionSet = theta.getOptions(ISO, ISO_SUPPORT, SHUTTER_SPEED);
System.out.println("ISO: " + optionSet.get(ISO));
System.out.println("ISO Support: " + optionSet.get(ISO_SUPPORT));
System.out.println("Shutter Speed: " + optionSet.get(SHUTTER_SPEED));

Set option value

import static org.theta4j.webapi.Options.*;
import org.theta4j.webapi.ISOSpeed;
...
theta.setOption(ISO, ISOSpeed._200);

Set multiple option values in one HTTP request

import org.theta4j.osc.OptionSet;
import static org.theta4j.webapi.Options.*;
import org.theta4j.webapi.ExposureProgram;
import org.theta4j.webapi.ISOSpeed;
...
final OptionSet optionSet = new OptionSet.Builder()
        .set(EXPOSURE_PROGRAM, ExposureProgram.ISO_SPEED)
        .set(ISO, ISOSpeed._200)
        .build();          
theta.setOptions(optionSet);

Development

theta-web-api's People

Contributors

shrhdk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

theta-web-api's Issues

Could not find org.theta4j:theta-web-api:1.5.0.

Could not find org.theta4j:theta-web-api:1.5.0.

dependencies {
...
implementation 'org.theta4j:theta-web-api:1.5.0' // insert this line
}

The above code gives an error
Where is 1.5.0?
1.4.0 exists
There is no 1.5.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.