Skip to content

Instantly share code, notes, and snippets.

@vbalnt
Created October 16, 2015 12:35
Show Gist options
  • Save vbalnt/650fec5297112d700df1 to your computer and use it in GitHub Desktop.
Save vbalnt/650fec5297112d700df1 to your computer and use it in GitHub Desktop.
#ifndef _UTILS_H_
#define _UTILS_H_
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include "vlfeat/generic.h"
#include "vlfeat/sift.h"
#include "vlfeat/imopv.h"
#include "pgm.h"
/* #include <plplot/plplot.h> */
#include <math.h>
#include <cairo/cairo.h>
#include <unistd.h>
/* dataset related */
typedef struct dataset
{
char *name;
float **patches;
float **smoothed;
int **gt;
int npatches;
} dataset;
void init_dataset(dataset *A,const char *path,const char *nm);
typedef struct bintest
{
int p1;
int p2;
} bintest;
/* BRIEF creation */
void create_brief_tests(bintest *tests,int dims,int patch_size);
void create_brief_tests_g2(bintest *tests,int dims,int patch_size);
/* Bintest methods */
/* void plot_bintests(bintest *tests,int dims,char *fname); */
void fwrite_bintests(bintest *tests,int dims,char *fname);
void fread_bintests(bintest *tests,int dims,char *fname);
/* Get bintest result */
void apply_tests(float *im,bintest *t,int *descr,int d);
/* Distances */
int hamming(int * a, int *b,int d);
/* ORB */
void learn_orb_tests_g1(dataset data,bintest *tests,int dims,int patch_size,int nlearn);
void learn_orb_tests_g2(dataset data,bintest *tests,int dims,int patch_size,int nlearn);
void gen_all_tests(bintest* tests,int n_all,int w);
/* LDA */
void learn_lda_tests(dataset data,bintest *ltests,int dims,int patch_size,int nlearn);
double get_test_fisherQ(dataset data,bintest t);
/* Greedy test choice methods */
double get_test_variance(dataset data,bintest t,int nlearn);
double cmp_data_bitstrings(dataset data,bintest t1,bintest t2,int nlearn);
/* Math stuff */
int nchoosek(int n,int k);
double gauss_rand(float mi, float sigma);
/* Creation of affine descriptors */
void create_descr_aff_matrix(bintest *orig,bintest **affines);
void get_orb_from_patch(float *patch,bintest **tests,int full_dims,int dims,double *mask);
int bold_hamming(int * a, int *b,int *mask,int d_mask);
double L2(float * a, float *b,int d);
/* new methods: instead of affine, learning */
void aff_tests(bintest *orig,bintest aff_tests[10][1024]);
void get_patch_tests(float *im,bintest *tests,bintest aff[10][1024],int *mask);
/* sift */
void get_sift(float* patch,float sift[128],double size);
/* /\* combinatorics *\/ */
/* int ncombs(int n,int k); */
/* int twiddle(int *x, int *y, int *z, int*p); */
/* void inittwiddle(int m, int n, int *p); */
/* int nchoosek(int n,int k); */
void deform_tests(bintest *orig,bintest *deformed,int n);
void get_mask(int *mask,int *descr,int *descrD,int n);
void get_mask2(int *mask,int *descr,int *descrD,int *descrD2,int n);
void rotate_tests(bintest *orig,bintest *rot,double ang,int n_tests);
int mask_card(int *mask,int n);
#endif /* _UTILS_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment