导航

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

    3a2u_1565069740

    @3a2u_1565069740

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

    3a2u_1565069740 关注

    3a2u_1565069740 发布的帖子

    • pixels_threshold大了就会出现name is not defined?

      #烧录进OPENMV程序,阈值待修改。2018年1月5日。
      import sensor, image, time,pyb,utime,math
      import json
      from pyb import UART
      #加载串口模块
      from pyb import Timer
      #加载定时器模块
      from pyb import LED
      #加载LED模块
      threshold_index = 0 # 0 for red, 1 for green, 2 for blue

      为了使色彩追踪效果真的很好,你应该在一个非常受控制的照明环境中。

      #threshold = (63, 100, 15, 127, -9, -4) #red
      #threshold = ( 0, 80, -70, -10, -0, 30) #小球
      #threshold = (30, 80, -39, -12, -52, 14)

      thresholds = [(26, 3, -14, 13, -22, 16)] #黑教鞭

      #设定感兴趣区域,阈值为10~99,这样保证输出为两位数
      #grayscale_threshold = (242,255)
      #grayscale_roi = (30,10,90,90)

      def timer4():
      global switch
      switch = 1
      #开启图像拍照识别开关,这样能稳定获得50帧的图像,前提是不链接电脑。
      #定义中断函数,作用是没20ms开启图像开关一次。
      #各个函数中使用全局变量要先用global关键字声明,然后再使用此全局变量。

      tim = Timer(4) #使用定时器4创建一个定时器对象
      tim.init(freq=50) # 以50Hz触发,测试使用
      tim.callback(lambda t: timer4())#中断持续进行要记得更新即加入lambda t:

      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 1000)
      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()

      #定义全局变量开关。
      global switch
      switch = 0

      count_time = 0 #计次,指示程序正在运行

      uart = UART(3, 115200) #串口初始化。

      while(True):
      clock.tick()
      if switch == 1:
      switch = 0
      #clock.tick() # Track elapsed milliseconds between snapshots().
      img = sensor.snapshot() # Take a picture and return the image.
      for blob in img.find_blobs([thresholds[0]], pixels_threshold =200, merge=True):
      cx = 0
      cy = 0
      img.draw_rectangle(blob.rect())
      img.draw_cross(blob.cx(), blob.cy())
      print(blob.cx(),blob.cy())
      cx=blob.cx()
      cy=blob.cy()
      img_data = bytearray([0xb3,0xb3,cx,cy,0xbb,0xbb])
      print(img_data)
      uart.write(img_data)
      print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
      0_1565069990289_QQ图片20190806133854.png

      注释掉串口,看到的数据是错误的
      0_1565070101395_2.png

      发布在 OpenMV Cam
      3
      3a2u_1565069740