Check the contents of the SDK for THETA plugin development (theta-plugin-sdk) published on github.
Updated on January 24, 2020: Updated to match the latest SDK (SDK ver.1.0.2-> ver.2.1.0). Fixed broken links.
RICOH THETA V is made of Android OS and did not initially support plug-ins, but [RICOH THETA V] at the end of June Plugin Partner Program Start](https://theta360.com/ja/info/news/2018-06-28-01/) allows you to install your own Android app (= plugin). Check the SDK and documentation here.
To install the developed plug-in on the THETA main unit via the adb command, you need to register as a THETA Plugin developer (a photo of the actual THETA V or Z1 machine is required). The site is on the RICOH Developer Connection, but you don't need to create a RICOH Account because plugin developer registration has nothing to do with the "RICOH Account".
Open theta-plugin-sdk (ver.2.1.0) cloned from github in Android Studio.
Looking at the source code, it is divided into two parts, app and plugin library. In app, classes such as network are implemented. Until ver.1.x of SDK, pluginlibrary was included as direct source code, but from ver.2.x, it looks like ʻimplementation'com.theta360: pluginlibrary: 2.1.0' in app / build.gradle. It is set up in the form of ʻimport com.theta360.pluginlibrary.activity.PluginActivity;
on the code such as MainActivity.java.
(↓ In the case of ver.1.0.2, theta-plugin-library was included as a code (plugin library).)
In theta-plugin-library, implementation corresponding to the specifications specific to the plugin is implemented. If you want to create your own plugin, mainly develop the app part, and if necessary, [theta-plugin] -library](https://github.com/ricohapi/theta-plugin-library) part can be modified. In addition, theta-plugin-sdk allows you to take a still image by pressing the shutter button of THETA V.
app -MainActivity.java (Screen capture above part) -To MainActivity that inherits PluginActivity Only onCreate (), onResume (), and onPause () are implemented. PluginActivity is defined in pluginlibrary. --Implementation in onCreate () --setKeyCallback is called and KeyCallback interface Is implemented. - onKeyDown() --When it was a shutter button (KEYCODE_CAMERA), it inherited AsyncTask TakePictureTask -plugin-sdk / blob / master / app / src / main / java / com / theta360 / pluginapplication / task / TakePictureTask.java) is called. In doInBackground () of TakePictureTask, address camera.takePicture to localhost ("127.0.0.1:8080"). .html) Web API is called. --Web API is Web API for THETA and Google's [Open Spherical Camera API](https://developers. It is an extension of google.com/streetview/open-spherical-camera/reference/). --HttpConnector which is also implemented in the app for Web API calls pluginapplication / network / HttpConnector.java) class is used. This class also implements commands other than takePicture, which you can use when you need to call a Web API. - onKeyUp() --NotificationLedBlink is called when you push (return) some button. --It is implemented to blink LED3 (Wireless Light) in blue using notificationLedBlink. - onKeyLongPress() --Not implemented in particular. The code corresponding to the long press of the mode button is implemented in the plugin library.
theta-plugin-library (pluginlibrary)
--The plugin library defines THETA's own broadcasts described in Documents.
-PluginActivity is [AppCompatActivity]( It inherits https://developer.android.com/reference/android/support/v7/app/AppCompatActivity) and is an Android app [Activity Lifecycle](https://developer.android.com/guide/components/ The activities / activity-lifecycle) part (onCreate, onResume, onPause) is implemented. The following figure is quoted from developer.android.com
![(Developer.android.com) [https://developer.android.com/guide/components/activities/activity-lifecycle]](https: / /developer.android.com/guide/components/images/activity_lifecycle.png)
- onCreate()
--UncaughtException class that inherits Android's UncaughtExceptionHandler is registered, and if any exception occurs, an error will occur. The plugin is supposed to end.
- onResume()
--The key event has been registered. KeyReceiver class implemented in pluginlibrary Is used, and the part that gets the broadcast intent as described in Receiving Button Events in this class It is implemented. onKeyReceiver is defined in PluginActivity class, and callbacks such as onKeyLongPress used in MainActivity of app are performed via onKeyReceiver.
- onPause()
--Depending on the isClosed setting, the termination process is called.
--Unregister the KeyReceiver class. Key events (callbacks) will not come after onPause.
--In addition, in the PluginActivity class The following methods are defined. Many of the controls described in Broadcast Intent are available for method calls.
--Methods that control WLAN, such as notificationWlanOff
--Methods for controlling LEDs such as notificationLedShow
--Methods for controlling sound such as notificationAudioShutter
--Methods required when using Camera API such as notificationCameraOpen
When making an existing Android application project into a plug-in, you can use it by importing or copying the necessary parts such as the plugin library from theta-plugin-sdk to the project.
Move it on your Android smartphone or THETA V to see it. Since my smartphone is Android 7.0, I had to change minSdkVersion and targetSdkVersion to API24. I ran the Plugin SDK app on my Android smartphone and saw it. Hello World is displayed (though Theta shouldn't have a screen). You can also run Android apps on THETA in the same way. You can use Vysor to display the screen of THETA.
Plug-in development can be done using Android Studio in the same way as normal Android application development. Classes that implement the functions specific to the THETA V plugin are defined in theta-plugin-sdk. By using the PluginActivity class Controlled THETA, HttpConnector class You can use the functions defined in Web API.
Recommended Posts