导航

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

    ws3g 发布的帖子

    • RE: 模块化以后,当我想要在主函数里面打印函数的返回值的时候,图片会一卡一卡的,是运算量太大的问题吗?

      刚刚又发现不打印返回值也会一卡一卡的了

      发布在 OpenMV Cam
      W
      ws3g
    • 模块化以后,当我想要在主函数里面打印函数的返回值的时候,图片会一卡一卡的,是运算量太大的问题吗?

      其中模块的代码

      import sensor, image, time,pyb
      def find_red_blob(count_flag):
          red_threshold=(1, 53, 4, 127, 127, 10)
          sensor.reset()
          sensor.set_pixformat(sensor.RGB565)
          sensor.set_framesize(sensor.QQVGA)
          sensor.skip_frames(10)
          sensor.set_auto_gain(False)
          sensor.set_auto_whitebal(False)
          clock = time.clock()
          count=0
          while(True):
              count+=1
              number=0
              img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0)
              red_blob1 = img.find_blobs([red_threshold],roi=(53,0,45,30))
              red_blob2 = img.find_blobs([red_threshold],roi=(0,40,45,30))
              red_blob3 = img.find_blobs([red_threshold],roi=(53,40,45,30))
              red_blob4 = img.find_blobs([red_threshold],roi=(106,40,45,30))
              red_blob5 = img.find_blobs([red_threshold],roi=(53,80,45,30))
              if red_blob1!=[]:
                  img.draw_rectangle(red_blob1[0][0:4])
                  img.draw_cross(red_blob1[0][5], red_blob1[0][6])
                  number+=1
              if red_blob2!=[]:
                  img.draw_rectangle(red_blob2[0][0:4])
                  img.draw_cross(red_blob2[0][5], red_blob2[0][6])
                  number+=1
              if red_blob3!=[]:
                  img.draw_rectangle(red_blob3[0][0:4])
                  img.draw_cross(red_blob3[0][5], red_blob3[0][6])
                  number+=1
              if red_blob4!=[]:
                  img.draw_rectangle(red_blob4[0][0:4])
                  img.draw_cross(red_blob4[0][5], red_blob4[0][6])
                  number+=1
              if red_blob5!=[]:
                  img.draw_rectangle(red_blob5[0][0:4])
                  img.draw_cross(red_blob5[0][5], red_blob5[0][6])
                  number+=1
              #print(number)
              if count>count_flag:
                  break
              return number
      主函数的代码:
      import sensor, image, time
      import black_blob,red_blob
      while(True):
          
          #print(clock.fps())              # Note: OpenMV Cam runs about half as fast when connected
          red_blob.find_red_blob(1000) 
          #black_blob.find_black_blob(1000,0,0)
          a=red_blob.find_red_blob(1000)
          #print(a)
      
      发布在 OpenMV Cam
      W
      ws3g