Skip to content

Instantly share code, notes, and snippets.

@berak
berak / error.log
Created May 26, 2022 06:10
import cv2 error
> make install
...
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/__init__.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/load_config_py2.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/load_config_py3.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/config.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/misc/__init__.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/misc/version.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/mat_wrapper/__init__.py
-- Up-to-date: C:/prog/Python37/Lib/site-packages/cv2/utils/__init__.py
@berak
berak / pyopencv_generated_funcs.h
Created January 31, 2022 11:29
calcHist python wrapper
static PyObject* pyopencv_cv_calcHist(PyObject* , PyObject* py_args, PyObject* kw)
{
using namespace cv;
pyPrepareArgumentConversionErrorsStorage(2);
{
PyObject* pyobj_images = NULL;
vector_Mat images;
PyObject* pyobj_channels = NULL;
@berak
berak / cv2. ipynb
Last active July 20, 2021 13:27
cv2 cuda colab
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
@berak
berak / fuse.cpp
Last active May 17, 2021 09:29
weighted box fusion
template<class _Tp>
struct WeightedBoxesFusion {
typedef Rect_<_Tp> RECT;
struct Box {
int label;
float x1,y1,x2,y2, score, weight;
Box() {}
Box(int label, float x1,float y1,float x2,float y2, float score, float weight)
@berak
berak / davinci-codex.py
Last active October 5, 2021 11:31
gpt3 quotes
"""
using cv2, open a webcam and record a video file
"""
def rec(cap_id, vid_filename):
cap = cv2.VideoCapture(cap_id)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(vid_filename, fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
#include "opencv2/opencv.hpp"
using namespace cv;
#include <iostream>
using namespace std;
int main()
{
int IMAGE_SIZE = 513;
cv::Mat faceImg= cv::imread("C:/data/persons/unsorted/139539.png");
@berak
berak / convert.py
Last active March 24, 2021 11:19
landmarks from speech audio
# i ran this on colab to convert the pth to onnx, so opencv can read it !
import torch;
import torch.nn as nn
import torch.nn.functional as F
class SPCH2FLM(nn.Module):
def __init__(self, numFilters=64, filterWidth=21):
super(SPCH2FLM, self).__init__()
self.numFilters = numFilters
@berak
berak / depth_from_single_img.txt
Last active September 10, 2020 10:37
depth from single image / www
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
@berak
berak / flow.prototxt
Created January 12, 2020 11:18
flownet1
input: "img0"
input: "img1"
input_shape {
dim: 1
dim: 3
dim: 720
dim: 1280
}
input_shape {
dim: 1
@berak
berak / mulim.cpp
Created December 27, 2019 13:09
dnn multiple images
#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/";