导航

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

    iv5d

    @iv5d

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

    iv5d 关注

    iv5d 发布的帖子

    • 这段代码是用的例程上的源码,但是不能左转是因为啥
      import sensor, image, time
      import car
      from pid import PID
      from time import sleep
      from pyb import Pin
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(10)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      green_threshold   = (46, 65, -53, -16, 18, 66)
      size_threshold = 2000
      x_pid = PID(p=0.1, i=1, imax=100)
      h_pid = PID(p=0.05, i=0.1, imax=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
      while(True):
          clock.tick()
          img = sensor.snapshot()
          blobs = img.find_blobs([green_threshold])
          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
              print("x error: ", x_error)
              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)
              print("h_output",h_output)
              car.run(-h_output-x_output,-h_output+x_output)
              sleep(0.1)
          else:
              car.run(26,-26)
      
      发布在 OpenMV Cam
      iv5d
    • 这段程序不能正常转弯,应该怎么改代码
      import sensor, image, time
      import car
      from pid import PID
      from time import sleep
      from pyb import Pin
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(10)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      green_threshold   = (46, 65, -53, -16, 18, 66)
      size_threshold = 2000
      x_pid = PID(p=0.1, i=1, imax=100)
      h_pid = PID(p=0.05, i=0.1, imax=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
      while(True):
          clock.tick()
          img = sensor.snapshot()
          blobs = img.find_blobs([green_threshold])
          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
              print("x error: ", x_error)
              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)
              print("h_output",h_output)
              car.run(-h_output-x_output,-h_output+x_output)
              sleep(0.1)
          else:
              car.run(26,-26)
      
      发布在 OpenMV Cam
      iv5d
    • 为啥转弯不是很灵敏,而且不会向左转弯
      # Blob Detection Example
      #
      # This example shows off how to use the find_blobs function to find color
      # blobs in the image. This example in particular looks for dark green objects.
      
      import sensor, image, time
      import utime
      import car
      from pid import PID
      
      # You may need to tweak the above settings for tracking green things...
      # Select an area in the Framebuffer to copy the color settings.
      
      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.RGB565) # use RGB565.
      sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
      sensor.skip_frames(10) # Let new settings take affect.
      sensor.set_auto_whitebal(False) # turn this off.
      clock = time.clock() # Tracks FPS.
      
      # For color tracking to work really well you should ideally be in a very, very,
      # very, controlled enviroment where the lighting is constant...
      green_threshold   = (48, 76, 0, 78, 42, 74)
      size_threshold = 2000
      x_pid = PID(p=0.5, i=1, imax=100)
      h_pid = PID(p=0.05, i=0.1, imax=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
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          blobs = img.find_blobs([green_threshold])
          if blobs:
      
      #        utime.sleep_ms(0)
      
              max_blob = find_max(blobs)
              x_error = max_blob[5]-img.width()/2
              h_error = max_blob[2]*max_blob[3]-size_threshold
              print("x error: ", x_error)
              '''
              for b in blobs:
                  # Draw a rect around the blob.
                  img.draw_rectangle(b[0:4]) # rect
                  img.draw_cross(b[5], b[6]) # cx, cy
              '''
      
      
              img.draw_rectangle(max_blob[0:4]) # rect
              img.draw_cross(max_blob[5], max_blob[6]) # cx, cy
              x_output=x_pid.get_pid(x_error,1)
              h_output=h_pid.get_pid(h_error,1)
              print("h_output",h_output)
              car.run(-h_output-x_output,-h_output+x_output)
          else:
              car.run(26,-26)
      
      
      发布在 OpenMV Cam
      iv5d
    • 这是啥情况,加了延时就不能正常运行了

      0_1618307753213_14449e69-0e54-4185-80c3-527a5ab8a157-image.png

      发布在 OpenMV Cam
      iv5d
    • 把TB6612换成L298N后代码应该咋改,电机的速度能不能改成定值

      把TB6612换成L298N后代码应该咋改,电机的速度能不能改成定值

      发布在 OpenMV Cam
      iv5d
    • RE: 怎么只识别黑色的图形,不识别其他颜色的?

      识别其他颜色的需要改阈值,在机器视觉里有阈值编辑器,调整合适后复制粘贴到相应的代码位置就好了

      发布在 OpenMV Cam
      iv5d
    • 如何控制小车的速度为定值,现在的小车跟疯了似的乱跑
      from pyb import Pin, Timer
      inverse_left=False  #change it to True to inverse left wheel
      inverse_right=False #change it to True to inverse right wheel
      
      ain1 =  Pin('P0', Pin.OUT_PP)
      ain2 =  Pin('P1', Pin.OUT_PP)
      bin1 =  Pin('P2', Pin.OUT_PP)
      bin2 =  Pin('P3', Pin.OUT_PP)
      ain1.low()
      ain2.low()
      bin1.low()
      bin2.low()
      
      pwma = Pin('P7')
      pwmb = Pin('P8')
      tim = Timer(4, freq=1000)
      ch1 = tim.channel(1, Timer.PWM, pin=pwma)
      ch2 = tim.channel(2, Timer.PWM, pin=pwmb)
      ch1.pulse_width_percent(0)
      ch2.pulse_width_percent(0)
      
      def run(left_speed, right_speed):
          if inverse_left==True:
              left_speed=(-left_speed)
          if inverse_right==True:
              right_speed=(-right_speed)
      
          if left_speed < 0:
              ain1.low()
              ain2.high()
          else:
              ain1.high()
              ain2.low()
          ch1.pulse_width_percent(int(abs(left_speed)))
      
          if right_speed < 0:
              bin1.low()
              bin2.high()
          else:
              bin1.high()
              bin2.low()
          ch2.pulse_width_percent(int(abs(right_speed)))
      
      
      发布在 OpenMV Cam
      iv5d
    • 有没有追小球的小车驱动与opmv连接的原理图,要接的电机自带的驱动带不起来,有点超负荷,一用就烧了

      有没有追小球的小车驱动与opmv连接的原理图,要接的电机自带的驱动带不起来,有点超负荷,一用就烧了

      发布在 OpenMV Cam
      iv5d
    • RE: 用电机驱动并联指示灯的话应该用哪两个引脚,是3.3V还是VCC引脚

      @kidswong999 就是并联一个指示灯,当他通电的话指示灯亮,不通电的话指示灯灭

      发布在 OpenMV Cam
      iv5d
    • 有源蜂鸣器因该接在哪两个引脚上,怎么控制

      有源蜂鸣器因该接在哪两个引脚上,怎么控制

      发布在 OpenMV Cam
      iv5d