No project description provided
Project description
Computer Vision Design Patterns
Tecnology stack
- uv for python and project manager
- pre-commit with ruff to mantain code consistency and pre-commit checks
- GitHub Actions to create release and publish package (also on a private registry)
Installation
Note: You need uv (and uv only) installed on your machine.
To install the package:
uv sync
Usage
Events
TimeEvent
TimeEvent activates immediately when triggered and automatically deactivates after a specified duration.
from computer_vision_design_patterns.event import TimeEvent
import time
# Create an event that stays active for 2 seconds
event = TimeEvent(2)
# Trigger the event
event.trigger()
print(event.is_active()) # True
# After 2 seconds
time.sleep(2)
print(event.is_active()) # False
# Retriggering resets the timer
event.trigger()
print(event.is_active()) # True again
CountdownEvent
CountdownEvent starts inactive, counts down for a specified duration, and then activates.
from computer_vision_design_patterns.event import CountdownEvent
import time
# Create a countdown event for 3 seconds
event = CountdownEvent(3)
# Start the countdown
event.trigger()
print(event.is_active()) # False (still counting down)
# After 3 seconds
time.sleep(3)
print(event.is_active()) # True (countdown completed)
# Reset the event
event.reset()
print(event.is_active()) # False
Key Differences
-
TimeEvent:
- Activates immediately upon trigger and can be triggered multiple times
- Automatically deactivates after the duration has elapsed
- Can be reset by triggering again
-
CountdownEvent:
- Starts inactive
- Can be triggered multiple times
- Activates only after countdown completes
- Stays active until manually reset
Examples
Check the dev folder for comprehensive examples of both event types.
Counters
ManualCounter
ManualCounter is a simple counter that activates when it reaches a specified threshold value. It requires manual updates and can be reset to start counting again.
from computer_vision_design_patterns.counter import ManualCounter
import time
# Create a counter that activates after 3 counts
counter = ManualCounter(3)
# Update the counter
counter.update()
print(counter.is_active()) # False (count = 1)
counter.update()
print(counter.is_active()) # False (count = 2)
counter.update()
print(counter.is_active()) # True (count = 3)
# Reset the counter
counter.reset()
print(counter.is_active()) # False (count = 0)
Examples
Check the dev/ folder for comprehensive examples of counter usage.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file computer_vision_design_patterns-2.0.11-py3-none-any.whl.
File metadata
- Download URL: computer_vision_design_patterns-2.0.11-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9467b028501ebd4e9edb1769dfa4bf374e1c9d81b724d7c27b2f11b7cfbd8d0d
|
|
| MD5 |
e2e532f474f93eaf81996cec48d75c98
|
|
| BLAKE2b-256 |
92f4baea278839d71cf126ab2005c03727a1d352168a419564d5ee61be8f1f36
|
Provenance
The following attestation bundles were made for computer_vision_design_patterns-2.0.11-py3-none-any.whl:
Publisher:
release.yml on lanzani/computer-vision-design-patterns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
computer_vision_design_patterns-2.0.11-py3-none-any.whl -
Subject digest:
9467b028501ebd4e9edb1769dfa4bf374e1c9d81b724d7c27b2f11b7cfbd8d0d - Sigstore transparency entry: 869055401
- Sigstore integration time:
-
Permalink:
lanzani/computer-vision-design-patterns@083d5d5f6849fd23f873715764801c7e894260a0 -
Branch / Tag:
refs/tags/2.0.11 - Owner: https://github.com/lanzani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@083d5d5f6849fd23f873715764801c7e894260a0 -
Trigger Event:
push
-
Statement type: