NVIDIA Jetson TK1学习与开发(十):人脸检测(Face Detection)
最后更新于:2022-04-01 16:04:19
本文介绍如何使用OpenCV检测人脸,并且给出示例,本平台仍然采用的是 Jetson TK1。
### 1、测试摄像头
为了能够从摄像头中实时检测出人脸,首先要做的就是判断你的摄像头是否可以工作,其基本方法如下:
~~~
sudo apt-get install luvcview
luvcview
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d61748bbf0.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d6174a8b3b.jpg)
如果摄像头可以正常工作,则出现如下界面:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d6174bb0a9.jpg)
### 2、安装OpenCV
参考网址:[图文详解OpenCV在Jetson TK1上的安装和使用](http://blog.csdn.net/frd2009041510/article/details/42930113)
### 3、新建工作文件夹并拷贝源码编译
~~~
mkdir ~/faceActivatedGPIO
cd ~/faceActivatedGPIO
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d6175036bc.jpg)
~~~
cp ~/opencv/samples/gpu/cascadeclassifier.cpp .
g++ cascadeclassifier.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o cascadeclassifier
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d61751e2c1.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d61753579e.jpg)
### 4、运行得到实验结果
~~~
./cascadeclassifier --cascade ~/opencv-2.4.9/data/haarcascades/haarcascade_frontalface_alt.xml --camera 0
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d61754a74a.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d6175640ac.jpg)