Cv::merge get error assertion failed

hello, everyone.I get an error when using cv::merge:

OpenCV(4.5.4) Error: Assertion failed (mv[i].size == mv[0].size && mv[i].depth() == depth) in cv::merge, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\merge.dispatch.cpp, line 129

my code:

        unsigned char* y_data = new unsigned char[1920 * 1080];
	unsigned char* u_data = new unsigned char[960 * 540];
	unsigned char* v_data = new unsigned char[960 * 540];

	FILE* file = fopen("MY_PATH\\test.yuv", "rb");
	if (file != NULL) {
		fread(y_data, 1, 1920 * 1080, file);
		fread(u_data, 1, 960 * 540, file);
		fread(v_data, 1, 960 * 540, file);
	}
	fclose(file);
	file = NULL;

	
	cv::Mat y(1080, 1920,  CV_8UC1, y_data);
	cv::Mat u(540, 960,  CV_8UC1, u_data);
	cv::Mat v(540, 960,  CV_8UC1, v_data);

	cv::resize(u, u, { u.size().width * 2, u.size().height * 2 }, 0, 0);
	cv::resize(v, v, { u.size().width * 2, u.size().height * 2 }, 0, 0);

	cv::Mat result;
	std::vector<cv::Mat> channels{ y,u,v };
	printf("channel number: %d\n", channels.size());
	printf("channels: %d, %d, %d\n", y.channels(), u.channels(), v.channels());
	printf("channels type: %d,%d,%d\n", y.type(), u.type(), v.type());
	cv::merge(channels, result);//**here I get error**
	cv::imshow("result", result);
	cv::waitKey();
	delete y_data;
	delete u_data;
	delete v_data;

the printf:

channel number: 3
channels: 1, 1, 1
channels type: 0,0,0

I’m using visual studio 2017 and opencv 4.5.4. The “test.yuv” is a yuv420 frame.
Could you tell me what’t wrong with my code? thank you in advance

after read the source code:

    int depth = mv[0].depth();
    bool allch1 = true;
    int k, cn = 0;
    size_t i;

    for( i = 0; i < n; i++ )
    {
        CV_Assert(mv[i].size == mv[0].size && mv[i].depth() == depth);
        allch1 = allch1 && mv[i].channels() == 1;
        cn += mv[i].channels();
    }

I try to print channels’s size:

printf("channels size: %d, %d, %d\n", channels[0].size, channels[1].size, channels[2].size);

and got:

channels size: 1407661640, 1407661736, 1407661832

So, that’s the point why I got the error,but I don’t what is mat.size and why they are different in my case.
Can some people explain? thanks.

I’m sorry for my stupid mistake, In my code:

cv::resize(u, u, { u.size().width * 2, u.size().height * 2 }, 0, 0);
cv::resize(v, v, { u.size().width * 2, u.size().height * 2 }, 0, 0);

the second resize should be “v.size” instead of “u.size”, now my code can run correctly.