Main Virtual Tours SC2 Linux

SOLVED: Check for THETA SC2 auto bracket completion

Hi,
I’m working on an app that can take automated brackets for hdr but I’m currently blocked because when calling “camera.startCapture” it never end.
right now, I do setOptions with

{
   "_autoBracket":  {
    "_bracketNumber":4,
    "_bracketParameters": [
  {
    "shutterSpeed":0.05,
    "iso":64,
    "whiteBalance":"auto"
  },
  {
    "shutterSpeed":0.07692307,
    "iso":64,
    "whiteBalance":"auto"
  },
  {
    "shutterSpeed":0.2,
    "iso":64,
    "whiteBalance":"auto"
  },
  {
    "shutterSpeed":0.33333333,
    "iso":64,
    "whiteBalance":"auto"
  }
  ]
}
}

that is working, then I’m calling startCapture with _mode:‘bracket’
then when following the capture status, I receive something like that

{"id": "5136", "name": "camera.startCapture", "progress": {"completion": 75}, "state": "inProgress"}
{"id": "5136", "name": "camera.startCapture", "progress": {"completion": 0}, "state": "inProgress"}
{"id": "5136", "name": "camera.startCapture", "progress": {"completion": 0}, "state": "inProgress"}

So basically it take all the pictures of my brackets, the progression is working too, but then it just go back to completion 0 and I never receive state done, it just stay “inProgress” forever.
I’m I missing an option or doing it wrong? I don’t really understand.
My SC2 is on the latest firmware (1.31)
Thanks!

Using /osc/command/status with the id received on startCapture didn’t work, state is always inProgess but I found a way to bypass that looking at /osc/state and waiting for _captureStatus to go back to “idle”. Then using camera.listFiles to get the list of images captured by my brackets.
Is there a better way to use the auto bracket feature?

1 Like

I ran a test with autoBracket and it works the same as your code with my setup, SC2, firmware 1.31.

From my tests, I believe that the /osc/command/status works differently on the SC2 compared to the Z1 and the V when used with camera.startCapture. I believe that for the SC2, you need to use state with camera.startCapture.

set autobracket

import 'package:http/http.dart' as http;
import 'package:apitest/pretty_print.dart';
import 'dart:async';
import 'dart:convert';

Future<http.Response> autoBracket() async {
  var url = 'http://192.168.1.1/osc/commands/execute';

  Map data = {
    'name': 'camera.setOptions',
    'parameters': {
      'options': {
        "_autoBracket": {
          "_bracketNumber": 3,
          "_bracketParameters": [
            {"shutterSpeed": 0.004, "iso": 400, "_colorTemperature": 5100},
            {"shutterSpeed": 0.004, "iso": 320, "_colorTemperature": 5100},
            {"shutterSpeed": 0.004, "iso": 2500, "_colorTemperature": 5000}
          ]
        }
      }
    }
  };

  //encode Map to JSON
  var body = jsonEncode(data);

  var response = await http.post(url,
      headers: {"Content-Type": "application/json;charset=utf-8"}, body: body);
  print("${response.statusCode}");
  prettyPrint("${response.body}");
  return response;
}

start capture

import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:apitest/pretty_print.dart';


Future<http.Response> startCapture () async {
  var url ='http://192.168.1.1/osc/commands/execute';

  Map data = {
    'name': 'camera.startCapture',
    'parameters': {
      "_mode": "bracket"
    }
  };
  //encode Map to JSON
  var body = jsonEncode(data);

  var response = await http.post(url,
      headers: {"Content-Type": "application/json;charset=utf-8"},
      body: body
  );
  print("The HTTP response code is: ${response.statusCode}");
  print("The HTTP response from camera.startCapture is: ");
  prettyPrint("${response.body}");
  return response;
}

response from startCapture

The HTTP response code is: 200
The HTTP response from camera.startCapture is:

{
  "name": "camera.startCapture",
  "id": "2079",
  "progress": {
    "completion": 0.0
  },
  "state": "inProgress"
}

Can you provide more information on if this is a problem in your application? You seem to have the correct process.

I’m assuming you have a loop that is checking state, similar to the example below for takePicture.

If there is no problem with your solution, I’m going to add it to the SC2 community documentation below and provide the example for startCapture

Important Note about _captureStatus and Downloading Images

The SC2 appears to take quite a bit longer to be ready for the next picture shoot. The V/Z1 is faster in my experience. When you write your own program you should check _captureStatus with state to make sure the _captureStatus is idle.

The flow of your program will be as follows:

<--- camera.takePicture

----> response

<--- POST /osc/state

----> response _captureStatus: shooting

<--- POST /osc/state

----> response _captureStatus: shooting

<--- POST /osc/state

----> response _captureStatus: shooting

<--- POST /osc/state

----> response _captureStatus: shooting

<--- POST /osc/state

----> response _captureStatus: idle

<--- GET URL *URL = _LatestFileUrl of the state received immediately before

I just realized that the public API documentation has an example on /osc/commands/status that does not appear to work with the SC2. I confirmed your test with my own test. I put the picture below in the community documentation and provided attribution to you. That’s a nice find that you made. I can only imagine the frustration that other people have having.

Since I can use /osc/state to get the capture status I guess that is a solution.
camera.takePicture is working perfectly with /osc/command/status the issue was only with camera.startCapture.

Also when using brackets, the state gives _captureStatus: "bracket shooting", _capturedPictures: 2, the capturedPictures will update its count.

something else that I found is the command to get the supported shutter speed doesn’t return good values but this one is a bit out of context

{
  "name":"camera.getOptions", 
  "parameters": {
    "optionNames" : ["shutterSpeedSupport"]
  }
}
1 Like

Thanks for all your testing and help you’re providing to other people. I’m going to do some tests based on your information and update the community document that I’m helping to maintain.

I’ll test the shutterspeed as well.

Have a nice day.

1 Like