项目地址:https://github.com/Starrynightzyq/Drone_Vehicle_Flow_Detection
改进版(带 GUI 界面):https://github.com/LeiWang1999/VehicleFlowDetection
效果展示:
检测:
计数:
准备
安装tensorflow
安装OpenCV
Homebrew安装OpenCV
1
brew install opencv
最新版本的
opencv
已经不分opencv3
了,而是在目录下分成python2
和python3
版本的文件夹。 安装好的opencv
库在/usr/local/Cellar/opencv/
。将OpenCV链接到Python的site-packages目录下
首先需要找到自己Python安装位置,可以用如下方法:
1
2
3
4
5
6# 打开Python
python3
# 通过sys查看Python安装路径
import sys
print(sys.path)
['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']可以看到最后一行就是site-packages的路径。
1
2
3
4# 进入site-packages目录
cd /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
# 建立软链接
sudo ln -s /usr/local/Cellar/opencv/4.2.0_1/lib/python3.7/site-packages/cv2/python-3.7/cv2.cpython-37m-darwin.so cv2.so依赖包
我们这时测试一下OpenCV是否可用
1
2
3
4
5import cv2
ModuleNotFoundError: No module named 'numpy'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import缺少numpy
1
2# 安装numpy
pip3 install --upgrade numpy成功
1
2
3
4
5
6$ python3
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
真不该手贱接下这个项目,完全没有头绪!
准确率
目前检测 VisDrone 数据集的正确率已经比较高了