Skip to content

Instantly share code, notes, and snippets.

@berak
berak / mace.cpp
Last active December 26, 2019 16:27
mace test
// images from
// https://drive.google.com/drive/folders/19tcwtgXRqyRxcNcfmyqUoBPM78mvfD9n?usp=sharing
int main(int argc, char **argv) {
Ptr<MACE> mace = MACE::create();
vector<string> fn;
glob("face",fn);
for (int i=0; i<fn.size(); i++) {
vector<Mat> train_img;
@berak
berak / pyopencv_generated_funcs.h
Created December 4, 2019 18:37
pyopencv_cv_solvePnPGeneric
static PyObject* pyopencv_cv_solvePnPGeneric(PyObject* , PyObject* args, PyObject* kw)
{
using namespace cv;
{
PyObject* pyobj_objectPoints = NULL;
Mat objectPoints;
PyObject* pyobj_imagePoints = NULL;
Mat imagePoints;
PyObject* pyobj_cameraMatrix = NULL;
@berak
berak / div.cpp
Created October 21, 2019 13:55
cv::Mat divide problem
Mat m1(3,3,CV_32FC3,Scalar(3,2,1));
Mat m2;
cout << m1 << endl << m2 << endl;
Mat n = m1/m2;
cout << n << endl;
divide(1,m1,n);
cout << n << endl;
@berak
berak / ar.cpp
Created October 5, 2019 19:11
resnet-34_kinetics action recognition
#include <fstream>
#include <iostream>
#include <sstream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
@berak
berak / batch.py
Last active August 20, 2019 11:50
torch dnn batchnorm
# colab - install latest
# !pip install opencv-python==4.1.0.25
import torch
import torch.nn as nn
import torchvision
import numpy as np
import cv2
@berak
berak / landmarks.py
Created March 30, 2019 10:26
python landmarks test script
# this is a travis related oddity, ignore ...
import sys
sys.path.append('/home/travis/build/berak/tt/ocv/lib/python2.7/dist-packages/')
import cv2, numpy as np
img = cv2.imread("david2.jpg",0)
cas = cv2.CascadeClassifier("haarcascade_frontalface_alt2.xml")
faces = cas.detectMultiScale(img, 1.5, 5)
print("faces",faces)
@berak
berak / fbox.cpp
Created January 13, 2019 16:15
face boxes
#include <opencv2/dnn.hpp>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace cv::dnn;
using namespace std;
int main(int argc, char **argv)
{
String modelTxt = "c:/data/mdl/faceboxes/deploy.prototxt";
@berak
berak / lenet2.pbtxt
Created January 6, 2019 15:25
lenet2.pbtxt
node {
name: "conv2d_input"
op: "Placeholder"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
@berak
berak / dnn_edges.cpp
Last active June 6, 2023 09:17
dnn edge detection
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/dnn/layer.details.hpp>
class CropLayer : public cv::dnn::Layer
{
public:
CropLayer(const cv::dnn::LayerParams &params) : Layer(params)
{
@berak
berak / core.hpp
Created December 28, 2018 18:51
LDA wrapped (minimally) to python/java
class CV_EXPORTS_W LDA
{
public:
/** @brief constructor
Initializes a LDA with num_components (default 0).
*/
explicit LDA(int num_components = 0);
/** Initializes and performs a Discriminant Analysis with Fisher's
Optimization Criterion on given data in src and corresponding labels