• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • Type Error: function missing 1 required positional arguments



    • Type Error: function missing 1 required positional arguments
      求教 为啥会出现这种错误啊

      import sensor, image, time,pyb,lcd
      import pyb, machine, sensor, image, pyb, os, lcd, time
      led_R = pyb.LED(1)
      led_G = pyb.LED(2)
      led_B = pyb.LED(3)
      led_R.off()
      led_G.off()
      led_B.off()
      lcd.init()
      from pyb import Pin,Timer,RTC

      pin1 = Pin('P1', Pin.IN, Pin.PULL_DOWN)
      pin4 = Pin('P4', Pin.IN, Pin.PULL_DOWN)
      pin5 = Pin('P5', Pin.OUT, Pin.PULL_NONE)
      pin6 = Pin('P6', Pin.OUT, Pin.PULL_NONE)
      pin9 = Pin('P9', Pin.OUT, Pin.PULL_NONE)
      light=Timer(2,freq=50000).channel(1,Timer.PWM,pin=Pin("P6")) #LED灯亮度调节
      a=0
      roi01 = (170,170,225,300)
      Count01 = 0
      Count02 = 0
      Count_ok = 0
      Count_ng = 0
      result = 0
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((0,0,500,400))
      sensor.skip_frames(time = 1000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      def check01(): #2.0T
      thresholds = [(35, 68, -20, 18, -59, -29),(68, 100, -35, -10, -58, -16)]
      Count_ok = 0
      Count_ng = 0
      roi01 = (170,170,225,300)
      for i in range(3):
      a=0
      light.pulse_width_percent(a)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((0,0,500,400))
      sensor.skip_frames(time = 1000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      img=sensor.snapshot()
      lcd.display(img,roi=roi01)
      if Count_ok >= 13:
      break
      a=80
      light.pulse_width_percent(a)
      for y in range(15):
      img=sensor.snapshot()
      lcd.display(img,roi=roi01)
      for blob in img.find_blobs(thresholds,roi=(175,135,190,95),pixels_threshold=100,area_threshold=100, merge=True,margin=7000):
      if blob.area()>1500 and blob.area()<23000:
      img.draw_rectangle(blob.rect(),color=(255,0,0))
      img.draw_cross(blob.cx(),blob.cy())
      img.draw_string(170,170,"OK",color=(255,255,255),scale=3,mono_space=False)
      lcd.display(img,roi=roi01)
      area=blob.area()
      print('OK')
      print(area)
      Count_ok += 1
      else:
      img.draw_rectangle(blob.rect(),color=(255,0,0))
      img.draw_cross(blob.cx(),blob.cy())
      img.draw_string(170,170,"NG",color=(255,255,255),scale=3,mono_space=False)
      lcd.display(img,roi=roi01)
      area=blob.area()
      print('NG')
      print(area)
      Count_ng += 1
      if Count_ok > 8:
      return True
      else:
      return False
      def check02(): #1.5T
      thresholds = [(49, 76, -31, -15, 7, 65),(64, 100, -35, 2, 8, 60)]
      Count_ok = 0
      Count_ng = 0
      roi01 = (170,170,225,300)
      for i in range(3):
      a=0
      light.pulse_width_percent(a)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((0,0,500,400))
      sensor.skip_frames(time = 1000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      img=sensor.snapshot()
      lcd.display(img,roi=roi01)
      if Count_ok >= 13:
      break
      a=80
      light.pulse_width_percent(a)
      for y in range(15):
      img=sensor.snapshot()
      lcd.display(img,roi=roi01)
      for blob in img.find_blobs(thresholds,roi=(185,135,190,95),pixels_threshold=300,area_threshold=200, merge=True,margin=300):
      if blob.area()>2500 and blob.area()<20000:
      img.draw_rectangle(blob.rect(),color=(255,0,0))
      img.draw_cross(blob.cx(),blob.cy())
      img.draw_string(170,170,"OK",color=(255,255,255),scale=3,mono_space=False)
      lcd.display(img,roi=roi01)
      area=blob.area()
      print('OK')
      print(area)
      Count_ok += 1
      else:
      img.draw_rectangle(blob.rect(),color=(255,0,0))
      img.draw_cross(blob.cx(),blob.cy())
      img.draw_string(170,170,"NG",color=(255,255,255),scale=3,mono_space=False)
      lcd.display(img,roi=roi01)
      area=blob.area()
      print('NG')
      print(area)
      Count_ng += 1
      if Count_ok > 8:
      return True
      else:
      return False

      while(True):
      img=sensor.snapshot()
      value1=pin1.value()
      value4=pin4.value()
      if value1==1: #2.0T
      rtc = RTC
      datetime = rtc.datetime()
      ye = str(datetime[0])
      mon = '%02d' %datetime[1]
      day = '%02d' %datetime[2]
      hou = '%02d' %datetime[4]
      minu = '%02d' %datetime[5]
      sec = '%02d' %datetime[6]
      subsec = str(datetime[7])

          file_name = 'NG'+ye+mon+day+hou+minu+sec
          Count01 += 1
          if Count01 == 1:
              lcd.display(img)
              result = check01()
          else:
              if result == True:
                  led_G.on()
                  print('2.0T OK')
                  a=0
                  light.pulse_width_percent(a)
                  pin5.value(1)
                  img.draw_string(170,170," 2.0T OK",color=(0,0,255),scale=4,mono_space=False)
                  lcd.display(img,roi=roi01)
              elif result == False:
                  led_R.on()
                  print('total ng')
                  sensor.snapshot().save("NG/%s.jpg"%(file_name))
                  a=0
                  light.pulse_width_percent(a)
                  pin9.value(1)
                  img.draw_string(170,170," 2.0T NG",color=(0,0,255),scale=4,mono_space=False)
                  lcd.display(img,roi=roi01)
      elif value4==1:    #1.5T
          rtc = RTC
          datetime = rtc.datetime()
          ye = str(datetime[0])
          mon = '%02d' %datetime[1]
          day = '%02d' %datetime[2]
          hou = '%02d' %datetime[4]
          minu = '%02d' %datetime[5]
          sec = '%02d' %datetime[6]
          subsec = str(datetime[7])
      
          file_name = 'NG'+ye+mon+day+hou+minu+sec
          Count02 += 1
          if Count02 == 1:
              lcd.display(img)
              result = check02()
          else:
              if result == True:
                  led_G.on()
                  print('total OK')
                  a=0
                  light.pulse_width_percent(a)
                  pin5.value(1)
                  img.draw_string(170,170," 1.5T OK",color=(0,0,255),scale=4,mono_space=False)
                  lcd.display(img,roi=roi01)
              elif result == False:
                  led_R.on()
                  print('total ng')
                  sensor.snapshot().save("NG/%s.jpg"%(file_name))
                  a=0
                  light.pulse_width_percent(a)
                  pin9.value(1)
                  img.draw_string(170,170," 1.5T NG",color=(0,0,255),scale=4,mono_space=False)
                  lcd.display(img,roi=roi01)
      else:
          img.draw_string(210,170," NO",color=(0,0,0),scale=3,mono_space=False)
          img.draw_string(210,200," KU",color=(0,0,0),scale=3,mono_space=False)
          img.draw_string(210,230," SKID",color=(0,0,0),scale=3,mono_space=False)
          lcd.display(img,roi=roi01)
          print('no skid')
          pin5.value(0)
          pin9.value(0)
          a=0
          light.pulse_width_percent(a)
          Count01 = 0
          Count02 = 0
          led_R.off()
          led_G.off()
          led_B.off()


    • 不用了,问题解决 具体咋解决的我也不知道。。。。。。。。



    • 就是函数有一个地方要参数,然后你没给。