Skip to content

Instantly share code, notes, and snippets.

@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;
void qsort(int a[], int l, int r) {
int first, last, key;
first = l; last = r;
key = a[last];
while (first < last) {
while (first<last && a[first]<=key) first++;
a[last] = a[first];
while (first<last && a[last]>=key) last--;
a[first] = a[last];
}
../configure --prefix=/usr/local --mandir=/usr/local/share/man --infodir=/usr/local/share/info --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,fortran --disable-dssi --enable-libgcj-multifile --with-ppl --with-cloog --with-tune=generic --build=x86_64-redhat-linux --with-mpc-include=/usr/local/include --with-mpc-lib=/usr/local/lib --disable-multilib