Python进行视频图像处理,通过串口发送给stm32,stm32接收数据,刷新OLED进行显示。
步骤:
1.按照接线图连接好硬件
2.把Keil工程的代码下载到STM32中
3.运行Python代码,通过串口把处理后的数据发送给STM32进行显示
注意:
1.Python需要预先安装依赖包,可以执行以下命令进行安装:
pip install numpy
pip install opencv-python
pip install pyserial
PS C:\Users\rsd\Desktop\OLED播放视频\OLED播放视频\Python代码> pip install numpy
Requirement already satisfied: numpy in d:\program files\python-310\lib\site-packages (1.24.2)[notice] A new release of pip is available: 23.1.2 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\rsd\Desktop\OLED播放视频\OLED播放视频\Python代码> python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in d:\program files\python-310\lib\site-packages (23.1.2)
Collecting pipDownloading pip-23.3.1-py3-none-any.whl (2.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.0 MB/s eta 0:00:00
Installing collected packages: pipAttempting uninstall: pipFound existing installation: pip 23.1.2Uninstalling pip-23.1.2:Successfully uninstalled pip-23.1.2
Successfully installed pip-23.3.1
PS C:\Users\rsd\Desktop\OLED播放视频\OLED播放视频\Python代码> pip install opencv-python
Collecting opencv-pythonDownloading opencv_python-4.8.1.78-cp37-abi3-win_amd64.whl.metadata (20 kB)
Requirement already satisfied: numpy>=1.21.2 in d:\program files\python-310\lib\site-packages (from opencv-python) (1.24.2)
Downloading opencv_python-4.8.1.78-cp37-abi3-win_amd64.whl (38.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.1/38.1 MB 8.3 MB/s eta 0:00:00
Installing collected packages: opencv-python
Successfully installed opencv-python-4.8.1.78
PS C:\Users\rsd\Desktop\OLED播放视频\OLED播放视频\Python代码> pip install pyserial
Collecting pyserialDownloading pyserial-3.5-py2.py3-none-any.whl (90 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.6/90.6 kB 854.7 kB/s eta 0:00:00
Installing collected packages: pyserial
Successfully installed pyserial-3.5
PS C:\Users\rsd\Desktop\OLED播放视频\OLED播放视频\Python代码>
2.打开串口时,串口号需要根据自己的设备进行指定,可以打开设备管理器查看
3.打开视频的文件可以自行指定
4.播放视频时,按q键退出
5.串口收发部分并没有帧同步的操作,所以需要保证每次收发都是一个完整的数据帧,如果显示中途被打断,最好把STM32复位一下,避免帧数据错位
实验现象
实验代码(参考江协科技)
https://pan.baidu.com/s/1wnN6D131hxmgW-5DfKY4ug?pwd=1234