Odd opencv remap bug

I’m having an issues where calling cv::remap causes my program to segfault. I’m pretty new to opencv and the tx2.

From doing some research, I have read that there is a problem with opencv and TBB.
https://stackoverflow.com/questions/42842661/cvremap-segfaults-with-stdthread

If I reduce the threads using cv::setNumThreads(0), it correctly reports only 1 thread, but it still segfaults. I am curious as to what else could be causing this. All my passed in parameters seem to be fine:

cv::remap(frame, undistorted_frame, distortion_map1, distortion_map2, cv::INTER_LINEAR, cv::BORDER_CONSTANT

Is it ok if undistorted_frame is empty? All of the rest of the values seems to be correct. Is there any issue with remap that anyone knows of on OpenCV4Tegra? I read here as well that there are issues with the gpu::remap https://devtalk.nvidia.com/default/topic/1000106/?comment=5132311.

One of the oddest parts is it occasionally runs fine. If I attempt to restart it 2-4 times, it will generally one fine eventually… That has me leaning towards a threading issue still, but having setNumThreads(0) in does not fix it.

For reference I am using OpenCV 2.4.13.1 (using TBB ver 4.4 interface 9002) on JetPack 3.1 and R28.1.0. Wondering if I just need to install openCV from source (hope not). Thanks in advance for any help!

ydyla7g7,

We no longer maintain opencv4tegra. Please try to build opencv from scratch and see if this issue is fixed.

Sorry for inconvenience.

Thanks WayneWWW,

I built openCV from scratch and had similar results. Turns out the remap was a red herring. It was a race condition elsewhere with another function modifying the frame contents.

Thanks for the response.