Laplace变换(视频边界检测)
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#include "cv.h" #include "highgui.h" #include <ctype.h> #include <stdio.h> int main(int argc , char **argv) { IplImage *laplace = 0; IplImage *coloelaplace = 0; IplImage *planes[3]={0,0,0};//多个图像面 CvCapture *capture = 0; if (argc==1|| (argc==2 && strlen(argv[1])==1 && isdigit(argv[1][0]))) { capture = cvCaptureFromCAM(-1); } else if(argc==2) { capture = cvCaptureFromAVI(argv[1]); } if (!capture) { fprintf(stderr,"Could not initialize capturing.../n"); return -1; } cvNamedWindow("main",0); for (;;) { IplImage *frame=0; int i; frame = cvQueryFrame(capture);//从摄像头或者文件中抓取并返回一帧 if (!frame) { break; } if (!laplace) { for (i=0;i<3;i++) { planes[i]=cvCreateImage(cvSize(frame->width,frame->height),8,1); } laplace=cvCreateImage(cvSize(frame->width,frame->height),IPL_DEPTH_16S,1); coloelaplace=cvCreateImage(cvSize(frame->width,frame->height),8,3); } cvCvtPixToPlane(frame,planes[0],planes[1],planes[2],0); //#define cvCvtPixToPlane cvSplit for (i=0;i<3;i++) { cvLaplace(planes[i],laplace,3);//计算图像planes[i]的 Laplacian 变换 cvConvertScaleAbs(laplace,planes[i],1,0);//planes[]=ABS(laplace) } cvCvtPlaneToPix(planes[0],planes[1],planes[2],0,coloelaplace); //#define cvCvtPlaneToPix cvMerge coloelaplace->origin=frame->origin; cvShowImage("main",coloelaplace); if (cvWaitKey(10)>=0) { break; } } cvReleaseCapture(&capture); cvDestroyWindow("main"); return 0; } |
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=497