当前位置:网站首页>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
边栏推荐
- Free and open source intelligent charging pile SaaS cloud platform of Internet of things
- STM32 control stepper motor (ULN2003 + 28byj)
- SSM框架系列——数据源配置day2-1
- Go language slicing operation
- Record Alibaba cloud server mining program processing
- pyqt5 将opencv图片存入内置SQLlite数据库,并查询
- After the data of El table is updated, the data in the page is not updated this$ Forceupdate() has no effect
- Introducing vant components on demand
- 梳理網絡IP代理的幾大用途
- 有趣的IDEA插件推荐,给你的开发工作增添色彩
猜你喜欢

Learning materials

Object.keys后key值数组乱序的问题

Deploying MySQL in cloud native kubesphere

Pytorch: a pit about the implementation of gradreverselayer

Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误

SSL certificate refund instructions

SSM框架系列——数据源配置day2-1

Synchronously update the newly added and edited data to the list

MySQL supports IP access

Record the problems encountered in using v-print
随机推荐
Date time type in database
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
31. 下一个排列
How to click an object to play an animation
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
HQL statement tuning
Community version Alibaba MQ ordinary message sending subscription demo
Sort out several uses of network IP agent
Introducing vant components on demand
Byte warehouse intern interview SQL questions
MySQL —— 16、索引的数据结构
只是不断地建构平台,不断地收拢流量,并不能够做好产业互联网
Introduction to servlet listener & filter
Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
Introduction to kubernetes
21 days learning mongodb notes
22. 括号生成
leetcode:437. Path sum III [DFS selected or not selected?]
Start mqbroker CMD failure resolution
Can I take the CPDA data analyst certificate for 0 foundation