Skip to content

Instantly share code, notes, and snippets.

Abbreviation Description
ldpi Low-density screens ~120dpi. (actually ppi)
mdpi Medium-density screens ~160dpi. (actually ppi)
hdpi High-density screens ~240dpi. (... ppi)
xhdpi Extra-high-density screens ~320dpi. (... ppi)
xxhdpi Extra-extra-high-density screens ~480dpi. (...)
xxxhdpi Extra-extra-extra-high-density (launcher icon only) ~640dpi.
tvdpi Screens between mdpi and hdpi; ~213dpi. Not a primary density group.
@soura-b
soura-b / contour_adaptive.py
Created September 3, 2021 10:32
Contour detection with adaptive gaussian thresholding
import cv2
import numpy as np
image = cv2.imread('images_09_03/Lot1_RT.jpeg', 1)
img_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply adaptive gaussian thresholding
thresh = cv2.adaptiveThreshold(img_gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)
cv2.imshow('primary', image)
cv2.imshow('gray', img_gray)
@soura-b
soura-b / contour-detection.py
Created August 27, 2021 04:54
Contour detection - TREE mode
import cv2
import numpy as np
# https://learnopencv.com/read-display-and-write-an-image-using-opencv/
# https://learnopencv.com/contour-detection-using-opencv-python-c/
image = cv2.imread('foot2.jpeg', 1) # 1 for color, 0 for greyscale
# stored as <class 'numpy.ndarray'>
img_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply binary thresholding
@soura-b
soura-b / dilation.py
Created August 27, 2021 04:50
Contour detection after pre-processing with diltion
import cv2
image = cv2.imread('foot2.jpeg', 1) # 1 for color, 0 for greyscale
img_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# ******** #
# Dilation #
# ******** #
from skimage.morphology import (erosion, dilation)
from skimage.morphology import disk
footprint = disk(1)
@soura-b
soura-b / download_image.py
Last active July 11, 2021 08:08
Download image over https using python
# using socket
import socket
import time
HOST = 'data.pr4e.org'
PORT = 80
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((HOST, PORT))
mysock.sendall(b'GET http://data.pr4e.org/cover3.jpg HTTP/1.0\r\n\r\n')
count = 0