Skip to content

Instantly share code, notes, and snippets.

View KenoLeon's full-sized avatar

Keno Leon KenoLeon

View GitHub Profile
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
# Change colorspace:
gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
# --------CASCADE---------
# Convert to Greyscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Denoise (also try bluring, this is expensive )
import cv2
# Callback function from trackbar
def onChange(x):
# print(x)
pass
cap = cv2.VideoCapture(0)
import pygame
from pygame.locals import KEYDOWN, K_ESCAPE
import cv2 as cv
import sys
import numpy as np
cap = cv.VideoCapture(0)
# Native Resolution:
W = cap.get(cv.CAP_PROP_FRAME_WIDTH)
H = cap.get(cv.CAP_PROP_FRAME_HEIGHT)
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.medianBlur(gray, 5)
# Extract regions/pixels of interest
@KenoLeon
KenoLeon / Create_Numpy_simple.py
Last active August 10, 2020 20:44
Create Simple Numpy Arrays
import numpy as np
# -------------- ||| --------------
array_of_zeroes = np.zeros(10)
# array of 10 zeroes
print(array_of_zeroes)
# >>> [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
# -------------- ||| --------------
@KenoLeon
KenoLeon / NumpyTypeConversion.py
Created August 11, 2020 02:01
Type conversion in Numpy
import numpy as np
linear_spaced_array = np.linspace(0, 60, 5)
print(linear_spaced_array)
# >>> [ 0. 15. 30. 45. 60.]
# What Type ?
print(linear_spaced_array.dtype)
# >>> float64
@KenoLeon
KenoLeon / Selecting_Numpy.py
Created August 12, 2020 19:07
Simple Selection Numpy
import numpy as np
randomNumbers = np.array([0, 15, 30, 45, 60])
# Append :
randomNumbers = np.append(randomNumbers, [10], axis=0)
# >>> [ 0 15 30 45 60 10]
# Insert:
randomNumbers = np.insert(randomNumbers, 2, 5)
@KenoLeon
KenoLeon / Indexing_Slicing_Numpy.py
Last active August 13, 2020 00:32
Indexing_Slicing_Numpy
import numpy as np
linear_spaced_array = np.linspace(0, 100, 11, dtype=np.uint8)
# >>> [ 0 10 20 30 40 50 60 70 80 90 100]
# -------------- SIMPLE INDEXING --------------
firstN = linear_spaced_array[:4]
# >>> [ 0 10 20 30]