41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
from dataclasses import dataclass
|
||
|
|
from typing import Dict
|
||
|
|
|
||
|
|
from entities.rgb_image512 import RgbImage512
|
||
|
|
from entities.label64 import Label64
|
||
|
|
from entities.sequence8 import Sequence8
|
||
|
|
from steg.embedder import Embedder
|
||
|
|
from steg.extractor import Extractor
|
||
|
|
from steg.component_pipeline import ComponentPipeline
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class EmbedMode:
|
||
|
|
"""CLI-режим встраивания метки в изображение."""
|
||
|
|
|
||
|
|
def run(
|
||
|
|
self,
|
||
|
|
input_path: str,
|
||
|
|
label_path: str,
|
||
|
|
output_path: str,
|
||
|
|
channel: str,
|
||
|
|
seq0: str,
|
||
|
|
) -> Dict[str, str]:
|
||
|
|
"""Выполнить встраивание и сохранить результат."""
|
||
|
|
rgb = RgbImage512.from_file(input_path)
|
||
|
|
label = Label64.from_image(label_path)
|
||
|
|
seq = Sequence8.from_string(seq0)
|
||
|
|
|
||
|
|
pipeline = ComponentPipeline(channel=channel, embedder=Embedder(), extractor=Extractor())
|
||
|
|
rgb_out = pipeline.embed_rgb(rgb, label, seq)
|
||
|
|
rgb_out.save(output_path)
|
||
|
|
|
||
|
|
return {
|
||
|
|
"status": "ok",
|
||
|
|
"output": output_path,
|
||
|
|
"channel": channel,
|
||
|
|
"seq0": seq0,
|
||
|
|
}
|