# Earth Mover's Distance EMD() results in memory access error

Hello,

i am trying to compute the Earth Mover's Distance using opencv's function EMD(). For most of my signatures that works fine. But for others i get an memory access error which i do not understand. At first i thought maybe the signature matrices were to big because they have 39015 rows and 3 columns and the other one has 9216 row and 3 cloumns. But that can not be the problem since a matrix with 36481 rows works fine. Until now i have not been able to tell exactly under which conditions i get this memory access error. But i was able to find the line in opencv where the error occures. That happens to be line 385 in OpenCV-2.4.2/modules/imgproc/src/emd.cpp. The error occours in earlier version like opencv 2.1. I call the function with "cv::EMD(signatureGroundTruthMat, signatureDetectionMat, CV_DIST_L2)". I could provide the matrices that cause the error if that would help. My question would be whether that is a bug in opencv that i should report or whether i have done something wrong with the matrices. Out of 1000 matrices i used EMD() on just a hand full produced that error. I would be thankful for any assistance

Gerrit