Skip to content

Commit

Permalink
refac: init project refac
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinKweyu committed Aug 16, 2024
1 parent c9ffc5f commit 0d42293
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 36 deletions.
9 changes: 8 additions & 1 deletion docs/colshare.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ Depending on how many colors you have or how many dominant colors you want to na

::

>>> from colordetect import col_share

from src.colordetect import col_share
>>> all_colors = my_video.get_video_frames()
>>> top_colors = col_share.sort_order(object_description=all_colors,key_count=5)
{'[0.0, 0.0, 0.0]': 68.83, '[5.0, 7.0, 24.0]': 22.48, '[5.0, 8.0, 24.0]': 22.22, '[4.0, 7.0, 24.0]': 21.7, '[6.0, 9.0, 26.0]': 19.11}

The sort gets the top 5 colors, by default, from all the colors obtained from all the frames present. This may be adjusted to suit your needs.
A reverse of the same may be obtained by passing the
>>> all_colors = my_video.get_video_frames()
>>> top_colors = col_share.sort_order(object_description=all_colors,key_count=5)
{'[0.0, 0.0, 0.0]': 68.83, '[5.0, 7.0, 24.0]': 22.48, '[5.0, 8.0, 24.0]': 22.22, '[4.0, 7.0, 24.0]': 21.7, '[6.0, 9.0, 26.0]': 19.11}
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"

[project]
name = "ColorDetect"
dynamic = ["version"]
description = "Detect and recognize colors in images or video"
readme = "README.md"
authors = [
{ name = "Marvin Kweyu", email = "mkweyu1@gmail.com" }
]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
keywords = ["ColorDetect", "color recognition","images", "video"]
dependencies = [
"numpy>=1.18.1",
"matplotlib>=3.2.1",
"opencv-python>=4.2.0.32",
"scikit-learn>=0.22.2.post1",
"webcolors>=1.11.1"
]
requires-python = ">=3.6"
[tool.setuptools]
tests = [
"tests/",
"*tests\\",
]

[project.optional-dependencies]
build = ["build", "twine"]
dev = ["black", "flake8","bumpver", "isort", "mypy", "pytest"]

[project.urls]
repository = "https://github.com/MarvinKweyu/ColorDetect"
documentation = "https://colordetect.readthedocs.io"
31 changes: 0 additions & 31 deletions setup.py

This file was deleted.

3 changes: 3 additions & 0 deletions colordetect/__init__.py → src/colordetect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from . import col_share
from .color_detect import ColorDetect
from .video_color_detect import VideoColor


__all__ = ['ColorDetect']
2 changes: 1 addition & 1 deletion colordetect/col_share.py → src/colordetect/col_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Usage:
>>> from colordetect import col_share
>>> from src.color_detect import col_share
# show a progress bar for a process
>>> col_share.progress_bar("<current_process_position>", "<total_process_length>", "<process_description>")
# sort a dictionary by value to required length or in specific order
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>>> colors = user_video.get_video_frames(frame_color_count=7)
>>> colors
# alternatively shorten the dictionary to get a specific number of sorted colors from the whole lot
>>> from colordetect import col_share
>>> from src.colordetect import col_share
>>> top_colors = col_share.sort_order(object_description=colors, key_count=8)
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import matplotlib.colors as mcolors

from ..colordetect import ColorDetect
from src.colordetect import ColorDetect


def test_existence_of_image_vid_path(image, video):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import cv2
import pytest

from ..colordetect import ColorDetect, VideoColor, col_share
from colordetect import ColorDetect, VideoColor, col_share


def test_image_vid_parsed_to_class(image, video):
Expand Down

0 comments on commit 0d42293

Please sign in to comment.