Convert RGB array to Mat (OpenCv)
问题 I've been trying to convert an array [R,G,B,..] in Mat object with opencv. But is returning wrong data, someone knows why? double data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_16UC3, data); and returns: M = [0, 0, 0, 0, 0, 0; 0, 0, 0, 0, 57344, 16495] EDIT: Solved! use uchar instead double, and CV_8UC3 回答1: i think, you wanted: uchar data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_8UC3, data); (all red, 2x2 rbg image) 来源: https://stackoverflow.com