Skip to content

Instantly share code, notes, and snippets.

@flipphillips
Last active December 1, 2021 01:42
Show Gist options
  • Save flipphillips/54277d4c72b1f68620a37d9dd35f02ba to your computer and use it in GitHub Desktop.
Save flipphillips/54277d4c72b1f68620a37d9dd35f02ba to your computer and use it in GitHub Desktop.
opencv resolution test. need to install pandas and lxml for it to work
import pandas as pd
import cv2
url = "https://en.wikipedia.org/wiki/List_of_common_resolutions"
table = pd.read_html(url)[0]
table.columns = table.columns.droplevel()
cap = cv2.VideoCapture(0)
resolutions = {}
for index, row in table[["W", "H"]].iterrows():
cap.set(cv2.CAP_PROP_FRAME_WIDTH, row["W"])
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, row["H"])
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
resolutions[str(width)+"x"+str(height)] = "OK"
print(resolutions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment