{"id":15546730,"url":"https://github.com/hansalemaos/locate_pixelcolor_cpp","last_synced_at":"2026-05-01T09:32:52.925Z","repository":{"id":65966500,"uuid":"603621871","full_name":"hansalemaos/locate_pixelcolor_cpp","owner":"hansalemaos","description":"Locate RGB values in a picture! Up to 10x faster than NumPy, 100x faster than PIL.","archived":false,"fork":false,"pushed_at":"2023-02-28T20:24:55.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-11T09:15:00.362Z","etag":null,"topics":["cpp","locate","pixelcolor","python","rgb"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/locate-pixelcolor-cpp","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-19T04:15:24.000Z","updated_at":"2023-02-19T04:18:02.000Z","dependencies_parsed_at":"2024-11-15T02:54:06.529Z","dependency_job_id":"6142057e-d6e4-4426-a21e-e3f9d25fd3d2","html_url":"https://github.com/hansalemaos/locate_pixelcolor_cpp","commit_stats":{"total_commits":2,"total_committers":2,"mean_commits":1.0,"dds":0.5,"last_synced_commit":"09a28b5b4fcde68de8cbdc8705a51a5bfb3bc25b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hansalemaos/locate_pixelcolor_cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Flocate_pixelcolor_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Flocate_pixelcolor_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Flocate_pixelcolor_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Flocate_pixelcolor_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/locate_pixelcolor_cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Flocate_pixelcolor_cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32492220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","locate","pixelcolor","python","rgb"],"created_at":"2024-10-02T13:04:00.122Z","updated_at":"2026-05-01T09:32:52.894Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Locate RGB values in a picture! Up to 10x faster than NumPy, 100x faster than PIL. \n\n## How to install \n\n### pip install locate-pixelcolor-cpp\n\n### Please install this C++ compiler:\n\nMSVC ..... C++ x64/x86 build tools from: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community\u0026channel=Release\u0026version=VS2022\u0026source=VSLandingPage\u0026passive=false\u0026cid=2030\n\nLocalize the following files (Version number might vary) and copy their path:\nvcvarsall_bat = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\"\n\ncl_exe = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\"\n\nlink_exe = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\"\n\n\n## Compile the code\n```python\nfrom locate_pixelcolor_cpp import compile_localize_picture_color_with_cpp\ncompile_localize_picture_color_with_cpp(\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n)\n```\n\n### Benchmark \n\n```python\n# Let's use a 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/\n\nfrom locate_pixelcolor_cpp import search_colors # The function can only be imported when the compilation was successful ( compile_localize_picture_color_with_cpp )\nimport cv2\npath=r\"C:\\Users\\Gamer\\Documents\\Downloads\\pexels-alex-andrews-2295744.jpg\"\nim = cv2.imread(path)\n\n\ncolors=[(66,  71,  69),(62,  67,  65),(144, 155, 153),(52,  57,  55),(127, 138, 136),(53,  58,  56),(51,  56,  54),(32,  27,  18),(24,  17,   8),]\n#%timeit search_colors(im, colors=colors)\n##127 ms ± 3.61 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\nfrom locate_pixelcolor import search_colors as search_colors2\n# first version with numexpr\n# https://github.com/hansalemaos/locate_pixelcolor\n#%timeit search_colors2(im,colors)\n##400 ms ± 18.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n\nimport numpy as np \nb,g,r = im[...,0],im[...,1],im[...,2]\n#%timeit np.where(((b==66)\u0026(g==71)\u0026(r==69))|((b==62)\u0026(g==67)\u0026(r==65))|((b==144)\u0026(g==155)\u0026(r==153))|((b==52)\u0026(g==57)\u0026(r==55))|((b==127)\u0026(g==138)\u0026(r==136))|((b==53)\u0026(g==58)\u0026(r==56))|((b==51)\u0026(g==56)\u0026(r==54))|((b==32)\u0026(g==27)\u0026(r==18))|((b==24)\u0026(g==17)\u0026(r==8)))\n##1 s ± 16.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n\n\nfrom PIL import Image\nimg = Image.open(path)\nimg = img.convert(\"RGB\")\ndatas = img.getdata()\n\ndef pi():\n    newData = []\n    for item in datas:\n        if (item[0] == 66 and item[1] == 71 and item[2] == 69) or (item[0] == 62 and item[1] == 67 and item[2] == 65) or (item[0] == 144 and item[1] == 155 and item[2] == 153) or (item[0] == 52 and item[1] == 57 and item[2] == 55) or (item[0] == 127 and item[1] == 138 and item[2] == 136) or (item[0] == 53 and item[1] == 58 and item[2] == 56) or (item[0] == 51 and item[1] == 56 and item[2] == 54) or (item[0] == 32 and item[1] == 27 and item[2] == 18) or (item[0] == 24 and item[1] == 17 and item[2] == 8):\n            newData.append(item)\n    return newData\n%timeit pi()\n\n##10.6 s ± 51.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n\n\n## One color \n\nfrom locate_pixelcolor_cpp import search_colors\nimport cv2\npath=r\"C:\\Users\\Gamer\\Documents\\Downloads\\pexels-alex-andrews-2295744.jpg\"\nim = cv2.imread(path)\n#%timeit search_colors(im, colors=[(255,255,255)])\n#75.3 ms ± 247 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\n\n\n# first version with numexpr\n# https://github.com/hansalemaos/locate_pixelcolor\nfrom locate_pixelcolor import search_colors\nimport cv2\npath=r\"C:\\Users\\Gamer\\Documents\\Downloads\\pexels-alex-andrews-2295744.jpg\"\nim = cv2.imread(path)\n# %timeit search_colors(im, colors=[(255,255,255)])\n# 98 ms ± 422 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\n\nb,g,r = im[...,0],im[...,1],im[...,2]\n# %timeit np.where(((b==255)\u0026(g==255)\u0026(r==255)))\n# 150 ms ± 209 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\n\n\nfrom PIL import Image\nimg = Image.open(path)\nimg = img.convert(\"RGB\")\ndatas = img.getdata()\ndef get_coords_with_pil(col):\n    newData = []\n    for item in datas:\n        if item[0] == col[0] and item[1] == col[1] and item[2] == col[2]:\n            newData.append(item)\n    return newData\n%timeit get_coords_with_pil(col=(255,255,255))\n3.41 s ± 14.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Flocate_pixelcolor_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Flocate_pixelcolor_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Flocate_pixelcolor_cpp/lists"}