whacamolefinder


Namewhacamolefinder JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/whacamolefinder
SummaryGet the difference between 2 images
upload_time2023-09-20 23:43:25
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords whac-a-mole compare images
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Get the difference between 2 images 

## Tested against Windows 10 / Python 3.11 / Anaconda

### pip install whacamolefinder

The WhacAMoleFinder class is designed for continuously comparing 
pairs of images and finding differences between them. 
It is used in scenarios where you want to monitor a changing image, 
such as a game or application interface, and detect any alterations or visual changes.

## The advantages:

### Continuous Image Comparison: 

The class allows you to continuously compare two consecutive screenshots or images, 
enabling real-time monitoring for changes.

### Difference Detection: 

It detects differences between the images using image processing techniques, 
highlighting regions where changes occur.

### Customizable Parameters: 

You can customize various parameters, such as the percentage of resizing, 
the color used for highlighting differences, the thickness 
of highlighting lines, and the threshold for difference detection. 
This flexibility allows you to adapt the class to different use cases and scenarios.

### Visualization: 

It provides an option to display the images with differences 
highlighted, making it easy to visualize what has changed.

### Interactive Control: 

The class includes a control mechanism to stop the comparison process, 
which is useful when you want to pause or terminate the monitoring.

### Yielding Results: 

It yields the results of the comparison as a list of Token namedtuples, 
providing information about the differences found in consecutive images.




