mirror of
https://github.com/Refound-445/nonebot-plugin-nailongremove.git
synced 2025-11-04 21:22:43 +08:00
up
This commit is contained in:
parent
4bc0cb168c
commit
e65f3ada15
@ -13,7 +13,7 @@ from nonebot.typing import T_State
|
|||||||
from nonebot_plugin_alconna.builtins.uniseg.market_face import MarketFace
|
from nonebot_plugin_alconna.builtins.uniseg.market_face import MarketFace
|
||||||
from nonebot_plugin_alconna.uniseg import Image, UniMessage, UniMsg, image_fetch
|
from nonebot_plugin_alconna.uniseg import Image, UniMessage, UniMsg, image_fetch
|
||||||
from nonebot_plugin_uninfo import QryItrface, Uninfo
|
from nonebot_plugin_uninfo import QryItrface, Uninfo
|
||||||
from PIL import Image as PilImage
|
from PIL import Image as PilImage, ImageSequence
|
||||||
|
|
||||||
from .config import config
|
from .config import config
|
||||||
from .model import CheckResultTuple, check_image
|
from .model import CheckResultTuple, check_image
|
||||||
@ -24,18 +24,10 @@ T = TypeVar("T")
|
|||||||
|
|
||||||
def transform_image(image_data: bytes) -> Iterator[np.ndarray]:
|
def transform_image(image_data: bytes) -> Iterator[np.ndarray]:
|
||||||
image = PilImage.open(io.BytesIO(image_data))
|
image = PilImage.open(io.BytesIO(image_data))
|
||||||
image = image.convert("RGB")
|
for frame in ImageSequence.Iterator(image):
|
||||||
|
image_array = np.array(frame.convert("RGB"))
|
||||||
def process_frame(index: int = 0) -> np.ndarray:
|
image_array = cv2.cvtColor(image_array, cv2.COLOR_RGB2BGR)
|
||||||
image.seek(index)
|
yield image_array
|
||||||
image_array = np.array(image)
|
|
||||||
# 转换为BGR格式
|
|
||||||
if len(image_array.shape) == 3 and image_array.shape[2] == 3:
|
|
||||||
image_array = cv2.cvtColor(image_array, cv2.COLOR_RGB2BGR)
|
|
||||||
return image_array
|
|
||||||
|
|
||||||
frame_num: int = getattr(image, "n_frames", 1)
|
|
||||||
yield from (process_frame(i) for i in range(frame_num))
|
|
||||||
|
|
||||||
|
|
||||||
def judge_list(lst: Iterable[T], val: T, blacklist: bool) -> bool:
|
def judge_list(lst: Iterable[T], val: T, blacklist: bool) -> bool:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user