解决 去掉UIO
K
k2ce
@k2ce
0
声望
5
楼层
334
资料浏览
0
粉丝
0
关注
k2ce 发布的帖子
-
为什么我使用文件操作既不能成功读文件,也不能写文件?
我这里只是展示了读文件,但是它返回一直为空,TXT文件里面是一串数字
number = 1 fo = uio.open("/keypoints/s1/bill1.txt" ,"r+" ) fo.seek(0) balance = fo.read(3).encode('utf-8') fo.close() print(balance) balance = int(balance)
-
RE: 0PENMV4 CAM H7 PIUS自检未通过
编译器报错:
Traceback (most recent call last):
File "", line 74, in
File "", line 67, in test_color_bars
Exception: COLOR BARS TEST FAILED.BAR#(1): RGB(255,255,255)
MicroPython: v1.15-r32 OpenMV: v4.0.2 HAL: v1.9.0 BOARD: OPENMV4P-STM32H743 -
0PENMV4 CAM H7 PIUS自检未通过
# 自检例程
版本是0PENMV4 CAM H7 PIUS,自检没通过,到这儿,我也不知道怎么回事了。
这个例子展示了OpenMV Cam在被允许出厂之前如何测试自己。每个OpenMV Cam都应该通过这个测试。
import sensor, time, pyb
def test_int_adc():
adc = pyb.ADCAll(12)
# VBAT测试
vbat = adc.read_core_vbat()
vbat_diff = abs(vbat-3.3)
if (vbat_diff > 0.1):
raise Exception('INTERNAL ADC TEST FAILED VBAT=%fv'%vbat)# 测试VREF vref = adc.read_core_vref() vref_diff = abs(vref-1.2) if (vref_diff > 0.1): raise Exception('INTERNAL ADC TEST FAILED VREF=%fv'%vref) adc = None print('INTERNAL ADC TEST PASSED...')
def test_color_bars():
sensor.reset()
# 设置传感器
sensor.set_brightness(0)
sensor.set_saturation(3)
sensor.set_gainceiling(8)
sensor.set_contrast(2)# 设置传感器像素格式 sensor.set_framesize(sensor.QVGA) sensor.set_pixformat(sensor.RGB565) # 启用颜色条测试模式 sensor.set_colorbar(True) # 跳过几帧,让传感器稳定下来 for i in range(0, 100): image = sensor.snapshot() # 颜色条阈值 t = [lambda r, g, b: r < 70 and g < 70 and b < 70, # Black lambda r, g, b: r < 70 and g < 70 and b > 200, # Blue lambda r, g, b: r > 200 and g < 70 and b < 70, # Red lambda r, g, b: r > 200 and g < 70 and b > 200, # Purple lambda r, g, b: r < 70 and g > 200 and b < 70, # Green lambda r, g, b: r < 70 and g > 200 and b > 200, # Aqua lambda r, g, b: r > 200 and g > 200 and b < 70, # Yellow lambda r, g, b: r > 200 and g > 200 and b > 200] # White # 颜色条在OV7725中是反向的 if (sensor.get_id() == sensor.OV7725): t = t[::-1] #320x240图像有8个颜色条,每个大约是40像素。 #我们从帧缓冲区的中心开始,并从每个颜色条的中心平均取10个采样像素的值。 for i in range(0, 8): avg = (0, 0, 0) idx = 40*i+20 #色条中心 for off in range(0, 10): #avg 10 pixels rgb = image.get_pixel(idx+off, 120) avg = tuple(map(sum, zip(avg, rgb))) if not t[i](avg[0]/10, avg[1]/10, avg[2]/10): raise Exception('COLOR BARS TEST FAILED.' 'BAR#(%d): RGB(%d,%d,%d)'%(i+1, avg[0]/10, avg[1]/10, avg[2]/10)) print('COLOR BARS TEST PASSED...')
if name == 'main':
print('')
test_int_adc()
test_color_bars() -
云台上下可以动,左右不能动,示波器显示有PWM波
# Motor Shield PWM Example # # This example shows off how to control the motor shield on your # OpenMV Cam. The motor shield is controlled by using the PYB module # which lets you do PWM to control the speed and set digital I/O pin # states. The motor shield needs 6 I/O pins for both motors. import pyb #from pyb import Pin, Timer tim = pyb.Timer(4, freq=50) chA = tim.channel(1, pyb.Timer.PWM, pin=pyb.Pin("P7"))# chB = tim.channel(2, pyb.Timer.PWM, pin=pyb.Pin("P8")) times = 500 while (times >1): chA.pulse_width_percent(40)# chB.pulse_width_percent(30)# times = times - 1 pyb.delay(10) chA.pulse_width_percent(0)#向前 chB.pulse_width_percent(0)#