很简单:与检测图片不同的是,测试图片用的是image.c。检测视频用的是image_opencv.c.因为用的opencv的库去读取视频。不知道是v4新写的文件还是修改的。
测试图片:image.c285行
// Creates array of detections with prob > thresh and fills best_class for them
detection_with_class* get_actual_detections(detection *dets, int dets_num, float thresh, int* selected_detections_num, char **names)
{
int selected_num = 0;
detection_with_class* result_arr = (detection_with_class*)xcalloc(dets_num, sizeof(detection_with_class));
int i;
for (i = 0; i < dets_num; ++i) {
int best_class = -1;
float best_class_prob = thresh;
int j;
for (j = 0; j < dets[i].classes; ++j) {
int show = strncmp(names[j], "dont_show", 9);
//if (j!=0)
//{
// continue; //只检测人
//}
if (dets[i].prob[j] > best_class_prob && show) {
best_class = j;
best_class_prob = dets[i].prob[j];
}
}
视频中:
extern "C" void draw_detections_cv_v3(mat_cv* mat, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output)
{
try {
cv::Mat *show_img = (cv::Mat*)mat;
int i, j;
if (!show_img) return; //直接返回
static int frame_id = 0;
frame_id++;
//修改,在每一帧上统计检测到的框的个数
int count_studentDesk = 0;
//==
for (i = 0; i < num; ++i) {
char labelstr[4096] = { 0 }; //空字符串,存放标签和置信度
char studentDesk[30] = { 0 };
char buff2[20];
int class_id = -1;
for (j = 0; j < classes; ++j) {
int show = strncmp(names[j], "dont_show", 9);
if (dets[i].prob[j] > thresh && show) { //大于阈值
if (j!=0)
{
continue;//只检测人,使用官方版本的修改
}
.......
.........
参考:
https://blog.csdn.net/limbos/article/details/81949591
https://xercis.blog.csdn.net/article/details/89019891