OpenCV除錯圖片視覺化工具
阿新 • • 發佈:2021-02-06
OpenCV除錯圖片視覺化工具
工具一 visual-logging
參考
安裝
pip install visual-logging
使用
# import 庫
from logging import FileHandler
from vlogging import VisualRecord
import logging
import webbrowser
# 初始化記錄器
Imglogger = logging. getLogger("marker_logging")
export_loggingFile = "export_logging.html" # 會在當前目錄建立一個Html檔案
# if os.path.exists(export_loggingFile)is not None:
# os.remove(export_loggingFile)
logfilehandler = FileHandler(export_loggingFile, mode="w")
Imglogger.setLevel(logging.DEBUG)
Imglogger.addHandler(logfilehandler)
# 使用記錄器記錄圖片
Img = cv2.imread('xxx.png', 0)
Imglogger.debug(VisualRecord("src", [Img], fmt="png"))
工具二 opencv-log
參考
安裝
pip install opencv-log
使用
例子:
import cvlog as log
# Set default mode and level
# If we dont set, then default mode is NONE
# and the default level is ERROR
log.set_mode(log.Mode.LOG)
log.set_level(log.Level.TRACE)
img = cv2.imread("sample.png")
# log or show the image or do nothing based on log mode and log level
log.image(log.Level.INFO, img)
# If mode is None, it remain as sleeper cell
# If mode is LOG, it logs image to html file.
# If mode is DEBUG, it shows image in pop window and wait for the key.