User Tools

Site Tools


script-hdr-gopro

HDR capturing with GoPro Hero cameras

This example shows how to capture exposure series (e.g. for HDR) using exposure compensation using GoPro Hero 4, 5, 6, and Fusion cameras. The following steps are executed:

  1. Connect the script to a camera.
  2. Set the camera mode to photo.
  3. Enable protune.
  4. Set the exposure compensation.
  5. Capture image.
/**
 * 9 picture HDR capturing example (GoPro Hero 4, 5, 6, and Fusion).
 * Author: Camera Controller
 * Web: http://www.tequnique.com/cameracontroller
 * Description: This example shows how to capture exposure series (e.g. for HDR).
 */
 
// Helper function for capturing an image with a specific exposure
function captureImage(cameraName, exposureCommand) {
    // Set exposure
    var result = sendCustomCameraCommand(cameraName, exposureCommand);
    if (!result.ok) {
        logMessage("Error setting exposure: " + result.message, true);
    }
 
    // Capture photo
    result = startRecording(cameraName);
    if (!result.ok) {
        logMessage("Error capturing photo: " + result.message, true);
    }
}
 
// Information
logMessage("This example captures 9 differently exposed pictures in photo mode with GoPro Hero 4, 5, 6, and Fusion cameras.");
 
// Use the currently connected camera:
var connectResult = connectToCamera();
if (connectResult.ok) {
    var cameraName = connectResult.message;
 
    // Change the camera mode to 4 (which is photo mode on the GoPro Hero 4, 5, 6). The index
    // depends on the camera model.
    var result = changeCameraMode(cameraName, 4);
    if (!result.ok) {
        logMessage("Error changing camera mode to photo: " + result.message, true);
    }
 
    // Give the camera some time for changing the mode
    waitMilliseconds(500);
 
    // Log the current camera mode
    var cameraModeIndex = getCurrentCameraMode(cameraName);
    logMessage("The current camera mode is: " + cameraModeIndex);
 
    // Enable Protune
    result = sendCustomCameraCommand(cameraName, "/setting/21/1");
    if (!result.ok) {
        logMessage("Error enabling Protune: " + result.message, true);
    }
 
    for (var i=0; i<9; i++) {
        logMessage("Capturing image " + (i+1));
        captureImage(cameraName, "/setting/26/" + i); // 1
        waitForCameraRecordingState(cameraName, 1000, "recording");
        waitForCameraRecordingState(cameraName, 0, "idle");
        waitMilliseconds(1000); // give the camera some time for capturing.
    }
 
    logMessage("Done");
}
else showMessageDialog("Error", "No camera found");
script-hdr-gopro.txt · Last modified: 2018/04/10 13:57 by teq