fast-color-checker


Namefast-color-checker JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/fast_color_checker
SummaryA couple of fast algorithms for counting and locating colors in pictures
upload_time2022-10-23 02:48:35
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords screenshot adb windows hwnd handle bot cv2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
### A couple of fast algorithms for counting and locating colors in pictures



#### Get all coordinates of a certain color in your picture



```python

$pip install fast-color-checker  

from fast_color_checker import ColorCheck

```



```python

pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")

x0, y0, xy0 = pic.get_coords_of_color((255, 212, 59))



x0

Out[4]:

array([164, 162, 163, 164, 161, 162, 163, 159, 160, 161, 162, 163, 158,

	   159, 160, 161, 162, 157, 158, 159, 160, 161, 162, 155, 156, 157,

	   158, 159, 160, 161, 154, 155, 156, 157, 158, 159, 160, 161, 152,

	   153, 154, 155, 156, 157, 158, 159, 160, 151, 152, 153, 154, 155,

	   156, 157, 158, 159, 160, 149, 150, 151, 152, 153, 154, 155, 156,

	   ....



y0

Out[7]:

array([117, 118, 118, 118, 119, 119, 119, 120, 120, 120, 120, 120, 121,

	   121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 123, 123, 123,

	   123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 124, 124, 125,

	   125, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126

	   ....



xy0

Out[9]: (if zipxy is True) / (None if zipxy is False)

((164, 117),

 (162, 118),

 (163, 118),

 (164, 118),

 (161, 119),

 (162, 119),

 (163, 119),

 (159, 120),

 (160, 120),

 (161, 120),

 (162, 120),

 (163, 120),

 ....



	Parameters:

		color:Union[str,tuple,list]

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

		zipxy: bool

			[50,100,200], [20,120,220] -> [(50,20), (100,120), (200,220)]

			(default=True)

		highlightcolor:Union[None,tuple]=None

			Only relevant if you want to see the output results with pic.show_result()

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

			(default=None)

	Returns:

		tuple

		(all x coordinates, all y coordinates, zipped x,y coordinates/None)

```



#### Get all coordinates of a certain color range in your picture



```python

pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")



each_color_detailed1,sum_1=pic.get_coords_of_color_range(start=(255,215,60),end=  '#FFE262',highlightcolor=(255,0,255))

#result https://github.com/hansalemaos/screenshots/raw/main/colorfind2.png



each_color_detailed1

....

  ((255, 210, 60), ()),

  ((255, 211, 55), ()),

  ((255, 211, 56), ()),

  ((255, 211, 57), ()),

  ((255, 211, 58), ()),

  ((255, 211, 59), ()),

  ((255, 211, 60), ()),

  ((255, 212, 55), ()),

  ((255, 212, 56), ()),

  ((255, 212, 57), ()),

  ((255, 212, 58), ()),

  ((255, 212, 59),

   ((164, 117),

	(162, 118),

	(163, 118),

	(164, 118),

	(161, 119),

	(162, 119),

	(163, 119),

	(159, 120),

	(160, 120),

	(161, 120),

	(162, 120),

	(163, 120),

....



sum1

...

 (132, 125),

 (130, 126),

 (131, 126),

 (129, 127),

 (130, 127),

 (128, 128),

 (126, 129),

 (127, 129),

 (125, 130),

 (123, 131),

 (124, 131),

 (115, 137),

 (113, 138),

 (114, 138),

 (112, 139),

 (110, 140),

 (111, 140),

 ...



	Parameters:

		start:Union[str,tuple,list]

			start of the color range

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

		end:Union[str,tuple,list]

			end of the color range

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

		highlightcolor:Union[None,tuple]=None

			Only relevant if you want to see the output results with pic.show_result()

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

			(default=None)

	Returns:

		tuple

		(all x coordinates, all y coordinates, zipped x,y coordinates/None)

```



#### Count how often a certain color is present



```python

Count how often a certain color is present

pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")



pic.count_color((255, 212, 59))

Out[12]: 477

	Parameters:

		color:Union[str,tuple,list]

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black



	Returns:

		int

```



#### Count how often the colors of a certain color range are present



