EasyMocap/easymocap/socket/utils.py
2021-06-04 17:12:30 +08:00

23 lines
804 B
Python

'''
@ Date: 2021-05-24 20:07:34
@ Author: Qing Shuai
@ LastEditors: Qing Shuai
@ LastEditTime: 2021-06-04 16:29:35
@ FilePath: /EasyMocapRelease/media/qing/Project/mirror/EasyMocap/easymocap/socket/utils.py
'''
import cv2
import numpy as np
from ..mytools.file_utils import write_common_results
def encode_detect(data):
res = write_common_results(None, data, ['keypoints3d'])
res = res.replace('\r', '').replace('\n', '').replace(' ', '')
return res.encode('ascii')
def encode_image(image):
fourcc = [int(cv2.IMWRITE_JPEG_QUALITY), 90]
#frame을 binary 형태로 변환 jpg로 decoding
result, img_encode = cv2.imencode('.jpg', image, fourcc)
data = np.array(img_encode) # numpy array로 안바꿔주면 ERROR
stringData = data.tostring()
return stringData