导航

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

    egxs

    @egxs

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

    egxs 关注

    egxs 发布的帖子

    • 怎么给arduino传16进制的数字1,2,3,4,5,,,,
      # Measure the distance
      #
      # This example shows off how to measure the distance through the size in imgage
      # This example in particular looks for yellow pingpong ball.
      
      import sensor, image, time
      import json
      # For color tracking to work really well you should ideally be in a very, very,
      # very, controlled enviroment where the lighting is constant...
      yellow_threshold   = (27, 61, 36, 127, -128, 127)
      # You may need to tweak the above settings for tracking green things...
      # Select an area in the Framebuffer to copy the color settings.
      from pyb import UART
      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.
      uart = UART(3, 9600)
      K=640#the value should be measured
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          blobs = img.find_blobs([yellow_threshold])
          if len(blobs) == 1:
              # Draw a rect around the blob.
              b = blobs[0]
              img.draw_rectangle(b[0:4]) # rect
              img.draw_cross(b[5], b[6]) # cx, cy
              if 0<b[5]<160/3 and 0<b[6]<40:
                  uart.write('0x01')
                  #print(b[5],b[6])
              if b[5]<320/3 and b[6]<40:
                  uart.write('2')
                  #print(b[5],b[6])
              if 320/3<b[5]<160 and 0<b[6]<40:
                  uart.write('3')
                  #print(b[5],b[6])
              if 0<b[5]<160/3 and 40<b[6]<80:
                  uart.write('4')
                  #print(b[5],b[6])
              if 160/3<b[5]<320/3 and 40<b[6]<80:
                  uart.write('5')
                  #print(b[5],b[6])
              if 320/3<b[5]<160 and 40<b[6]<80:
                  uart.write('6')
                  #print(b[5],b[6])
              if 0<b[5]<160/3 and 80<b[6]<120:
                  uart.write('7')
                  #print(b[5],b[6])
              if 160/3<b[5]<320/3 and 80<b[6]<120:
                  uart.write('8')
                  #print(b[5],b[6])
              if 320/3<b[5]<160 and 80<b[6]<120:
                  uart.write('9')
                  #print(b[5],b[6])
          #print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
          # connected to your computer. The FPS should increase once disconnected.
      

      怎么给arduino传16进制的数字1,2,3,4,5,,,,

      发布在 OpenMV Cam
      E
      egxs
    • 一个物体需要满足,是矩形和满足设置的颜色阈值这两个条件才会被识别出来,if语句应该怎么写?
      import sensor, image, time
      
      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()
      
      K=660#the value should be measured
      yellow_threshold   = (9, 62, 9, 65, -80, -7)
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob.pixels() > max_size:
                  max_blob=blob
                  max_size = blob.pixels()
          return max_blob
      while(True):
          clock.tick()
          img = sensor.snapshot()
          sensor.set_hmirror(False) #水平方向翻转
          sensor.set_vflip(False) #垂直方向翻转
          blobs = img.find_blobs([yellow_threshold])
      
      
          #if not blobs:
          for r in img.find_rects(threshold = 30000):
              img.draw_rectangle(r.rect(), color = (255, 0, 0))
              area = (r.x(),r.y(),r.w(),r.h())
              for p in r.corners():
                  img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
        #  for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
         #     r_min = 2, r_max = 100, r_step = 2):
              print (r)
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              #print(statistics)
              #(94, 100, -128, 127, -128, 127)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if 56<statistics.l_mode()<79 and 35<statistics.a_mode()<127 and -128<statistics.b_mode()<127:#if the circle is red
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          if blobs :#and len(blobs)==1 :就是这里应该怎么改!!!!!!!!!!!!!!
                      # Draw a rect around the blob.
              max_blob=find_max(blobs)
              img.draw_rectangle(max_blob.rect())
              img.draw_cross(max_blob.cx(), max_blob.cy())
              output_str="[%d,%d]\n" % (max_blob.cx(),max_blob.cy()) #方式1
                      #output_str=json.dumps([max_blob.cx(),max_blob.cy()]) #方式2
              print('you send:',output_str)
              b = blobs[0]
              img.draw_rectangle(b[0:4]) # rect
              img.draw_cross(b[5], b[6]) # cx, cy
              Lm = (b[2]+b[3])/2
              length = K/Lm
                      #print(Lm)
              print(length)
      
      

      怎么设置找到我要的颜色阈值并且该物体是矩形,就是一个物体需要满足,是矩形和是我设置的颜色阈值这两个条件才会被识别出来,所以if语句应该怎么写

      发布在 OpenMV Cam
      E
      egxs
    • RE: 我想要将颜色识别、形状识别、测距三种融合在一起可以实现吗?

      @4oqs

      import sensor, image, time
      
      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()
      
      K=500#the value should be measured
      yellow_threshold   = (56, 79, 35, 127, -128, 127)
      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().lens_corr(1.8)
          sensor.set_hmirror(False) #水平方向翻转
          sensor.set_vflip(False) #垂直方向翻转
          for r in img.find_rects(threshold = 20000):
              img.draw_rectangle(r.rect(), color = (255, 0, 0))
              area = (r.x(),r.y(),r.w(),r.h())        
              for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
        #  for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
         #     r_min = 2, r_max = 100, r_step = 2):
              print (r)
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
             #print(statistics)
              #(94, 100, -128, 127, -128, 127)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if 56<statistics.l_mode()<79 and 35<statistics.a_mode()<127 and -128<statistics.b_mode()<127:#if the circle is red
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
      
          blobs = img.find_blobs([yellow_threshold])
          
          if len(blobs) == 1:
              # Draw a rect around the blob.
              max_blob=find_max(blobs)
              b = blobs[0]
              img.draw_rectangle(b[0:4]) # rect
              img.draw_cross(b[5], b[6]) # cx, cy
              Lm = (b[2]+b[3])/2
              length = K/Lm
              #print(Lm)
              print(length)
      

      你试试看,我这里用的是红色的阈值

      发布在 OpenMV Cam
      E
      egxs
    • RE: 我想要将颜色识别、形状识别、测距三种融合在一起可以实现吗?

      @4oqs 你这纯复制粘贴。。。。咋会有用呢,k的值没改,距离是不对的,而且输出的是像素,不是距离
      另外这个是识别圆形区域的

      发布在 OpenMV Cam
      E
      egxs
    • RE: openmv什么时候可以使用VGA模式?

      能不能识别多种颜色然后同时画框

      发布在 OpenMV Cam
      E
      egxs