Добавлено описание и документация для HVideoTool, включая функционал, требования, установку и запуск приложения для обнаружения цензуры на изображениях.

This commit is contained in:
Leonid Pershin
2026-06-06 15:11:53 +03:00
parent 10bf87aa47
commit 33f20fe681
28 changed files with 2256 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Unicode-safe image read/write.
``cv2.imread``/``cv2.imwrite`` mishandle non-ASCII paths on Windows. These
helpers go through ``np.fromfile``/``ndarray.tofile`` + ``imdecode``/``imencode``
so paths with Cyrillic (etc.) work regardless of the system locale.
"""
from __future__ import annotations
import os
import cv2
import numpy as np
def imread_unicode(path: str) -> np.ndarray | None:
try:
data = np.fromfile(path, dtype=np.uint8)
except OSError:
return None
if data.size == 0:
return None
return cv2.imdecode(data, cv2.IMREAD_COLOR)
def imwrite_unicode(path: str, image: np.ndarray, params: list[int] | None = None) -> bool:
ext = os.path.splitext(path)[1] or ".jpg"
ok, buf = cv2.imencode(ext, image, params or [])
if not ok:
return False
buf.tofile(path)
return True