时间作为文件名

#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;
}

posted @ 2018-12-07 10:19  西北逍遥  阅读(435)  评论(0编辑  收藏  举报