1 Star 0 Fork 12

MrStrawberry/FFMPEG_arc_FaceRecognize

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
opencv_queue.cpp 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
Harry123 提交于 2022-07-11 19:13 . 修改了虹软识别率问题
#include "opencv_queue.h"
#include <sys/time.h>
OPENCV_QUEUE::OPENCV_QUEUE()
{
pthread_mutex_init(&matMutex, NULL);
pthread_cond_init(&matCond, NULL);
}
OPENCV_QUEUE ::~OPENCV_QUEUE()
{
pthread_mutex_destroy(&matMutex);
pthread_cond_destroy(&matCond);
}
int OPENCV_QUEUE::putMatQueue(Mat mat)
{
pthread_mutex_lock(&matMutex);
matPictureQueue.push(mat);
pthread_cond_broadcast(&matCond);
pthread_mutex_unlock(&matMutex);
}
Mat OPENCV_QUEUE::getMatQueue()
{
pthread_mutex_lock(&matMutex);
while (matPictureQueue.size() == 0)
{
pthread_cond_wait(&matCond, &matMutex);
}
Mat item = matPictureQueue.front();
matPictureQueue.pop();
pthread_mutex_unlock(&matMutex);
return item;
}
Mat OPENCV_QUEUE::getMatQueue_TimeOut()
{
pthread_mutex_lock(&matMutex);
if (matPictureQueue.size() == 0)
{
struct timeval timeval_now;
struct timespec timespec_out;
gettimeofday(&timeval_now, NULL);
timespec_out.tv_sec = timeval_now.tv_sec + 1;
timespec_out.tv_nsec = timeval_now.tv_usec * 1000;
int ret = pthread_cond_timedwait(&matCond, &matMutex, &timespec_out);
if (ret != 0)
{
pthread_mutex_unlock(&matMutex);
//return NULL;
}
}
Mat item = matPictureQueue.front();
matPictureQueue.pop();
pthread_mutex_lock(&matMutex);
return item;
}
int OPENCV_QUEUE::getMatQueueSize()
{
unsigned int count = 0;
pthread_mutex_lock(&matMutex);
count = matPictureQueue.size();
pthread_mutex_unlock(&matMutex);
return count;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Mrbuchixiangcai/ffmpeg_arc_face-recognize.git
git@gitee.com:Mrbuchixiangcai/ffmpeg_arc_face-recognize.git
Mrbuchixiangcai
ffmpeg_arc_face-recognize
FFMPEG_arc_FaceRecognize
master

搜索帮助