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 /
Last active Oct 8, 2019
Download All PDFs in a URL using Python mechanize
# This is kind-of based off of this:
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 /
Created Sep 29, 2017
Laplacian pyramid blending with a mask in OpenCV-Python
# adapted from
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 / NRUBSOpenCV.cpp
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
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<Mat> tmpsplit; split(in,tmpsplit);
for(int i=0;i<3;i++) {
//find the low and high precentile values (based on the input percentile)
royshil /
Last active Oct 1, 2019
Warp an image to cylindrical coordinates for cylindrical panorama stitching, using Python OpenCV
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 / SimpleVideoStabilizer.cpp
Last active Sep 16, 2019
A simple video stabilizer in OpenCV, based on goodFeaturesToTrack, calcOpticalFlowPyrLK and estimateRigidTransform.
View SimpleVideoStabilizer.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/video/video.hpp>
#include <iostream>
using namespace cv;
using namespace std;
royshil /
Last active Sep 6, 2019
How to implement Touch-to-Focus in Android using Camera2 APIs
//Override in your touch-enabled view (this can be differen than the view you use for displaying the cam preview)
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 / CompressYUYV2JPEG.cpp
Created Jan 14, 2016
Example of converting a YUYV buffer to JPEG using libJPEG
View CompressYUYV2JPEG.cpp
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>
#include <memory>
#include <jpeglib.h>
using namespace std;
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 {
royshil /
Last active May 9, 2019
A script to copy Tensorflow headers to build custom C++ applications
# inspired by a part of:
# Assumes Tensorflow libraries and were built with Bazel,
# and the ${TF_ROOT}/tensorflow/contrib/makefile/ script was executed.
set -o nounset
set -o errexit
set -o pipefail
You can’t perform that action at this time.