Skip to content

Instantly share code, notes, and snippets.

View fjolublar's full-sized avatar

Indrit Fejza fjolublar

View GitHub Profile
@fjolublar
fjolublar / get_self_ip.py
Last active July 30, 2020 08:23
Function to get own ip of the system in python.
#https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib #fatal_error
def get_ip(self):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.255.255.255', 1))
IP = s.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
@fjolublar
fjolublar / find_lines_opencv.py
Created July 28, 2020 15:00
Finding lines in frames in OpenCV
def find_lines(frame):
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray,(5,5),0)
# ret, gray = cv2.threshold(gray,190,255,cv2.THRESH_BINARY_INV)
edges = cv2.Canny(gray, 30, 150, apertureSize = 3)
# edges = cv2.Canny(gray, 50, 200, apertureSize = 3)
lines = cv2.HoughLines(edges, 1, np.pi/180, 200)
if lines is not None:
@fjolublar
fjolublar / Python_Cool_Libraries.py
Last active July 1, 2020 08:41
Working with interesting python libraries.
# Pretty Print.
from pprint import pprint
playsound #is the most straightforward package to use if you simply want to play a WAV or MP3 file. It offers no functionality other than simple playback.
simpleaudio #lets you play WAV files and NumPy arrays, and gives you options to check whether a file is still playing.
winsound #allows you to play WAV files or beep your speakers, but it works only on Windows.
@fjolublar
fjolublar / Camera_control.py
Last active June 25, 2020 08:46
System Info for Linux
Manual USB camera settings in Linux
https://www.kurokesu.com/main/2016/01/16/manual-usb-camera-settings-in-linux/
uvcdynctrl libwebcam command line tool
http://www.linux-commands-examples.com/uvcdynctrl
@fjolublar
fjolublar / QR_Code_Detection_Python.py
Last active June 19, 2020 12:14
QR_Code_Detection in Python
# Import the necessary packages
from pyzbar import pyzbar
import cv2
#--------------------------------------------------------------------------------------------------------#
def initCamera(camera_id, frame_width, frame_height): #Function to initialize the CV videocapture.
print('==> Trying to initialize the camera...')
cap = cv2.VideoCapture( int(camera_id) ) #Start VideoCapture with the appropriate camera ID.
if not cap.isOpened(): #Test if the stream is opened.