现象: VS2010编译运行时出错,
1>f:\test-dev\imagetest\imagetest\imagetest.cpp(41): error C2668: “log”: 对重载函数的调用不明确
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(575): 可能是“long double log(long double)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(527): 或 “float log(float)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(120): 或 “double log(double)”
1> 尝试匹配参数列表“(int)”时
1>f:\test-dev\imagetest\imagetest\imagetest.cpp(42): error C2668: “log”: 对重载函数的调用不明确
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(575): 可能是“long double log(long double)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(527): 或 “float log(float)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(120): 或 “double log(double)”
1> 尝试匹配参数列表“(int)”时
1>f:\test-dev\imagetest\imagetest\imagetest.cpp(43): error C2668: “log”: 对重载函数的调用不明确
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(575): 可能是“long double log(long double)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(527): 或 “float log(float)”
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(120): 或 “double log(double)”
1> 尝试匹配参数列表“(int)”时
解决方案:
使用double或float类型进行转换,如下:
imageLog.at<Vec3f>(i, j)[0] = log(double(1 + image.at<Vec3b>(i, j)[0]));