Skip to content

Instantly share code, notes, and snippets.

@berak
berak / gist:9907a116f514022d4fcd
Last active August 26, 2015 06:01
svm trainAuto test
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main(int argc, char **argv)
{
cv::Mat trainingData, trainingLabels;
vector<String> fn;
import org.opencv.core.*;
import org.opencv.imgproc.*;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.videoio.*;
class SimpleSample {
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
//~ static int fcc(char a, char b, char c, char d) {
//~ return (d<<24 | c<<16 | b<<8 | a);
@berak
berak / gist:9830239
Last active August 29, 2015 13:57
missing cv::createLBPHFaceRecognizer() code for java/jni wrap
//
// facerec.cpp, this goes into your dll/so.
// this is just an example for lbp, but it will work similar for fisher and eigen, too.
//
#include "jni.h"
#include "opencv2/contrib/contrib.hpp"
//
int tv=13;
namedWindow("win1");
createTrackbar("win1","win1",&tv,100);
Mat img(400,400,CV_8UC3,Scalar(200,80,80));
while(1)
{
Mat m2 = img.clone();
// do something with tv:
m2 += Scalar::all(tv);
@berak
berak / msbp
Created December 4, 2014 07:56
#include <opencv2/opencv.hpp>
using namespace std;
#include <cstdio>
#include <iostream>
using namespace cv;
//
//
// "Multimode Spatiotemporal Background Modeling for Complex Scenes"
@berak
berak / gist:615702b399a05f79fb89
Last active August 29, 2015 14:14
restricted face compare
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
//
// try to find a frontal face 1st, if that fails, fall back to profile
//
@berak
berak / gen_matlab.py
Created June 3, 2015 05:09
matlab wrapper
#!/usr/bin/env python
import sys, re, os, time
from string import Template
from parse_tree import ParseTree, todict, constants
from filters import *
class MatlabWrapperGenerator(object):
"""
MatlabWrapperGenerator is a class for generating Matlab mex sources from
a set of C++ headers. MatlabWrapperGenerator objects can be default
@berak
berak / gist:b16ad1238035f5054208
Created June 7, 2015 13:49
opencv c-api wrapper
;try this ;)
void* cv_createFisherFaceRecognizer(int num_components, double threshold)
{
typedef Ptr<FaceRecognizer> ptr_fr;
ptr_fr _retval_ = cv::createFisherFaceRecognizer(num_components, threshold);
return (void*)(new ptr_fr(_retval_));
}
@berak
berak / gist:f369932f86d86861ba2e
Created June 8, 2015 11:46
opencv_master heroku ssh output
>echo -n ../cmake-2.8.12.1/bin/cmake -G \"Unix Makefiles\" -DOPENCV_EXTRA_MODULE
S_PATH=../opencv_contrib/modules -DBUILD_TIFF=> cm.in
echo -n ON -DWITH_TIFF=ON -DWITH_IPP=ON -DBUILD_PNG=ON -DWITH_PNG=>> cm.in
echo -n ON -DBUILD_ZLIB=ON -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DBUILD_OPENEXR=
OFF -DBUILD_SHARED_LIBS= >> cm.in
echo -n OFF -DCMAKE_INSTALL_PREFIX=/app/ocv3 -DBUILD_TESTS=OFF -DBUILD_PERF_TES
TS= >> cm.in
echo OFF -DBUILD_opencv_apps=OFF -DBUILD_examples=OFF -DANT_EXECUTABLE=../apach
e-ant-1.9.4/bin/ant >> cm.in
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
#ifndef CV_SQR
# define CV_SQR(x) ((x)*(x))
#endif