Skip to content

Instantly share code, notes, and snippets.

"""
Usage: python scaled_template_matching_multi.py --template tmp.jpg --image img.jpg
Installation:
pip install opencv-contrib-python numpy imutils
https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html#template-matching-with-multiple-objects
https://stackoverflow.com/questions/49464639/opencv-matchtemplate-threshold-values-for-different-methods
"""
import glob
@cheng10
cheng10 / scaled_template_matching.py
Last active July 22, 2020 15:37
Template Matching using Python and OpenCV with the Help of Scaling
"""
Usage: python scaled_template_matching.py --template tmp.jpg --image img.jpg
Installation: 
pip install opencv-contrib-python numpy imutils
blog post about this scale image & cv2.matchTemplate method:
https://www.pyimagesearch.com/2015/01/26/multi-scale-template-matching-using-python-opencv/
"""
import glob
@cheng10
cheng10 / vscode config
Last active February 1, 2019 08:40
.vscode
{
"python.venvPath": "~/.venvs",
"python.linting.pylintEnabled": false,
"python.pythonPath": "/Users/cheng/.venvs/offer/bin/python",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"editor.rulers": [80],
"html.format.wrapLineLength": 80,
@cheng10
cheng10 / setup_ubuntu_dev.sh
Last active January 28, 2019 07:25
setup_ubuntu_dev.sh
#! /bin/sh
# basic package
sudo apt-get update
sudo apt install -y vim git htop curl wget zsh byobu mysql-server terminator
# setup git
git config --global user.name cheng10
git config --global user.email cheng10@ualberta.ca
git config --global core.editor vim
@cheng10
cheng10 / china_ip_direct.pac
Last active January 10, 2019 09:26
china_ip_direct.pac
var PROXY = 'SOCKS5 127.0.0.1:8387;SOCKS 127.0.0.1:8387';
var CHINA_IPv4 = [
['1.12.0.0', '255.252.0.0'],
['1.24.0.0', '255.248.0.0'],
['1.45.0.0', '255.255.0.0'],
['1.48.0.0', '255.252.0.0'],
['1.56.0.0', '255.248.0.0'],
['1.68.0.0', '255.252.0.0'],
['1.80.0.0', '255.240.0.0'],
['1.116.0.0', '255.252.0.0'],
@cheng10
cheng10 / start a second redis with systemctl on centos7.txt
Last active July 22, 2020 15:34
start a second redis with systemctl on centos7
1. get default redis.service path
[centos@offertest ~]$ sudo systemctl status redis
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since Thu 2018-05-03 07:55:48 UTC; 2h 7min ago
Main PID: 4990 (redis-server)
@cheng10
cheng10 / django FilteredSelectMultiple widget
Last active May 2, 2018 03:38
django FilteredSelectMultiple widget
# forms.py
from django.contrib.auth.models import User
from django import forms
from django.contrib.admin.widgets import FilteredSelectMultiple
class AdvertiserAdminForm(forms.ModelForm):
user = forms.ModelMultipleChoiceField(
required=False,
queryset=User.objects.all(),