From 0d42293b9cc1d6f8a5cd754ef0248280ae79d845 Mon Sep 17 00:00:00 2001 From: MarvinKweyu Date: Fri, 16 Aug 2024 18:23:26 +0300 Subject: [PATCH 1/3] refac: init project refac --- docs/colshare.rst | 9 ++++- pyproject.toml | 40 +++++++++++++++++++ setup.py | 31 -------------- {colordetect => src/colordetect}/__init__.py | 3 ++ {colordetect => src/colordetect}/col_share.py | 2 +- .../colordetect}/color_detect.py | 0 .../colordetect}/video_color_detect.py | 2 +- tests/test_functional.py | 2 +- tests/test_unit.py | 2 +- 9 files changed, 55 insertions(+), 36 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py rename {colordetect => src/colordetect}/__init__.py (79%) rename {colordetect => src/colordetect}/col_share.py (98%) rename {colordetect => src/colordetect}/color_detect.py (100%) rename {colordetect => src/colordetect}/video_color_detect.py (99%) diff --git a/docs/colshare.rst b/docs/colshare.rst index aca4f3c..5850a3b 100644 --- a/docs/colshare.rst +++ b/docs/colshare.rst @@ -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} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..264a751 --- /dev/null +++ b/pyproject.toml @@ -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" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 5399abc..0000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="ColorDetect", - version="1.6.2", - author="Marvin Kweyu", - author_email="mkweyu1@gmail.com", - description="Detect and recognize colors in images or video", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/MarvinKweyu/ColorDetect", - packages=setuptools.find_packages(), - include_package_data=True, - license="MIT", - install_requires=[ - "numpy>=1.18.1", - "matplotlib>=3.2.1", - "opencv-python>=4.2.0.32", - "scikit-learn>=0.22.2.post1", - "webcolors>=1.11.1", - ], - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX :: Linux", - ], - python_requires=">=3.6", -) diff --git a/colordetect/__init__.py b/src/colordetect/__init__.py similarity index 79% rename from colordetect/__init__.py rename to src/colordetect/__init__.py index b819b12..2dca2b7 100644 --- a/colordetect/__init__.py +++ b/src/colordetect/__init__.py @@ -1,3 +1,6 @@ from . import col_share from .color_detect import ColorDetect from .video_color_detect import VideoColor + + +__all__ = ['ColorDetect'] \ No newline at end of file diff --git a/colordetect/col_share.py b/src/colordetect/col_share.py similarity index 98% rename from colordetect/col_share.py rename to src/colordetect/col_share.py index c4ffa2c..3623034 100644 --- a/colordetect/col_share.py +++ b/src/colordetect/col_share.py @@ -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("", "", "") # sort a dictionary by value to required length or in specific order diff --git a/colordetect/color_detect.py b/src/colordetect/color_detect.py similarity index 100% rename from colordetect/color_detect.py rename to src/colordetect/color_detect.py diff --git a/colordetect/video_color_detect.py b/src/colordetect/video_color_detect.py similarity index 99% rename from colordetect/video_color_detect.py rename to src/colordetect/video_color_detect.py index 49b0472..9e8ac87 100644 --- a/colordetect/video_color_detect.py +++ b/src/colordetect/video_color_detect.py @@ -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) """ diff --git a/tests/test_functional.py b/tests/test_functional.py index 6de785a..2adc90a 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -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): diff --git a/tests/test_unit.py b/tests/test_unit.py index 92595f8..e97d788 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -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): From a6353e14882982039d70f52a3a000d8ca273da07 Mon Sep 17 00:00:00 2001 From: MarvinKweyu Date: Sat, 17 Aug 2024 19:54:20 +0300 Subject: [PATCH 2/3] refac: imports --- __init__.py | 0 src/colordetect/__init__.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/colordetect/__init__.py b/src/colordetect/__init__.py index 2dca2b7..1abe8e1 100644 --- a/src/colordetect/__init__.py +++ b/src/colordetect/__init__.py @@ -1,6 +1,6 @@ -from . import col_share -from .color_detect import ColorDetect -from .video_color_detect import VideoColor +from color_detect import ColorDetect +from video_color_detect import VideoColor +from . import col_share -__all__ = ['ColorDetect'] \ No newline at end of file +__all__ = ['ColorDetect', 'VideoColor', 'col_share'] \ No newline at end of file From 679fbeec4362c01b74ad546bc06e15864884e98a Mon Sep 17 00:00:00 2001 From: MarvinKweyu Date: Sat, 17 Aug 2024 20:05:34 +0300 Subject: [PATCH 3/3] docs: update readme tags --- README.md | 4 ++-- src/colordetect/col_share.py | 2 +- tests/test_unit.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9046498..b0b362a 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ ![Lint workflow](https://github.com/MarvinKweyu/ColorDetect/actions/workflows/lint.yml/badge.svg?branch=master) [![PyPI version](https://badge.fury.io/py/ColorDetect.svg)](https://pypi.org/project/ColorDetect/) -[![Python](https://img.shields.io/badge/python-3.6%7C3.7%7C3.8%7C3.9-green)](https://pypi.org/project/ColorDetect/) -[![CircleCI](https://circleci.com/gh/MarvinKweyu/ColorDetect.svg?style=svg)](https://circleci.com/gh/MarvinKweyu/ColorDetect) +[![Python](https://img.shields.io/badge/python->=3.6-green)](https://pypi.org/project/ColorDetect/) +![Package tests](https://github.com/MarvinKweyu/ColorDetect/actions/workflows/package-tests.yml/badge.svg?branch=master) [![Downloads](https://pepy.tech/badge/colordetect)](https://pypi.org/project/ColorDetect/) [![Documentation Status](https://readthedocs.org/projects/colordetect/badge/?version=master)](https://colordetect.readthedocs.io/en/master/) diff --git a/src/colordetect/col_share.py b/src/colordetect/col_share.py index 3623034..41028a8 100644 --- a/src/colordetect/col_share.py +++ b/src/colordetect/col_share.py @@ -7,7 +7,7 @@ Usage: ->>> from src.color_detect import col_share +>>> from src.colordetect import col_share # show a progress bar for a process >>> col_share.progress_bar("", "", "") # sort a dictionary by value to required length or in specific order diff --git a/tests/test_unit.py b/tests/test_unit.py index e97d788..1d63e1e 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -10,7 +10,7 @@ import cv2 import pytest -from colordetect import ColorDetect, VideoColor, col_share +from src.colordetect import ColorDetect, VideoColor, col_share def test_image_vid_parsed_to_class(image, video):