After I downloaded the source code of opencv-4.8.0 on github(and opencv_opencv_contrib-4.8.0), I compiled it manually. The compilation parameters are as follows:
cmake -D BUILD_opencv_python3=ON
-D BUILD_opencv_python2=OFF
-D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_FFMPEG=1
-D CUDA_ARCH_BIN=5.3
-D WITH_CUDA=1
-D ENABLE_FAST_MATH=1
-D CUDA_FAST_MATH=1
-D WITH_CUBLAS=1
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.8.0/modules..
After the compilation is successful, make install
is performed. After the operation is completed, I enter python3 and enter import cv2
in the python terminal, and it prompts me that the library cannot be found.
But I can successfully import the cv2 library by entering import cv2
under the /opencv/opencv-4.8.0/build/python_loader
path.
Then I conducted a simple loading video test, the code is as follows:
root@concotianqi-desktop:/home/concotianqi/opencv/opencv-4.8.0/build/python_loader# python3
Python 3.6.9 (default, Mar 10 2023, 16:46:00)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import cv2
x = cv2.VideoCapture(“2.avi”)
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 260
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 260
[ WARN:0@11.588] global cap_gstreamer.cpp:2785 handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module avidemux0 reported: Internal data stream error.
[ WARN:0@11.601] global cap_gstreamer.cpp:1679 open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0@11.602] global cap_gstreamer.cpp:1164 isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
x. read()
(False, None)
It can be seen that the video frame data cannot be successfully read. It is known that the video is lossless after completion, and the video frame data can be successfully read using the same code on other computers. What is going on here, and how can I go about it? Solved, thanks. Bothered me for a long time.