Change the Camera Properties

To change camera properties, for example F number, shutter speed, ISO and so on, send change property commands by using SetDeviceProperty(). There are two parameters, the first parameter is the device handle of the target camera, and the second parameter is the CrDeviceProperty class object. In this CrDeviceProperty object, only the code and value members are referred to in Camera Remote SDK.

If the value is invalid, the command is ignored, for example, where the out-of-range F number or setting F number in exposure mode is “S”.

The combination of the code and the available value is described in API Reference section.

Note that this SetDeviceProperty() call is not synchronous. Once SetDeviceProperty() is called, the command is queued in the command queue in Camera Remote SDK and it is transmitted to camera at the appropriate time. It means that there is a short time lag between this function call and the camera’s property change.

The properties in Camera Remote SDK are also not updated by the SetDeviceProperty() function. SDK keeps the property status of the camera. It is updated after the camera changes its status.

../_images/op_seq_change_camera_properties.png

If the property is not changed because of the camera status, Camera Remote SDK does not notify you of anything. It is recommended to set the 3- to 5-second timer in the user interface and try to get the property status to SDK and update the user interface state.

The following is sample code for updating device property of numeric type.

Example:

SCRSDK::CrDeviceProperty prop;
prop.SetCode(code); // Specify the code of the device property you want to update
prop.SetValueType(type); // Specify the type of the device property you want to update
prop.SetCurrentValue((CrInt64u)newValue);
SCRSDK::SetDeviceProperty(handle, &prop);

The following is sample code for updating a device property of type CrDataType_STR.

Example:

SCRSDK::CrDeviceProperty prop;
prop.SetCode(code); // Specify the code of CrDataType_STR device property you want to update
prop.SetValueType(type); // Specify the type of CrDataType_STR device property you want to update
#if defined (_WIN32) || defined (_WIN64)
std::wstring input(L"TEST1");
#else
std::string input("TEST1");
#endif
// The string length that can be set varies depending on the device property.
// Check the maximum character length of the device property to be updated.
// The only CrDataType_STR device property that can be updated in version 1.08.00 is CrDeviceProperty_ImageID_String.
int strLen = input.length();
if (64 < strLen)
    return;  // String is too long.

// Prepare a place to store the string to be set.
// Notes:
//          Append  a null-terminate and pass it to the Camera Remote SDK.
//          The first 2 bytes are the character string length including the null-terminate.
CrInt16u* setStr = new CrInt16u[strLen+2];
memset(setStr, 0, sizeof(setStr));
setStr[0] = (CrInt16u)strLen + 1; // +1 = null-terminate
#if defined (_WIN32) || defined (_WIN64)
lstrcpy((wchar_t*)&setStr[1], input.c_str());
#else
// Convert multi byte char to wide byte char
wchar_t wbuff;
for (int i = 0; i < input.length(); ++i) {
    int retLen = mbtowc(&wbuff, &input.at(i), 1);
    if (-1 != retLen) {
        setStr[i + 1] = (CrInt16u)wbuff;
        //setStr[i + 1] = (CrInt16u)((wbuff & 0xFF) << 8 | ((wbuff >> 8) & 0xFF)); // For endian convert
    }
}
#endif
prop.SetCurrentStr(setStr); // Use SetCurrentStr() for CrDataType_STR
SCRSDK::SetDeviceProperty(handle, &prop);
delete[] setStr;