Skip to content

Commit

Permalink
update 新增AclliteImage转cv2 Image
Browse files Browse the repository at this point in the history
  • Loading branch information
jadehh committed Dec 6, 2022
1 parent eb92d18 commit 6e35085
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion acllite/acllite_image.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import numpy as np
from PIL import Image

import acl
import acllite.acllite_utils as utils
import acllite.acllite_logger as acl_log
import acllite.constants as const
import cv2

class AclLiteImage(object):
"""Image data and operation class
Expand Down Expand Up @@ -199,6 +199,12 @@ def save(self, filename):
image_np = self.byte_data_to_np_array()
image_np.tofile(filename)


def jpeg_to_cv2(self):
image_np = self.byte_data_to_np_array()
img_cv = cv2.imdecode(np.frombuffer(image_np, np.uint8), cv2.IMREAD_ANYCOLOR)
return img_cv

def destroy(self):
"""Release image memory"""
if (self._data is None) or (self.size == 0):
Expand Down

0 comments on commit 6e35085

Please sign in to comment.