Tags¶
Whenever a class is assigned to an image (or a bounding box within an image), it is recorded within this table.
Table Set Up¶
| Column Name | Content | Type | Unique | Nullable | Custom Constraints | Linked Table |
|---|---|---|---|---|---|---|
| ID | ID for entry | Integer | True | False | ||
| Class | class the image was tagged with | Integer | False | False | Classes ("ID") | |
| Tagger | person or AI that tagged the image | Integer | False | False | Taggers ("ID") | |
| Date | date the image was tagged | Date | False | False | ||
| Image | image that was tagged with given class | Integer | False | False | Images ("ID") | |
| X1 | relative distance from left border to left bounding box border | Float | False | False | Float [0,1] | |
| Y1 | relative distance from bottom border to bottom bbox border | Float | False | False | Float [0,1] | |
| X2 | relative distance from left border to right bounding box border | Float | False | False | Float [0,1] | |
| Y2 | relative distance from bottom border to top bbox border | Float | False | False | Float [0,1] |
Bounding Box¶
A standard approach for camera trap analysis is to run all imags through MegaDetector. MegaDetecor will then set a bounding box around the object of interest (Animal, Human, Vehicle). There may be more than one object of interest on an image. The bounding box is documented with 4 values: X1, Y1, X2 , Y2. All these values are relative values in regards to the image and are therefore a float between (and including) 0 and 1. The bounding boxes need to be stored in this way, to ensure that all bounding boxes and tags assigned to the bounding boxes can be processed in the same way. If the whole image was tagged, the bounding box given is [0,0,1,1]
Functions¶
Test code for each function of the Tags table is shown in Functions_Tags.ipynb
In order to use the class functions, an instance of the class needs to be created
import T_Tables as tableClasses
#create class instance
Tags = tableClasses.T_Tags()
add¶
This function adds a tag for an image to the database.
Tags.add(tag: str, tagger: str, image: str, cropCoordinates: list, date: datetime = None)
Parameters
- tag: name of class. This has to be documented in the Classes Table.
- tagger: who / what generated the tag. This has to be documented in the Taggers Table
- image: image the tag is assigned to.
- cropCoordinates: the 4 values that make up the bounding box in the order [X1, Y1, X2 , Y2].
- date: date the tag was created. If none given, the current date will be used as a default.
Returns
The function returns nothing.
addBatch¶
This function adds several tags at a time.
Tags.addBatch(df: pd.DataFrame)
Parameters
- df: dataframe with the following columns (names need to match the ones given below):
- required columns: Class, Tagger, Image, CropCoordinates
- optional columns: Date
CropCoordinates column have to be a string in a list format :
"[0.1,0.3,0.6,0.7]"
Returns
The function returns nothing.
getAll¶
This function gets all information for a all tags.
Tags.getAll()
Parameters
This Function has no parameters.
Returns
This function returns a pd.dataframe with one row for each documented tag.
filter¶
This function allows you to filter using specific conditions:
Tags.filter(
tagClass: str = None,
tagger: str = None,
image: str = None,
startDate: datetime = None,
endDate: datetime = None
)
Parameters
- tagClass: name of class the image/bounding box was tagged with. This only includes exactly that class and none of its retired children.
- tagger: who / what generated the tag.
- image: all tags for a specific image.
- startDate: date after a tag was documented.
- date: date before a tag was documented.
Returns
This function returns a pd.dataframe with one row for each tag that matches the filter conditions.
getSpeciesTags¶
This function gets all tags that reference a species class. In addition, it merges all retired or individual species tags into its current active class. E.g. The current active name is African Leopard with its retired children being "african leopard", "pantpard", "papa". Any of these classes will be returned uniformly as an African Leopard tag.
Tags.getSpeciesTags(minExpertise: int = 0)
minExpertise: the minimum level of expertise a tagger has to have for a tag to be included in the output.
Returns
This function returns a pd.dataframe with one row for each species tag that matches the filter conditions.
getVegetationTags¶
This function gets all tags that reference a vegetation class. In addition, it merges all children of vegetation (eg. Fire) into vegetation.
Tags.getVegetationTags(minExpertise: int = 0)
minExpertise: the minimum level of expertise a tagger has to have for a tag to be included in the output.
Returns
This function returns a pd.dataframe with one row for each vegetation tag that matches the filter conditions.