This script fetches an image from Český hydrometeorologický ústav, processes it to detect specific color ranges, and gets the probability of mushroom growth in a specified region. Additionally, it sends an email with the results. The code is automated via GitHub actions to send it on every Thursday.
requests
Pillow
(PIL)numpy
matplotlib
opencv-python
email
smtplib
sys
datetime
os
-
Set up environment variables:
Ensure the following environment variables are set:
EMAIL_USERNAME
: Your email username.EMAIL_PASSWORD
: Your email password.RECIPIENTS
: A comma-separated list of email recipients.
-
Run the script:
python mushrooms.py
The script performs the following steps:
- Downloads an image from the specified URL.
- Processes the image to detect specific color ranges.
- Gets the probability of mushroom growth in the specified region.
- Displays the probabilities and the processed image.
- Sends an email with the results.
Sends an email with the specified subject and body to the list of recipients.
Visualizes the color ranges defined for mushroom growth probabilities.
Detects and displays the probabilities of mushroom growth in the specified region of the image.
The script processes an image from this URL, extracts a specific region, and calculates the probability of mushroom growth based on defined color ranges. The result is displayed and sent via email.
Edit the following variables in the script to customize the region and color ranges:
img_url
: URL of the image to be processed.y_range
andx_range
: Define the region of the image to be analyzed.color_values
: Define the color ranges for different probability levels.
The script will print the dominant probability of mushroom growth in the specified region and send an email with the details.