项目地址:https://gitee.com/HuaweiAtlas/FaceRecognition
1. 依赖
- 项目需要ffmpeg,opencv,gflags。直接按照项目的说明进行编译
- 一个海康摄像头(用rtsp流作为输入)
- easydarwin rtsp流媒体服务器
2. 测试
2.1 编译
到build文件夹下去编译
cd $project/build/
bash ./build_atlas500.sh
2.2 修改setup.config
编译之后会在bin文件夹下产生可执行文件,修改data/setup.config
,修改注释中的两个地址
cd $project/bin
vi ./data/setup.config
#one config per line
#use '=' to seprate key and value
#chip config
device_id = 0 #use the device to run the program
#cam config
used_cam_num = 6 #use top n cams in cam list # 1. 用6个摄像头做测试
#cam list // test
cam0 = rtsp://admin:[email protected] # 2. 海康的rtsp流地址
# cam0 = rtsp://192.168.143.243/test
cam1 = rtsp://admin:[email protected]
cam2 = rtsp://admin:[email protected]
cam3 = rtsp://admin:[email protected]
cam4 = rtsp://admin:[email protected]
cam5 = rtsp://admin:[email protected]
cam6 = rtsp://admin:[email protected]
cam7 = rtsp://admin:[email protected]
cam8 = rtsp://admin:[email protected]
cam9 = rtsp://admin:[email protected]
cam10 = rtsp://admin:[email protected]
cam11 = rtsp://admin:[email protected]
2.3 启动easydarwin
在同一网段的一台电脑上,启动easydarwin。
2.4 修改graph.config
修改bin/data/graph.config
中的rtsp_link,/live后缀随便设置,前面的ip:192.168.143.225
是easydarwin服务器的地址
ai_config{
items {
name: "rtsp_link"
value: "rtsp://192.168.143.225/live"
}
3. 测试
将bin文件夹上传到atlas500
cd $bin
./facedemo_main
# 会打印
channel: 3, frame id: #21508, bound box: (1533, 422),(1947, 963), largest similarity:0.038,ID=Unknown, isTracked=1, throughoutput=7.5
channel: 4, frame id: #21506, bound box: (1539, 427),(1952, 957), largest similarity:0.328,ID=Unknown, isTracked=1, throughoutput=7.5
channel: 5, frame id: #21508, bound box: (1533, 422),(1947, 963), largest similarity:0.034,ID=Unknown, isTracked=1, throughoutput=7.5
4. 可能错误
我提交的升腾论坛:可能问题
解决
对host/StreamPullerEngine.cpp中的 int StreamPullerEngine::GetStreamInfo
做如下修改:
int StreamPullerEngine::GetStreamInfo(shared_ptr<AVFormatContext> pFormatCtx, int& format, int& videoIndex)
{
/*
* 为了对format, videoIndex进行赋值
* format:视频编码格式; videoIndex:视频流次序
*/
if (pFormatCtx == nullptr) {
cout << "pFormatCtx is null!." << endl;
return -1;
}
videoIndex = -1;
for (int i = 0; i < pFormatCtx->nb_streams; i++) {
AVStream* inStream = pFormatCtx->streams[i];
// if (inStream->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
// cout << "Error codec_type " << inStream->codecpar->codec_type << endl;
// return -1;
// }
if (inStream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO){
videoIndex = i;
AVCodecID codecId = inStream->codecpar->codec_id;
if (codecId == AV_CODEC_ID_H264) {
format = 0;
} else if (codecId == AV_CODEC_ID_H265) {
format = 1;
} else {
cout << "Error unsupported format " << codecId << endl;
return -1;
}
}
}
if (videoIndex == -1) {
cout << "Didn't find a video stream." << endl;
return -1;
}
return 0;
}