Simple Opencv example segmentation fault

In 09_camera_jpeg_capture I just ended up adding a simple opencv line in the very beginning of the main function:
cv::Mat picture = cv::imread(“picture.jpg”);
and I have a segmentation fault.

In the Makefile I just added:
+CPPFLAGS+=pkg-config --cflags opencv4
+LDFLAGS+=pkg-config --libs opencv4

Does the file actually exist in the working directory of the running program?

Yes it does exist.The problem is strange.

When I remove the "$(wildcard $(CLASS_DIR)/*.cpp) " line in the Makefile the OpenCV code runs fine. But then I’m unable to actually use the provided example.

SRCS :=
main.cpp
$(wildcard $(CLASS_DIR)/*.cpp)
$(ARGUS_UTILS_DIR)/Thread.cpp

It might be due to a conflict between jpeg lib used by opencv (/usr/lib/aarch64-linux-gnu/libjpeg.so.8) and nvjpeg lib used by 09_camera_jpeg_capture (/usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so).
These have different structures that make them incompatible.

Hi Honey_Patouceul,

Thank you for helping!
I plan to use the OpenCV for inference, what would you advise me?

The samples are just that – samples. You can remove the use of nvjpeg in the sample, for decoding/encoding JPEG, and instead use the OpenCV built in functions. This requires a little bit of code surgery, but it’s reasonably straightforward.

Separately, my experience has been that OpenCV for inference is generally slower, and has less good support, than using the NVIDIA supplied engines (TensorRT etc.)
Also, another good example for inference on the Jetsons, is the jetson-inference sample project on github.