Skip to content

Instantly share code, notes, and snippets.

@docPhil99
docPhil99 / opencv_qt_label.md
Last active April 13, 2024 15:48
How to display opencv video in pyqt apps

The code for this tutorial is here

Opencv provides are useful, but limited, method of building a GUI. A much more complete system could be acheived using pyqt. The question is, how do we display images. There are quite a few possible routes but perhaps the easiest is to use QLabel since it has a setPixmap function. Below is some code that creates two labels. It then creates a grey pixmap and displays it one of the labels. code: staticLabel1.py

from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QVBoxLayout
from PyQt5.QtGui import QPixmap, QColor
import sys
@tlatsas
tlatsas / dpi.py
Last active December 8, 2022 10:27
calculate screen DPI
#!/usr/bin/env python
# calculate screen DPI
# supports both python 2 and 3
import re
import argparse
from math import sqrt
from subprocess import check_output