What is a namespace object?

The documentation for argparse.Namespace can be found here. You can access the s attribute by doing args.s. If you’d like to access this as a dictionary, you can do vars(args), which means you can also do vars(args)[‘s’]

Why would cv2.COLOR_RGB2GRAY and cv2.COLOR_BGR2GRAY give different results?

RGB->gray conversion actually isn’t an average — different channels are weighed differently. Specifically: This is also mentioned in the documentation. Thus, it’s expected that RGB2GRAY and BGR2GRAY give different results. Regarding the discrepancy between sum-then-divide and divide-then-sum approaches, i.e. between and Recall that cv2.imread returns a uint8 numpy array. Thus, the latter operation (where all channels are combined … Read more

Rolling or sliding window iterator?

There’s one in an old version of the Python docs with itertools examples: The one from the docs is a little more succinct and uses itertools to greater effect I imagine. If your iterator is a simple list/tuple a simple way to slide through it with a specified window size would be: Output: