Skip to content

Instantly share code, notes, and snippets.

@hfeeki
hfeeki / imgcompare.py
Last active September 8, 2022 01:11
利用opencv做图片相似度比较
# coding: utf8
'''
对于图片相似度比较有很多方法,我们这以RGB直方图为例。
我们以一种规则,使得每个图片生成一组描述的特征向量。
opencv的直方图比较函数我们可以巧妙的利用,其有若干比较规则,但只支持直方图的数据结构,我们可以将特征向量拟合成直方图的数据结构,然后使用其的相似度比较函数。
具体的数学计算方法有兴趣的可以看opencv的官方教程,这里我们期望生成百分比形式的相似度参数,所以使用CV_COMP_CORREL
以下是代码,以python编写
'''
import cv2.cv as cv
@hfeeki
hfeeki / add_git_user.sh
Created December 25, 2013 04:02
Create a git user
#Create git user account
sudo adduser --shell $(which git-shell) --gecos 'git version control' --disabled-password git
sudo addgroup developers
#Add git user to the appropriate groups
sudo usermod -a -G www-data git
sudo usermod -a -G developers git
#Setup authorized_keys file for access
@hfeeki
hfeeki / console.py
Created January 18, 2014 06:00
How to get console window width in python
import os
import fcntl, termios, struct, os
def getTerminalSize():
env = os.environ
def ioctl_GWINSZ(fd):
try:
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,'1234'))
except:
return
@hfeeki
hfeeki / build_erlang_wx.sh
Created February 28, 2014 01:54
Use kerl to build erlang with observer
# sudo apt-get install libwxgtk2.8-dev
# install erlang observer
KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --enable-shared-zlib --enable-dynamic-ssl-lib --enable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --with-wx"
kerl build R16B02 r16b02.wx
kerl install r16b01.wx ~/erlang/r16b02wx
erl -s observer start
@hfeeki
hfeeki / screencap.go
Last active February 3, 2020 08:12
golang use import command from imagemagick to capture screen (should work on a platform that can run imagemagick) on ubuntu
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
)
func main() {
@hfeeki
hfeeki / install_rabbitmq.sh
Last active August 13, 2019 00:56
Use rabbitmq's apt repository to install rabbitmq for ubuntu
# maybe need to stop the rabbit server first
# invoke-rc.d rabbitmq-server stop
# sudo echo "deb http://www.rabbitmq.com/debian/ testing main" >> /etc/apt/sources.list # this line will cause error
cd
mkdir temp
cd temp
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
@hfeeki
hfeeki / install_protobuf_c.sh
Created February 17, 2014 05:43
install protobuf-c in ubuntu 12.04
sudo apt-get install protobuf-compiler libprotobuf-dev libprotoc-dev
git clone https://github.com/protobuf-c/protobuf-c
cd protobuf-c
./autogen.sh
make
sudo make install
@hfeeki
hfeeki / build_openbr.sh
Last active August 26, 2016 01:16
Build openbr in ubuntu
# Install GCC 4.7.3
sudo apt-add-repository ppa:ubuntu-sdk-team/ppa
sudo apt-get update
sudo apt-get install -y build-essential
# Install CMake 2.8.10.1
sudo apt-get install -y cmake cmake-curses-gui
wget http://netcologne.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.5/opencv-2.4.5.tar.gz
tar -xf opencv-2.4.5.tar.gz
@hfeeki
hfeeki / install_qt5.sh
Created January 20, 2014 12:53
Install qt 5 in ubuntu
sudo apt-get install -y build-essential
sudo apt-get install -y mesa-common-dev
wget http://download.qt-project.org/official_releases/qt/5.0/5.0.2/qt-linux-opensource-5.0.2-x86-offline.run
chmod +x qt-linux-opensource-5.0.2-x86-offline.run
./qt-linux-opensource-5.0.2-x86-offline.run
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost