IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    用opencv检查是否为白纸

    coder4发表于 2023-04-27 09:47:24
    love 0
    def check_blank_image(file): img = cv2.imread(file) if img is None: return False # grary img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # threshold to two value image ret,thresh = cv2.threshold(img, 127, 255,cv2.THRESH_BINARY) # white % nonzero = np.count_nonzero(thresh) all = thresh.size return (nonzero / float(all)) > 0.99 解释下:先转灰度,再做二值化,然后判断白色占比


沪ICP备19023445号-2号
友情链接