Skip to content

Instantly share code, notes, and snippets.

@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 \
@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 / 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 / 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 / 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 / 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 / lora_play.c
Created May 3, 2019 07:38
Study LoraWAN
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Ref:
// https://www.eebreakdown.com/2017/01/lora-ii.html
// https://lora-alliance.org/sites/default/files/2018-07/lorawan1.0.3.pdf
typedef struct _Personalized {
// DevEUI: 64 bit -> Static
unsigned char DevEUI[8];
// AppEUI: 64 bit -> Static
@sepfy
sepfy / build-armhf-fs.sh
Last active June 27, 2019 09:31
Construct a debian rootfs
#/bin/bash
apt-get install binfmt-support qemu qemu-user-static debootstrap
debootstrap --foreign --arch armhf stretch rootfs http://ftp.debian.org/debian/
cp /usr/bin/qemu-arm-static rootfs/usr/bin
sudo chroot rootfs
LC_ALL=C LANGUAGE=C LANG=C chroot . /debootstrap/debootstrap --second-stage
@sepfy
sepfy / LibusbSerial.py
Created August 21, 2019 06:20
pyusb (libusb) connect to CDC device
import usb.core
import usb.util
import usb.control
import time
import array
import json
# Test by Arduino
VENDER = 0x2341
def mobilenet(inputs):
mobilenet_conv_defs = [
{"kernel": [3, 3], "stride": 1, "depth": 64},
{"kernel": [3, 3], "stride": 2, "depth": 128},
{"kernel": [3, 3], "stride": 1, "depth": 128},
{"kernel": [3, 3], "stride": 2, "depth": 256},
{"kernel": [3, 3], "stride": 1, "depth": 256},
{"kernel": [3, 3], "stride": 2, "depth": 512},
{"kernel": [3, 3], "stride": 1, "depth": 512},
{"kernel": [3, 3], "stride": 1, "depth": 512},