Application =========== .. py:module:: Application Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/Application/billing/index /autoapi/Application/database/index /autoapi/Application/detect/index /autoapi/Application/image_procesing/index /autoapi/Application/images/index /autoapi/Application/music/index /autoapi/Application/rename_rolls/index /autoapi/Application/search/index /autoapi/Application/store/index /autoapi/Application/utils/index Classes ------- .. autoapisummary:: Application.Image Application.ImageManager Application.DJ Application.SearchMachine Application.ShittyMultiThreading Application.SimpleTimer Functions --------- .. autoapisummary:: Application.generate_bill Application.detect Application.visualise Application.rename_rolls Application.copy_images Application.load Application.write Application.colour_balance Application.merge Application.levels Application.get_rgb_histogram Application.split_rgb Application.split_smh Application.get_histogram Application.add Package Contents ---------------- .. py:function:: generate_bill(path: pathlib.Path, bill: collections.Counter) .. py:function:: detect(path: pathlib.Path) .. py:function:: visualise(path: pathlib.Path, faces, dimensions, thickness=5) .. py:class:: 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. .. py:attribute:: _version .. py:attribute:: path .. py:attribute:: raw_image .. py:attribute:: main_image_dimensions .. py:attribute:: thumbnail_dimensions .. py:method:: save() .. py:method:: dpg_texture() .. py:method:: thumbnail() .. py:method:: dpg_raw() .. py:method:: get_scaled_image(factor=0.15) .. py:method:: frompath(path: pathlib.Path, main_image_dimensions: Tuple[int, int], thumbnail_dimensions: Tuple[int, int], _version=None) :classmethod: Creates an Image object from the path of the image. Args: path (Path): Path to the image Returns: Image .. py:method:: fromserver(roll, id) :classmethod: Implement this function when the server is up and running. This doesn't work right now. Args: roll (str): id (str): .. py:class:: 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 .. py:attribute:: mode .. py:attribute:: current_index :value: 0 .. py:attribute:: main_image_dimensions .. py:attribute:: thumbnail_dimensions .. py:attribute:: images :type: list[pathlib.Path] :value: [] .. py:method:: from_path(path: pathlib.Path, main_image_dimensions, thumbnail_dimensions) :classmethod: .. py:method:: from_file_list(files: list[pathlib.Path], main_image_dimensions, thumbnail_dimensions) :classmethod: .. py:method:: from_server(url) :classmethod: .. py:method:: end_index() .. py:method:: 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: .. py:method:: load_in_background() Loads all the images in the background using ShittMultiThreading from utils.py This works because the images are cached. .. py:method:: 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 .. py:method:: next() Helper function to peek the next image Returns: Image .. py:method:: previous() Helper function to peek the previous image Returns: Image .. py:class:: 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 .. py:attribute:: audio_buffer .. py:attribute:: visualiser :value: None .. py:attribute:: fft .. py:attribute:: stream :value: None .. py:method:: callback(outdata: numpy.ndarray, frames: int, time: cffi.backend_ctypes.CTypesData, status: sounddevice.CallbackFlags) .. py:method:: file_reader(path) .. py:method:: compute_fft(data) .. py:method:: audio_buffer_setup_from_file(path) .. py:method:: finished_callback() .. py:method:: play(path) .. py:method:: stop() .. py:function:: rename_rolls(path: pathlib.Path, dubious_list: list) .. py:class:: SearchMachine .. py:attribute:: parser .. py:attribute:: fts_text :value: 'SELECT name, idno, hoscode, roomno FROM students WHERE rowid IN (SELECT * from (SELECT rowid... .. py:attribute:: id_text :value: 'SELECT name, idno, hoscode, roomno from students WHERE idno LIKE ?' .. py:attribute:: bhawan_text :value: 'SELECT name, idno, hoscode, roomno from students WHERE hoscode LIKE ?' .. py:attribute:: id_regex .. py:method:: get_name(argument) .. py:method:: get_id(argument) .. py:method:: get_bhawan(argument) .. py:method:: evaluate(argument) .. py:method:: search(text) -> set[SearchResult] | None .. py:function:: copy_images(counters: list[collections.Counter], path: pathlib.Path, source: list[pathlib.Path]) .. py:function:: load(roll: str) .. py:function:: write(counters: list[collections.Counter], roll: str) .. py:class:: ShittyMultiThreading(work, tasks, num_threads=5) terrible, utterly horrendous. doesn't even store the return values lmao .. py:attribute:: work .. py:attribute:: num_threads :value: 5 .. py:attribute:: queue .. py:method:: worker() .. py:method:: start() .. py:class:: 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) .. py:attribute:: start :value: 0 .. py:attribute:: time :value: 0 .. py:attribute:: name :value: None .. py:attribute:: log :value: False .. py:method:: __enter__() .. py:method:: __exit__(*args) .. py:method:: __str__() .. py:function:: 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 .. py:function:: merge(images) .. py:function:: levels(img: PIL.Image.Image, black, white, gamma) .. py:function:: get_rgb_histogram(image: PIL.Image.Image) .. py:function:: split_rgb(image: PIL.Image.Image) .. py:function:: split_smh(image: PIL.Image.Image) .. py:function:: get_histogram(image: PIL.Image.Image) .. py:function:: add(image, dx)