Skip to content

Instantly share code, notes, and snippets.

View alasin's full-sized avatar

Anuj Pahuja alasin

  • Carnegie Mellon University
View GitHub Profile
@alasin
alasin / ransac-2.py
Created May 30, 2019 15:41
Plane fitting with RANSAC
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import math
def RANSAC(x, y, z, num_iter, threshold):
best_inliers = []
num_best_inliers = 0
@alasin
alasin / random_batch.py
Created August 10, 2017 08:40
Gets a batch of random patches from images in memory
def get_random_patch(input_image, target_image, patch_size):
start_x = np.random.randint(input_image.shape[0] - patch_size)
start_y = np.random.randint(input_image.shape[1] - patch_size)
end_x = start_x + patch_size
end_y = start_y + patch_size
input_patch = input_image[start_x:end_x, start_y:end_y]
target_patch = target_image[start_x:end_x, start_y:end_y]
return [input_patch, target_patch]
@alasin
alasin / Gstreamer - mixnrecord
Last active July 11, 2017 10:23
Play/Record 2 videos simultaneously
gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw, width=640, height=480" ! videobox border-alpha=0 left=-640 ! queue ! videomixer name=mix ! videoconvert ! x264enc ! matroskamux ! filesink location=test.mkv sync=false videotestsrc ! "video/x-raw, width=640, height=480" ! videobox border-alpha=0 left=0 ! mix.
@alasin
alasin / install_gstreamer.sh
Last active October 21, 2020 21:31
Script for installing Gstreamer and plugins. Change version number accordingly.
#!/bin/bash
VERSION=1.12.0
mkdir ~/gstreamer_$VERSION
cd ~/gstreamer_$VERSION
wget https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$VERSION.tar.xz
wget https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$VERSION.tar.xz
wget https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-$VERSION.tar.xz
@alasin
alasin / install.sh
Created November 8, 2016 06:42
Docker installation on Ubuntu 14.04
#https://docs.docker.com/engine/installation/linux/ubuntulinux/
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
@alasin
alasin / WLSfilter snippet
Created October 4, 2016 09:32
Code for WLS filter for OpenCV version <3.1
#define EPS 1e-43f
typedef float WorkType;
typedef Vec<WorkType, 1> WorkVec;
typedef WorkType (*get_weight_op)(WorkType*, unsigned char*,unsigned char*);
inline WorkType get_weight_1channel(WorkType* LUT, unsigned char* p1,unsigned char* p2)
{
return LUT[ (p1[0]-p2[0])*(p1[0]-p2[0]) ];
}
@alasin
alasin / Mplayer PAL script
Last active August 5, 2016 10:10
Mplayer script
mplayer tv:// -tv driver=v4l2:norm=PAL:input=0:amode=1:width=704:height=576:outfmt=yv12:device=/dev/video1
@alasin
alasin / Udpsrc receiver
Last active August 5, 2016 10:10
Udpsrc receiver - Gstreamer
gst-launch-1.0 udpsrc port=5004 ! "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, depth=(string)8, width=(string)720, height=(string)576, colorimetry=(string)BT601-5, payload=(int)96" ! rtpvrawdepay ! videoconvert ! autovideosink -v
@alasin
alasin / FFmpeg conversions.txt
Created February 19, 2016 07:15
FFmpeg useful conversions
JPG -> YUV
ffmpeg -i test-640x480.jpg -s 640x480 -pix_fmt yuv420p test-yuv420p.yuv
YUV -> JPG
ffmpeg -s 640x480 -pix_fmt yuv420p -i test-yuv420p.yuv test-640x480.jpg