Connect Wireless when using Camera API

What I am trying
I am trying to communicate with the camera via wifi while taking pictures. I am using camera API in my plugin to take pictures (I want to set RIC_JPEG_COMP_FILESIZE value). So I am starting wifi p2p connection (with android phone) and when I am trying to open the camera (in the plugin) it throws error with the code WifiP2pManager.BUSY.

Questions regarding this:

  • Can I set RIC_JPEG_COMP_FILESIZE without using Camera API? (I didn’t find this in the Web API)
  • Is there a way to connect to the camera wireless while using Camera API with my plugin?

Sorry this is a little bit general topic about the problem, but hope someone has experience like this.

You must specify camera control versus plug-in control by opening and closing the resources.

Notifying Camera Device Control

When using “com.theta360.plugin.ACTION_MAIN_CAMERA_CLOSE” with Broadcast Intent, the fact that the plug-in is controlling camera resources will be reported to the camera, and the Camera API will be able to be used.

When using “com.theta360.plugin.ACTION_MAIN_CAMERA_OPEN” with Broadcast Intent, the fact that the plug-in has released camera resources will be reported to the camera, and the Camera API will not be able to be used.

If you’re having difficulty using the Wi-Fi (HTTP) API for the camera from within the plug-in, there is a nice library called theta4j that makes it easier. There’s several minimal examples that we built for a meetup at the link below. You need to go into the branches to see the examples.

I believe that some of the TensorFlow and OpenCV examples on this site use the Wi-Fi API to trigger a picture

1 Like

This plug-in uses the CameraAPI and also has a WebUI. You need to run a web server inside the plug-in

Simple WebUI

Update April 17

@Vigen_Baghdasaryan, I believe I misunderstood your question originally.

If you want to use a mobile app with the plug-in, you can expose a web server from inside of the plug-in to enable the mobile app to send commands to the plug-in over Wi-Fi. As the plug-in is an Android app running inside of the camera, you can write your own simple server in Java/Kotlin or use something like this:

If you’re trying to use the plug-in with a sensor such as orientation or object recognition to trigger a picture with the WebAPI inside the camera, then you need to switch between the two. (However, now I think that this is not what you want to do, so maybe ignore my first response).

You cannot use the Wi-Fi API to change the JPEG compression. You can change the video compression with the Wi-Fi API, but not the still image JPEG compression. For this, you must use the CameraAPI.

1 Like

Hi @craig,

thanks for the response.

Yes, you are right. I want to take pictures and communicate with mobile app. The only thing that we can’t do with Web API is image compression (it’s critical for us now). The option with switching between Web API and Camera API can work. The only downside of this option can be time needed to switch between APIs.

I didn’t try yet this option. Will post the results later.