If the image show and cv2 functions are accelerated by GPU?

Hi everyone,

I used the jetson nano for object tracking, but the frame rate appers to be slow when magnify the window from small window to full screen. I use the cv2 to show the image like this.

cv2.imshow(video_name, img)

The frame rate slow down from 10 to about 3bps, when the cpu and memory are nearly 90% used.
I build the opencv with CUDA and gstreamer support.

And the frame rate is very low when cv2.warpAffine is called for 1920*1080 image, from 20 to about 3fps.

If the image show and cv2 functions are accelerated by GPU?

cv2.version
‘3.4.6’

cv2.getBuildInformation()

General configuration for OpenCV 3.4.6 =====================================
Version control: unknown

Platform:
Timestamp: 2019-07-25T01:07:56Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: RELEASE

CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3

C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/bin/c++ (ver 7.4.0)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,–gc-sections
Linker flags (Debug): -Wl,–gc-sections
ccache: NO
Precompiled headers: YES
Extra dependencies: m pthread /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:

OpenCV modules:
To be built: calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python2 python3 shape stitching superres video videoio videostab
Disabled: world
Disabled by dependency: -
Unavailable: java js ts viz
Applications: apps
Documentation: NO
Non-free algorithms: NO

GUI:
QT: YES (ver 5.9.5)
QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
GTK+: NO
OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
VTK support: NO

Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
HDR: YES
SUNRASTER: YES
PXM: YES

Video I/O:
DC1394: YES (ver 2.2.5)
FFMPEG: YES
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: NO
GStreamer:
base: YES (ver 1.14.4)
video: YES (ver 1.14.4)
app: YES (ver 1.14.4)
riff: YES (ver 1.14.4)
pbutils: YES (ver 1.14.4)
libv4l/libv4l2: 1.14.2 / 1.14.2
v4l/v4l2: linux/videodev2.h

Parallel framework: pthreads

Trace: YES (built-in)

Other third-party libraries:
Lapack: YES (/usr/lib/aarch64-linux-gnu/liblapack.so /usr/lib/aarch64-linux-gnu/libcblas.so /usr/lib/aarch64-linux-gnu/libatlas.so)
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)

NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)

NVIDIA GPU arch: 53
NVIDIA PTX archs:

OpenCL: YES (no extra features)
Include path: /home/atsing/src/opencv-3.4.6/3rdparty/include/opencl/1.2
Link libraries: Dynamic load

Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.15)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15+)
numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.4)
install path: lib/python2.7/dist-packages/cv2/python-2.7

Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.8)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.8)
numpy: /home/atsing/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.16.4)
install path: lib/python3.6/dist-packages/cv2/python-3.6

Python (for build): /usr/bin/python2.7

Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO

Install to: /usr/local

thanks.

Hi,

It looks like NO.
The CUDA based implementation is defined as cv::cuda::xxx rather than cv::xxx.

Thanks.

With gstreamer, the solution is nvoverlaysink. It’s much faster than cv2.imshow

This is the C++ method, no python method available?
We made some GUI with pyqt, then can’t used together now.

Thanks.

Hi,

OpenCV has python wrapper.
You can launch a GStreamer pipeline within cv2.VideoCapture(…).

Thanks.

I found jetson-utils for NVIDIA Jetson - camera, codecs, CUDA, GStreamer, HID, OpenGL/XGL

I think the best way is combine Qt and CUDA together in C++, Python is nor a good choice to do these works.

If C++ is an option for you, it will be good.

Thanks.