I hit this error after modifying the 15-image_view sample of VPI-2.3 to accept usb camera input via opencv.
My system:
Changes to CMakeLists.txt:
xxx@ubuntu:~/NVIDIA_VPI-2.3-samples/15-image_view$ diff CMakeLists.txt /opt/nvidia/vpi2/samples/15-image_view/CMakeLists.txt
35,48c35
< #target_link_libraries(${PROJECT_NAME} vpi opencv_core opencv_imgproc)
<
< # Link your application with OpenCV libraries
< target_link_libraries(${PROJECT_NAME} PRIVATE vpi ${OpenCV_LIBS})
<
< # If the package has been found, several variables will
< # be set, you can find the full list with descriptions
< # in the OpenCVConfig.cmake file.
< # Print some message showing some of them
< message(STATUS "OpenCV library status:")
< message(STATUS " config: ${OpenCV_DIR}")
< message(STATUS " version: ${OpenCV_VERSION}")
< message(STATUS " libraries: ${OpenCV_LIBS}")
< message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
---
> target_link_libraries(${PROJECT_NAME} vpi opencv_core opencv_imgproc)
49a37
> target_link_libraries(${PROJECT_NAME} opencv_imgcodecs)
Changes to main.cpp:
xxx@ubuntu:~/NVIDIA_VPI-2.3-samples/15-image_view$ diff main.cpp /opt/nvidia/vpi2/samples/15-image_view/main.cpp
32,33d31
< #include <opencv2/videoio.hpp>
< #include <opencv2/highgui.hpp>
84,100d81
<
< // Initialize camera
< cv::VideoCapture cap;
< cap.open(0);
<
< if(!cap.isOpened()) {
< std::cout << "ERROR opening camera..." << std::endl;
< return -1;
< }
<
<
< int w = cap.get(cv::CAP_PROP_FRAME_WIDTH);
< int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
<
< while (cap.read(cvImage)) {
<
< /*
114d94
< */
121,122d100
< //const int parentWidth = w;
< //const int parentHeight = h;
141c119
< for (int i = 0; i < 2; ++i)
---
> for (int i = 0; i < 4; ++i)
173,174c151,152
< //CHECK_STATUS(vpiStreamWaitEvent(streams[2], parentEvent));
< //CHECK_STATUS(vpiStreamWaitEvent(streams[3], parentEvent));
---
> CHECK_STATUS(vpiStreamWaitEvent(streams[2], parentEvent));
> CHECK_STATUS(vpiStreamWaitEvent(streams[3], parentEvent));
184c162
< //CHECK_STATUS(vpiSubmitImageFlip(streams[2], VPI_BACKEND_CUDA, inViews[2], outViews[2], VPI_FLIP_VERT));
---
> CHECK_STATUS(vpiSubmitImageFlip(streams[2], VPI_BACKEND_CUDA, inViews[2], outViews[2], VPI_FLIP_VERT));
187c165
< //CHECK_STATUS(vpiSubmitImageFlip(streams[3], VPI_BACKEND_CUDA, inViews[3], outViews[3], VPI_FLIP_BOTH));
---
> CHECK_STATUS(vpiSubmitImageFlip(streams[3], VPI_BACKEND_CUDA, inViews[3], outViews[3], VPI_FLIP_BOTH));
192,193c170,171
< //CHECK_STATUS(vpiStreamSync(streams[2]));
< //CHECK_STATUS(vpiStreamSync(streams[3]));
---
> CHECK_STATUS(vpiStreamSync(streams[2]));
> CHECK_STATUS(vpiStreamSync(streams[3]));
204,208c182,183
< CHECK_STATUS(vpiImageDataExportOpenCVMat(outData, &cvOut));
< //imwrite("output_views.png", cvOut);
<
< cv::imshow("output", cvOut);
< cv::waitKey(30);
---
> vpiImageDataExportOpenCVMat(outData, &cvOut);
> imwrite("output_views.png", cvOut);
213d187
< }
223c197
< for (int i = 0; i < 2; ++i)
---
> for (int i = 0; i < 4; ++i)
232c206
< for (int i = 0; i < 2; ++i)
---
> for (int i = 0; i < 4; ++i)
Error symptom:
xxx@ubuntu:~/NVIDIA_VPI-2.3-samples/15-image_view/build$ ./vpi_sample_15_image_view
[ WARN:0] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1100) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 14:33:30.453: Failed to load module "canberra-gtk-module"
NVMAP_IOC_GET_FD failed: Bad address
NVMAP_IOC_GET_FD failed: Bad address
PosixMemMap:74 FD from Handle failed : Bad address
[WARN ] 2023-08-17 14:33:36 VPI_ERROR_INTERNAL: Failed to create the NvVic handle
NVMAP_IOC_GET_FD failed: Bad address
PosixMemMap:74 FD from Handle failed : Bad address
NvRmStream: Buffer mapping failed (err=196611)
[WARN ] 2023-08-17 14:33:36 VPI_ERROR_INTERNAL: Failed to create the NvVic handle
NVMAP_IOC_GET_FD failed: Bad address
PosixMemMap:74 FD from Handle failed : Bad address
NvRmStream: Buffer mapping failed (err=196611)
(repeat the last three lines...)
[WARN ] 2023-08-17 14:33:40 VPI_ERROR_INTERNAL: Failed to create the NvVic handle
NVMAP_IOC_GET_FD failed: Bad address
PosixMemMap:74 FD from Handle failed : Bad address
NvRmStream: Buffer mapping failed (err=196611)
[WARN ] 2023-08-17 14:33:40 VPI_ERROR_INTERNAL: Failed to create the NvVic handle
[WARN ] 2023-08-17 14:33:40 PvaError_PVAKMDBuffPinSlotsExceeded
NVMAP_IOC_GET_FD failed: Bad address
PosixMemMap:74 FD from Handle failed : Bad address
NvRmStream: Buffer mapping failed (err=196611)
[WARN ] 2023-08-17 14:33:40 VPI_ERROR_INTERNAL: Failed to create the NvVic handle
VPI_ERROR_OUT_OF_MEMORY: Requested size to allocate PVA memory backend is beyond the maximum value
I’ve masked off all CUDA backend used in this sample main.cpp so only CPU backend is invovled besides the added opencv camera. It is weired to see the complaints of VIC and PVA related memory errors.
This also errors on AGX Orin with Jetpack 5.1.1, BTW. It seems the latest version of VPI 2.3 in Jetpack 5.1.2 I’m using here doesn’t resolve this issue.