Skip to content

Latest commit

 

History

History
68 lines (49 loc) · 1.47 KB

README.md

File metadata and controls

68 lines (49 loc) · 1.47 KB

qtcam

PyQt5 widget for OpenCV camera preview with multiple instantiation and real time image filtering.

This module contains the next classes:

  • CameraDevice: Manages image capture and emits a signal when a new frame is available.
  • CameraWidget: Implements a Qt widget for camera image preview.
  • Filters: Implements some basic image filters.

Usage

Simple preview widget

from PyQt5.QtWidgets import QApplication

from qtcam import CameraDevice, CameraWidget

app = QApplication([])

widget = CameraWidget(CameraDevice())
widget.show()

app.exec_()

Multiple widget instances with image filtering

from PyQt5.QtWidgets import QApplication

from qtcam import CameraDevice, CameraWidget, Filter

app = QApplication([])

device = CameraDevice()
widget_1 = CameraWidget(device)
widget_1.show()

widget_2 = CameraWidget(device)
widget_2.add_filter(Filter.gray)
widget_2.show()

app.exec_()

Custom filtering

import cv2
from PyQt5.QtWidgets import QApplication

from qtcam import CameraDevice, CameraWidget

def custom_filter(frame):
    return cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

app = QApplication([])

widget = CameraWidget(CameraDevice())
widget.add_filter(custom_filter)
widget.show()

app.exec_()

Examples