Skip to content

Instantly share code, notes, and snippets.

View crearo's full-sized avatar
🥨

Rish Bhardwaj crearo

🥨
View GitHub Profile
@crearo
crearo / gstreamer-recording-dynamic-from-stream.c
Last active December 14, 2023 22:03
Example of dynamic recording of a stream received from udpsrc.
#include <string.h>
#include <gst/gst.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
// udpsrc port=8554 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, width=(int)720, height=(int)480, encoding-name=(string)H264, payload=(int)96" !
// rtpjitterbuffer name=rtpjitbuff ! rtph264depay !
// tee name=t t. ! avdec_h264 ! appsink name=sink sync=false
@crearo
crearo / Shader.java
Created June 8, 2017 04:54
Extremely helpful utility class for loading Shaders from resources and maintaining handles for OPENGL | ES 2
package rish.crearo.imagestablization.camera;
import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@crearo
crearo / LineGraphView.java
Last active July 13, 2017 05:54
A simple line graph view that renders at 60fps. Fast, elegant.
package rish.crearo.imagestabv2;
/**
* Original author unknown.
*
* Modified by rish on 10/7/17.
* [email protected]
*/
import android.content.Context;
@crearo
crearo / fragment_shader_NV12_to_RGB.frag
Last active August 1, 2024 01:57
A fragment shader to convert NV12 to RGB.
/** A fragment shader to convert NV12 to RGB.
* Input textures Y - is a block of size w*h.
* texture UV is of size w*h/2.
* Remember, both U and V are individually of size w/2*h/2, but they are interleaved.
* The layout looks like this :
* ----------
* | |
* | Y | size = w*h
* | |
* |________|
@crearo
crearo / fragment_shader_YUV420P_to_RGB.frag
Last active December 19, 2024 13:14
A fragment shader to convert YUV420P to RGB.
/** A fragment shader to convert YUV420P to RGB.
* Input textures Y - is a block of size w*h.
* texture U is of size w/2*h/2.
* texture V is of size w/2*h/2.
* In this case, the layout looks like the following :
* __________
* | |
* | Y | size = w*h
* | |
* |________|
@crearo
crearo / WiFiConnector.java
Created September 13, 2017 03:06
Android code to connect to a WiFi network programatically.
package com.tonbo.streamer.network;
import android.content.Context;
import android.content.IntentFilter;
import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.support.annotation.CheckResult;
@crearo
crearo / video-side-by-side.py
Created December 15, 2017 10:50
Takes two input videos of the same dimensions and stores them side by side
'''
A small script to play videos of the same dimensions side by side.
I needed this while showing two videos side by side; one stabilized and one not stabilized during my
works on video stabilization.
'''
import cv2, sys
import numpy as np
if len(sys.argv) < 3:
@crearo
crearo / FileLogger.java
Created December 18, 2017 10:11
Provides Android's Log.d() like logging for logging to files
package com.rish.imagestab.utils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
/**
* Created by rish on 14/6/17.
@crearo
crearo / software-stab.py
Created December 21, 2017 08:06
Simple software stabilization with linear smoothing filter
'''
Performs software stabilization using optical flow + linear smoothing.
Vision algos used :
- KLT for flow tracking
- Harris corner detection to detect points to be tracked in each frame
This is the Python translation I wrote of the original .cpp code written by nghiaho.com/?p=2093
'''
import cv2
import numpy as np
@crearo
crearo / pedestrian-detector.py
Created April 4, 2018 17:30
A simple pedestrian detector based on PyImageSearch's blogpost
import numpy as np
import cv2
from imutils.object_detection import non_max_suppression
from imutils import paths
import argparse
import imutils
"""
The parameters passed to the hog detector need to be played around
with to get optimum speed vs accuracy. This will always be a tradeoff.