在IDE上正常运行,脱机运行后出现了ERROR_log文件
报错内容是SDRAM failed testing!
代码如下
enable_lens_corr = False # turn on for straighter lines...
import sensor, image, time
from pyb import UART
import ujson
sensor.reset()
sensor.set_contrast(3)
sensor.set_pixformat(sensor.GRAYSCALE) # grayscale is faster
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
uart=UART(3,9600)
# All line objects have a `theta()` method to get their rotation angle in degrees.
# You can filter lines based on their rotation angle.
min_degree = 0
max_degree = 179
rx1_l=[]
rx2_l=[]
ry1_l=[]
ry2_l=[]
rx1_r=[]
rx2_r=[]
ry1_r=[]
ry2_r=[]
# All lines also have `x1()`, `y1()`, `x2()`, and `y2()` methods to get their end-points
# and a `line()` method to get all the above as one 4 value tuple for `draw_line()`.
while(True):
clock.tick()
img = sensor.snapshot()
if enable_lens_corr: img.lens_corr(0.7) # for 2.8mm lens...
# `threshold` controls how many lines in the image are found. Only lines with
# edge difference magnitude sums greater than `threshold` are detected...
# More about `threshold` - each pixel in the image contributes a magnitude value
# to a line. The sum of all contributions is the magintude for that line. Then
# when lines are merged their magnitudes are added togheter. Note that `threshold`
# filters out lines with low magnitudes before merging. To see the magnitude of
# un-merged lines set `theta_margin` and `rho_margin` to 0...
# `theta_margin` and `rho_margin` control merging similar lines. If two lines
# theta and rho value differences are less than the margins then they are merged.
for l in img.find_lines(threshold = 2800, theta_margin = 35, rho_margin = 35):
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
img.draw_line(l.line(), color = (255, 0, 0))
# print(l)
#print("x1:",l.x1,"x2:",l.x2)
#print(l.theta())
#k=(l.y1()-l.y2())/(l.x1()-l.x2())
if(l.x1()<125 and l.theta()<45):
rx1_l.append(l.x1())
rx2_l.append(l.x2())
ry1_l.append(l.y1())
ry2_l.append(l.y2())
#print("left:",l.theta())
#print(l.x1(),l.y1(),l.x2(),l.y2())
if(l.x1()>125 and l.theta()>135):
rx1_r.append(l.x1())
rx2_r.append(l.x2())
ry1_r.append(l.y1())
ry2_r.append(l.y2())
#print(l.x1(),l.y1(),l.x2(),l.y2())
if rx1_l:
if rx1_r:
A_1=ry2_l[-1]-ry1_l[-1]
B_1=rx1_l[-1]-rx2_l[-1]
C_1=rx1_l[-1]*(ry1_l[-1]-ry2_l[-1])+ry1_l[-1]*(rx2_l[-1]-rx1_l[-1])
A_2=ry2_r[-1]-ry1_r[-1]
B_2=rx1_r[-1]-rx2_r[-1]
C_2=rx1_r[-1]*(ry1_r[-1]-ry2_r[-1])+ry1_r[-1]*(rx2_r[-1]-rx1_r[-1])
cross_x=(B_1*C_2-B_2*C_1)/(B_2*A_1-B_1*A_2)
if(cross_x>0 and cross_x<320):
rcx=cross_x-125
print(cross_x-125)
rxy={"rx":rcx,"ry":0}
uart.write(ujson.dumps(rxy)+'\r\n')
#print("FPS %f" % clock.fps())
# About negative rho values:
#
# A [theta+0:-rho] tuple is the same as [theta+180:+rho].另外还有一个问题,我又两个Openmv4 plusi,出现报错的这台插入SD卡后无法被电脑识别
可以联系卖家维修。