【问题标题】:How to save an image filename with Date & time in C++?如何在 C++ 中保存带有日期和时间的图像文件名?
【发布时间】:2016-11-15 05:35:11
【问题描述】:

我正在使用代码保存相机中的图像,但我需要使用当前拍摄图像的日期和时间来保存文件名。我怎样才能做到这一点?我从互联网上尝试了许多不同的代码,但我总是遇到很多错误,而且编程不是我的强项。任何建议或帮助将不胜感激。这是代码:https://github.com/stereolabs/zed-save-depth/blob/master/src/main.cpp

【问题讨论】:

  • 您需要从图像中提取元数据。这包含有关相机设置和照片拍摄时间的信息。有许多图书馆。特别是如果图像是 jpeg 图像。

标签: c++ image datetime stereo-3d


【解决方案1】:

你可以使用:

    #include <time.h>

时间。获取当前时间:

    time_t current_time = clock();

要获取当前日期,您可以使用:

    struct tm *localtime(const time_t *time);

它返回一个本地时间的结构,如下所示:

    struct tm {
      int tm_sec;   // seconds of minutes from 0 to 61
      int tm_min;   // minutes of hour from 0 to 59
      int tm_hour;  // hours of day from 0 to 24
      int tm_mday;  // day of month from 1 to 31
      int tm_mon;   // month of year from 0 to 11
      int tm_year;  // year since 1900
      int tm_wday;  // days since sunday
      int tm_yday;  // days since January 1st
      int tm_isdst; // hours of daylight savings time
    }

【讨论】:

    猜你喜欢
    • 2017-02-04
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    相关资源
    最近更新 更多