Navigation

    • Login
    • Search
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. Home
    2. h2my
    H
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    h2my

    @h2my

    0
    Reputation
    9
    Posts
    544
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    h2my Follow

    Posts made by h2my

    • RE: Openmv的rgb灯

      程序没有问题还可以运行啊,就是运行以后才突然不行的

      posted in OpenMV Cam
      H
      h2my
    • RE: Openmv的rgb灯
      #2018.8.2
      import sensor, image, time , pyb
      from pyb import UART
      from pyb import Timer
      from pyb import LED
      import json
      
      led = pyb.LED(3) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4.
      thresholds = [(27, 67, 19, 91, 45, 76), # 红色
                    #(21, 75, 3, -38, 34, 68), # 绿色
                    (27, 90, -3, -28, 31, 125),
                    (0, 30, 0, 64, -128, 0)]  # generic_blue_thresholds
      threshold_index = 1 # 0 for red, 1 for gre9en, 2 for blue
      
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)   #320*240
      sensor.skip_frames(time = 100)
      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()
      uart = UART(3, 115200)
      uart.init(115200, bits=8, parity=None, stop=1, timeout_char=1000) # 使用给定参数初始化
      
      def tick(timer):            # we will receive the timer object when being called
          global data
          if blobs:
              print("Find")
              print('you send:',output_str)
              uart.write(data)
      
      
      tim = Timer(4, freq=10)      # create a timer object using timer 4 - trigger at 1Hz
      tim.callback(tick)          # set the callback to our tick function
      
      
      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
      
      def Uart_Receive():   #UART接收 改变框小球的颜色阈值
          global threshold_index
          if uart.any():
              temp_data = uart.readchar()
              if temp_data==0:   #红色
                 threshold_index=0
      
                 print(temp_data,threshold_index)
              elif temp_data==1:
                 threshold_index=1
                 print(temp_data,threshold_index)
      
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          Uart_Receive()
          blobs = img.find_blobs([thresholds[threshold_index]])
          if blobs:
      
              max_blob = find_max(blobs)
              b = max_blob[0] #方框元组
              L = (max_blob[2]+max_blob[3])/2
              l=int(1000/L)
              #x_error = max_blob[5]-img.width()/2   #求横向偏差
              x_error = max_blob[5]-img.width()/2
      
              img.draw_rectangle(max_blob[0:4])        # 画矩形
              img.draw_cross(max_blob[5], max_blob[6]) # 画十字
      
              #发送 小球的(x,y,l,n)
              #x为横坐标,y为纵坐标,l为粗略的距离,n为小球颜色(0:红 1:绿)
              output_str="%d,%d,%d,%d" % (max_blob.cx(),max_blob.cy(),l,threshold_index) #10进制字符包
              checkout=0xAA+0x55+0x07+int(max_blob.cx()/2)+max_blob.cy()+l+threshold_index
              data = bytearray([0xAA,0x55,0x07,int(max_blob.cx()/2),max_blob.cy(),l,threshold_index,0x00,0x00,checkout])#转成16进制
              #uart.write(data)
              time.sleep(1)
              led.on()
          else:
              print("NO FIND")
              data = bytearray([0xAA,0x55,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x06])
              uart.write(data)
              led.off()
      
      
      
      
      

      这段代码连接32,在追小球的过程中,代码里面有补光灯的设置,所以一开始补光灯是亮着的,追小球也没问题,但是找不到小球的时候,突然就闪红灯,随后补光灯也不亮了,就无法追小球了。

      posted in OpenMV Cam
      H
      h2my
    • Openmv的rgb灯

      在追小球的例程中,开了补光灯,为什么当rgb灯闪红色的时候,补光灯就不亮了,就无法追小球了?

      posted in OpenMV Cam
      H
      h2my
    • Openmv多个功能

      在openmv里同时保存了巡线和颜色识别的代码,那么在脱机的时候,两个功能可以分别实现吗?

      posted in OpenMV Cam
      H
      h2my
    • Openmv颜色识别

      Openmv颜色识别,可以连接32然后显示1602上吗?

      posted in OpenMV Cam
      H
      h2my
    • Openmv上的rgb灯

      为什么颜色识别的时候rgb灯亮不同的颜色

      posted in OpenMV Cam
      H
      h2my
    • 请问openmv与32连接需要注意什么?

      使用openmv摄像头和32控制小车的巡线,请问要注意什么?

      posted in OpenMV Cam
      H
      h2my
    • Open mv支持4轮小车吗

      Open mv代码里面都是支持两轮小车的,是否可以支持4轮小车,还有就是当只有摄像头的时候能否实现巡线

      posted in OpenMV Cam
      H
      h2my
    • 电脑无法显示openmv的驱动

      笔记本电脑插入open mv后没有显示驱动,只相当于一个u盘,这种情况怎么办?

      posted in OpenMV Cam
      H
      h2my