这段代码工作正常,直到最后一行.它将正确的图像保存在磁盘上但在退出函数后显示"内存泄漏" - 堆损坏.我读过Mat不需要明确发布.在我的情况下,它会在释放和w/o释放时崩溃.请帮忙.
void CannyEdgeDetectionFilter::applyFilter(Mat& mat, Mat& mixedBandsMat)
{
//Mat mixedBandsMat;
vector<Mat> bandWiseImages;
split(mat, bandWiseImages);
//! Evaluate numChannels to be filtered in the input image
int numChannels = mat.channels();
int type = mat.type();
//! Multiplied by 8 to get bits from Bytes
int singleChannelDepth = 8*mat.elemSize1();
for (int i = 0; i < numChannels; i++)
{
Canny(bandWiseImages[i], bandWiseImages[i], m_LowerThreshold,
m_UpperThreshold, m_Kernel.rows);
}
//! Creating filteredImgMat in order to set DataValues
mixedBandsMat.create(mat.rows, mat.cols, mat.type());
//! Unifying the channels back to the …Run Code Online (Sandbox Code Playgroud)