Skip to content

Commit

Permalink
Perform check on availability of color description in write
Browse files Browse the repository at this point in the history
-  edit readme and package description  to reflect video color recognition
  • Loading branch information
MarvinKweyu committed Oct 17, 2020
1 parent ea98e77 commit 8b8b9c2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Documentation

- Add ``write_text`` method along with other breaking changes to the documentation

.. _0.3.1:
0.3.1 (17-10-2020)
==================

Bug fix
-------

- Perform check to ensure the color description has content before writing color count.

.. _0.3.0:
0.3.0 (26-09-2020)
==================
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![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/)

ColorDetect works to recognize and identify different colors in an image.
ColorDetect works to recognize and identify different colors in an image or video.


### Installation
Expand Down
14 changes: 9 additions & 5 deletions colordetect/color_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def write_color_count(self):
-----------------
Write the number of colors found to the image
"""

if not self.color_description:
raise AttributeError(f"No color description found on this object. Perform get_color_count() first.")

line_spacing = 0
for k, v in self.color_description.items():
color_values = str(v) + '% :' + k
Expand Down Expand Up @@ -162,10 +166,10 @@ def write_text(self, text: str = "", line_spacing: int = 0):
lineType = 1

cv2.putText(self.image, text, bottomLeftCornerOfText,
font,
fontScale,
fontColor,
lineType)
font,
fontScale,
fontColor,
lineType)

def save_image(self, location=".", file_name: str = "out.jpg"):
"""
Expand All @@ -184,7 +188,7 @@ def save_image(self, location=".", file_name: str = "out.jpg"):
"""
if type(file_name) != str:
raise TypeError(f"file_name should be a string.Provided {file_name}")
raise TypeError(f"file_name should be a string.Provided {type(file_name)}")

image_folder = Path(location)
image_to_save = image_folder / file_name
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author = 'Marvin Kweyu'

# The full version, including alpha/beta/rc tags
release = '0.3.0'
release = '0.3.1'

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

setuptools.setup(
name="ColorDetect",
version="0.3.0",
version="0.3.1",
author="Marvin Kweyu",
author_email="mkweyu1@gmail.com",
description="Detect and recognize colors in images",
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",
Expand Down
7 changes: 5 additions & 2 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ def test_valid_params_to_get_color_count(image):
user_image.get_color_count(color_count="many_colors")


def test_file_name_param_is_valid(image, datadir):
def test_save_params_are_valid(image, datadir):
"""
A string is being used as a file name
A string is being used as a file name as well as location
"""
user_image = ColorDetect(image)
user_image.get_color_count(color_count=1)

with pytest.raises(Exception) as e_info:
user_image.save_image(location=datadir, file_name=5)

# with pytest.raises(Exception) as e_info:
# user_image.save_image(location=500, file_name="output.jpg")


def test_result_file_name_is_valid(image, datadir):
"""
Expand Down

0 comments on commit 8b8b9c2

Please sign in to comment.