Skip to content

Instantly share code, notes, and snippets.

View femioladeji's full-sized avatar

Femi Oladeji femioladeji

View GitHub Profile
@femioladeji
femioladeji / binary_image.py
Created July 14, 2017 22:11
Read the car image and convert it to binary
from skimage.io import imread
from skimage.filters import threshold_otsu
import matplotlib.pyplot as plt
car_image = imread("car.jpg", as_grey=True)
# it should be a 2 dimensional array
print(car_image.shape)
# the next line is not compulsory however, a grey scale pixel
# in skimage ranges between 0 & 1. multiplying it with 255
@femioladeji
femioladeji / cca.py
Created July 16, 2017 11:11
Connected Component Analysis on the binary image to identify connected regions
from skimage import measure
from skimage.measure import regionprops
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import localization
# this gets all the connected regions and groups them together
label_image = measure.label(localization.binary_car_image)
fig, (ax1) = plt.subplots(1)
ax1.imshow(localization.gray_car_image, cmap="gray");
@femioladeji
femioladeji / cca2.py
Last active June 27, 2018 06:50
Improved Connected Component Analysis that removes some regions based on some characteristics
from skimage import measure
from skimage.measure import regionprops
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import localization
# this gets all the connected regions and groups them together
label_image = measure.label(localization.binary_car_image)
# getting the maximum width, height and minimum width and height that a license plate can be
@femioladeji
femioladeji / segmentation.py
Created July 18, 2017 11:12
Character segmentation to map out all the character regions
import numpy as np
from skimage.transform import resize
from skimage import measure
from skimage.measure import regionprops
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import cca2
# on the image I'm using, the headlamps were categorized as a license plate
# because their shapes were similar
import os
import numpy as np
from sklearn.svm import SVC
from sklearn.model_selection import cross_val_score
from sklearn.externals import joblib
from skimage.io import imread
from skimage.filters import threshold_otsu
letters = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
import os
import segmentation
from sklearn.externals import joblib
# load the model
current_dir = os.path.dirname(os.path.realpath(__file__))
model_dir = os.path.join(current_dir, 'models/svc/svc.pkl')
model = joblib.load(model_dir)
classification_result = []
@femioladeji
femioladeji / localization.py
Last active July 10, 2022 00:35
Read the car image and convert it to binary
from skimage.io import imread
from skimage.filters import threshold_otsu
import matplotlib.pyplot as plt
car_image = imread("car.jpg", as_gray=True)
# it should be a 2 dimensional array
print(car_image.shape)
# the next line is not compulsory however, a grey scale pixel
# in skimage ranges between 0 & 1. multiplying it with 255
{
"manifest_version": 2,
"name": "Social Media Screentime",
"description": "Control how much time you invest in social media",
"short_name": "social media screentime",
"version": "1.0",
"browser_action": {
"default_popup": "index.html"
},
"background": {
const urls = [
'*://*.facebook.com/',
'*://*.twitter.com/',
'*://*.youtube.com/',
'*://*.instagram.com/'
]
let active = {};
const end = () => {
const urls = [
'*://*.facebook.com/',
'*://*.twitter.com/',
'*://*.youtube.com/',
'*://*.instagram.com/'
]
const STORAGE = chrome.storage.local;
let active = {};