This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// For modules that we care about the memory safety, we should never allow user | |
/// to have a way to access the memory directly. In this case, handle will be a | |
/// more useful tool. But in order to use handle safely, some tricks required. | |
/// Here I try to make an example of using handle to design simple API. | |
/// NOTE: for now we assume all codes will only be ran in single-thread, MT | |
// could be enabled easily though. | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
# | |
# http://marc-b-reynolds.github.io/math/2018/06/21/SFPoints4ET.html | |
import numpy as np | |
""" | |
// constant turning rate: | |
// TX = cos(2pi K) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import cv2 | |
import numpy as np | |
def GetNeighbors(r, c, A, B, C): | |
# 1 2 3 | |
# 4 5 6 | |
# 7 8 9 | |
n = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)] | |
neighbors = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "paraknn.h" | |
#define SIFTDIM 128 | |
// need AVX2 + FMA, compiler options: -march=native -O3 | |
static inline float | |
_Distance2_SIFT128(const float *va, const float *vb) { | |
__m256 zmm= _mm256_set1_ps(0.f), amm, bmm; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download full circle magazines. | |
# This script are copied from some where else. | |
from os.path import basename | |
from urlparse import urlsplit | |
import urllib2 | |
def url2name(url): | |
return basename(urlsplit(url)[2]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "aligned-mem.h" | |
#include <stdlib.h> | |
void * | |
aligned_malloc(size_t sz, size_t align) { | |
if (align & (align-1)) | |
return 0; | |
void *m = malloc(sz + align + sizeof(void *)); | |
void **p = (void **)((size_t)(m + align + sizeof(void*)) & ~(align-1)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Codes to show the 'uniform pattern' of LBP | |
#include <stdio.h> | |
typedef unsigned char uint8_t; | |
#define BIT_AT(v, pos) (((v) >> (pos)) & 1) | |
static int | |
numOfTran(uint8_t v) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implement a min binary heap class for scalar type. | |
*/ | |
#ifndef MHEAP_H | |
#define MHEAP_H | |
#include <vector> | |
#include <assert.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple warpper for Capture in C++. | |
* | |
* @blackball | |
*/ | |
#ifndef OPENCV_CAP_H | |
#define OPENCV_CAP_H | |
#include <opencv/cv.h> |
NewerOlder