fixed constant names and function return values for opencv 2.3, 2.4

I have successfully tested the patched code with both OpenCV 2.3.1 on Linux (from the Ubuntu 12.04 LTS repo) and 2.4.7 on Mac OS X (from the ports repo). I don't know which version of OpenCV introduced the change, and whether it also affects the Windows version.