Skip to content

Instantly share code, notes, and snippets.

Roy Shilkrot royshil

Block or report user

Report or block royshil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@royshil
royshil / cylindricalWarping.py
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)
@royshil
royshil / copy_tf_headers.sh
Last active May 9, 2019
A script to copy Tensorflow headers to build custom C++ applications
View copy_tf_headers.sh
#!/bin/bash
# inspired by a part of: https://github.com/cjweeks/tensorflow-cmake/blob/master/build.sh
#
# Assumes Tensorflow libraries libtensorflow_framework.so and libtensorflow_cc.so were built with Bazel,
# and the ${TF_ROOT}/tensorflow/contrib/makefile/download_dependencies.sh script was executed.
set -o nounset
set -o errexit
set -o pipefail
@royshil
royshil / BUILD
Created Mar 8, 2018
Scripts for cross-compiling Tensorflow 1.5+ for the Jetson TK1 arm-based SoM
View BUILD
package(default_visibility = ["//visibility:public"])
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"armeabi-v7a|compiler": ":cc-compiler-armeabi",
"k8|compiler": ":cc-compiler-local",
},
)
@royshil
royshil / setup.sh
Last active Jan 27, 2018
Setup an automatic Tensorflow-CUDA-Docker-Jupyter machine on Google Cloud Platform
View setup.sh
#!/bin/bash
# First you must install the 4.4.0 kernel:
# $ sudo apt-get install linux-image-4.4.0-112-generic
# find all the other kernels and remove them:
# $ sudo apt-get purge linux-image-4.13.0-1008-gcp
# $ sudo update-grub
# $ sudo reboot
sudo apt-get update && sudo apt-get install -y \
View segmentation_graphcut_superpixels.py
import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage.segmentation import slic
from skimage.segmentation import mark_boundaries
from skimage.data import astronaut
from skimage.util import img_as_float
import maxflow
from scipy.spatial import Delaunay
@royshil
royshil / lap_pyr.py
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()
@royshil
royshil / circle_of_deadlines.html
Created Jun 20, 2017
A d3v4 visualization of yearly submission deadlines (conference, grant, etc). Tool for the hungry assistant professor.
View circle_of_deadlines.html
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.23.1/babel.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/4.6.0/d3.min.js"></script>
<script src="http://unpkg.com/d3-radial-axis@1.5/dist/d3-radial-axis.min.js"></script>
<script src="https://npmcdn.com/d3fc-rebind@4.0.1/build/d3fc-rebind.js"></script>
<script src="https://npmcdn.com/d3fc-data-join@2.0.0/build/d3fc-data-join.js"></script>
<script src="https://npmcdn.com/d3fc-label-layout@4.0.0/build/d3fc-label-layout.js"></script>
@royshil
royshil / AndroidCamera2TouchToFocus.java
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;
@royshil
royshil / downloadPDFs.py
Last active Oct 8, 2019
Download All PDFs in a URL using Python mechanize
View downloadPDFs.py
# 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
@royshil
royshil / GLWidgetOpenGL4Example.cpp
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:
You can’t perform that action at this time.