设置当前日期时间 - SONY SDK

问题描述 投票:0回答:1

我正在尝试使用索尼 SDK 将索尼 alpha 7s iii 的日期时间设置为 PC 当前日期时间。 在没有对作为示例提供的 RemoteCli.cpp 代码进行太多修改的情况下,我在那里添加了一个案例:

while (true) {
    cli::tout << "<< Time Sync >>\nWhat would you like to do? Enter the corresponding number.\n";
    cli::tout
        << "(0) Return to REMOTE-MENU\n"
        << "(1) Set Camera Time From PC \n"
        ;
    cli::tout << "input> ";
    cli::text select;
    std::getline(cli::tin, select);
    cli::tout << '\n';
    if (select == TEXT("1")) { /* Time Sync */
        camera->set_datetime();
    }
    else if (select == TEXT("0")) {
        cli::tout << "Return to REMOTE-MENU.\n";
        break;
    }
    cli::tout << std::endl;
}// end of loop-Menu7

基于这个问题 ,我在 CameraDevice.cpp 中创建了一个新的

set_datetime
函数:

void CameraDevice::set_datetime() {
    std::time_t result = std::time(nullptr);
    std::asctime(std::localtime(&result));
    cli::tout << result;

    CrInt64 time = static_cast<CrInt64>(result);
    SDK::CrDeviceProperty prop;
    prop.SetCode(SDK::CrDevicePropertyCode::CrDeviceProperty_DateTime_Settings);
    prop.SetCurrentValue(time);
    prop.SetValueType(SDK::CrDataType::CrDataType_UInt64);
}

不幸的是,PC当前时间未写在相机上。

c++ sdk sony
1个回答
0
投票

我没有注意到我忘记添加设置设备属性命令 -

SDK::SetDeviceProperty(m_device_handle, &prop);

改成这样:

void CameraDevice::set_datetime() {
    std::time_t result = std::time(nullptr);
    std::asctime(std::localtime(&result));
    cli::tout << result;

    SDK::CrDeviceProperty prop;
    prop.SetCode(SDK::CrDevicePropertyCode::CrDeviceProperty_DateTime_Settings);
    prop.SetCurrentValue((CrInt64u)(result));
    prop.SetValueType(SDK::CrDataType::CrDataType_UInt64);

    SDK::SetDeviceProperty(m_device_handle, &prop);
}

而且成功了!

此外,当查看相机屏幕上的日期时间(在设置中)时,它不起作用。

需要关闭相机设置菜单。

© www.soinside.com 2019 - 2024. All rights reserved.