Run OpenCV with video output

I have a RockPi 4 with a USB camera and a small HDMI screen. All I want to do is display the live camera image with some simple effects and overlays. So I guess OpenCV would be perfect for this. I have a basic dietpi image already installed. But I’m not sure what else is needed to run my OpenCV application… Do I have to install a desktop environment like lxde in order to have video output or will it work with a headless setup? Are there any other requirements I should be aware of? Any pointers in the right direction are appreciated.

It seems like you don’t need a desktop environment and prerequisites are also handled in the guides below:
https://raspberrypi-guide.github.io/programming/install-opencv
YT video: How to Install OpenCV on a Raspberry Pi

uhh quite some dependency requires, at least following the guide posted by @Jappe

Anway, thinks like build-essential cmake should not be required as precompiled wheels are available on pypi. opencv-python · PyPI

Using version 4.5.3.56 seems to be working

root@DietPiR5S:~# python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.3'
>>>
root@DietPiR5S:~#
1 Like