Skip to content

Instantly share code, notes, and snippets.

View debanga's full-sized avatar
🚀
Deep into learning new things.

Debanga R. Neog, Ph.D. debanga

🚀
Deep into learning new things.
View GitHub Profile
@debanga
debanga / Notes: Android OpenCV
Last active March 9, 2019 01:04
Runtime camera permission android opencv (google forced from 2018 end)
In "AndroidMenifest.xml"
<uses-permission android:name="android.permission.CAMERA"/>
In "MainActivity.java"
import android.content.pm.PackageManager;
public void onCreate(Bundle savedInstanceState) { ...
@debanga
debanga / opencv_android_focus
Created March 9, 2019 01:56
OpenCV + Android Focus Control
https://www.thecodecity.com/2016/08/focus-modes-opencv-javacameraview-android.html
@debanga
debanga / JavaCamera2View
Created March 10, 2019 02:01
JavaCamera2View
package org.opencv.android;
import java.nio.ByteBuffer;
import java.util.Arrays;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@debanga
debanga / SinglyLinkedList.cpp
Created November 4, 2019 20:40
Singly Linked List
template <class T>
class SinglyLinkedList {
private:
SinglyLinkedList* next;
T data;
public:
// Constructor
SinglyLinkedList(const T &value) : next(NULL), data(value) {}
@debanga
debanga / quick_plot.py
Last active April 25, 2020 19:41
Plotly Pretty Plot
import plotly.graph_objs as go
from plotly.offline import iplot
def plot(x,y,type='scatter',title="title",xlabel="x", ylabel="y"):
if type=='scatter':
data = go.Scatter(x=x, y=y)
elif type=='bar':
data = go.Bar(x=x, y=y)
layout = go.Layout(title=title, xaxis=dict(title=xlabel), yaxis=dict(title=ylabel))
@debanga
debanga / figsize.py
Created April 25, 2020 19:36
Increase Inline Image Size in Jupyter Notebooks
import seaborn as sns
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [15, 15]
@debanga
debanga / Silhouette Analysis.py
Last active May 15, 2020 20:06
Perform Silhouette Analysis of a Cluster
def draw_silhouette(sample_silhouette_values, silhouette_avg, n_clusters):
"""
Perform silhouette analysis.
Args:
- sample_silhouette_values
- silhouette_avg
Returns:
- Draws silhouette plot.
@debanga
debanga / cutmix_bbox.py
Last active May 20, 2020 09:23
CutMix Random Bounding Box
def rand_bbox(size, lamb):
""" Generate random bounding box
Args:
- size: [width, breadth] of the bounding box
- lamb: (lambda) cut ratio parameter, sampled from Beta distribution
Returns:
- Bounding box
"""
W = size[0]
H = size[1]