Application#

Submodules#

Classes#

Image

Dataclass that stores images that are served by the ImageManager. Dearpygui cannot display PImage.Image from Pillow

ImageManager

Does what the name suggests, creates Images. Regardless of wherever it is from, the interface stays the same

DJ

There can only be one DJ object created throughout the entire program.

SearchMachine

ShittyMultiThreading

terrible, utterly horrendous. doesn't even store the return values lmao

SimpleTimer

Basic timer utility.

Functions#

generate_bill(path, bill)

detect(path)

visualise(path, faces, dimensions[, thickness])

rename_rolls(path, dubious_list)

copy_images(counters, path, source)

load(roll)

write(counters, roll)

colour_balance(→ PIL.Image.Image)

merge(images)

levels(img, black, white, gamma)

get_rgb_histogram(image)

split_rgb(image)

split_smh(image)

get_histogram(image)

add(image, dx)

Package Contents#

Application.generate_bill(path: pathlib.Path, bill: collections.Counter)#
Application.detect(path: pathlib.Path)#
Application.visualise(path: pathlib.Path, faces, dimensions, thickness=5)#
class Application.Image(path: pathlib.Path, raw_image: PIL.Image.Image, main_image_dimensions, thumbnail_dimensions)#

Dataclass that stores images that are served by the ImageManager. Dearpygui cannot display PImage.Image from Pillow directly, so this converts the image into a numpy array that dearpygui can display as a texture. The image is also padded with black borders if it’s aspect ratio doesn’t fit the ImageWindow.

_version#
path#
raw_image#
main_image_dimensions#
thumbnail_dimensions#
save()#
dpg_texture()#
thumbnail()#
dpg_raw()#
get_scaled_image(factor=0.15)#
classmethod frompath(path: pathlib.Path, main_image_dimensions: Tuple[int, int], thumbnail_dimensions: Tuple[int, int], _version=None)#

Creates an Image object from the path of the image.

Args:

path (Path): Path to the image

Returns:

Image

classmethod fromserver(roll, id)#

Implement this function when the server is up and running. This doesn’t work right now.

Args:

roll (str): id (str):

class Application.ImageManager(mode: Literal['online', 'offline'], main_image_dimensions, thumbnail_dimensions)#

Does what the name suggests, creates Images. Regardless of wherever it is from, the interface stays the same

mode#
current_index = 0#
main_image_dimensions#
thumbnail_dimensions#
images: list[pathlib.Path] = []#
classmethod from_path(path: pathlib.Path, main_image_dimensions, thumbnail_dimensions)#
classmethod from_file_list(files: list[pathlib.Path], main_image_dimensions, thumbnail_dimensions)#
classmethod from_server(url)#
end_index()#
load(index, force_reload=False)#

Returns an Image object, given an index

Args:

index (int): The index of the roll that needs to be loaded

Returns:

load_in_background()#

Loads all the images in the background using ShittMultiThreading from utils.py This works because the images are cached.

peek(index)#

Returns an image object without moving the current_index

Args:

index (int): The index of the image we want to view

Returns: Image

next()#

Helper function to peek the next image

Returns:

Image

previous()#

Helper function to peek the previous image

Returns:

Image

class Application.DJ(visualiser=None)#

There can only be one DJ object created throughout the entire program. DJ can play local files without blocking the calling thread

audio_buffer#
visualiser = None#
fft#
stream = None#
callback(outdata: numpy.ndarray, frames: int, time: cffi.backend_ctypes.CTypesData, status: sounddevice.CallbackFlags)#
file_reader(path)#
compute_fft(data)#
audio_buffer_setup_from_file(path)#
finished_callback()#
play(path)#
stop()#
Application.rename_rolls(path: pathlib.Path, dubious_list: list)#
class Application.SearchMachine#
parser#
fts_text = 'SELECT name, idno, hoscode, roomno FROM students WHERE rowid IN (SELECT * from (SELECT rowid...#
id_text = 'SELECT name, idno, hoscode, roomno from students WHERE idno LIKE ?'#
bhawan_text = 'SELECT name, idno, hoscode, roomno from students WHERE hoscode LIKE ?'#
id_regex#
get_name(argument)#
get_id(argument)#
get_bhawan(argument)#
evaluate(argument)#
search(text) set[SearchResult] | None#
Application.copy_images(counters: list[collections.Counter], path: pathlib.Path, source: list[pathlib.Path])#
Application.load(roll: str)#
Application.write(counters: list[collections.Counter], roll: str)#
class Application.ShittyMultiThreading(work, tasks, num_threads=5)#

terrible, utterly horrendous. doesn’t even store the return values lmao

work#
num_threads = 5#
queue#
worker()#
start()#
class Application.SimpleTimer(process_name=None, log=False)#

Basic timer utility.

This is for when you want to see just how incredibly inefficient your pile of shit it.

Example#

Timing something and printing the total time as a formatted string:

with SimpleTimer("Test Timer") as timer:
    ...

print(timer)
start = 0#
time = 0#
name = None#
log = False#
__enter__()#
__exit__(*args)#
__str__()#
Application.colour_balance(img: PIL.Image.Image, shadows: tuple[float, float, float], midtones: tuple[float, float, float], highlights: tuple[float, float, float], preserve_luminance: bool = False) PIL.Image.Image#
Application.merge(images)#
Application.levels(img: PIL.Image.Image, black, white, gamma)#
Application.get_rgb_histogram(image: PIL.Image.Image)#
Application.split_rgb(image: PIL.Image.Image)#
Application.split_smh(image: PIL.Image.Image)#
Application.get_histogram(image: PIL.Image.Image)#
Application.add(image, dx)#