OpenCV C++常用功能介绍

显示图片

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

打开摄像头

1cvNamedWindow("CameraFrame", CV_WINDOW_AUTOSIZE); 2cv::VideoCapture cap(0); 3 4if (!cap.open(0)) { 5 return -1; 6} 7 8bool stop = false; 9cv::Mat frame; 10 11while(!stop) { 12 cap >> frame; 13 if (!frame.data) { 14 stop = true; 15 continue; 16 } 17 18 imshow("CameraFrame", frame); 19 cvWaitKey(30); 20}

时间/日期

1struct timeval tv; 2struct timezone tz; 3 4// current time since 1900 5gettimeofday(&tv, &tz); 6 7// second 8printf("tv_sec:%ld\n",tv.tv_sec); 9// usecond 10printf("tv_usec:%ld\n",tv.tv_usec); 11 12printf("tz_minuteswest:%d\n",tz.tz_minuteswest); 13printf("tz_dsttime:%d\n",tz.tz_dsttime); 14 15struct tm *p; 16p = localtime(&tv.tv_sec); 17 18// data && time 19printf("time_now:%d/%d/%d %dh-%dm-%ds %ld\n", 20 1900+p->tm_year, 21 1+p->tm_mon, 22 p->tm_mday, 23 p->tm_hour, 24 p->tm_min, 25 p->tm_sec, 26 tv.tv_usec);

时间差/微妙级别

1static int getCurrentMicroSecond() { 2 struct timeval current; 3 double timer; 4 5 gettimeofday(&current, NULL); 6 timer = 1000000 * current.tv_sec + current.tv_usec; 7 8 return timer; 9}
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

一篇文章带你了解JavaScript日期

日期对象允许您使用日期(年、月、日、小时、分钟、秒和毫秒)。一、JavaScript的日期格式一个JavaScript日期可以写为一个字符串:ThuFeb02201909:59:51GMT0800(中国标准时间)或者是一个数字:1486000791164写数字的日期,指定的毫秒数自1970年1月1日00:00:00到现在。1\.显示日期使用

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )