add opencl hw decoding in gst and intel acceeleration's opencv that reduce double the CPU usage rate in a sot task.

This commit is contained in:
Daniel 2024-05-25 17:19:22 +08:00
parent 88e92030ad
commit 091d50e66b
4 changed files with 50 additions and 2 deletions

View File

@ -0,0 +1,20 @@
#!/bin/sh
sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install -y libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base
sudo apt install -y gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
sudo apt install -y gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc
sudo apt install -y gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa
sudo apt install -y gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5
sudo apt install -y gstreamer1.0-pulseaudio
sudo apt install -y gtk-doc-tools
sudo apt install -y libeigen3-dev libfmt-dev v4l-utils
git clone https://gitee.com/jario-jin/gst-rtsp-server-b18.git
cd gst-rtsp-server-b18
./autogen.sh
make
sudo make install
cd ..
sudo rm -r gst-rtsp-server-b18

View File

@ -0,0 +1,6 @@
#!/bin/sh
sudo apt-get install -y libmfx1 libmfx-tools libva-dev libmfx-dev intel-media-va-driver-non-free vainfo va-driver-all vdpau-va-driver
echo "export LIBVA_DRIVER_NAME=i965" >> ~/.bashrc
export LIBVA_DRIVER_NAME=i965

View File

@ -60,7 +60,19 @@ cmake -D CMAKE_BUILD_TYPE=Release \
-D WITH_CUDA=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.7.0/modules ..
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.7.0/modules \
-D BUILD_PNG=ON \
-D BUILD_JASPER=ON \
-D BUILD_JPEG=ON \
-D BUILD_TIFF=ON \
-D BUILD_ZLIB=ON \
-D WITH_JPEG=ON \
-D WITH_PNG=ON \
-D WITH_JASPER=ON \
-D WITH_TIFF=ON \
-D WITH_TBB=ON \
-D WITH_ZLIB=ON \
-D WITH_OPENCL=ON ..
make -j2
sudo make install

View File

@ -159,13 +159,23 @@ void Camera::openImpl()
this->_fps = 30;
}
#if defined(PLATFORM_X86_CUDA) || defined(PLATFORM_X86_INTEL)
#if defined(PLATFORM_X86_CUDA)
sprintf(pipe, "rtspsrc location=%s?W=%d&H=%d&FPS=%d latency=100 ! \
application/x-rtp,media=video ! rtph264depay ! parsebin ! avdec_h264 ! \
videoconvert ! appsink sync=false",
this->_rtsp_url.c_str(), this->_width, this->_height, this->_fps);
this->_cap.open(pipe, cv::CAP_GSTREAMER);
#endif
#if defined(PLATFORM_X86_INTEL)
sprintf(pipe, "rtspsrc location=%s?W=%d&H=%d&FPS=%d latency=100 ! \
application/x-rtp,media=video ! rtph264depay ! parsebin ! vaapih264dec ! \
vaapipostproc ! video/x-raw,format=YV12,framerate=25/1 ! videoconvert ! videorate ! video/x-raw,framerate=25/1 ! \
appsink sync=false",
this->_rtsp_url.c_str(), this->_width, this->_height, this->_fps);
this->_cap.open(pipe, cv::CAP_GSTREAMER);
#endif
#ifdef PLATFORM_JETSON
sprintf(pipe, "rtspsrc location=%s?W=%d&H=%d&FPS=%d latency=100 ! application/x-rtp,media=video ! rtph264depay ! parsebin ! nvv4l2decoder enable-max-performancegst=1 ! nvvidconv ! video/x-raw,format=(string)BGRx ! videoconvert ! appsink sync=false", this->_rtsp_url.c_str(), this->_width, this->_height, this->_fps);
this->_cap.open(pipe, cv::CAP_GSTREAMER);