Skip to content

Instantly share code, notes, and snippets.

View royshil's full-sized avatar

Roy Shilkrot royshil

View GitHub Profile
@royshil
royshil / OGL_OCV_common.cpp
Created February 16, 2015 17:16
OpenCV OpenGL common interop: OpenCV Mat to OpenGL texture, 2D drawing of textures
/*
* OGL_OCV_common.cpp
* Common interop between OpenCV and OpenGL
*
* Created by Roy Shilkrot on 2/16/2015
* Copyright 2015 Roy Shilkrot. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@royshil
royshil / setup.sh
Last active January 27, 2018 14:05
Setup an automatic Tensorflow-CUDA-Docker-Jupyter machine on Google Cloud Platform
#!/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 \
@royshil
royshil / BUILD
Created March 8, 2018 20:51
Scripts for cross-compiling Tensorflow 1.5+ for the Jetson TK1 arm-based SoM
package(default_visibility = ["//visibility:public"])
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"armeabi-v7a|compiler": ":cc-compiler-armeabi",
"k8|compiler": ":cc-compiler-local",
},
)
@royshil
royshil / SimpleARQGLViewer.cpp
Created February 16, 2015 19:31
Augmented Reality application with QGLViewer
/*
* SimpleARQGLViewer.cpp
* Creating an AR application with QGLViewer
*
* Created by Roy Shilkrot on 2/16/2015
* Copyright 2015 Roy Shilkrot. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@royshil
royshil / GLWidgetOpenGL4Example.cpp
Last active July 17, 2019 01:38
Simple example of OpenGL 4.1 in a QGLWidget
/*
* GLWidgetOpenGL4Example.h
*
* Created on: Apr 23, 2016
* Author: roy_shilkrot
*
*/
class GLWidgetOpenGL4Example : public QGLWidget {
public:
@royshil
royshil / NRUBSOpenCV.cpp
Last active October 7, 2019 12:21
Simple 2D NURBS renderer for OpenCV, reading a DXF file.
/*
* 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
@royshil
royshil / copy_tf_headers.sh
Last active January 21, 2020 08:01
A script to copy Tensorflow headers to build custom C++ applications
#!/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 / downloadPDFs.py
Last active March 22, 2020 01:27
Download All PDFs in a URL using Python mechanize
# 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
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
/// 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)