Skip to content

Instantly share code, notes, and snippets.

View anujonthemove's full-sized avatar

Anuj Khandelwal anujonthemove

View GitHub Profile
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
double median( cv::Mat channel )
double m = (channel.rows*channel.cols) / 2;
int bin = 0;
double med = -1.0;
int histSize = 256;
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 /
Created July 1, 2018 14:27 — forked from DominicBreuker/
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 / 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 / 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)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
anujonthemove /
Created July 26, 2019 10:27
Sample data push to HTTP endpoints
import json
import subprocess
new_cdata='{"input": {"data": {"SensorMetaInfo": {"CameraDescription": "cisco_cam_type_1", "Ly": "20.98S", "Lx": "10.233N", "FeatureId": "9", "ServerId": "vijaywada_PC_01", "ProductCategoryId": "2", "CameraID": "akashwani_east", "LongDescription": "high range camera"}, "Data": {"CongressionThreshold": "20.0%", "ImageURL": "/home/anuj/git/work/end-to-end-api/hyderabad/deputy-01/vehicle-counter/output/2018-10-17/images/vehicle_counter_08:36:58.jpg", "Vehicles": {"AreaOccupied": "34.0%", "BikeCount": 2, "MiniBusCount": 0, "CarCount": 1, "ReportedTime": "2018-02-26t10:23:51", "HeavyVehicleCount": 0}, "VideoURL": "http://<ip-address>/video-analytics/hyderabad/akashwani_east/vehicle_counter/output/videos/2018_02_26_10_23_11_video.mp4", "CapturedTime": "2018-10-17 08:36:58.041400"}, "Event": {"EventID": 11, "EventDescription": "Threshold Congestion Exceeded"}}}, "configName": "Congestion", "groupName": "TrafficAnalytics", "tenantId": ""}'["curl", "-X", "
anujonthemove / config
Last active January 2, 2020 12:56
SSH User Configuration File
# taken entirely from:
## 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
anujonthemove / useful ffmpeg commands
Created May 15, 2020 16:20
useful ffmpeg commands
# convert-mp4-to-webm-for-rtsp
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm
anujonthemove /
Created May 24, 2020 13:03 — forked from TheSalarKhan/
Background Averaging (Background Subtraction) in Python+OpenCV
import numpy as np
import cv2
class BackGroundSubtractor:
# When constructing background subtractor, we
# take in two arguments:
# 1) alpha: The background learning factor, its value should
# be between 0 and 1. The higher the value, the more quickly
# your program learns the changes in the background. Therefore,