导航

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

    myzn 发布的帖子

    • 我想要通过别人给我发送信息,更换目标,但是摄像头为什么会卡

      Blob Detection Example#by:王雨晴 2019年7月16日import sensor, image, time,pyb,mathfrom pyb import UARTfrom pyb import Pinred_threshold_01 = (58, 72, 44, 70, -1, 38)yellow_threshold_01 = (70, 98, -16, 7, 58, 72)#设置红色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,# maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需#设置(min, max)两个数字即可。# You may need to tweak the above settings for tracking green things...# Select an area in the Framebuffer to copy the color settings.K=800sensor.reset() # Initialize the camera sensor.sensor.set_pixformat(sensor.RGB565) # use RGB565.sensor.set_framesize(sensor.QQVGA) # use QVGA for quailtiy ,use QQVGA for speed.分辨率为120160sensor.skip_frames(10) # Let new settings take affect.sensor.set_auto_whitebal(False)#关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。clock = time.clock() # Tracks FPS.uart3= UART(3, 9600)uart1= UART(1, 9600)uart1= UART(1, 9600, timeout_char=1000)''' 扩宽roi'''def expand_roi(roi): # set for QQVGA 160120 extra = 5 win_size = (160, 120) (x, y, width, height) = roi new_roi = [x-extra, y-extra, width+2extra, height+2extra] if new_roi[0] < 0: new_roi[0] = 0 if new_roi[1] < 0: new_roi[1] = 0 if new_roi[2] > win_size[0]: new_roi[2] = win_size[0] if new_roi[3] > win_size[1]: new_roi[3] = win_size[1] return tuple(new_roi)AH = bytearray([0x40])uart1.write(AH)while(True): if uart1.any(): a=uart1.readline().decode().strip() print(a) else: a=0 if a==0: clock.tick() img = sensor.snapshot()#.lens_corr(1.8) # Take a picture and return the image. blobs = img.find_blobs([red_threshold_01], area_threshold=150)#如果返回的边界框小于area_threshold就返回none if blobs: #如果找到了目标颜色 for b in blobs: x = b.cx() y = b.cy() print(x,y) if x>=60 and x<=100: is_circle = False max_circle = None max_radius = -1 new_roi = expand_roi(b.rect()) for c in img.find_circles(threshold = 3500, x_margin = 20, y_margin = 20, r_margin = 10, roi=new_roi): is_circle = True if c.r() > max_radius: max_radius = c.r() max_circle = c if is_circle: # 如果有对应颜色的圆形 标记外框 # Draw a rect around the blob. img.draw_rectangle(new_roi) # rect img.draw_rectangle(b.rect()) # rect #用矩形标记出目标颜色区域 img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) # cx, cy img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r(), color = (0, 255, 0)) img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r() + 1, color = (0, 255, 0)) Lm = (b[2]+b[3])/2 #b2是色块的长,b3是色块的宽 length =(K/Lm) print(length) str='%d'%(length) print(length) #uart1.write(str) if a==0: clock.tick() img = sensor.snapshot()#.lens_corr(1.8) # Take a picture and return the image. blobs = img.find_blobs([yellow_threshold_01], area_threshold=150)#如果返回的边界框小于area_threshold就返回none if blobs: #如果找到了目标颜色 for b in blobs: x = b.cx() y = b.cy() print(x,y) if x>=60 and x<=100: uart3.write('1') is_circle = False max_circle = None max_radius = -1 new_roi = expand_roi(b.rect()) for c in img.find_circles(threshold = 3500, x_margin = 20, y_margin = 20, r_margin = 10, roi=new_roi): is_circle = True # img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 255)) if c.r() > max_radius: max_radius = c.r() max_circle = c if is_circle: img.draw_rectangle(new_roi) # rect img.draw_rectangle(b.rect()) # rect img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) # cx, cy img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r(), color = (0, 255, 0)) img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r() + 1, color = (0, 255, 0)) Lm = (b[2]+b[3])/2 #b2是色块的长,b3是色块的宽 length =(K/Lm) print(length) str='%d'%(length) print(length)

      发布在 OpenMV Cam
      M
      myzn
    • 我用openmv与感光模块通信,但在接收数据等我时候总是出现UnicodeError的问题

      -- coding: utf-8 --

      import sensor, image, time, pyb, json

      from pyb import UART

      from pyb import Pin

      yellow_threshold = (60 ,83 , -9, 46, 31, 72)

      sensor.reset()

      sensor.set_pixformat(sensor.RGB565)

      sensor.set_framesize(sensor.QQVGA)

      sensor.skip_frames(time = 2000 )

      sensor.set_auto_whitebal(False)

      sensor.set_auto_whitebal(False)

      #关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。

      uart = UART(3, 9600, timeout_char=1000)
      uart = UART(3,9600)

      clock = time.clock()

      while(True):
      clock.tick()
      #FH = 0x55
      #str='%d'%(FH)
      uart.write('U')
      if uart.any():
      a=uart.readline().decode().strip()#首先是一个字节串,加入decode变为字符串,strip删掉回车和换行
      print(a)
      m = a[2:7]
      print(m)
      #n=int(m)
      # if n>=00000 and n<00130:
      # yellow_threshold = (39 ,72 , -11, 11, -46, -34)
      # print(1)
      #if n>=00130 and n<00200:
      # yellow_threshold = (19 ,68 , -9, 12, -40, -13)
      # print(2)
      #if n>=00450 and n<00650:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(3)
      #if n>=00650 and n<00850:
      # yellow_threshold = (0 ,0 , -11, 3, -33, -23)
      # print(4)
      #if n>=00850 and n<01050:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(5)
      #if n>=01050 and n<01250:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(6)
      #if n>=01250 and n<01450:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(7)
      #if n>=01450 and n<01650:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(8)
      #if n>=01650 and n<01850:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(9)
      #if n>=01850 and n<02000:
      # yellow_threshold = (60 ,23 , -9, 46, 31, 72)
      # print(10)

      img = sensor.snapshot().lens_corr(1.9)
      blob= img.find_blobs([yellow_threshold])#寻找黄色最大的色块
      if blob: #如果找到了目标颜色
          for b in blob:
              img.draw_rectangle(b[0:4]) # rect
              img.draw_cross(b[5], b[6]) # cx, cy这是我的代码
      发布在 OpenMV Cam
      M
      myzn
    • RE: 摄像头在照到目标物体后会泛红是怎么回事

      0_1561725542165_QQ图片20190628203654.jpg

      发布在 OpenMV Cam
      M
      myzn
    • RE: 摄像头在照到目标物体后会泛红是怎么回事

      @17788265935 0_1561725449073_QQ图片20190628203709.jpg

      发布在 OpenMV Cam
      M
      myzn