2024-05-28 15:22:11 +08:00
|
|
|
import cv2
|
2024-06-26 11:15:24 +08:00
|
|
|
|
2024-05-28 15:22:11 +08:00
|
|
|
from .builder import ITEMS
|
|
|
|
|
from .pipelines import Compose
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ITEMS.register_module()
|
|
|
|
|
class Body(object):
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
|
pipeline = [
|
|
|
|
|
dict(type='LoadBodyImageFromFile', body_path=kwargs['body_path']),
|
|
|
|
|
# dict(type='ImageShow', key=['body_image', "body_mask"])
|
|
|
|
|
]
|
|
|
|
|
self.pipeline = Compose(pipeline)
|
|
|
|
|
self.result = dict()
|
|
|
|
|
|
|
|
|
|
def process(self):
|
|
|
|
|
self.pipeline(self.result)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def organize(self, layer):
|
|
|
|
|
body_layer = dict(priority=0,
|
|
|
|
|
name=type(self).__name__.lower(),
|
|
|
|
|
image=self.result['body_image'],
|
|
|
|
|
image_url=self.result['image_url'],
|
|
|
|
|
mask_image=None,
|
|
|
|
|
mask_url=None,
|
|
|
|
|
sacle=1,
|
|
|
|
|
# mask=self.result['body_mask'],
|
|
|
|
|
position=(0, 0))
|
|
|
|
|
layer.insert(body_layer)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def show(img):
|
|
|
|
|
cv2.imshow('', img)
|
|
|
|
|
cv2.waitKey(0)
|