• 时间作为文件名


    #include <stdio.h>
    #include <iostream>
    #include <cstring>
    #include <fstream>
    #include <winsock2.h>
    #include <opencv2/opencv.hpp>
    //#include <netlistmgr.h>
    #include <time.h>

    #pragma comment(lib, "ws2_32.lib")

    using namespace std;
    using namespace cv;


    #define PACKAGE_NUM 1
    #define IMG_WIDTH 640
    #define IMG_HEIGHT 480
    #define BLOCKSIZE IMG_WIDTH*IMG_HEIGHT*3/PACKAGE_NUM

    struct recvBuf
    {
      char buf[BLOCKSIZE];
      int flag;
    };

    char pStrPath1[220];
    int a1 = 0;
    time_t currTime;
    struct tm *mt;

    SOCKET m_Client;

    int test1();
    void RecvFile();
    //int receive(cv::Mat& image,int sockConn);
    int socketConnect(const char* IP, int PORT);
    int socketConnect2();
    Mat receiveImg(int sockConn);

    int main()
    {
      //int socketClient = socketConnect("101.6.49.97", 8899);
      int socketClient = socketConnect2();
      if (socketClient<0)
      {
        return 0;
      }

      //string Imagespath = "D:\images\5\";
      Mat img_1 = receiveImg(socketClient);

      currTime = time(NULL);
      mt = localtime(&currTime);
      sprintf(pStrPath1, "D:\images\5\%d%02d%02d%02d%02d%02d.jpg", mt->tm_year + 1900, mt->tm_mon + 1, mt->tm_mday, mt->tm_hour, mt->tm_min, mt->tm_sec);
      imwrite(pStrPath1,img_1);
      imshow("win1",img_1);

      waitKey(0);
      return 0;
    }

  • 相关阅读:
    3.15第三周编程总结
    2019.3.9编程总结
    2019.3.3编程总结2
    编程总结1
    编程总结2
    编程总结3
    我的老师
    关于sublime text 3使用记录
    12. 整数转罗马数字
    4. 寻找两个有序数组的中位数
  • 原文地址:https://www.cnblogs.com/herd/p/10081380.html
Copyright © 2020-2023  润新知