diff --git a/README.md b/README.md index 3fb3bee..521712d 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,18 @@ This package has only been tested on a Windows system. Using the [Anaconda distribution](https://www.anaconda.com/products/individual) of Python is recommended for easiest installation of the toolbox requirements. ### Installation -1. Clone this repo onto your PC: `git clone http://git.wrl.unsw.edu.au:3000/jonoc/coastsnap.git` -2. Change your working directory into the repo: `cd CoastsnapAuto` -3. Create a new conda environment called "coastsnap" with the required dependencies. This is the same environment as for the Leaman CoastSnap Toolbox, so you may already have it. If you're not sure, run: `conda info --envs` and look for "coastsnap". Otherwise, create the environment by runnning: -`conda env create -f environment.yml` +1. Install Git (if you don't already have it) for windows from the following link https://git-scm.com/download/win +2. Clone this repo onto your PC: `git clone http://git.wrl.unsw.edu.au:3000/jonoc/coastsnap.git` +3. Change your working directory into the repo: `cd CoastsnapAuto` +4. Update or create a new conda environment called "coastsnap" with the required dependencies. This is (almost) the same environment as for the Leaman CoastSnap Toolbox, so you may already have it. If you're not sure, run: `conda info --envs` and look for "coastsnap". If you already have the environment, run: `conda env update --name coastsnap --file environment.yml` to update it. Otherwise, create the environment by runnning: +`conda env create -f environment.yml`. +5. Check if you can activate the conda environment with `activate coastsnap`. If not, you may need to update your environment `Path` variable to include paths to the Anaconda install, like the following: +```sh +C:\Users\z5079346\Applications\Anaconda +C:\Users\z5079346\Applications\Anaconda\Scripts +C:\Users\z5079346\Applications\Anaconda\Library\bin +``` +If `activate coastsnap` is still not working, you will have to edit each of the .bat files and substitute the first line `call activate coastsnap` with the direct path to the `activate.bat` file, such as "C:\Users\z5079346\Applications\Anaconda\Scripts\activate.bat". Substitute the third line `call deactivate` with the path to `deactivate.bat` ### Demo (optional) The following is a demo to make sure all of the code is working and for the user to get a sense of the intended workflow. It'll take approx. 10 mins (assuming everything works). The code will run on a demo CoastSnap directory (`CoastSnap_DEMO`) with 3 sites. @@ -30,14 +38,15 @@ The following is a demo to make sure all of the code is working and for the user 1. Open up `coastsnap_sites.csv`. Change the path name in cell E2, to the path of the CoastsnapAuto/CoastSnap_DEMO directory. 2. Open the CoastsnapAuto/coastsnap directory -3. Run `batch_spotteron_download.bat` [30s] +3. Run `1_batch_spotteron_download.bat` [30s] - This downloads 5 images each for 3 sites and stores them in CoastSnap_DEMO/Images/Site_Name/Processed) -4. Run `batch_photoshop_registration.bat` [2 mins] +4. Run `2_batch_photoshop_registration.bat` [2 mins] +- Note: If this doesn't work. Make sure - This registers the 15 images in photoshop and stores them in CoastSnap_DEMO/Images/Site_Name/Photoshop -5. Run `batch_tag_registered.bat` [3 mins] +5. Run `3_batch_tag_registered.bat` [3 mins] - This tags the photoshop registered images and stores them in CoastSnap_DEMO/Images/Site_Name/Registered. Note: Loading .mat tide data in Python takes a while. 6. Delete any poorly registered/tagged images in CoastSnap_DEMO/Images/Site_Name/Registered -7. Run `generate_images_snapshot.bat` +7. Run `4_generate_images_snapshot.bat` - This generates a snapshot of the CoastSnap images directory at `images_snapshot.csv` ### Update file paths diff --git a/coastsnap/batch_spotteron_download.bat b/coastsnap/1_batch_spotteron_download.bat similarity index 100% rename from coastsnap/batch_spotteron_download.bat rename to coastsnap/1_batch_spotteron_download.bat diff --git a/coastsnap/batch_photoshop_registration.bat b/coastsnap/2_batch_photoshop_registration.bat similarity index 100% rename from coastsnap/batch_photoshop_registration.bat rename to coastsnap/2_batch_photoshop_registration.bat diff --git a/coastsnap/batch_tag_registered.bat b/coastsnap/3_batch_tag_registered.bat similarity index 100% rename from coastsnap/batch_tag_registered.bat rename to coastsnap/3_batch_tag_registered.bat diff --git a/coastsnap/generate_images_snapshot.bat b/coastsnap/4_generate_images_snapshot.bat similarity index 100% rename from coastsnap/generate_images_snapshot.bat rename to coastsnap/4_generate_images_snapshot.bat diff --git a/coastsnap/spotteron_batch_download.py b/coastsnap/spotteron_batch_download.py index aae5337..17e7cb9 100644 --- a/coastsnap/spotteron_batch_download.py +++ b/coastsnap/spotteron_batch_download.py @@ -11,7 +11,6 @@ from os import path, makedirs, getcwd import attr import pytz import requests -#import typer import pandas as pd from loguru import logger from timezonefinder import TimezoneFinder diff --git a/coastsnap/tag_registered.py b/coastsnap/tag_registered.py index 970b9b1..b9027c3 100644 --- a/coastsnap/tag_registered.py +++ b/coastsnap/tag_registered.py @@ -1,30 +1,11 @@ -import datetime -import shutil -from enum import Enum -from functools import cached_property -from itertools import product from pathlib import Path - -import attr -import cv2 -import numpy as np import pandas as pd -from loguru import logger -from moviepy.editor import * - import os os.chdir(Path(__file__).parent.resolve()) - -from utils import divide_chunks, datenum_to_datetime, nearest, progressbar, RegisteredImage -import time # progress bar - -from PIL import Image, ImageFont, ImageDraw -from time import strptime -from dateutil import tz - +from utils import datenum_to_datetime, RegisteredImage import openpyxl import scipy.io as sio -from datetime import datetime, timedelta +from PIL import Image, ImageDraw ''' SCRIPT LOGIC @@ -97,6 +78,8 @@ def tag_image(image2tag): image.save(registered_path) +image2tag = None #initialize this here + for site in os.listdir(images_dir): # Loop through SITES i=0 site_complete = False # A flag to stop tagging images when found @@ -114,22 +97,20 @@ for site in os.listdir(images_dir): # Loop through SITES image_list = os.listdir(year_path) image_list.reverse() for image_filename in image_list: # Loop through IMAGES - #print(image_filename) registered_year_path = year_path.replace('Photoshop', 'Registered') registered_image_path = registered_year_path + '/' + image_filename[:-4] + '_registered.jpg' - if site not in image_filename: + if site not in image_filename: # Check the filename has the site in it continue - # Check if image already tagged - if os.path.isfile(registered_image_path): + if os.path.isfile(registered_image_path): # Image already tagged. Go to next site. site_complete = True; if i == 0: print(site + ": " + str(i) + " images tagged") - elif image2tag.tide: + elif image2tag and image2tag.tide: print(site + ": " + str(i) + " images tagged with tide") else: print(site + ": " + str(i) + " images tagged no tide") break - else: + else: # Image not tagged. Tag it. if not os.path.exists(registered_year_path): # Chech that registered/year directory exists os.makedirs(registered_year_path) # if not, create it i += 1