I am trying to make a simple program that shows me what the first frame of a video looks like when it's converted into the different colourspaces available in openCV.
I am trying to use an iterator like this:
for item in flags: arg = 'cv2.' + str(item) newCs = cv2.cvtColor(frame, arg) cv2.imshow('newCs', newCs) # if I press no, destroy if cv2.waitKey(0) & 0xFF == ord('n'): cv2.destroyAllWindows() # if I press yes, save and destroy if cv2.waitKey(0) & 0xFF == ord('y'): filename = str(item) + '.jpg' cv2.imwrite(filename, newCs) cv2.destroyAllWindows()
where 'flags' is an array containing all the flags like 'COLOR_BGR2HSV' and arg successfully returns a string that looks like the flag you would enter manually into the function eg. 'cv2.COLOR_BGR2HSV'
This program returns an error, saying that it was expecting an int in place of 'arg'
Is this because what I'm trying to do is impossible, or is there a way of doing this?