Skip to content

Instantly share code, notes, and snippets.

@luoyetx
luoyetx / convelution.py
Last active December 22, 2015 12:29
计算离散卷积
import numpy as np
def conv_m(x, nx, h, nh):
'''计算x与h的卷积,nx与nh为其序列下标范围'''
nyb = nx[0] + nh[0]
nye = nx[-1] + nh[-1]
ny = np.arange(nyb, nye+1)
y = np.convolve(x, h)
return y, ny
@luoyetx
luoyetx / qsort.c
Last active December 25, 2015 22:39
quick sort algorithm
void qsort(int *a, int l, int r)
{
int i, j, mid;
i = l; j = r;
mid = a[(i + j)/2];
do {
while (a[i] < mid) i++;
while (a[j] > mid) j--;
if (i <= j) {
int temp = a[i];
@luoyetx
luoyetx / cached_property.py
Created May 26, 2014 05:09
cached_property
class cached_property(object):
"""A cached property only computed once
"""
def __init__(self, func):
self.func = func
def __get__(self, obj, cls):
if obj is None: return self
value = obj.__dict__[self.func.__name__] = self.func(obj)
return value
@luoyetx
luoyetx / readDir.cpp
Created July 21, 2014 07:21
read Dir
#include <io.h>
/**
* readDir("F://pic", files, "jpg")
*/
bool readDir(string dirPath, vector<string>& files, string extension)
{
long fd;
_finddata_t fileInfo;
string matchPath = dirPath + "/*." + extension;

matio库

使用开源matio库来读取rcpr_COFW.mat文件的矩阵数据。matio的源码可从这里下载

###1.编译matio库

1.下载依赖库zlib和HDF5(windows下编译好的HDF5自带zlib库)。HDF5可以从这里下载,下载预先编译好的动态库版本并进行安装

2.安装完后添加系统变量HDF5_DIR,其值为HDF5的安装目录,例如D:\Program Files (x86)\HDF_Group\HDF5\1.8.13,并将库的bin目录加入系统环境变量PATH中,%HDF5_DIR%\bin

# -*- coding: gbk -*-
# usd on windows
"""
Created on Thu Oct 16 09:14:42 2014
@author: zhangjie
"""
import os
import sys
private void startExplicitActivation() {
Log.i(TAG,"Entered startExplicitActivation()");
// TODO - Create a new intent to launch the ExplicitlyLoadedActivity class
Intent explicitIntent = new Intent(ActivityLoaderActivity.this, ExplicitlyLoadedActivity.class);
// TODO - Start an Activity using that intent and the request code defined above
startActivityForResult(explicitIntent, 0);

###准备编译环境

官方现在只提供了win64的二进制编译,用的opencv2.4.9 Qt5.x.x(不知道Qt的具体版本- -!)

我们使用32位编译,需要一个VC编译器(版本不要太低) 下载Qt5,OpenCV,两者的版本不是很大的问题,opencv自带了32位和64位,而Qt是分开,Qt下载32位。

我们还需要CMake来生成Makefile用来编译。

###下载openbr源码

@luoyetx
luoyetx / filesystem.cpp
Last active August 29, 2015 14:12
跨平台文件系统访问
#ifdef WIN32
// on Windows
#include <io.h>
#include <direct.h>
#else
// on Linux
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#panel {
/*background-color: black;*/
background-color: rgba(0,0,0,0.4);
font-weight: bold;
height: 1.86em;
}
.panel-corner {
/*-panel-corner-radius: 6px;*/
-panel-corner-radius: 0px;