导航

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

    mi62

    @mi62

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

    mi62 关注

    mi62 发布的帖子

    • 如果只想识别图片左侧,roi应该怎么设置啊

      ,,,,,,,gfgfgfgfgf

      发布在 OpenMV Cam
      M
      mi62
    • 为什么最后一句会报错“non-keyword arg after keyword arg”

      img = sensor.snapshot().lens_corr(1.8)
      for r in img.find_blobs(thresholds1=[30,100,-64,-8,-32,32],invert=False,roi)
      img.draw_rectangle(blob.rect(),color = (255, 0, 0))

      发布在 OpenMV Cam
      M
      mi62
    • RE: 为什么这个程序他只能识别出红色?

      这段代码大致就是六个色块,从上往下排列,一个色块有一种颜色(总共三种),一个数字代表一个色块,然后你按顺序输出对应的数字,但是他最后只能识别到红色,(我觉得我阈值设置的没有问题

      发布在 OpenMV Cam
      M
      mi62
    • 为什么这个程序他只能识别出红色?
      import sensor, image, time, math
       
      # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
      # The below thresholds track in general red/green things. You may wish to tune them...
      thresholds = [(13, 30, 1, 45, -24, 47), # generic_red_thresholds
                   (23, 55, -44, -24, -2, 39), # generic_green_thresholds
                   (0, 15, 0, 40, -80, -20)] # generic_blue_thresholds
      # You may pass up to 16 thresholds above. However, it's not really possible to segment any
      # scene with 16 thresholds before color thresholds start to overlap heavily.
       
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      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()
       
      # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
      # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
      # camera resolution. Don't set "merge=True" becuase that will merge blobs which we don't want here.
       
       
      while(True):
         clock.tick()
         red=[]
         green=[]
         blue=[]
         shit=[]
         order=[]
         img = sensor.snapshot().lens_corr(1.8)
         for r in img.find_rects(threshold = 10000):
             img.draw_rectangle(r.rect(), color = (255, 0, 0))
             for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
             area = (r.rect())
             #area为识别到的矩形的区域
             statistics = img.get_statistics(roi=area)#像素颜色统计i=0,j=0,n=0
             #print(statistics)
             #(0,100,0,120,0,120)是红色的阈值
             #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
             if 8<statistics.l_mode()<20 and 10<statistics.a_mode()<45 and 0<statistics.b_mode()<36:
       
                img.draw_rectangle(area, color = (255, 0, 0))#识别到的红色矩形用红色的矩形框出来
                if 1.8<(r.w()/r.h())<2.2:
       
                     red.append(r.y())
       
                elif (0.8<(r.w()/r.h())<1.2):
       
       
                     red.append(r.y())
                     red.append(r.y()-r.h()/2)
       
       
                 elif (0.5<=(r.w()/r.h())<=0.79):
       
                     red.append(r.y()-2*r.h()/3)
                     red.append(r.y()-r.h()/3)
                     red.append(r.y())
       
             if 30<statistics.l_mode()<51 and -45<statistics.a_mode()<-21 and 9<statistics.b_mode()<46:
       
                 img.draw_rectangle(area, color = (255, 0, 0))
                 if 1.8<=r.w()/r.h()<=2.2:
       
                     green.append(r.y())
       
                 elif(0.8<=r.w()/r.h()<=1.2):
       
                     green.append(r.y())
                     green.append(r.y()-r.h()/2)
       
                 elif(0.5<=r.w()/r.h()<0.8):
       
                     green.append(r.y())
                     green.append(r.y()-2*r.h()/3)
                     green.append(r.y()-r.h()/3)
       
             if 44<statistics.l_mode()<55 and -30<statistics.a_mode()<-5 and -24<statistics.b_mode()<0:
       
                 img.draw_rectangle(area, color = (255, 0, 0))
                 if 1.8<=r.w()/r.h()<=2.2:
       
                     blue.append(r.y())
       
                 elif(0.8<=r.w()/r.h()<=1.2):
       
                     blue.append(r.y()-r.h()/2)
                     blue.append(r.y())
       
                 elif(0.5<=r.w()/r.h()<0.8):
       
                     blue.append(r.y())
                     blue.append(r.y()-2*r.h()/3)
                     blue.append(r.y()-h/3)
       
         l1=len(red)
         l2=len(green)
         l3=len(blue)
         i=0
         while i<l1:
            shit.append(red[i])
            order.append(3)
            i=i+1
         while i<(l1+l2):
       
             shit.append(green[i-l1])
             order.append(1)
             i=i+1
       
         while i<(l1+l2+l3):
       
             shit.append(blue[i-l1-l2])
             order.append(2)
             i=i+1
       
         i=0
         n=0
         print('red')
         print(red)
         while len(shit)<6:
       
             shit.append(0)
             order.append(0)
             n=n+1
       
          for i in range(5):
             for j in range(5-i):
                 if shit[j]>shit[j+1]:
       
                     shit[j],shit[j+1]=shit[j+1],shit[j]
                     order[j],order[j+1]=order[j+1],order[j]
       
       
       
         print(order)
      
      发布在 OpenMV Cam
      M
      mi62
    • RE: 图中有两个红色物体,怎么把他们的横坐标分别赋值给两个变量?

      可是当我识别红色色块的时候,两个色块的值是一起出来的,分不清哪个是哪个,就没办法赋值

      发布在 OpenMV Cam
      M
      mi62
    • 图中有两个红色物体,怎么把他们的横坐标分别赋值给两个变量?

      ……………
      ……………

      发布在 OpenMV Cam
      M
      mi62
    • 三个矩形色块从上往下排列,其中有两红一绿,如何判断三个色块的顺序?
      请在这里粘贴代码
      
      发布在 OpenMV Cam
      M
      mi62