Skip to content

Instantly share code, notes, and snippets.

View Lukse's full-sized avatar

Saulius Lukse Lukse

View GitHub Profile
@Lukse
Lukse / img_brightest.py
Created August 15, 2016 11:00
Stack images by using brightest pixel
import os
import fnmatch
import numpy as np
from PIL import Image
from tqdm import trange
images_in = "img"
def find(directory, pattern):
file_list = []
@Lukse
Lukse / img_avg.py
Created August 15, 2016 10:59
Stack images by averaging frames
import os
import fnmatch
import numpy as np
from PIL import Image
from tqdm import trange
images_in = "img"
def find(directory, pattern):
file_list = []
@Lukse
Lukse / pyqt_opencv.py
Last active January 20, 2021 07:54
OpenCV USB camera object in PyQT
# -*- coding: utf-8 -*-
__author__ = "Saulius Lukse"
__copyright__ = "Copyright 2016, kurokesu.com"
__version__ = "0.1"
__license__ = "GPL"
from PyQt4 import QtCore, QtGui, uic
import sys
@Lukse
Lukse / detect_blur.py
Created July 25, 2016 16:09
OpenCV 3 Python blur detection
import cv2
from tqdm import trange
cap = cv2.VideoCapture('10.avi')
f = open('results.txt', 'w')
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
for i in trange(frame_count, unit=' frames', leave=False, dynamic_ncols=True, desc='Calculating blur ratio'):
@Lukse
Lukse / animated_gif.py
Last active July 25, 2016 06:32
Making animated GIF’s
from moviepy.editor import *
start = 0.0
end = 10.0
width = 500
fps = 20
speedx = 2
file_in = "video.avi"
file_out = "img.gif"
@Lukse
Lukse / detect.py
Last active October 22, 2018 07:13
Advanced OpenCV 3 python hole detection
import cv2
import sys
import numpy as np
camera = cv2.VideoCapture("video.avi")
# Setup BlobDetector
detector = cv2.SimpleBlobDetector_create()
params = cv2.SimpleBlobDetector_Params()
def dict2obj(d):
if isinstance(d, list):
d = [dict2obj(x) for x in d]
if not isinstance(d, dict):
return d
class C(object):
pass
o = C()
for k in d:
o.__dict__[k] = dict2obj(d[k])
@Lukse
Lukse / gist:8634d9544c67ee0d8c18
Created May 29, 2014 06:07
Count number of times value appears in particular column in MySQL
-- Duomenys:
-- zigmas
-- zigmas
-- petras
-- Rezultatai:
-- zigmas 2
-- petras 1
select name, count(*) as n FROM orders order by n GROUP BY name
import os
import fnmatch
def recursive_glob(treeroot, pattern):
results = []
for base, dirs, files in os.walk(treeroot):
goodfiles = fnmatch.filter(files, pattern)
results.extend(os.path.join(base, f) for f in goodfiles)
return results
@Lukse
Lukse / execution_folders.py
Last active August 29, 2015 14:01
Get execution directory
import os
def execution_directory():
exec_place = os.getcwd()
script_place = os.path.dirname(os.path.realpath(__file__))
arguments_place = str(sys.argv[0])
arguments_place = ("\\").join(arguments_place.split('\\')[0:-1])
return exec_place, script_place, arguments_place
print execution_folders()