2024-10-12 11:57:24 +00:00
|
|
|
#encoding = utf8
|
2024-10-22 11:57:30 +00:00
|
|
|
import copy
|
2024-10-23 09:44:33 +00:00
|
|
|
import time
|
2024-10-22 11:57:30 +00:00
|
|
|
from queue import Empty
|
2024-10-25 00:23:55 +00:00
|
|
|
from enum import Enum
|
2024-10-22 11:57:30 +00:00
|
|
|
|
|
|
|
import cv2
|
|
|
|
import numpy as np
|
|
|
|
|
2024-10-23 09:44:33 +00:00
|
|
|
from .base_render import BaseRender
|
2024-10-25 00:23:55 +00:00
|
|
|
from human.message_type import MessageType
|
2024-10-12 11:57:24 +00:00
|
|
|
|
|
|
|
|
2024-10-22 11:57:30 +00:00
|
|
|
class VideoRender(BaseRender):
|
|
|
|
def __init__(self, play_clock, context, human_render):
|
2024-11-05 11:40:03 +00:00
|
|
|
super().__init__(play_clock, context, 'Video')
|
2024-10-22 11:57:30 +00:00
|
|
|
self._human_render = human_render
|
|
|
|
|
2024-11-04 05:40:05 +00:00
|
|
|
def render(self, frame, ps):
|
|
|
|
res_frame, idx, type_ = frame
|
|
|
|
|
|
|
|
if type_ == 0:
|
|
|
|
combine_frame = self._context.frame_list_cycle[idx]
|
|
|
|
else:
|
|
|
|
bbox = self._context.coord_list_cycle[idx]
|
|
|
|
combine_frame = copy.deepcopy(self._context.frame_list_cycle[idx])
|
|
|
|
y1, y2, x1, x2 = bbox
|
|
|
|
try:
|
|
|
|
res_frame = cv2.resize(res_frame.astype(np.uint8), (x2 - x1, y2 - y1))
|
|
|
|
except:
|
|
|
|
print('resize error')
|
|
|
|
return
|
|
|
|
combine_frame[y1:y2, x1:x2, :3] = res_frame
|
|
|
|
|
|
|
|
image = combine_frame
|
|
|
|
# image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
|
|
|
if self._human_render is not None:
|
|
|
|
self._human_render.put_image(image)
|