This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # based on this document (https://pynacl.readthedocs.io/en/latest/signing/) | |
| from nacl.signing import SigningKey | |
| from nacl.encoding import Base64Encoder | |
| # generate key pair | |
| signing_key = SigningKey.generate() | |
| signed_1 = signing_key.sign(b"test text toat") | |
| public_key_1 = signing_key.verify_key.encode(encoder=Base64Encoder) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def to_numpy(im:Image): | |
| im.load() | |
| e = Image._getencoder(im.mode, 'raw', im.mode) | |
| e.setimage(im.im) | |
| # NumPy buffer for the result | |
| shape, typestr = Image._conv_type_shape(im) | |
| data = np.empty(shape, dtype=np.dtype(typestr)) | |
| mem = data.data.cast('B', (data.data.nbytes,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import grpc | |
| from concurrent.futures import ThreadPoolExecutor | |
| from protos import threadpooltask_pb2 as pb2 | |
| from protos import threadpooltask_pb2_grpc as pb2_grpc | |
| MAX_WORKERS = 100 | |
| IP_PORT = "0.0.0.0:20000" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ffmpeg # https://github.com/kkroening/ffmpeg-python # pip3 install ffmpeg-python | |
| import klvdata # https://github.com/paretech/klvdata # pip3 install klvdata | |
| import cv2 | |
| import numpy as np | |
| stream_path = "klv_stream_sample.ts" | |
| probe = ffmpeg.probe(stream_path) | |
| video_streams = [stream for stream in probe['streams'] if stream['codec_type'] == "video"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from PIL import Image, ExifTags | |
| image = Image.open("./sample.JPG") | |
| exif = image._getexif() | |
| exif_dict = {} | |
| for key, value in exif.items(): | |
| if key in ExifTags.TAGS: | |
| exif_dict[ExifTags.TAGS[key]] = value | |
| else: |