Skip to content

Instantly share code, notes, and snippets.

@sepfy
sepfy / util.py
Created April 19, 2019 05:35
Preprocess image for Tensorflow
import cv2
import numpy as np
import os
def load_images(image_dir):
batch = np.empty((0, 224, 224, 3), dtype=np.float32)
for image_name in os.listdir(image_dir)[:]:
img_path = image_dir + "/" + image_name
@sepfy
sepfy / Makefile
Last active March 24, 2019 05:29
Share opencv image data in Linux
all:
g++ server.cc -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio -o server
g++ client.cc -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio -o client
@sepfy
sepfy / H264 format
Created March 23, 2019 15:52
Study for rtmp streaming
H264包含多個NAL Unit
NAL Unit:
由 00 00 00 01開頭, 分為SPS, PPS, IFrame與PFrame
通常h264檔案內容會以SPS PPS IFrame...的方式排序
00 00 00 01接著是NAL Unit的類型, 可以用來判斷一個NAL Unit的類型
67: SPS
68: PPS
65: IFrame
@sepfy
sepfy / x509-cmd
Last active March 8, 2019 03:53
x.509 with OpenSSL
# Generate root CA
openssl req -newkey rsa:2048 -nodes -keyout root-key.pem -x509 -days 365 -out root-ca.pem
# Generate leaf CSR
openssl req -new -newkey rsa:2048 -nodes -keyout leaf-key.pem -out leaf-csr.pem
# Generate leaf CA
openssl x509 -req -days 3650 -in leaf-csr.pem \
-CA root-ca.pem -CAkey root-key.pem \
-CAcreateserial -out leaf-ca.pem
@sepfy
sepfy / AWS Kinesis
Last active January 25, 2019 08:49
For AMD64 testing
FROM amd64/ubuntu:xenial
MAINTAINER courant
RUN apt-get update -y
RUN apt-get install -y git g++ cmake curl pkg-config python libtool libtool-bin automake flex bison
RUN git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
RUN cd /amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build && echo "y" | ./install-script
@sepfy
sepfy / Dockerfile.aarch64
Last active January 28, 2019 01:32
Dockerfile for OpenCV3.4
FROM arm64v8/ubuntu:xenial
MAINTAINER courant
RUN apt-get update -y
RUN apt-get install -y build-essential checkinstall -y cmake pkg-config yasm \
libjpeg8-dev libjasper-dev libpng12-dev \
libtiff5-dev \
libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev \
libxine2-dev libv4l-dev \