import cv2
from utils import Dataloader

# Initialise the dataset
dataset = Dataloader(root="irships")

# Use the len keyword to get the length of the dataset
print("\nDataset length: %i" % len(dataset))

print("\nShuffling dataset")
dataset.shuffle()

print("\nLet's iterate through the dataset:")

# Finally, you can iterate over the dataset like this...
for i, (inp, lab) in enumerate(dataset):

    print("Image %i:\n--------------" % i)
    print(inp, "\n")  # The 'inp' contains meta data and the input image

    print("Label %i:\n--------------" % i)
    print(lab, "\n")  # The 'lab' contains meta data too, and the object extents (x1, y1, x2, y2)
    
    cv2.imshow("IRShips Image", inp.image)  # Display the current image
    print("Press 'q' to quit or press any other key to continue...\n")
    if (cv2.waitKey(0) & 0xFF) == ord("q"):
        cv2.destroyAllWindows()
        break

