OpenCV计数车辆
OpenCV counting vehicles
本文关键字:OpenCV 更新时间:2023-10-16
我已经完成了在OpenCV C++中检测车辆的工作,但我需要计算它们,而不是计算"frame"中的车辆。我需要数一下所有通过的车。这是我的检测代码,我该怎么办?
arac_cascade.detectMultiScale(
frame_gray, arac, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(20, 20));
for (int i = 0; i < arac.size(); i++)
{
Point pt1(arac[i].x + arac[i].width, arac[i].y + arac[i].height);
Point pt2(arac[i].x, arac[i].y);
rectangle(frame, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8, 0);
Mat aracROI = frame_gray(arac[i]);
}
检测后,arac.size()
是当前帧中检测到的车辆总数。如果你需要计算所有帧的数量,你可以简单地将它们相加,比如:
int num_total = 0;
for (-every-frame-){
// detection code...
num_total += arac.size();
}
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- OpenCV C++.快速计算混淆矩阵
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 哪些库可以通过Opencv调整曝光率
- 安装opencv失败-粘贴CMakeError.log的内容
- C++中的openCV Mat访问冲突
- OpenCV Android C++ imwrite not found
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- OpenCV 4.1.2 - 从网络摄像头获取帧并将其拆分
- C++ OpenCV 卡尔曼滤波器构造函数错误
- 使用OpenCV和覆盆子上的多个网络摄像头拍摄延时摄影,出现多个V4L错误
- 如何使用OpenCV-C++编写*.mp4视频?
- Mingw-64 在构建和安装后不会编译 openCV 代码