Skip to content

Instantly share code, notes, and snippets.

View blackball's full-sized avatar
🎯
Focusing

Hui blackball

🎯
Focusing
View GitHub Profile
/**
* Fast non-maximum suppression in C, port from
* http://quantombone.blogspot.com/2011/08/blazing-fast-nmsm-from-exemplar-svm.html
*
* @blackball (bugway@gmail.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
@blackball
blackball / tips_recods.c
Created March 12, 2012 03:56
record tips used or saw in dailylife
// 0.有时候,我们需要在两个不同的值之间切换,类似于开关。普遍的做法是:
if (t == value0) {
t = value1;
} else {
t = value0;
}
// 条件分支是一个开销相对较大的操作,所以,另外一种高效的做法是:
t = value0 + value1 - t;
// 为了避免value0或者value1值都较大,可以加上一括号:
t = value0 + (value1 - t);
@blackball
blackball / gsl_rng_mt.h
Created March 8, 2012 14:34
A standalone MT RNG extracted from GSL
/**
* well, I feel it's annoying to configure gsl everytime
* for PF tracking, so, I made a new one according to gsl.:)
* @author blackball @date Feb.12.2011
* @todo this filename is worng, change it to gsl_rng_dist.h
*/
#ifndef _GSL_RNG_MT_H_
#define _GSL_RNG_MT_H_
/**
* Definition of ...MT random number generator
* @author blackball @date Feb.12.2011
**/
#include "gsl_rng_mt.h"
#include <malloc.h>
#include <math.h>
#define N 624
/**
* Binary search tree, a C implementation.
*
* I hope it could be a bit more efficient ;)
*
* @blackball
*/
#include <stdlib.h>
/* for futher use */
/* Simple linked-list demo */
typedef struct node{
void *data;
struct node *next;
struct node *prev;
} node;
node* create(node **ns, void *data);
node* search(node **ns, void *data);
@blackball
blackball / example.c
Created January 4, 2012 04:37
example for vpack
#include "vpack.h"
#include <stdio.h>
struct Model
{
char c;
int pts[4];
float vec[1024];
};
@blackball
blackball / demo.py
Created December 6, 2011 09:04
subprocess
#!/usr/bin/python
"""
Simulate a command pipe in windows.
reason: I always need to do batch processing
in my dailylife, rename a bunch of files,
generate some sets from it, and move files
into different folders. Or, I have a module,
and I need to processing lots of file, but,
this module can only process one at most, and I
//----------.h file ------------
#ifndef MYVIDEOWIDGET_H
#define MYVIDEOWIDGET_H
#include <QtOpenGL/QtOpenGL>
#include <QtGui/QImage>
class MyVideoWidget : public QGLWidget
{
Q_OBJECT
int pack_arr(struct db *dbase, void *data, int len)
{
int code = -1;
struct db_node *node = new_node(len);
memcpy(node->data, data, len);
// insert node into dbase
dump(dbase, node);
code = 0;