Skip to content

Instantly share code, notes, and snippets.

View ufxpri's full-sized avatar
🗨️
work with ai

조승준 ufxpri

🗨️
work with ai
View GitHub Profile
@ufxpri
ufxpri / Ed25519_PoC.py
Last active May 26, 2023 02:27
pynacl reuse private_key for later use (Ed25519)
# 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)
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,))
@ufxpri
ufxpri / client.py
Last active June 7, 2022 06:49
client side thread pool execute POC
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"
@ufxpri
ufxpri / klv_stream_player.py
Created June 3, 2022 04:38
play klv stream with ffmpeg and klvdata
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"]
@ufxpri
ufxpri / python_pillow_exif.py
Created May 19, 2022 06:19
get exif data from image using pillow
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:
@ufxpri
ufxpri / video_memory_sharer.py
Last active May 12, 2022 08:52
python shared memory video transfer
from multiprocessing.shared_memory import SharedMemory
import cv2
# import time
import numpy as np
video_source = 'rtsp://admin:1234qwer!@192.168.50.51/ch1/stream1'
cap = cv2.VideoCapture(video_source)
ret, frame = cap.read()
if not ret: raise Exception("Failed to read video source")