Skip to content

Instantly share code, notes, and snippets.

View yjxiong's full-sized avatar
💒
Working from home

yjxiong

💒
Working from home
View GitHub Profile
@yjxiong
yjxiong / pnp.py
Last active February 3, 2024 03:32
SolvePnP for Head Pose Estimation
"""
Light weight head pose estimation with SolvePnP
Author: Yuanjun Xiong
"""
# parameters
fx = 1
# model points
@yjxiong
yjxiong / OpenCV.sh
Created July 7, 2016 04:03
Install OpenCV with ffmpeg and CUDA
version="2.4.12"
echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"

To use OpenCV's VideoWriter class to write an H264 encoded video, one would encounter some error like

Could not open codec libx264: unspecified error

Here is the trick. Beforehand, one has to make sure

  • --enable-libx264 is switched on in ffmpeg
  • OpenCV is downloaded in sources.
__author__ = 'Yuanjun Xiong'
"""
This script will transform an image based Caffe model to its optic flow ready form
The basic approach is to average the three channels of the first set of convolution filters.
Averaged filters are then replicated K times to incorporate K input frames of optical flow maps.
Refer to "Towards Good Practices for Very Deep Two-Stream ConvNets" for more details.
======================================================================
Usage:
python build_flow_network.py <caffe root> <first layer name> <image model prototxt> <image model weights> <flow model prototxt> <flow model weights[out]>
@yjxiong
yjxiong / 1 - WIDER Baseline CNN.md
Last active November 14, 2018 00:14
The model spec for the baseline CNN Model on WIDER dataset

This gist holds the model spec for the baseline CNN model on the WIDER dataset.

The CNN structure is AlexNet. Network parameters are initialized using a model pretrained on ImageNet.

The weights can be downloaded at

cuhk_wider_baseline_cnn.caffemodel

Please refer to

This gist holds the Caffe style model spec for the CVPR'15 paper

Recognize Complex Events from Static Images by Fusing Deep Channels

The model has two channels, one for appearance analysis, the other one for detection bounding box analysis.

The appearcance analysis channel has the similar structure of the AlexNet and thus is initialized using a model pretrained on ImageNet.


@yjxiong
yjxiong / tracking.py
Created August 14, 2018 04:36
Sample code for tracking
import cv2
import sys
(major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')
assert minor_ver >= 2, "Must use opencv 3.2.x up"
if __name__ == '__main__' :
# Set up tracker.
# Instead of MIL, you can also use
@yjxiong
yjxiong / dummyfig.tex
Created November 13, 2016 13:31 — forked from dpgettings/dummyfig.tex
Fancy placeholder figures in LaTeX
%% This part goes in preamble
\newcommand{\dummyfig}[1]{
\centering
\fbox{
\begin{minipage}[c][0.33\textheight][c]{0.5\textwidth}
\centering{#1}
\end{minipage}
}
}
@yjxiong
yjxiong / run.sh
Last active April 4, 2016 08:20
Download youtube videos in best format
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' \
--merge-output-format mp4 \
"http://www.youtube.com/watch?v=P9pzm5b6FFY"
# This command downloads the best available quality video together with the best audio. Then it combines them with the post-processor.
@yjxiong
yjxiong / nltk_word_extract.py
Created October 13, 2015 04:06
use NLTK to do word extraction
__author__ = 'alex'
# from pyspark import SparkContext, SparkConf
import nltk
from nltk.corpus import stopwords
sw = stopwords.words('english')
tk = nltk.tokenize.WordPunctTokenizer()