导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. wlfg
    W
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    wlfg

    @wlfg

    0
    声望
    8
    楼层
    926
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    wlfg 关注

    wlfg 发布的帖子

    • Value error sensor control failed 是怎么回事?
      import pyb
      import sensor, image, time,utime
      import car
      from pid import PID
      from pyb import UART
      from code_123 import code_123
      from code_132 import code_132
      from code_213 import code_213
      from code_231 import code_231
      from code_321 import code_321
      from code_312 import code_312
      from Read import uart_read
      from red import find_red
      from blue import find_blue
      from green import find_green
      from Test import wave_distance_process
      
      sensor.reset()
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(10)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      uart = UART(3, 115200)
      m = [0,0,0]
      while(True):
          car.run(50,50)
          img = sensor.snapshot()
          img.lens_corr(1)
          for code in img.find_qrcodes():
              uart.write(code.payload()+'\0')
              m=list(code.payload())
              if(m!=[0,0,0]):
                  print(m)
                  if m[0]=='1' and m[1]=='2' and m[2]=='3':
                      find_red()
                      wave_distance_process()
                      while(wave_distance_process()>=6.0 and wave_distance_process()<=9.0):
                          find_red()
                      find_green()
                      while(wave_distance_process()>=6.0 and wave_distance_process()<=9.0):
                          find_green()
                      find_blue()
                      while(wave_distance_process()>=6.0 and wave_distance_process()<=9.0):
                          find_blue()
      
      发布在 OpenMV Cam
      W
      wlfg
    • RE: 大佬,这个是怎么回事?应该怎么解决?这是已经插上SD卡了,没插也是类似错误。为什么?
      import pyb
      import sensor, image, time,utime
      import car
      from pid import PID
      from pyb import UART
      from pyb import Pin
      from pyb import Timer
      sensor.reset()
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(10)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      uart = UART(3, 115200)
      thresholds = [(0, 100, 23, 127, -128, 127),
                    (0, 100, -128, -20, 126, -128),
                    (0, 80, 0, -128, -8, -128)]
      size_threshold = 500000
      x_pid = PID(p=0.5, i=1, imax=100)
      h_pid = PID(p=0.05, i=0.1, imax=50)
      def func():
          car.run(50,50)
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      m = [0,0,0]
      flag1 = 1
      flag2 = 1
      flag3 = 1
      while(True):
          clock.tick()
          if(time.ticks()<=2700):
              car.run(0,0)
          elif(time.ticks()<=3500):
              car.run(100,100)
          elif(time.ticks()<=4500):
              car.run(50,-50)
          elif(time.ticks()<=7500):
              car.run(100,100)
          elif(time.ticks()<=8500):
              car.run(50,-50)
          elif(time.ticks()<=9000):
              car.run(100,100)
          else:
              car.run(0,0)
          img = sensor.snapshot()
          img.lens_corr(1)
          for code in img.find_qrcodes():
              uart.write(code.payload())
              m=list(code.payload())
              if(m!=[0,0,0]):
                  print(m)
                  while(flag1):
                      sensor.set_auto_whitebal(False)
                      img = sensor.snapshot()
                      if(m[0]=='1'):
                          blobs = img.find_blobs([thresholds[0]])
                          if blobs:
                              max_blob = find_max(blobs)
                              x_error = max_blob[5]-img.width()/2
                              h_error = max_blob[2]*max_blob[3]-size_threshold
                              img.draw_rectangle(max_blob[0:4])
                              img.draw_cross(max_blob[5], max_blob[6])
                              x_output=x_pid.get_pid(x_error,1)
                              h_output=h_pid.get_pid(h_error,1)
                              car.run(-h_output-x_output,-h_output+x_output)
                              blobs = img.find_blobs([thresholds[0]])
                              k = h_error+500000
                              if(k>=16000):
                                  img = sensor.snapshot()
                                  tim = time.ticks()
                                  while(tim+500>=time.ticks()):
                                      img = sensor.snapshot()
                                      car.run(50,50)
                                  tim = time.ticks()
                                  while(tim+2000>=time.ticks()):
                                      img = sensor.snapshot()
                                      car.run(0,0)
                                  tim = time.ticks()
                                  while(tim+1000>=time.ticks()):
                                      img = sensor.snapshot()
                                      car.run(-100,-100)
                                  while(True):
                                      img = sensor.snapshot()
                                      blobs = img.find_blobs([thresholds[0]])
                                      if blobs:
                                          max_blob = find_max(blobs)
                                          x_error = max_blob[5]-img.width()/2
                                          h_error = max_blob[2]*max_blob[3]-size_threshold
                                          img.draw_rectangle(max_blob[0:4])
                                          img.draw_cross(max_blob[5], max_blob[6])
                                          x_output=x_pid.get_pid(x_error,1)
                                          h_output=h_pid.get_pid(h_error,1)
                                          car.run(-h_output-x_output,-h_output+x_output)
                                          blobs = img.find_blobs([thresholds[0]])
                                          k = h_error+500000
                                          if k >= 1000:
                                              img = sensor.snapshot()
                                              tim = time.ticks()
                                              while(tim+1000>=time.ticks()):
                                                  img = sensor.snapshot()
                                                  car.run(50,50)
                                              tim = time.ticks()
                                              while(tim+2000>=time.ticks()):
                                                  img = sensor.snapshot()
                                                  car.run(0,0)
                                              tim = time.ticks()
                                              while(tim+1000>=time.ticks()):
                                                  img = sensor.snapshot()
                                                  car.run(-100,-100)
                                              while(True):
                                                  img = sensor.snapshot()
                                                  if(m[1]=='2'):
                                                      blobs = img.find_blobs([thresholds[1]])
                                                      if blobs:
                                                          max_blob = find_max(blobs)
                                                          x_error = max_blob[5]-img.width()/2
                                                          h_error = max_blob[2]*max_blob[3]-size_threshold
                                                          img.draw_rectangle(max_blob[0:4])
                                                          img.draw_cross(max_blob[5], max_blob[6])
                                                          x_output=x_pid.get_pid(x_error,1)
                                                          h_output=h_pid.get_pid(h_error,1)
                                                          car.run(-h_output-x_output,-h_output+x_output)
                                                          k = h_error+500000
                                                          if(k>=16000):
                                                              img = sensor.snapshot()
                                                              tim = time.ticks()
                                                              while(tim+500>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(50,50)
                                                              tim = time.ticks()
                                                              while(tim+2000>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(0,0)
                                                              tim = time.ticks()
                                                              while(tim+1000>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(-100,-100)
                                                              while(True):
                                                                  img = sensor.snapshot()
                                                                  blobs = img.find_blobs([thresholds[1]])
                                                                  if blobs:
                                                                      max_blob = find_max(blobs)
                                                                      x_error = max_blob[5]-img.width()/2
                                                                      h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                      img.draw_rectangle(max_blob[0:4])
                                                                      img.draw_cross(max_blob[5], max_blob[6])
                                                                      x_output=x_pid.get_pid(x_error,1)
                                                                      h_output=h_pid.get_pid(h_error,1)
                                                                      car.run(-h_output-x_output,-h_output+x_output)
                                                                      blobs = img.find_blobs([thresholds[1]])
                                                                      k = h_error+500000
                                                                      if k >= 1000:
                                                                          img = sensor.snapshot()
                                                                          tim = time.ticks()
                                                                          while(tim+1000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(50,50)
                                                                          tim = time.ticks()
                                                                          while(tim+2000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(0,0)
                                                                          tim = time.ticks()
                                                                          while(tim+1000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(-100,-100)
                                                                          while(True):
                                                                              if(m[2]=='3'):
                                                                                  blobs = img.find_blobs([thresholds[2]])
                                                                                  if blobs:
                                                                                      max_blob = find_max(blobs)
                                                                                      x_error = max_blob[5]-img.width()/2
                                                                                      h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                                      img.draw_rectangle(max_blob[0:4])
                                                                                      img.draw_cross(max_blob[5], max_blob[6])
                                                                                      x_output=x_pid.get_pid(x_error,1)
                                                                                      h_output=h_pid.get_pid(h_error,1)
                                                                                      car.run(-h_output-x_output,-h_output+x_output)
                                                                                      k = h_error+500000
                                                                                      if(k>=16000):
                                                                                          img = sensor.snapshot()
                                                                                          tim = time.ticks()
                                                                                          while(tim+500>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(50,50)
                                                                                          tim = time.ticks()
                                                                                          while(tim+2000>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(0,0)
                                                                                          tim = time.ticks()
                                                                                          while(tim+1000>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(-100,-100)
                                                                                          while(True):
                                                                                              img = sensor.snapshot()
                                                                                              blobs = img.find_blobs([thresholds[2]])
                                                                                              if blobs:
                                                                                                  max_blob = find_max(blobs)
                                                                                                  x_error = max_blob[5]-img.width()/2
                                                                                                  h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                                                  img.draw_rectangle(max_blob[0:4])
                                                                                                  img.draw_cross(max_blob[5], max_blob[6])
                                                                                                  x_output=x_pid.get_pid(x_error,1)
                                                                                                  h_output=h_pid.get_pid(h_error,1)
                                                                                                  car.run(-h_output-x_output,-h_output+x_output)
                                                                                                  blobs = img.find_blobs([thresholds[2]])
                                                                                                  k = h_error+500000
                                                                                                  if k >= 1000:
                                                                                                      img = sensor.snapshot()
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+1000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(50,50)
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+2000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(0,0)
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+1000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(-100,-100)
                                                                                              else:
                                                                                                  car.run(50,-50)
                                                                                            
                                                                                  else:
                                                                                      car.run(50,-50)
                                                                  else:
                                                                      car.run(50,-50)
                                                                
                                                      else:
                                                          car.run(50,-50)
                                                  if(m[1]=='3'):
                                                      blobs = img.find_blobs([thresholds[2]])
                                                      if blobs:
                                                          max_blob = find_max(blobs)
                                                          x_error = max_blob[5]-img.width()/2
                                                          h_error = max_blob[2]*max_blob[3]-size_threshold
                                                          img.draw_rectangle(max_blob[0:4])
                                                          img.draw_cross(max_blob[5], max_blob[6])
                                                          x_output=x_pid.get_pid(x_error,1)
                                                          h_output=h_pid.get_pid(h_error,1)
                                                          car.run(-h_output-x_output,-h_output+x_output)
                                                          k = h_error+500000
                                                          if(k>=16000):
                                                              img = sensor.snapshot()
                                                              tim = time.ticks()
                                                              while(tim+500>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(50,50)
                                                              tim = time.ticks()
                                                              while(tim+2000>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(0,0)
                                                              tim = time.ticks()
                                                              while(tim+1000>=time.ticks()):
                                                                  img = sensor.snapshot()
                                                                  car.run(-100,-100)
                                                              while(True):
                                                                  img = sensor.snapshot()
                                                                  blobs = img.find_blobs([thresholds[2]])
                                                                  if blobs:
                                                                      max_blob = find_max(blobs)
                                                                      x_error = max_blob[5]-img.width()/2
                                                                      h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                      img.draw_rectangle(max_blob[0:4])
                                                                      img.draw_cross(max_blob[5], max_blob[6])
                                                                      x_output=x_pid.get_pid(x_error,1)
                                                                      h_output=h_pid.get_pid(h_error,1)
                                                                      car.run(-h_output-x_output,-h_output+x_output)
                                                                      blobs = img.find_blobs([thresholds[2]])
                                                                      k = h_error+500000
                                                                      if k >= 1000:
                                                                          img = sensor.snapshot()
                                                                          tim = time.ticks()
                                                                          while(tim+1000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(50,50)
                                                                          tim = time.ticks()
                                                                          while(tim+2000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(0,0)
                                                                          tim = time.ticks()
                                                                          while(tim+1000>=time.ticks()):
                                                                              img = sensor.snapshot()
                                                                              car.run(-100,-100)
                                                                          while(True):
                                                                              if(m[2]=='2'):
                                                                                  blobs = img.find_blobs([thresholds[1]])
                                                                                  if blobs:
                                                                                      max_blob = find_max(blobs)
                                                                                      x_error = max_blob[5]-img.width()/2
                                                                                      h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                                      img.draw_rectangle(max_blob[0:4])
                                                                                      img.draw_cross(max_blob[5], max_blob[6])
                                                                                      x_output=x_pid.get_pid(x_error,1)
                                                                                      h_output=h_pid.get_pid(h_error,1)
                                                                                      car.run(-h_output-x_output,-h_output+x_output)
                                                                                      k = h_error+500000
                                                                                      if(k>=16000):
                                                                                          img = sensor.snapshot()
                                                                                          tim = time.ticks()
                                                                                          while(tim+500>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(50,50)
                                                                                          tim = time.ticks()
                                                                                          while(tim+2000>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(0,0)
                                                                                          tim = time.ticks()
                                                                                          while(tim+1000>=time.ticks()):
                                                                                              img = sensor.snapshot()
                                                                                              car.run(-100,-100)
                                                                                          while(True):
                                                                                              img = sensor.snapshot()
                                                                                              blobs = img.find_blobs([thresholds[1]])
                                                                                              if blobs:
                                                                                                  max_blob = find_max(blobs)
                                                                                                  x_error = max_blob[5]-img.width()/2
                                                                                                  h_error = max_blob[2]*max_blob[3]-size_threshold
                                                                                                  img.draw_rectangle(max_blob[0:4])
                                                                                                  img.draw_cross(max_blob[5], max_blob[6])
                                                                                                  x_output=x_pid.get_pid(x_error,1)
                                                                                                  h_output=h_pid.get_pid(h_error,1)
                                                                                                  car.run(-h_output-x_output,-h_output+x_output)
                                                                                                  blobs = img.find_blobs([thresholds[1]])
                                                                                                  k = h_error+500000
                                                                                                  if k >= 1000:
                                                                                                      img = sensor.snapshot()
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+1000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(50,50)
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+2000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(0,0)
                                                                                                      tim = time.ticks()
                                                                                                      while(tim+1000>=time.ticks()):
                                                                                                          img = sensor.snapshot()
                                                                                                          car.run(-100,-100)
                                                                                          else:
                                                                                              car.run(50,-50)
                                                                                        
                                                                              else:
                                                                                  car.run(50,-50)
                                                                  else:
                                                                      car.run(50,-50)
                                                                
                                                      else:
                                                          car.run(50,-50)
                                          else:
                                          car.run(50,-50)
                          else:
                              car.run(50,-50)
      
      发布在 OpenMV Cam
      W
      wlfg
    • 大佬,这个是怎么回事?应该怎么解决?这是已经插上SD卡了,没插也是类似错误。为什么?

      0_1540130736075_a8472630-fc75-46f5-9d25-c38ac2160e36-image.png

      发布在 OpenMV Cam
      W
      wlfg
    • 为什么文件好端端的会自己损毁?

      0_1538915929080_TIM图片20181007203838.jpg

      发布在 OpenMV Cam
      W
      wlfg
    • RE: 我要怎样做才能让扫完码直接开始处理二维码信息,我现在的代码一直在读取二维码的信息。求大神?

      我对于这个while(True)死循环不是很理解,读取图像信息时是一帧一帧来的,读取二维码的过程已经是死循环了,我退出这个循环后,我接下来还需要继续处理新的图像信息,这个转变,或者说这个程序的工作改变不是很懂,openmv有这方面的教程吗?亲

      发布在 OpenMV Cam
      W
      wlfg
    • RE: 我要怎样做才能让扫完码直接开始处理二维码信息,我现在的代码一直在读取二维码的信息。求大神?

      什么意思?我不太明白,您能讲的细一点吗?麻烦啦

      发布在 OpenMV Cam
      W
      wlfg
    • 我要怎样做才能让扫完码直接开始处理二维码信息,我现在的代码一直在读取二维码的信息。求大神?
      while(True):
          m = [0,0,0]
          img = sensor.snapshot()
          img.lens_corr(1)
          for code in img.find_qrcodes():
              uart.write(code.payload())
              m=list(code.payload())
              if(m!=[0,0,0]):
                  break
          for i in range(3):
              if(m!=[0,0,0]):
                  print(m)
                  if(m[0]==1):
                      break
                      for blob in img.find_blobs([thresholds], pixels_threshold=200, area_threshold=200, merge=True):
                          img.draw_rectangle(blob.rect())
                          img.draw_cross(blob.cx(), blob.cy())
      
      发布在 OpenMV Cam
      W
      wlfg
    • RE: 这个程序为什么偶尔会报错,但有时也会运行?

      0_1538273672457_TIM图片20180930101424.png

      发布在 OpenMV Cam
      W
      wlfg