```python

Count how often the colors of a certain color range are present

pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")

each_color_detailed, sum_ = pic.count_color_range(start=(255, 215, 60), end="FFE262")



sum_

Out[5]: 2976



each_color_detailed

Out[6]:

[((255, 215, 60), 0),

 ((255, 215, 61), 0),

 ((255, 215, 62), 0),

 ((255, 215, 63), 0),

 ((255, 215, 64), 0),

 ((255, 215, 65), 0),

 ((255, 215, 66), 48),

 ((255, 215, 67), 69),

 ((255, 215, 68), 87),

 ((255, 215, 69), 19),

 ...



	Parameters:

		start:Union[str,tuple,list]

			start of the color range

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black

		end:Union[str,tuple,list]

			end of the color range

			examples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black



	Returns:

		tuple

```



#### Get all colors in an image



```python

pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")

pic.get_all_colors_in_image()

((0, 0, 0),

 (77, 64, 18),

 (80, 66, 18),

 (83, 69, 20),

 (86, 72, 20),

 (87, 72, 20),

 (88, 73, 20),

 (77, 66, 21),

 (73, 63, 23),

 (81, 70, 26),

 (118, 98, 27),

 ...

```



#### Count all colors



```python

pic.count_all_colors()

Out[4]:

[((0, 0, 0), 27515),

 ((77, 64, 18), 1),

 ((80, 66, 18), 1),

 ((83, 69, 20), 1),

 ((86, 72, 20), 1),

 ((87, 72, 20), 1),

 ((88, 73, 20), 1),

 ((77, 66, 21), 1),

 ...

```



#### Limit search region



```python

Limit search to a certain region of the picture



pic = ColorCheck(r"https://www.python.org/static/opengraph-icon-200x200.png")



pic.crop_imageselection((100, 100), (150, 150))



each_color_detailed1, sum_1 = pic.get_coords_of_color_range(

	start=(255, 215, 60), end="#FFE262", highlightcolor=(255, 0, 255)

)



pic.reset_cropped_imageselection()



x1, y1, xy1 = pic.get_coords_of_color(

	(255, 212, 59), zipxy=False, highlightcolor=(255, 0, 0)

)



pic.show_result()



#result: https://github.com/hansalemaos/screenshots/raw/main/colorfind4.png



	Parameters:

		start: tuple

			x,y coordinates

		end: tuple

			x,y coordinates

	Returns:

		self

```



#### Reset limited search region



```python

pic.reset_cropped_imageselection()

```



#### Show results