```python

Args:
	screenshotiter: A generator or iterator that provides screenshots for comparison.

Attributes:
	screenshotiter (generator): The iterator supplying screenshots.
	stop (bool): A flag to control the comparison process. Set to True to stop comparing.
	last_screenshot
	before_last_screenshot

Methods:
	start_comparing: Begin the image comparison process and yield results.

Example:
	from whacamolefinder import WhacAMoleFinder
	from fast_ctypes_screenshots import (
		ScreenshotOfOneMonitor,
	)

	# create your own screenshot function, you can use whatever you want (fast_ctypes_screenshots/adb/mss/pyautogui/...),
	# but it is important to use a loop and yield!
	def screenshot_iter_function():
		while True:
			with ScreenshotOfOneMonitor(
				monitor=0, ascontiguousarray=False
			) as screenshots_monitor:
				yield screenshots_monitor.screenshot_one_monitor()



	# Create an instance of WhacAMoleFinder

	piit = WhacAMoleFinder(screenshot_iter_function) # pass the function without calling it!
	for ini, di in enumerate(
		piit.start_comparing(
			percent_resize=10,
			draw_output=True,
			draw_color=(255, 0, 255),
			thickness=20,
			thresh=3,
			maxval=255,
			draw_on_1_or_2=2,
			break_key="q",
		)
	):
		print(di)
		if ini > 100:
		piit.stop = True
		print(piitlast_screenshot)
		print(piitbefore_last_screenshot)

#You can compare 2 images without using the class:
# Call the get_difference_of_2_pics function to compare the two images
allresults, out = get_difference_of_2_pics(
	pic1='c:/pic1.jpg',
	pic2='c:/pic2.jpg',
	percent_resize=10,
	draw_output=True,  # Set to True to visualize the differences
	draw_color=(255, 0, 255),  # Custom color for highlighting differences
	thickness=2,  # Line thickness for highlighting
	thresh=3,  # Threshold for difference detection
	maxval=255,  # Maximum value for thresholding
	draw_on_1_or_2=1,  # Draw differences on the first image
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/whacamolefinder",
    "name": "whacamolefinder",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "whac-a-mole,compare,images",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/d9/7b351d9e9393c3f829450012592c03c0c81e7612cf4736d791f0139346ac/whacamolefinder-0.11.tar.gz",
    "platform": null,
    "description": "\r\n# Get the difference between 2 images \r\n\r\n## Tested against Windows 10 / Python 3.11 / Anaconda\r\n\r\n### pip install whacamolefinder\r\n\r\nThe WhacAMoleFinder class is designed for continuously comparing \r\npairs of images and finding differences between them. \r\nIt is used in scenarios where you want to monitor a changing image, \r\nsuch as a game or application interface, and detect any alterations or visual changes.\r\n\r\n## The advantages:\r\n\r\n### Continuous Image Comparison: \r\n\r\nThe class allows you to continuously compare two consecutive screenshots or images, \r\nenabling real-time monitoring for changes.\r\n\r\n### Difference Detection: \r\n\r\nIt detects differences between the images using image processing techniques, \r\nhighlighting regions where changes occur.\r\n\r\n### Customizable Parameters: \r\n\r\nYou can customize various parameters, such as the percentage of resizing, \r\nthe color used for highlighting differences, the thickness \r\nof highlighting lines, and the threshold for difference detection. \r\nThis flexibility allows you to adapt the class to different use cases and scenarios.\r\n\r\n### Visualization: \r\n\r\nIt provides an option to display the images with differences \r\nhighlighted, making it easy to visualize what has changed.\r\n\r\n### Interactive Control: \r\n\r\nThe class includes a control mechanism to stop the comparison process, \r\nwhich is useful when you want to pause or terminate the monitoring.\r\n\r\n### Yielding Results: \r\n\r\nIt yields the results of the comparison as a list of Token namedtuples, \r\nproviding information about the differences found in consecutive images.\r\n\r\n\r\n\r\n\r\n```python\r\n\r\nArgs:\r\n\tscreenshotiter: A generator or iterator that provides screenshots for comparison.\r\n\r\nAttributes:\r\n\tscreenshotiter (generator): The iterator supplying screenshots.\r\n\tstop (bool): A flag to control the comparison process. Set to True to stop comparing.\r\n\tlast_screenshot\r\n\tbefore_last_screenshot\r\n\r\nMethods:\r\n\tstart_comparing: Begin the image comparison process and yield results.\r\n\r\nExample:\r\n\tfrom whacamolefinder import WhacAMoleFinder\r\n\tfrom fast_ctypes_screenshots import (\r\n\t\tScreenshotOfOneMonitor,\r\n\t)\r\n\r\n\t# create your own screenshot function, you can use whatever you want (fast_ctypes_screenshots/adb/mss/pyautogui/...),\r\n\t# but it is important to use a loop and yield!\r\n\tdef screenshot_iter_function():\r\n\t\twhile True:\r\n\t\t\twith ScreenshotOfOneMonitor(\r\n\t\t\t\tmonitor=0, ascontiguousarray=False\r\n\t\t\t) as screenshots_monitor:\r\n\t\t\t\tyield screenshots_monitor.screenshot_one_monitor()\r\n\r\n\r\n\r\n\t# Create an instance of WhacAMoleFinder\r\n\r\n\tpiit = WhacAMoleFinder(screenshot_iter_function) # pass the function without calling it!\r\n\tfor ini, di in enumerate(\r\n\t\tpiit.start_comparing(\r\n\t\t\tpercent_resize=10,\r\n\t\t\tdraw_output=True,\r\n\t\t\tdraw_color=(255, 0, 255),\r\n\t\t\tthickness=20,\r\n\t\t\tthresh=3,\r\n\t\t\tmaxval=255,\r\n\t\t\tdraw_on_1_or_2=2,\r\n\t\t\tbreak_key=\"q\",\r\n\t\t)\r\n\t):\r\n\t\tprint(di)\r\n\t\tif ini > 100:\r\n\t\tpiit.stop = True\r\n\t\tprint(piitlast_screenshot)\r\n\t\tprint(piitbefore_last_screenshot)\r\n\r\n#You can compare 2 images without using the class:\r\n# Call the get_difference_of_2_pics function to compare the two images\r\nallresults, out = get_difference_of_2_pics(\r\n\tpic1='c:/pic1.jpg',\r\n\tpic2='c:/pic2.jpg',\r\n\tpercent_resize=10,\r\n\tdraw_output=True,  # Set to True to visualize the differences\r\n\tdraw_color=(255, 0, 255),  # Custom color for highlighting differences\r\n\tthickness=2,  # Line thickness for highlighting\r\n\tthresh=3,  # Threshold for difference detection\r\n\tmaxval=255,  # Maximum value for thresholding\r\n\tdraw_on_1_or_2=1,  # Draw differences on the first image\r\n)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Get the difference between 2 images",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/whacamolefinder"
    },
    "split_keywords": [
        "whac-a-mole",
        "compare",
        "images"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90bf0a674d89011ba7e47b75c4c27285e05fb81b6a50dafd8fa0c402f19c1e2d",
                "md5": "24f453898a1dfc5cdfd2e7d5a055fd7a",
                "sha256": "02ab50365ed2b026a2b1bcfdc7d64c8145ff6dafd0db495555c3aadfc928df5b"
            },
            "downloads": -1,
            "filename": "whacamolefinder-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "24f453898a1dfc5cdfd2e7d5a055fd7a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 60153,
            "upload_time": "2023-09-20T23:43:23",
            "upload_time_iso_8601": "2023-09-20T23:43:23.999705Z",
            "url": "https://files.pythonhosted.org/packages/90/bf/0a674d89011ba7e47b75c4c27285e05fb81b6a50dafd8fa0c402f19c1e2d/whacamolefinder-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97d97b351d9e9393c3f829450012592c03c0c81e7612cf4736d791f0139346ac",
                "md5": "2f475160dd8811fcface79537101ae33",
                "sha256": "d55563e4c451e30c4243637903c812210aadcf5d3102681c358622b7e9118f7f"
            },
            "downloads": -1,
            "filename": "whacamolefinder-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "2f475160dd8811fcface79537101ae33",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 59330,
            "upload_time": "2023-09-20T23:43:25",
            "upload_time_iso_8601": "2023-09-20T23:43:25.921947Z",
            "url": "https://files.pythonhosted.org/packages/97/d9/7b351d9e9393c3f829450012592c03c0c81e7612cf4736d791f0139346ac/whacamolefinder-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-20 23:43:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "whacamolefinder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "whacamolefinder"
}
        
Elapsed time: 0.11394s