当前位置:网站首页>STM32 tracking based on open MV
STM32 tracking based on open MV
2022-04-23 13:00:00 【ZLP~】
be based on open mv collocation stm32 Trace
One . Code
THRESHOLD = (0, 43, 20, -8, -37, 14) # Grayscale threshold for dark things...
import sensor, image, time
from pyb import LED
import car
from pid import PID
from pyb import UART
from pyb import Pin
rho_pid = PID(p=0.4, i=0)
theta_pid = PID(p=0.001, i=0)
sensor.reset()
sensor.set_vflip(True)
sensor.set_hmirror(True)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
#sensor.set_windowing([0,20,80,40])
sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds
clock = time.clock() # to process a frame sometimes.
uart = UART(3, 115200)
while(True):
clock.tick()
img = sensor.snapshot().binary([THRESHOLD])
line = img.get_regression([(100,100)], robust = True)# Two valued
if (line):
rho_err = abs(line.rho())-img.width()/2
if line.theta()>90:
theta_err = line.theta()-180
else:
theta_err = line.theta()
img.draw_line(line.line(), color = 127)
#print(rho_err,line.magnitude(),rho_err)
if line.magnitude()>8: # The larger the value, the better the linear regression effect
#if -40<b_err<40 and -30<t_err<30:
rho_output = rho_pid.get_pid(rho_err,1)
theta_output = theta_pid.get_pid(theta_err,1)
output = rho_output+theta_output
if rho_err > -3 and rho_err < 3:
uart.write("1")
p_out = Pin('P0', Pin.OUT_PP)
p_out.high()
p_out = Pin('P1', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
p_out = Pin('P2', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
print('0')
elif rho_err <= -3:
p_out = Pin('P1', Pin.OUT_PP)# Set up p_out Is the output pin
p_out.high()# Set up p_out Pin is high
p_out = Pin('P0', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
p_out = Pin('P2', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
uart.write("2")
print('1')
elif rho_err >= 3:
uart.write("3")
p_out = Pin('P2', Pin.OUT_PP)# Set up p_out Is the output pin
p_out.high()# Set up p_out Pin is high
p_out = Pin('P1', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
p_out = Pin('P0', Pin.OUT_PP)
p_out.low()# Set up p_out The pin is low
print('2')
#print(clock.fps())
Here is the routine of using star pupil , Add your own thoughts , Because I just learned OPEN MV So use this simple idea . here OPEN MV Equivalent to tracking module .
Two . thought
Here I mainly use rho_err This function , In the star pupil routine, a line will be drawn in the middle of the tracked object , and rho_err Is the error that the line follows for , It's less than... To the left 0, It's bigger than 0,rho_err >= Some number , A certain number is the offset , A certain number can be adjusted to make the route more accurate . Then on IO Set high and low levels at the port .32 Read io Adjust the route according to the level .
If you have any questions, you can leave a message below .
版权声明
本文为[ZLP~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230613177324.html
边栏推荐
- Kubernetes 入门教程
- JMeter operation redis
- JDBC connection pool
- 5 free audio material websites, recommended collection
- V-model binding value in El select, data echo only displays value, not label
- Common problems of unity (1)
- World Book Day: I'd like to recommend these books
- 教你快速开发一个 狼人杀微信小程序(附源码)
- R语言中dcast 和 melt的使用 简单易懂
- SSM framework series - annotation development day2-2
猜你喜欢
云原生KubeSphere部署Redis
8086 of x86 architecture
PC starts multiple wechat at one time
CGC: contractual graph clustering for community detection and tracking
About the 'enum' enumeration type and structure.
How to click an object to play an animation
mysql8安装
Fashion cloud learning - input attribute summary
SSL certificate refund instructions
Customize the shortcut options in El date picker, and dynamically set the disabled date
随机推荐
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
No idle servers? Import OVF image to quickly experience smartx super fusion community version
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
leetcode:437. Path sum III [DFS selected or not selected?]
Connect orcale
Synchronously update the newly added and edited data to the list
The quill editor image zooms, multiple rich text boxes are used on one page, and the quill editor upload image address is the server address
将新增和编辑的数据同步更新到列表
Keyword interpretation and some APIs in RT thread
Timing role in the project
Fashion cloud learning - input attribute summary
mysql8安装
Go language: passing slices between functions
SSM框架系列——Junit单元测试优化day2-3
Van uploader upload picture implementation process, using native input to upload pictures
MySQL supports IP access
[csnote] ER diagram
Unable to create servlet under SRC subfile of idea
Teach you to quickly develop a werewolf killing wechat applet (with source code)
Summary of JVM knowledge points - continuously updated