Skip to content

Commit

Permalink
ADD: cv2 example
Browse files Browse the repository at this point in the history
  • Loading branch information
desty2k committed Jul 5, 2021
1 parent 75c1d9a commit 01fcde2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
23 changes: 23 additions & 0 deletions example/cv2/cv2_example.py
@@ -0,0 +1,23 @@
"""
Use `python cv_dump.py` to create json file.
Uninstall opencv-python before running this script.
"""

import paker
import logging
import numpy as np

file = "cv2.json"
logging.basicConfig(level=logging.NOTSET)

if __name__ == '__main__':
# read psutil code from json and load it using paker
with open(file, "r") as f:
with paker.load(f) as loader:
import cv2

black = np.zeros([200, 250, 1], dtype="uint8")
cv2.imshow("Black", black)

cv2.waitKey(0)
cv2.destroyAllWindows()
10 changes: 10 additions & 0 deletions example/cv2/cv_dump.py
@@ -0,0 +1,10 @@
"""
Use this script to dump cv2 to JSON file.
Make sure that opecv-python is installed.
"""

import cv2
import paker

with open("cv2.json", "w+") as f:
paker.dump(cv2, f)
2 changes: 1 addition & 1 deletion example/dill/dill_example.py
Expand Up @@ -24,7 +24,7 @@ class SerializableClass:
print("Serialized object is {}".format(dilled))
print("Deserialized object is {}".format(dill.loads(dilled)))

# import will throw error dill has been unloaded
# import will throw error
try:
import dill
except ImportError as f:
Expand Down

0 comments on commit 01fcde2

Please sign in to comment.