Memorize Zoom Distance and Focal Distance

You can save the zoom position and focus position of the lens on the camera body, and recall and use the saved information.

Newer models have added lens name and other information to the saved information. Please check the API list for supported models.

The following is an example of acquiring and displaying the information saved in the body using CrDeviceProperty_ZoomAndFocusPosition_Save using the newly established “Zoom&Focus Preset” API.

Example:

// Save the current zoom value and focus value in the 0th area of the 5 areas from 0 to 4.
SCRSDK::CrDeviceProperty prop;
prop.SetCode(SCRSDK::CrDevicePropertyCode::CrDeviceProperty_ZoomAndFocusPosition_Save);
prop.SetCurrentValue(0); // index : 0
prop.SetValueType(SCRSDK::CrDataType::CrDataType_UInt8); // Use target DP's CrDataType
SCRSDK::SetDeviceProperty(handle, &prop);

// Get the saved information using the new API and display it on the console
SCRSDK::CrError ret = SCRSDK::RequestZoomAndFocusPreset(handle);
if (CR_FAILED(ret))
{
  printf("fail RequestZoomAndFocusPreset send.\n");
}

Example:

// Check OnWarning() callback

// If the request is successful, CrWarning_RequestZoomAndFocusPreset_Result_Success will be notified in the OnWarning() callback

class MyDeviceCallback : public IDeviceCallback
{
  void OnWarning(CrInt32u warning)
  {
    switch (warning)
    {
      case SCRSDK::CrWarning_RequestZoomAndFocusPreset_Result_Success:
        m_bResultSuccess = true;
        printf("RequestZoomAndFocusPreset Success.\n");
        break;
      case SCRSDK::CrWarning_RequestZoomAndFocusPreset_Result_DeviceBusy:
        m_bResultSuccess = false;
        printf("RequestZoomAndFocusPreset DeviceBusy.\n");
        break;
      case SCRSDK::CrWarning_RequestZoomAndFocusPreset_Result_Error:
        m_bResultSuccess = false;
        printf("RequestZoomAndFocusPreset Error.\n");
        break;

    // etc.
// If the request is successful
if (m_bResultSuccess)
{
  SCRSDK::CrZoomAndFocusPresetInfo* presetInfo = nullptr;
  CrInt32u nums = 0;
  ret =  SCRSDK::GetZoomAndFocusPreset(handle, &presetInfo, &nums);
  if (CR_SUCCEEDED(ret) && 0 < nums)
  {
    char buff[32];
    CrInt32 numDivision;
    CrInt32 numRemainder;
    for (CrInt32u i = 0; i < nums; i++)
    {
      CrInt16u* pName = (CrInt16u*)presetInfo[i].lensModelName;
      if (0 < pName[0])
      {
          // case Windows:WideChar(UTF-16)
          std::wstring sLensName = std::wstring((const wchar_t*)&pName[1]);
          wprintf(L"Lens Model Name : %s\n", sLensName.c_str());
      }

      numDivision = presetInfo[i].zoomDistance / 1000;
      memset(buff, 0, sizeof(buff));
      sprintf_s(buff, sizeof(buff), "%dmm", numDivision);
      printf("Zoom Distance   : %s\n", buff);

      if (SCRSDK::CrFocalDistance_Infinity != presetInfo[i].focalDistance)
      {
          numDivision = presetInfo[i].focalDistance / 1000;
          numRemainder = presetInfo[i].focalDistance % 1000 / 100;
          memset(buff, 0, sizeof(buff));
          sprintf_s(buff, sizeof(buff), "%d.%dm", numDivision, numRemainder);
          printf("Focal Distance  : %s\n", buff);
      }

      // etc.
    }

    // release
    SCRSDK::ReleaseZoomAndFocusPreset(handle, presetInfo);
  }

}
This information can be confirmed in the Preset Zoom&Focus on the camera body.

ex. ILCE-9M3

../_images/op_seq_memorize_zoom_distance_and_focal_distance.png