@kidswong999 大佬。真的不知道咋改,开头两次循环J还正常,后面全都变2了,在大循环While(True)中,我已经赋值给J=0了啊,求助了
D
duyl
@duyl
0
声望
12
楼层
650
资料浏览
0
粉丝
1
关注
duyl 发布的帖子
-
RE: Openmv运行几秒卡住不动,固件已经升级到最新了
-
RE: Openmv运行几秒卡住不动,固件已经升级到最新了
import sensor, image, time import json from image import SEARCH_EX, SEARCH_DS from pyb import UART uart = UART(3, 9600) red_threshold = ((18, 59, 15, 50, 2, 42));#第一步!!!!中点坐标 blue_threshold = (((10, 55, -15, 16, -40, -6))); sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() while(True): #zifu = uart.readchar() #if(zifu == 3): zifu = '' circlefalg = 0 rectflag = 0 sum=0 bb=0 j=0 a = {} SANY=45 SANYH=55 SANX=100 SANXW=110 A = 0 b = 0 z = 0x00 k = 0x00 j = 0x00 img = sensor.snapshot().lens_corr(1.8) blob1 = img.find_blobs([red_threshold],roi=(10,1,111,112),pixels_threshold=300) blob2 = img.find_blobs([blue_threshold],roi=(10,1,111,112),pixels_threshold=300) clock.tick() while(j<3): for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 20, r_max =100 , r_step = 2): circleflag = 1 area1 = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r()) z = 0x01 statistics = img.get_statistics(roi=area1)#像素颜色统计 if 18<statistics.l_mode()<59 and 15<statistics.a_mode()<50 and 2<statistics.b_mode()<42: img.draw_circle(c.x(), c.y(), c.r(), color = (0, 255, 0)) A=1 elif 10<statistics.l_mode()<55 and -15<statistics.a_mode()<16 and -40<statistics.b_mode()<-6: img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) A=2 for r in img.find_rects(threshold = 10000): rectflag = 1 area2 = (r.rect()) statistics = img.get_statistics(roi=area2) j = 0x01 if 18<statistics.l_mode()<59 and 15<statistics.a_mode()<50 and 2<statistics.b_mode()<42: img.draw_rectangle(area2, color = (0, 255, 0)) A=3 elif 10<statistics.l_mode()<55 and -15<statistics.a_mode()<16 and -40<statistics.b_mode()<-6: img.draw_rectangle(area2, color = (255, 0, 0)) A=4 if z != 0x01 and j != 0x01: #红色 if blob1: A=5 if blob2: #蓝色 A=6 j = j+1 b = b+A if(b == A*3 and b != 0): print(c) if(A == 1): uart.write('1') elif(A == 2): uart.write('2') elif(A == 3): uart.write('3') elif(A == 4): uart.write('4') elif(A == 5): uart.write('5') elif(A == 6): uart.write('6')
硬件是::::Traceback (most recent call last):
File "", line 12, in
Exception: IDE interrupt
MicroPython: v1.15-r32 OpenMV: v4.0.2 HAL: v1.9.0 BOARD: OPENMV4P-STM32H743
Type "help()" for more information. -
RE: Openmv运行几秒卡住不动,固件已经升级到最新了
右侧lab值一点都不变了,动都动不了,换了一个openmv,结果输出几下然后也卡住不动了,镜头不动,lab的阈值也不动,输出也没有 -
RE: 为什么没反应,传不到arduino数据,电脑显示不出来
![0_1621341455618_1 (1).png](正在上传 95%) 图片一直上传失败,用的是arduino mega 2560的板子
-
为什么没反应,传不到arduino数据,电脑显示不出来
![0_1621341440835_22.png](正在上传 98%)
这是openmv的: import sensor, image, time import json from image import SEARCH_EX, SEARCH_DS from pyb import UART uart = UART(3, 9600) thresholds = [(22, 40, 2, 49, 3, 37), # generic_red_thresholds (31, 46, -20, 19, -31, -9)] # generic_blue_thresholds # 不要超过16个颜色阈值 sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() j = 1 clock.tick() while(j<=6): img = sensor.snapshot().lens_corr(1.8) for blob in img.find_blobs(thresholds, pixels_threshold=200, area_threshold=200): if(blob.code() == 1): img = img.to_grayscale() for t1 in template1s: template1 = image.Image(t1) r_1 = img.find_template(template1, 0.80, step=4, search=SEARCH_EX) for t2 in template2s: template2 = image.Image(t2) r_2 = img.find_template(template2, 0.80, step=4, search=SEARCH_EX) for t3 in template3s: template3 = image.Image(t3) r_3 = img.find_template(template3, 0.80, step=4, search=SEARCH_EX) if r_1: uart.write('1') elif r_2: uart.write('2') elif r_3: uart.write('3') else: uart.write('9') 这是arduino的代码: #include<SoftwareSerial.h> SoftwareSerial mySerial(14,15); void setup() { mySerial.begin(9600); Serial.begin(9600); pinMode(14,INPUT); pinMode(15,INPUT); } void loop() { while(mySerial.available()>0) { char abc1 = (char)mySerial.read(); Serial.print(abc1); } }![0_1621341426420_1 (1).png](正在上传 95%)