#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2022/4/29 17:22:41

@author: LiuKuan
@copyright: Apache License, Version 2.0
'''
from laok.third_lib import cv2, np
#===============================================================================
'''     
'''
#===============================================================================
__all__ = ['show_img_cv', 'wait_cv']

def show_img_cv(mat, winname='img', winflag = None, title = None,
                need_wait=False, wait_delay=0):
    if winflag is None:
        winflag = cv2.WINDOW_NORMAL

    cv2.namedWindow(winname, winflag)
    if title:
        cv2.setWindowTitle(winname, title)

    if mat.dtype == np.bool: #转换bool 类型
        mat = mat.astype(np.uint8) * 255
    elif mat.dtype != np.uint8:  # 转换 其它类型
        mat = cv2.normalize(mat, None, alpha=0, beta=255,
                            norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8U)

    cv2.imshow(winname, mat)

    if need_wait:
        wait_cv(wait_delay)

def wait_cv(wait_delay=0):
    key = cv2.waitKey(wait_delay)
    if key == 27:  # 'Esc' to quit
        exit()
