camera.getLivePreview doesn"t work with Theta SC2?

Hello, I use web Ricoh API v2.1, it work’s well on Theta V and Z1 but when I use “camera.getLivePreview” on Theta SC2 I should get a content stream but I got null

I use C# to make call API

 // Some code
 public override async Task<Stream> StartPreviewAsync()
 {
       string json = "{\"name\":\"camera.getLivePreview\"," +
                                 "\"parameters\":{}}";
       try
       {
            HttpResponseMessage response = await MakeRequest("commands/execute", json, HttpCompletionOption.ResponseHeadersRead);
            return await response.Content.ReadAsStreamAsync();
       }
       catch (Exception e)
       {
           //  Error = Failed to connect to /192.168.1.1:80       
           return null;
       }
}

    public async static Task<HttpResponseMessage> MakeRequest(string endpoint, string body, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead)
    {
           client = new HttpClient();
           HttpResponseMessage responseMessage = new HttpResponseMessage();
           string requestUrl = "http://192.168.1.1/osc/" + endpoint;
           StringContent HttpContent = new StringContent(body, Encoding.UTF8, "application/json");
           HttpRequestMessage httpRequestMessage;

           if (endpoint.Equals("info"))
                httpRequestMessage = new HttpRequestMessage(new HttpMethod("GET"), requestUrl);
           else
           {
                httpRequestMessage = new HttpRequestMessage(new HttpMethod("POST"), requestUrl)
                {
                     Content = HttpContent
                };
           }

           try
           {
              responseMessage = await Shooting.client.SendAsync(httpRequestMessage, httpCompletionOption);
           }
           catch (Exception e)
           {
                   Console.WriteLine("Error" + e.Message);
           }

           return responseMessage;
}

I noticed that I got an error : “Failed to connect to /192.168.1.1:80”
Can someone have the same problem with THETA SC2

To be honest, I am having API call connection problems with the SC2.

You may have noticed that the API documentation for camera.getLivePreview does not mention anything about SC2 support.

If you’re working on a commercial project for company that has a business relationship with the RICOH sales team, you may be able to contact them and find out when the API documentation is going to be updated for SC2. That might help us.

I did some quick testing on Friday and I ran into some problems where my test programs ran on the THETA V and Z1, but not on the SC2.

I think we will be able to figure things out in time as the RICOH official mobile app seems to work fine with the SC2.

If I figure something out, I will definitely post here, but I have the same problem as you at the moment.

I have the same issue on an app I develop that use this API since the Theta V.
And the live streaming doesn’t work very well with the SC2, we have to send the same command several times in order to work.

And some commands makes the SC2 freeze completly, like this one :

{"name":"camera.setOptions","parameters":{"captureMode":"image"}}

I have the latest v1.20 firmware.

If you are building a large-scale commercial app, please contact us and we may be able to get more information from RICOH.

This document may help:

See this:

Note this:

SC2

{
  "name": "camera.getOpions",
  "state": "done",
  "results": {
    "options": {
      "offDelay": 65535,
      "sleepDelay": 65535,
      "remainingSpace": 2168410112,
      "_colorTemperature": 2500,
      "previewFormat": {
        "width": 0,
        "height": 0
      },
      "framerate": 0
    }
  }
}

Test of SC2 LivePreview


There is more information available at the link below (requires free registration):

Are you trying to tell me that the livePreview isn’t supposed to work with the SC2 ?
The empty returned values for previewFormat suggest that ?
Note that for me previewFormatSupport return a 1-length array : 1440 x 720 @ 30fps.
And again, it’s working for me, but the API is very unstable, making the camera crashes…

I’m developping a large-scale, commercial app as you said, we have also contacted Ricoh.

The live preview works. I have it working with the SC2. It also works with the RICOH THETA official app.

The return value (JSON format response) is incorrect and is different from the V/Z1.

It’s possible that your app is sending another API command at the same time as the live preview and thus crashing the app. This doesn’t occur with the V/Z1, but does occur with the SC2. I’ll send you a note by email. I’m going to send it to the email you used to register on this forum.

Also, this may help.

I know it works, as I said, it’s “just” very instable.
All you’re saying suggests that Ricoh needs to fix the API on the SC2 and publish a new firmware, because it’s inconsistent and buggy.
Maybe you can tell them to do so ?
In the meantime I’ve found a crappy workaround, which happens to be similar that the one suggested on your last link, but it’s not safe.
Thanks

Device info

{
  "manufacturer": "RICOH",
  "model": "RICOH THETA SC2",
  "serialNumber": "20117373",
  "firmwareVersion": "01.64",
  "supportUrl": "https://theta360.com/en/support/",
  "gps": false,
  "gyro": true,
  "endpoints": {
    "httpPort": 80,
    "httpUpdatesPort": 80
  },
  "apiLevel": [
    2
  ],
  "api": [
    "/osc/info",
    "/osc/state",
    "/osc/checkForUpdates",
    "/osc/commands/execute",
    "/osc/commands/status"
  ],
  "uptime": 8655,
  "_wlanMacAddress": "58:38:79:67:f8:aa",
  "_bluetoothMacAddress": "20:50:e7:73:8b:fb"
}

Option info


{
  "name": "camera.getOptions",
  "state": "done",
  "results": {
    "options": {
      "offDelay": 1500,
      "sleepDelay": 1500,
      "captureMode": "image",
      "previewFormat": {
        "width": 0,
        "height": 0,
        "framerate": 0
      },
      "_wlanChannel": 0,
      "remainingSpace": 2173018112,
      "_colorTemperature": 2500
    }
  }
}

please explain me below code, it fails, i cant get response to show live preview

  • when calling camera.getLivePreview I think it should respond, I see a change in data usage up to more than 1MB/s but can’t get a response.
  • only jumps to success when I stop live preview by taking a photo
  • i tried both axios and fetch with this problem
    => please help me, i am processing with javascript (reactnative)

image

I’m having a problem with javascript, can’t get the response
I can’t get the data in the response yet, so I can’t process it to display, the problem is that I can’t receive the response

your example use java or flutter, i am having problem with javascript (react-native)

The last example is JavaScript.

Are you receiving an HTTP stream?

Your code needs to accept a stream of data, not a single response.

Can you see a continuous stream of data in your debug console?

1 Like

I used your code, but I can’t get past line 21

I am currently not receiving HTTP stream

that line is for client mode. If the client is using access point mode, you don’t need to use digest authentication.

I’m not familiar with React Native and do not know JavaScript very well.

In other languages, I know that the camera.getLivePreview is set up differently and you need to accept a stream.

For example, in Dart, you need to accept an async stream and set up a listener on the stream.

There’s likely JavaScript tutorials on the Internet that show how to use stream listeners.

As far as the API command is concerned, the way to start the stream is simple. Even though the command below is in dart, you can likely figure out that the API command is simple.

    Uri url = Uri.parse('http://192.168.1.1/osc/commands/execute');
    var request = http.Request('POST', url);

    Map<String, String> bodyMap = {"name": "camera.getLivePreview"};
    request.body = jsonEncode(bodyMap);

    Map<String, String> headers = {
      "Content-Type": "application/json; charset=UTF-8"
    };