zoukankan      html  css  js  c++  java
  • OpenCV C++常用功能介绍

    显示图片

    IplImage* img = cvLoadImage("~/temp.jpeg", 1);
    //create a window to display the image
    cvNamedWindow("picture", 1);
    //show the image in the window
    cvShowImage("picture", img);
    //wait for the user to hit a key
    cvWaitKey(0);
    //delete the image and window
    cvReleaseImage(&img);
    cvDestroyWindow("picture");
    

      

    打开摄像头

    cvNamedWindow("CameraFrame", CV_WINDOW_AUTOSIZE);
    cv::VideoCapture cap(0);
    
    if (!cap.open(0)) {
        return -1;
    }
    
    bool stop = false;
    cv::Mat frame;
    
    while(!stop) {
        cap >> frame;
        if (!frame.data) {
            stop = true;
            continue;
        }
        
        imshow("CameraFrame", frame);
        cvWaitKey(30);
    }
    

      

    时间/日期

    struct timeval tv;
    struct timezone tz;
    
    // current time since 1900
    gettimeofday(&tv, &tz);
    
    // second
    printf("tv_sec:%ld
    ",tv.tv_sec);
    // usecond
    printf("tv_usec:%ld
    ",tv.tv_usec);
    
    printf("tz_minuteswest:%d
    ",tz.tz_minuteswest);
    printf("tz_dsttime:%d
    ",tz.tz_dsttime);
    
    struct tm *p;
    p = localtime(&tv.tv_sec);
    
    // data && time
    printf("time_now:%d/%d/%d %dh-%dm-%ds %ld
    ",
           1900+p->tm_year,
           1+p->tm_mon,
           p->tm_mday,
           p->tm_hour,
           p->tm_min,
           p->tm_sec,
           tv.tv_usec);
    

      

    时间差/微妙级别

    static int getCurrentMicroSecond() {
        struct timeval current;
        double timer;
        
        gettimeofday(&current, NULL);
        timer = 1000000 * current.tv_sec + current.tv_usec;
        
        return timer;
    }
    

      

  • 相关阅读:
    Eclipse maven构建springmvc项目
    [转载]Maven初级入门笔记
    NumCPU()在slice中的使用
    126短地址测试
    SVG操作插件:SVG.JS 个人提取部分实用中文文档
    sql联合查询去除重复计算总和
    计算某个月的最后一天
    JQ关于浏览器宽高的获取方式
    js不间断滚动
    DIV嵌套垂直居中
  • 原文地址:https://www.cnblogs.com/alanfang/p/11290876.html
Copyright © 2011-2022 走看看