V4L2_PIX_FMT_UYVY to opencv Mat in TX2

Hi,
I meet a real problem confused me. when i use

cv::Mat mat = cv::Mat(480,640,CV_8UC2,(void*)fbuffer,len);
 cv::Mat rgb_mat_UYVY
cv::cvtColor(mat,rgb_mat_UYVY,CV_YUV2BGR_UYVY);

.

And i meet a Segmentation fault (core dumped)
So i use gdb and print the backtrace.

(gdb) bt
#0  0x0000007fb7a1a9cc in cv::YUV422toRGB888Invoker<0, 0, 1>::operator()(cv::Range const&) const () from /usr/lib/libopencv_imgproc.so.2.4
#1  0x0000007fb7659a10 in ?? () from /usr/lib/libopencv_core.so.2.4
#2  0x0000007fb591589c in ?? () from /usr/lib/aarch64-linux-gnu/libtbb.so.2
#3  0x0000007fb590f76c in ?? () from /usr/lib/aarch64-linux-gnu/libtbb.so.2
#4  0x0000007fb590e44c in ?? () from /usr/lib/aarch64-linux-gnu/libtbb.so.2
#5  0x0000007fb5909c78 in ?? () from /usr/lib/aarch64-linux-gnu/libtbb.so.2
#6  0x0000007fb5909f84 in ?? () from /usr/lib/aarch64-linux-gnu/libtbb.so.2
#7  0x0000007fb7f88fc4 in start_thread (arg=0x7fb5909f78) at pthread_create.c:335
#8  0x0000007fb73b52e0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:89

How can i fix that???
Thank you much…

Why are you using CV_8UC2 ? You may try CV_8UC3 instead.
Also be sure you really have a valid buffer for your input image.

[EDIT: you may also make sure you don’t have various versions of opencv installed and running at run time with different libraries than expected.]

I used Tx2, and i did installed other version of opencv on it. The buffer is valid cause i can put it on screen by gst_memory_new_wrapped and nvoverlaysink some thing by gstreamer used with the same buffer.