An open API service indexing awesome lists of open source software.

https://github.com/greatcattw/ubuntu_22_usb_camera_qt5_gstreamer

Display USB camera on ubuntu22 with Qt
https://github.com/greatcattw/ubuntu_22_usb_camera_qt5_gstreamer

gstreamer ubuntu22 usbcamera videooverlay videowidget

Last synced: about 2 months ago
JSON representation

Display USB camera on ubuntu22 with Qt

Awesome Lists containing this project

README

        

# ubuntu_22_usb_camera_qt5_gstreamer
Display USB camera on ubuntu22 with Qt

OS: Ubuntu 22.04.3

Qt Creator 4.11.1, Qt 5.14.1, GCC 5.3.1



There are 2 way to use:

(1) overlay

(2) QVideoWidget

From QT5.12.2, there is a quick call.

QMediaplayer->setMedia(QUrl("gst-pipeline: videotestsrc ! videoconvert ! xvimagesink name=\\\"qtvideosink\\\""));



Overlay and USB camera

![pic](pic/1.png)



QVideoWidget and videotestsrc

![pic](pic/2.png)



QVideoWidget and USB camera

![pic](pic/3.png)



# Just run executable file
sudo apt-get update

sudo apt-get install libqt5widgets5

sudo apt-get install libqt5multimedia5 libqt5multimediawidgets5

sudo apt-get install libqt5multimedia5-plugins

# Compile the source code
sudo apt-get update



sudo apt-get install build-essential

sudo apt-get install libfontconfig1

sudo apt-get install mesa-common-dev

sudo apt-get install libglu1-mesa-dev

sudo apt-get install libx11-dev libxext-dev libxtst-dev



download and install qt-opensource-linux-x64-5.14.2.run



sudo apt-get install libqt5widgets5

sudo apt-get install libqt5multimedia5 libqt5multimediawidgets5

sudo apt-get install libqt5multimedia5-plugins



sudo apt-get install libqt5gstreamer-dev


# Note 1 : Install driver
ASUS S501MER RTX5060 NVIDIA

OS: Ubuntu 22.04.3

sudo apt-get update

sudo apt-get install libc-dev -y

sudo apt-get install linux-headers-$(uname -r) -y

sudo apt-get install ubuntu-drivers-common -y

sudo apt-get install nvidia-driver-550 -y

# Note 2 : Install full gstreamer
sudo apt-get -y install \

libgstreamer1.0-dev \

libgstreamer-plugins-base1.0-dev \

libgstreamer-plugins-bad1.0-dev \

gstreamer1.0-plugins-base \

gstreamer1.0-plugins-good \

gstreamer1.0-plugins-bad \

gstreamer1.0-plugins-ugly \

gstreamer1.0-libav \

gstreamer1.0-tools \

gstreamer1.0-x \

gstreamer1.0-alsa \

gstreamer1.0-gl \

gstreamer1.0-gtk3 \

gstreamer1.0-qt5 \

gstreamer1.0-pulseaudio

# Note 3: Autorun
在Ubuntu, 要讓程式開機自動啟動, 方法之一是用systemd服務.

在/lib/systemd/system加個文字檔.

若是程式是有視窗與聲音的, 還要加環境參數

User=gcat

Group=gcat

Environment=DISPLAY=:0

Environment=XAUTHORITY=/home/gcat/.Xauthority

Environment=XDG_RUNTIME_DIR=/run/user/1000

Environment=QT_QPA_PLATFORM=xcb

## 例子
[Unit]

Description=autorun test09

After=multi-user.target

Wants=multi-user.target

#After=graphical.target



[Service]

#ExecStartPre=/bin/sleep 5

ExecStart=/usr/bin/test09

Restart=no

User=gcat

Group=gcat

Environment=DISPLAY=:0

Environment=XAUTHORITY=/home/gcat/.Xauthority

Environment=XDG_RUNTIME_DIR=/run/user/1000

Environment=QT_QPA_PLATFORM=xcb



[Install]

WantedBy=multi-user.target