Issue in merging multiple cv::Mat type CV_16FC3

Issue:
Merging multiple cv::Mat type CV_16FC3

OpenCV version 4.4.0

Code to reproduce to merge

cv::Mat bgr_img_cv8u = cv::imread("car.jpg", 1);
  cv::Mat img1_cv16f;
  cv::Mat img2_cv16f;

  bgr_img_cv8u.convertTo(img1_cv16f, CV_16FC3);
  bgr_img_cv8u.convertTo(img2_cv16f, CV_16FC3);

  std::cout << "bgr_img_cv8u " << bgr_img_cv8u.type() << std::endl;
  std::cout << "img1_cv16f " << img1_cv16f.type() << std::endl;
  std::cout << "img2_cv16f " << img2_cv16f.type() << std::endl;

  std::vector<cv::Mat> imgs = {img1_cv16f, img2_cv16f};
  cv::Mat merged_img;
  cv::merge(imgs, merged_img);
  std::cout << "merged_img " << merged_img.type() << std::endl;

It is necessary to give the channel parameter in merge() if I remember well.

@MakeItGreatAgain
for the Mat* version, yes, but not for the std::vector<Mat> overload

16bit floats are not fully supported in opencv (yet?)
your example segfaults, because there is no entry for depth==7 here
so func is a null pointer here

this is a bug, you should report it

however, as a temp workaround, you could split your Mat’s into single channels, and merge those:

  std::vector<cv::Mat> i1,i2;
  split(img1_cv16f,i1);
  split(img2_cv16f,i2);
  std::vector<cv::Mat> imgs = {i1[0], i1[1], i1[2], i2[0], i2[1], i2[2]};

  cv::Mat merged_img;
  cv::merge(imgs, merged_img);

(this avoids calling mixChannels() internally)