This file contains 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
template <typename Iterator> | |
typename std::iterator_traits<Iterator>::value_type | |
median(Iterator _start, Iterator _end) | |
{ | |
typedef typename std::iterator_traits<Iterator>::value_type value_t; | |
std::vector<value_t> low; | |
std::vector<value_t> high; | |
high.push_back(*_start); |
This file contains 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 <dirent.h> | |
vector<string> list_dir(const string &path) | |
{ | |
vector<string> result; | |
dirent *pdir; | |
DIR *dir = opendir(path.c_str()); // open current directory | |
while (pdir = readdir(dir)) | |
result.push_back(pdir->d_name); | |
closedir(dir); |
This file contains 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 <ctime> | |
using namespace std; | |
inline std::string date_string() | |
{ | |
time_t rawtime; | |
std::time(&rawtime); | |
struct tm *tinfo = std::localtime(&rawtime); | |
char buffer[12]; |
This file contains 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
string string_format(const string fmt, ...) | |
{ | |
int size = 512; | |
std::string str; | |
va_list ap; | |
while (1) { | |
str.resize(size); | |
va_start(ap, fmt); | |
int n = vsnprintf((char *)str.c_str(), size, fmt.c_str(), ap); |
This file contains 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
def loadmat(filename): | |
''' | |
this function should be called instead of direct spio.loadmat | |
as it cures the problem of not properly recovering python dictionaries | |
from mat files. It calls the function check keys to cure all entries | |
which are still mat-objects | |
''' | |
data = sio.loadmat(filename, struct_as_record=False, squeeze_me=True) | |
return _check_keys(data) |
This file contains 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
map<double, size_t> top; | |
size_t max_size = 100; | |
auto top_add = [&top,max_size](double value, size_t id) | |
{ | |
if (top.size() < max_size) | |
top.insert(make_pair(value, id)); | |
else | |
{ | |
if (top.begin()->first < value) |
This file contains 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
vector<cv::Mat> gradient_histogram(const cv::Mat &M, const cv::Mat &O, int num_channels) | |
{ | |
vector<cv::Mat> channels; | |
double step = 2 * M_PI / num_channels; | |
for (int t = 0; t < num_channels; ++t) | |
{ | |
cv::Mat C; | |
cv::inRange(O, t*step, t*step+1, C); | |
C.convertTo(C, CV_64F); | |
C /= 255.0; |
This file contains 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
inline arma::mat integral_image(const arma::mat &a) | |
{ | |
using namespace arma; | |
mat a_ii = zeros(a.n_rows+1, a.n_cols+1); | |
for (size_t j = 0; j < a.n_rows; ++j) | |
{ | |
double sum = 0.0; | |
for (size_t i = 0; i < a.n_cols; ++i) | |
{ | |
sum += a(j,i); |
This file contains 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
function addressToCoordinates($address) { | |
$BASE_URL = 'http://maps.googleapis.com/maps/api/geocode/json'; | |
$socket = new HttpSocket(); | |
$args = array('address' => $address, | |
'sensor' => 'false'); | |
$results = json_decode($socket->get($BASE_URL, $args)); |
This file contains 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
<?php | |
/** | |
* Application level Controller | |
* | |
* This file is application-wide controller file. You can put all | |
* application-wide controller-related methods here. | |
* | |
* PHP versions 4 and 5 | |
* | |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
OlderNewer