左右铺开的图呗 Python

import cv2
import numpy
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
import uuid




def equalHist(img):
    # img = cv.imread('/UsersPycharmProjects/ImageProcess/a_Server/img.png',0)

    path = '/Users/PycharmProjects/ImageProcess/a_Server/'+str(uuid.uuid4())+'.png'

    equ = cv.equalizeHist(img)


    # 9.23-----____——————————————
    res = np.hstack((img,equ))
    # 9.23-----____——————————————





    # cv.imwrite('res.png',res)
    # return 'res.png'


    cv.imwrite(path,equ)

    # 在这里序列化图片
    import pickle
    import base64
    # 读取图片
    with open(path, 'rb') as image_file:
        image_data = image_file.read()
    # 序列化图片
    # img = cv2.imread(imagePath)


    serialized_image = base64.b64encode(pickle.dumps(image_data)).decode('utf-8')



    # 存储或传输序列化后的图片

    # serialized_image = base64.b64encode(pickle.dumps(image_data))

    # return path
    return serialized_image



# if __name__=='__main__':
#     img = cv.imread('/Users/PycharmProjects/ImageProcess/a_Server/img.png',0)
#
#     equalHist(img)

你可能感兴趣的:(opencv,人工智能,计算机视觉)