I have encountered a bizarre situation. In my project, I am using some morphological operations of OpenCV and they work well when I run the application by Visual Studio (in both Debug and Release modes) but whenever I run the application out of VS (how a release application supposed to be run), directly from a directory, the Erode and Dilate functions produce weird results. I followed the code by attaching the release app as a process to visual studio and debugged it, finally catched what causes this weirdness.
If I use erode and dilate functions like below:
cv::erode(l_Foreground, l_Foreground, cv::Mat(7, 7, CV_8U));
This works as expected in VS, but weird out of VS. With weird, I mean, the value "7", the size of cv::Mat parameters that given to cv::erode is ignored and it uses some default value or something itself and does not produce required results.
The problem is solved when I use this functions as below:
cv::Mat elementErode = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(7, 7));
cv::erode(l_Foreground, l_Foreground, elementErode);
It works correct everywhere, both in VS and out of VS. I followed the dll calls and both by VS and out of VS runs call the same dlls.
Any idea about this strange situation?
Thanks in advance.