Skip to content

Instantly share code, notes, and snippets.

@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
// If no image path was given, then supply some information on how this tool works
const char *keys =
"{ help h ? | | show this message }"
"{ images i | | folder_location }"
"{ annotations a |annotations.txt| ouput_file }"
;
CommandLineParser parser(argc, argv, keys);
String image_folder = parser.get<String>("images");
@berak
berak / gist:f5c0662b7538fee67f87
Created August 14, 2015 05:33
initUndistortRectifyMap java wrapper
//
// void initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat& map1, Mat& map2)
//
JNIEXPORT void JNICALL Java_org_opencv_calib3d_Calib3d_initUndistortRectifyMap_10 (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jdouble, jdouble, jint, jlong, jlong);
JNIEXPORT void JNICALL Java_org_opencv_calib3d_Calib3d_initUndistortRectifyMap_10
(JNIEnv* env, jclass , jlong K_nativeObj, jlong D_nativeObj, jlong R_nativeObj, jlong P_nativeObj, jdouble size_width, jdouble size_height, jint m1type, jlong map1_nativeObj, jlong map2_nativeObj)
{
@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 / chili.js
Last active October 4, 2015 17:23
http.io
db = {
_get: function(hook,key,who,proc) {
hook.datastore.get(key, function(err, result){
if (err) { return hook.res.end(err.message); }
proc(hook,result,who);
});
},
_setraw: function(hook,key,val,proc) {
hook.datastore.set(key, val, function(err, val){
if (err) { return hook.res.end(err.message); }
#include <opencv2/opencv.hpp>
#include "face_x.h"
FaceX face_x("model.xml.gz");
// if you have a Rect, e.g. from CascadeDetector:
std::vector<cv::Point2d> landmarks = face_x.Alignment(img, cv::Rect(0,0,img.cols,img.rows));
// or track previous landmarks:
#include <opencv2/opencv.hpp>
#include <opencv2/core/core_c.h> // needed for IplImage ;(
#include <dlib/image_processing.h>
#include <dlib/opencv/cv_image.h>
// IMPORTANT:
// do **not** use namespace cv or dlib,
// but prefix everything correctly !!!