Skip to content

Instantly share code, notes, and snippets.

@berak
berak / depth_from_single_img.txt
Last active Sep 10, 2020
depth from single image / www
View depth_from_single_img.txt
code running https://berak.pythonanywhere.com/
run get_model.sh to download the pretrained 'unet.onnx'
wsgi.py is a webserver, receiving images of indoor scenes and sending back depth images.
up.html is the main webpage
View flow.prototxt
input: "img0"
input: "img1"
input_shape {
dim: 1
dim: 3
dim: 720
dim: 1280
}
input_shape {
dim: 1
@berak
berak / mulim.cpp
Created Dec 27, 2019
dnn multiple images
View mulim.cpp
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
string folder = "c:/data/dnn/tcnn/";
@berak
berak / mace.cpp
Last active Dec 26, 2019
mace test
View mace.cpp
// 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 Dec 4, 2019
pyopencv_cv_solvePnPGeneric
View pyopencv_generated_funcs.h
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 Oct 21, 2019
cv::Mat divide problem
View div.cpp
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 Oct 5, 2019
resnet-34_kinetics action recognition
View ar.cpp
#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 Aug 20, 2019
torch dnn batchnorm
View batch.py
# 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 Mar 30, 2019
python landmarks test script
View landmarks.py
# 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)
View fbox.cpp
#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";
You can’t perform that action at this time.