I was having this problem today, with the HoughLinesP function.
From searching the internet and looking at questions like these, I have finally found the answer. VisionC's answer here seems to be on the right track, but lacks a bit of explanation. I imagine you don't still need the answer anymore, but this might be helpful to others maybe.
What the problem is:
I'm no expert, but thanks to Michael's answer here, as I understand it, the Platform Toolset used to build OpenCV is v100 (i.e. the toolset used in Visual Studio 10). In Visual Studio 11 (2012), projects default to using the newer v110 Platform Toolset. (I haven't been able to find anything that says if new versions of OpenCV use v110.)
What seems to be happening is that you give an OpenCV function (which is using some v100 dll's) a vector, which the function then modifies. When the vector is cleaned up by your program (using v110 dll's) there's an incompatibility, due to it being modified by OpenCV, which causes the error.
Sorry that's so vague, but as I said I don't really understand the ins-and-outs of it.
How to fix it:
Anyway, answers I've found on this didn't really have good solutions. They'd talk about rebuilding OpenCV and other tedious things. As you've discovered, going back to VS2010 fixes the issue, but having to convert the project and go back to the old IDE isn't too much fun. And if you're using C++/CLI like I am, you don't get IntelliSense in VS2010. :(
All you need to do to is go to your project properties in VS2012. Make sure the configuration is set to "All Configurations". Then, under "Configuration Properties->General->Platform Toolset" choose "Visual Studio 2010 (v100)". This should fix the problem, and in the future you can easily change the setting back if needed.
As described here though, you do still need to have VS 2010 installed (or the Windows Platform SDK) to be able to do this.