Instantly share code, notes, and snippets.

# Roy Shilkrotroyshil

• Sort options
Last active Oct 8, 2019
 # This is kind-of based off of this: http://stackoverflow.com/questions/5974595/download-all-the-linksrelated-documents-on-a-webpage-using-python import cookielib import urllib2 import mechanize from time import sleep import os import cgi # A routine to download a file from a link, by simulating a click on it
Created Sep 29, 2017
Laplacian pyramid blending with a mask in OpenCV-Python
View lap_pyr.py
 # adapted from http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_pyramids/py_pyramids.html import cv2 import numpy as np def Laplacian_Pyramid_Blending_with_mask(A, B, m, num_levels = 6): # assume mask is float32 [0,1] # generate Gaussian pyramid for A,B and mask GA = A.copy()
Last active Oct 7, 2019
Simple 2D NURBS renderer for OpenCV, reading a DXF file.
View NRUBSOpenCV.cpp
 /* * Simple 2D NURBS renderer for OpenCV, reading DXF files * * The MIT License (MIT) * * Copyright (c) 2013 Roy Shilkrot * * Updated: Nov 2016 * * Permission is hereby granted, free of charge, to any person obtaining a copy
Created Jan 14, 2015
View SimplestColorBalance.cpp
 /// perform the Simplest Color Balancing algorithm void SimplestCB(Mat& in, Mat& out, float percent) { assert(in.channels() == 3); assert(percent > 0 && percent < 100); float half_percent = percent / 200.0f; vector tmpsplit; split(in,tmpsplit); for(int i=0;i<3;i++) { //find the low and high precentile values (based on the input percentile)
Last active Oct 1, 2019
Warp an image to cylindrical coordinates for cylindrical panorama stitching, using Python OpenCV
View cylindricalWarping.py
 import cv2 import numpy as np def cylindricalWarp(img, K): """This function returns the cylindrical warp for a given image and intrinsics matrix K""" h_,w_ = img.shape[:2] # pixel coordinates y_i, x_i = np.indices((h_,w_)) X = np.stack([x_i,y_i,np.ones_like(x_i)],axis=-1).reshape(h_*w_,3) # to homog Kinv = np.linalg.inv(K)
Last active Sep 16, 2019
A simple video stabilizer in OpenCV, based on goodFeaturesToTrack, calcOpticalFlowPyrLK and estimateRigidTransform.
View SimpleVideoStabilizer.cpp
 #include #include #include #include #include #include using namespace cv; using namespace std;
Last active Sep 6, 2019
How to implement Touch-to-Focus in Android using Camera2 APIs
View AndroidCamera2TouchToFocus.java
 //Override in your touch-enabled view (this can be differen than the view you use for displaying the cam preview) @Override public boolean onTouch(View view, MotionEvent motionEvent) { final int actionMasked = motionEvent.getActionMasked(); if (actionMasked != MotionEvent.ACTION_DOWN) { return false; } if (mManualFocusEngaged) { Log.d(TAG, "Manual focus already engaged"); return true;
Created Jan 14, 2016
Example of converting a YUYV buffer to JPEG using libJPEG
View CompressYUYV2JPEG.cpp
 #include #include #include #include #include #include using namespace std;
Last active Jul 17, 2019
Simple example of OpenGL 4.1 in a QGLWidget
View GLWidgetOpenGL4Example.cpp
 /* * GLWidgetOpenGL4Example.h * * Created on: Apr 23, 2016 * Author: roy_shilkrot * */ class GLWidgetOpenGL4Example : public QGLWidget { public:
Last active May 9, 2019
A script to copy Tensorflow headers to build custom C++ applications