赞
踩
一、编码过程
1、调用摄像头
- Mat frame;
- VideoCapture capture(0);
2、读取人脸数据
- CascadeClassifier stFaceCascade;
- if (!stFaceCascade.load("C:\\Users\\lenovo\\Downloads\\opencv\\opencv\\sources\\data\\lbpcascades\\lbpcascade_frontalface.xml"))
- {
- printf("Loading cascade error\n");
- return -1;
- }
3、视频保存
VideoWriter writer("D:\\face.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));
4、视频处理
- while (true)
- {
- capture >> frame;
- if (!frame.empty()) {
- //frame经过检测算法
- IplImage* transIplimage = cvCloneImage(&(IplImage)frame);
- std::vector<Rect> faceRects;//矩形描绘
- stFaceCascade.detectMultiScale(transIplimage,
- faceRects, //检
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。