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 / 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 / gist:6318407
Created Aug 23, 2013
A CMake Find module for FFMPEG that will tear the HD apart looking for the libs and includes ;)
View gist:6318407
# - Try to find FFMPEG
# Once done this will define
# FFMPEG_INCLUDE_DIRS - The FFMPEG include directories
# FFMPEG_LIBRARIES - The libraries needed to use FFMPEG
# FFMPEG_LIBRARY_DIRS - The directory to find FFMPEG libraries
# written by Roy Shilkrot 2013
royshil /
Last active May 12, 2020
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 /
Created Mar 4, 2016
A way to set V4L2 camera params for OpenCV, when cv2.VideoCapture doesn't work. This requires the python-v42lcapture module (
#!/usr/bin/env python
import numpy as np
import cv2
import os
import v4l2capture
import select
if __name__ == '__main__':
#cap = cv2.VideoCapture(0)
royshil /
Last active Mar 22, 2020
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
import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage.segmentation import slic
from skimage.segmentation import mark_boundaries
from import astronaut
from skimage.util import img_as_float
import maxflow
from scipy.spatial import Delaunay
royshil /
Last active Feb 12, 2020
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 /
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 /
Last active Jan 21, 2020
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
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
You can’t perform that action at this time.