Skip to content

Instantly share code, notes, and snippets.

View anujonthemove's full-sized avatar
Working

Anuj Khandelwal anujonthemove

Working
View GitHub Profile
@anujonthemove
anujonthemove / cv_median.cpp
Created July 19, 2016 18:25 — forked from heisters/cv_median.cpp
Find the median of a single channel using OpenCv
namespace cv {
// calculates the median value of a single channel
// based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp
double median( cv::Mat channel )
{
double m = (channel.rows*channel.cols) / 2;
int bin = 0;
double med = -1.0;
int histSize = 256;
@anujonthemove
anujonthemove / opencv-temporal-blurring.cpp
Created August 14, 2016 09:22
Temporal blurring over successive frames.
// OpenCV imports
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
// C++ imports
#include <iostream>
// namespaces
using namespace std;
using namespace cv;
@anujonthemove
anujonthemove / Birds-Eye-View Transformation.pdf
Last active April 29, 2024 01:07
Bird's eye view perspective transformation using OpenCV
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anujonthemove
anujonthemove / validate_credit_card.js
Created January 2, 2017 16:47 — forked from DiegoSalazar/validate_credit_card.js
Luhn algorithm in Javascript. Check valid credit card numbers
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@anujonthemove
anujonthemove / opencv-videocapture-useful-properties.txt
Last active April 5, 2024 14:24
A handy list of VideoCapture object parameters taken from official OpenCV docs.
CAP_PROP_POS_MSEC =0, //!< Current position of the video file in milliseconds.
CAP_PROP_POS_FRAMES =1, //!< 0-based index of the frame to be decoded/captured next.
CAP_PROP_POS_AVI_RATIO =2, //!< Relative position of the video file: 0=start of the film, 1=end of the film.
CAP_PROP_FRAME_WIDTH =3, //!< Width of the frames in the video stream.
CAP_PROP_FRAME_HEIGHT =4, //!< Height of the frames in the video stream.
CAP_PROP_FPS =5, //!< Frame rate.
CAP_PROP_FOURCC =6, //!< 4-character code of codec. see VideoWriter::fourcc .
CAP_PROP_FRAME_COUNT =7, //!< Number of frames in the video file.
CAP_PROP_FORMAT =8, //!< Format of the %Mat objects returned by VideoCapture::retrieve().
CAP_PROP_MODE =9, //!< Backend-specific value indicating the current capture mode.
@anujonthemove
anujonthemove / gd_simple.py
Created July 1, 2018 14:27 — forked from DominicBreuker/gd_simple.py
Simple example of gradient descent in tensorflow
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
log_x_squared = tf.square(log_x)
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(log_x_squared)
init = tf.initialize_all_variables()
@anujonthemove
anujonthemove / setup-venv.sh
Last active January 16, 2023 01:22
Steps to setup Python 3 virtual environment and virtual environment wrapper.
# Commands to install virtual environments
# With this setup, all your virtual environments will be placed
# at one place inside .virtualenvs folder under home directory in Linux
sudo apt update
sudo pip install virtualenv virtualenvwrapper
# open .bashrc file and copy paste the following lines below:
# virtualenv and virtualenvwrapper
@anujonthemove
anujonthemove / cuda-cudnn-export-paths.txt
Last active April 20, 2024 20:53
Export paths for CUDA and cuDNN.
export CUDA_HOME=/usr/local/cuda
export PATH=/usr/local/cuda/bin:$PATH
export CPATH=/usr/local/cuda/include:$CPATH
export LIBRARY_PATH=/usr/local/cuda/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
@anujonthemove
anujonthemove / jupyter-ipykernel-essentials.txt
Last active February 6, 2019 08:47
Command to add a new Jupyter kernel.
# add jupyter kernel
# if you are working inside a virtual environment, activate it and run the following command (change the names accordingly, of course!)
python -m ipykernel install --user --name video-analytics --display-name "Python2 (video-analytics)"
# list all available kernels
jupyter kernelspec list
# remove a kernel
jupyter kernelspec remove "kernel-name" (without quotes)
@anujonthemove
anujonthemove / config
Last active January 2, 2020 12:56
SSH User Configuration File
# taken entirely from: https://dzone.com/articles/password-less-ssh-access-for-automation
## Proxy ##
## Forward all local port 8888 traffic to port 8888 on the remote server ##
Host <your host name>
HostName <your IP>
ForwardX11 yes
User <your username>
IdentityFile /path/to/<your pem file>.pem
LocalForward localhost <or some of your IP>:8888 <server IP address>:8888