mdegans / gst-nvmanualcamerasrc

(unofficial) Nvidia argus camera source fork
MIT License
4 stars 2 forks source link

Using nvarguscamerasrc in conda environment? #18

Open beniroquai opened 2 years ago

beniroquai commented 2 years ago

Hey @mdegans,

thanks for putting so much effort into ensuring people to get access to machine vision on the Jetson! I've succesfully used your script to install opencv in a miniforge environment and face an issue when trying to access the camera. I think I'm very close, but there is one last error when executing the following line:

mypipeline = "nvarguscamerasrc sensor-id=0 !video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, width=(int)960, height=(int)540, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
cv2.VideoCapture(mypipeline, cv2.CAP_GSTREAMER)

It gives the following error:

[ WARN:0] global /home/uc2/Downloads/opencv-4.5.2/modules/videoio/src/cap_gstreamer.cpp (854) open OpenCV | GStreamer warning: Error opening bin: no element "nvarguscamerasrc"
[ WARN:0] global /home/uc2/Downloads/opencv-4.5.2/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Error: Unable to open camera

gstreamer should be installed properly and the shared library created with tis script is linked properly (at least it installed).. Did I miss anything? In the non pyhton environment python it works just fine. Same as in the terminal.

>>> cv2.getBuildInformation()
'\nGeneral configuration for OpenCV 4.5.2 =====================================\n  Version control:               unknown\n\n  Platform:\n    Timestamp:                   2022-01-25T22:14:52Z\n    Host:                        Linux 4.9.253-tegra aarch64\n    CMake:                       3.10.2\n    CMake generator:             Unix Makefiles\n    CMake build tool:            /usr/bin/make\n    Configuration:               RELEASE\n\n  CPU/HW features:\n    Baseline:                    NEON FP16\n\n  C/C++:\n    Built as dynamic libs?:      YES\n    C++ standard:                11\n    C++ Compiler:                /usr/bin/c++  (ver 7.5.0)\n    C++ flags (Release):         -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG\n    C++ flags (Debug):           -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG\n    C Compiler:                  /usr/bin/cc\n    C flags (Release):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG\n    C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG\n    Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  \n    Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  \n    ccache:                      NO\n    Precompiled headers:         NO\n    Extra dependencies:          dl m pthread rt\n    3rdparty dependencies:\n\n  OpenCV modules:\n    To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching ts video videoio\n    Disabled:                    world\n    Disabled by dependency:      -\n    Unavailable:                 java python2\n    Applications:                tests perf_tests examples apps\n    Documentation:               NO\n    Non-free algorithms:         YES\n\n  GUI: \n    GTK+:                        NO\n    OpenGL support:              NO\n    VTK support:                 NO\n\n  Media I/O: \n    ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)\n    JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)\n    WEBP:                        build (ver encoder: 0x020f)\n    PNG:                         /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)\n    TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)\n    JPEG 2000:                   build (ver 2.4.0)\n    OpenEXR:                     build (ver 2.3.0)\n    HDR:                         YES\n    SUNRASTER:                   YES\n    PXM:                         YES\n    PFM:                         YES\n\n  Video I/O:\n    DC1394:                      NO\n    FFMPEG:                      YES\n      avcodec:                   YES (57.107.100)\n      avformat:                  YES (57.83.100)\n      avutil:                    YES (55.78.100)\n      swscale:                   YES (4.8.100)\n      avresample:                YES (3.7.0)\n    GStreamer:                   YES (1.14.5)\n    v4l/v4l2:                    YES (linux/videodev2.h)\n\n  Parallel framework:            TBB (ver 2017.0 interface 9107)\n\n  Trace:                         YES (with Intel ITT)\n\n  Other third-party libraries:\n    Lapack:                      NO\n    Eigen:                       YES (ver 3.3.4)\n    Custom HAL:                  YES (carotene (ver 0.0.1))\n    Protobuf:                    build (3.5.1)\n\n  OpenCL:                        YES (no extra features)\n    Include path:                /home/uc2/Downloads/opencv-4.5.2/3rdparty/include/opencl/1.2\n    Link libraries:              Dynamic load\n\n  Python 3:\n    Interpreter:                 /home/uc2/miniforge3/envs/imswitch/bin/python3 (ver 3.7.12)\n    Libraries:                   /home/uc2/miniforge3/envs/imswitch/lib/libpython3.7m.so (ver 3.7.12)\n    numpy:                       /home/uc2/miniforge3/envs/imswitch/lib/python3.7/site-packages/numpy/core/include (ver 1.21.5)\n    install path:                /home/uc2/miniforge3/envs/imswitch/lib/python3.7/site-packages/cv2/python-3.7\n\n  Python (for build):            /home/uc2/miniforge3/envs/imswitch/bin/python3\n\n  Java:                          \n    ant:                         NO\n    JNI:                         NO\n    Java wrappers:               NO\n    Java tests:                  NO\n\n  Install to:                    /home/uc2/miniforge3/envs/imswitch\n-----------------------------------------------------------------\n\n'
mdegans commented 2 years ago

Sorry, the camera in the dev branch is intended to bypass cv2.VideoCapture and still in development. It's only been tested with an IMX477, but intended usage is a bit like this

(see the Camera class's docstring for how it's supposed to work)

It also yields RGBA frames, not BGR or BGRA since that's what I was dealing with on the project where I used this. The reason why VideoCapture must be bypassed is because there is no way (I know of) to pairs of images with metadata through that function.

beniroquai commented 2 years ago

Thanks! :)