导航

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

    mzes

    @mzes

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

    mzes 关注

    mzes 发布的帖子

    • RE: 我想问问,我通过识别出圆形再识别颜色,来识别围棋棋子,为什么识别情况很不稳定

      @kidswong999 不稳定,总是闪烁

      发布在 OpenMV Cam
      M
      mzes
    • RE: 我想问问,我通过识别出圆形再识别颜色,来识别围棋棋子,为什么识别情况很不稳定

      @kidswong999 0_1593840879863_批注 2020-07-04 133417.png

      发布在 OpenMV Cam
      M
      mzes
    • 我想问问,我通过识别出圆形再识别颜色,来识别围棋棋子,为什么识别情况很不稳定
      import sensor, image, time
      import math
      from mywuzi import chess
      from movement import move
      from movement import cgj
      from pyb import UART
      
      
      uart=UART(1,9600)
      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()
      chess1 = [[0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0],
               [0,0,0,0,0,0,0,0,0,0]]
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 1500, x_margin = 10, y_margin = 10, r_margin = 10,
                  r_min = 0, r_max = 7, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              #(0,20,-20,20,-10,20)是黑色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是黑棋。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if c.r() <= 6:
                  if 0<statistics.l_mode()<26 and -28<statistics.a_mode()<22 and -47<statistics.b_mode()<29:#if the circle is black
                      img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))#识别到的黑棋用红色的圆框出来
                      m1 = (c.x()-32)/12
                      m2 = (c.x()-20)/12
                      m = int(m2)
                      n1 = (106-c.y())/12
                      n2 = (118-c.y())/12
                      n = int(n2)
                      chess1[m][n] = -1
                  else:
                      img.draw_rectangle(area, color = (255, 255, 255))#将白棋用白色的矩形框出来
                      m1 = (c.x()-32)/12
                      m2 = (c.x()-20)/12
                      m = int(m2)
                      n1 = (106-c.y())/12
                      n2 = (118-c.y())/12
                      n = int(n2)
                      chess1[m][n] = 1
      
      发布在 OpenMV Cam
      M
      mzes