Create a two channels blob for dnn::Net
I want to pass 2 dimension channels into the dnn::Net, but blobFromImage do not support it, so I try to do it by myself
int sz[] = { 1, 2, 128, 128};
cv::Mat blob = Mat(4, sz, CV_32F);
cv::Mat img1 = cv::imread("left_img.jpg", IMREAD_GRAYSCALE);
cv::Mat img2 = cv::imread("right_img.jpg", IMREAD_GRAYSCALE);
img1.copyTo(Mat(img.rows, img.cols, CV_32F, blob.ptr((0, 0))));
img2.copyTo(Mat(img.rows, img.cols, CV_32F, blob.ptr((0, 1))));
net.setInput(blob, "input"); //set the network input
Mat result = net.forward(); //compute output
However, this give me error
tensorflow_model_loader': malloc(): smallbin double linked list corrupted: 0x00000000024d1490 ***
What is the correct way of passing two channels blob into dnn::Net?
Edit :
Two bugs, 1 of them pointed out by berak(thanks), another is due to the extra "()", should change blob.ptr((0, 0)) to blob.ptr(0, 0)