小白练手
人脸识别——opencv应用
前言
(小白练手)C++学习项目——人脸识别,主要用opencv库 和百度云。
使用步骤
代码如下(示例):
1.引入库
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
2.读入数据
int main()
{
VideoCapture cap(0);// open the default camera, 0--The number of camera
if(!cap.isOpened())// check if we succeeded
{
cout <<" camera open failed!" << endl;
return -1;
}
cout << "camera open success!" << endl;
Mat img;
for(;;)
{
cap >> img; //get a new frame camera
imshow ("video",img);/* "video"--name of the window,
img--image to be show;*/
waitKey(42); // delay 42s
}
# 总结
VideoCapture cap(0):——视觉抓捕,摄像头编号
imshow ("video",img);——图像展示,“video”——名称,img——图片
`linux
g++ main.cpp -o main -lopencv_highgui -lopencv_core ——编辑需要-l+数据库名称
mkdir——创建文件夹。