```python

pic.show_result()

Show results

	Parameters:

		window_name: str

			OpenCV window title

			(default = "")

		quit_key: str

			Key to close OpenCV window

			(default = "q")

	Returns:

		self

```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/fast_color_checker",
    "name": "fast-color-checker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "screenshot,adb,windows,hwnd,handle,bot,cv2",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6d/67/3c21c93e09c2c40a1c3ed11be4d359922457ccbf2b0a8ff07594d2852572/fast_color_checker-0.10.tar.gz",
    "platform": null,
    "description": "\n### A couple of fast algorithms for counting and locating colors in pictures\n\n\n\n#### Get all coordinates of a certain color in your picture\n\n\n\n```python\n\n$pip install fast-color-checker  \n\nfrom fast_color_checker import ColorCheck\n\n```\n\n\n\n```python\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\nx0, y0, xy0 = pic.get_coords_of_color((255, 212, 59))\n\n\n\nx0\n\nOut[4]:\n\narray([164, 162, 163, 164, 161, 162, 163, 159, 160, 161, 162, 163, 158,\n\n\t   159, 160, 161, 162, 157, 158, 159, 160, 161, 162, 155, 156, 157,\n\n\t   158, 159, 160, 161, 154, 155, 156, 157, 158, 159, 160, 161, 152,\n\n\t   153, 154, 155, 156, 157, 158, 159, 160, 151, 152, 153, 154, 155,\n\n\t   156, 157, 158, 159, 160, 149, 150, 151, 152, 153, 154, 155, 156,\n\n\t   ....\n\n\n\ny0\n\nOut[7]:\n\narray([117, 118, 118, 118, 119, 119, 119, 120, 120, 120, 120, 120, 121,\n\n\t   121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 123, 123, 123,\n\n\t   123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 124, 124, 125,\n\n\t   125, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126\n\n\t   ....\n\n\n\nxy0\n\nOut[9]: (if zipxy is True) / (None if zipxy is False)\n\n((164, 117),\n\n (162, 118),\n\n (163, 118),\n\n (164, 118),\n\n (161, 119),\n\n (162, 119),\n\n (163, 119),\n\n (159, 120),\n\n (160, 120),\n\n (161, 120),\n\n (162, 120),\n\n (163, 120),\n\n ....\n\n\n\n\tParameters:\n\n\t\tcolor:Union[str,tuple,list]\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\tzipxy: bool\n\n\t\t\t[50,100,200], [20,120,220] -> [(50,20), (100,120), (200,220)]\n\n\t\t\t(default=True)\n\n\t\thighlightcolor:Union[None,tuple]=None\n\n\t\t\tOnly relevant if you want to see the output results with pic.show_result()\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\t\t(default=None)\n\n\tReturns:\n\n\t\ttuple\n\n\t\t(all x coordinates, all y coordinates, zipped x,y coordinates/None)\n\n```\n\n\n\n#### Get all coordinates of a certain color range in your picture\n\n\n\n```python\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\n\n\neach_color_detailed1,sum_1=pic.get_coords_of_color_range(start=(255,215,60),end=  '#FFE262',highlightcolor=(255,0,255))\n\n#result https://github.com/hansalemaos/screenshots/raw/main/colorfind2.png\n\n\n\neach_color_detailed1\n\n....\n\n  ((255, 210, 60), ()),\n\n  ((255, 211, 55), ()),\n\n  ((255, 211, 56), ()),\n\n  ((255, 211, 57), ()),\n\n  ((255, 211, 58), ()),\n\n  ((255, 211, 59), ()),\n\n  ((255, 211, 60), ()),\n\n  ((255, 212, 55), ()),\n\n  ((255, 212, 56), ()),\n\n  ((255, 212, 57), ()),\n\n  ((255, 212, 58), ()),\n\n  ((255, 212, 59),\n\n   ((164, 117),\n\n\t(162, 118),\n\n\t(163, 118),\n\n\t(164, 118),\n\n\t(161, 119),\n\n\t(162, 119),\n\n\t(163, 119),\n\n\t(159, 120),\n\n\t(160, 120),\n\n\t(161, 120),\n\n\t(162, 120),\n\n\t(163, 120),\n\n....\n\n\n\nsum1\n\n...\n\n (132, 125),\n\n (130, 126),\n\n (131, 126),\n\n (129, 127),\n\n (130, 127),\n\n (128, 128),\n\n (126, 129),\n\n (127, 129),\n\n (125, 130),\n\n (123, 131),\n\n (124, 131),\n\n (115, 137),\n\n (113, 138),\n\n (114, 138),\n\n (112, 139),\n\n (110, 140),\n\n (111, 140),\n\n ...\n\n\n\n\tParameters:\n\n\t\tstart:Union[str,tuple,list]\n\n\t\t\tstart of the color range\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\tend:Union[str,tuple,list]\n\n\t\t\tend of the color range\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\thighlightcolor:Union[None,tuple]=None\n\n\t\t\tOnly relevant if you want to see the output results with pic.show_result()\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\t\t(default=None)\n\n\tReturns:\n\n\t\ttuple\n\n\t\t(all x coordinates, all y coordinates, zipped x,y coordinates/None)\n\n```\n\n\n\n#### Count how often a certain color is present\n\n\n\n```python\n\nCount how often a certain color is present\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\n\n\npic.count_color((255, 212, 59))\n\nOut[12]: 477\n\n\tParameters:\n\n\t\tcolor:Union[str,tuple,list]\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\n\n\tReturns:\n\n\t\tint\n\n```\n\n\n\n#### Count how often the colors of a certain color range are present\n\n\n\n```python\n\nCount how often the colors of a certain color range are present\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\neach_color_detailed, sum_ = pic.count_color_range(start=(255, 215, 60), end=\"FFE262\")\n\n\n\nsum_\n\nOut[5]: 2976\n\n\n\neach_color_detailed\n\nOut[6]:\n\n[((255, 215, 60), 0),\n\n ((255, 215, 61), 0),\n\n ((255, 215, 62), 0),\n\n ((255, 215, 63), 0),\n\n ((255, 215, 64), 0),\n\n ((255, 215, 65), 0),\n\n ((255, 215, 66), 48),\n\n ((255, 215, 67), 69),\n\n ((255, 215, 68), 87),\n\n ((255, 215, 69), 19),\n\n ...\n\n\n\n\tParameters:\n\n\t\tstart:Union[str,tuple,list]\n\n\t\t\tstart of the color range\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\t\tend:Union[str,tuple,list]\n\n\t\t\tend of the color range\n\n\t\t\texamples of valid inputs: (255, 212, 59), ffa7d7, #ffa9d9, black\n\n\n\n\tReturns:\n\n\t\ttuple\n\n```\n\n\n\n#### Get all colors in an image\n\n\n\n```python\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\npic.get_all_colors_in_image()\n\n((0, 0, 0),\n\n (77, 64, 18),\n\n (80, 66, 18),\n\n (83, 69, 20),\n\n (86, 72, 20),\n\n (87, 72, 20),\n\n (88, 73, 20),\n\n (77, 66, 21),\n\n (73, 63, 23),\n\n (81, 70, 26),\n\n (118, 98, 27),\n\n ...\n\n```\n\n\n\n#### Count all colors\n\n\n\n```python\n\npic.count_all_colors()\n\nOut[4]:\n\n[((0, 0, 0), 27515),\n\n ((77, 64, 18), 1),\n\n ((80, 66, 18), 1),\n\n ((83, 69, 20), 1),\n\n ((86, 72, 20), 1),\n\n ((87, 72, 20), 1),\n\n ((88, 73, 20), 1),\n\n ((77, 66, 21), 1),\n\n ...\n\n```\n\n\n\n#### Limit search region\n\n\n\n```python\n\nLimit search to a certain region of the picture\n\n\n\npic = ColorCheck(r\"https://www.python.org/static/opengraph-icon-200x200.png\")\n\n\n\npic.crop_imageselection((100, 100), (150, 150))\n\n\n\neach_color_detailed1, sum_1 = pic.get_coords_of_color_range(\n\n\tstart=(255, 215, 60), end=\"#FFE262\", highlightcolor=(255, 0, 255)\n\n)\n\n\n\npic.reset_cropped_imageselection()\n\n\n\nx1, y1, xy1 = pic.get_coords_of_color(\n\n\t(255, 212, 59), zipxy=False, highlightcolor=(255, 0, 0)\n\n)\n\n\n\npic.show_result()\n\n\n\n#result: https://github.com/hansalemaos/screenshots/raw/main/colorfind4.png\n\n\n\n\tParameters:\n\n\t\tstart: tuple\n\n\t\t\tx,y coordinates\n\n\t\tend: tuple\n\n\t\t\tx,y coordinates\n\n\tReturns:\n\n\t\tself\n\n```\n\n\n\n#### Reset limited search region\n\n\n\n```python\n\npic.reset_cropped_imageselection()\n\n```\n\n\n\n#### Show results\n\n\n\n```python\n\npic.show_result()\n\nShow results\n\n\tParameters:\n\n\t\twindow_name: str\n\n\t\t\tOpenCV window title\n\n\t\t\t(default = \"\")\n\n\t\tquit_key: str\n\n\t\t\tKey to close OpenCV window\n\n\t\t\t(default = \"q\")\n\n\tReturns:\n\n\t\tself\n\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A couple of fast algorithms for counting and locating colors in pictures",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/fast_color_checker"
    },
    "split_keywords": [
        "screenshot",
        "adb",
        "windows",
        "hwnd",
        "handle",
        "bot",
        "cv2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dae8078d80aab73f9dd731599f89c01f0a4955b0cb1f4f8d0dde5b644f50645e",
                "md5": "f11a39f700f0161d2bbc38af3661948c",
                "sha256": "cc4723d17c9904bee6e5d7fcd4701e766f94aa225a3fca1886ba280f28132969"
            },
            "downloads": -1,
            "filename": "fast_color_checker-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f11a39f700f0161d2bbc38af3661948c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12924,
            "upload_time": "2022-10-23T02:48:34",
            "upload_time_iso_8601": "2022-10-23T02:48:34.347931Z",
            "url": "https://files.pythonhosted.org/packages/da/e8/078d80aab73f9dd731599f89c01f0a4955b0cb1f4f8d0dde5b644f50645e/fast_color_checker-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d673c21c93e09c2c40a1c3ed11be4d359922457ccbf2b0a8ff07594d2852572",
                "md5": "84698a6d17f421fcfb98e1a72275e1fb",
                "sha256": "8139b2ff71ef2f3c7d0578b5e5f3898b2b5f6aed733bdec99060292179bd695d"
            },
            "downloads": -1,
            "filename": "fast_color_checker-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "84698a6d17f421fcfb98e1a72275e1fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11517,
            "upload_time": "2022-10-23T02:48:35",
            "upload_time_iso_8601": "2022-10-23T02:48:35.895183Z",
            "url": "https://files.pythonhosted.org/packages/6d/67/3c21c93e09c2c40a1c3ed11be4d359922457ccbf2b0a8ff07594d2852572/fast_color_checker-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-23 02:48:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "fast_color_checker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "fast-color-checker"
}
        
Elapsed time: 0.18428s