I want to find an instance of a class, where an attribute has a certain value:
import numpy as np
import inspect
import matplotlib.pyplot as plt
class Frame():
def __init__(self, img, idx):
self.image = img
self.idx = idx
for i in range(10):
img = np.random.randint(0, high=255, size=(720, 1280, 3), dtype=np.uint8) # generate a random, noisy image
Frame(img, i)
# Pseudo Code below:
frame = inspect.getmembers(Frame, idx=5) # find an instance of a class where the index is equal to 5
plt.imshow(frame.img)