cv.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  2. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 {0}_EXPORTS
  3. // 符号编译的。在使用此 DLL 的
  4. // 任何项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  5. // {0}_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  6. // 符号视为是被导出的。
  7. #ifdef CV_EXPORTS
  8. #define CV_API __declspec(dllexport)
  9. #else
  10. #define CV_API __declspec(dllimport)
  11. #endif
  12. // 此类是从 dll 导出的
  13. //class CV_API Ccv {
  14. //public:
  15. // Ccv(void);
  16. // // TODO: 在此处添加方法。
  17. //};
  18. //
  19. //extern CV_API int ncv;
  20. //
  21. //CV_API int fncv(void);
  22. //////////////////////////////////////////////////////////////////////////
  23. // gdiplus;
  24. // 初始化gdiplus环境;
  25. CV_API void InitGdiplus();
  26. // 关闭gdiplus环境;
  27. CV_API void ShutGdiplus();
  28. // 读取图片,返回gdiplus对象;
  29. CV_API bool GdiplusReadImage(std::string strImgPath, Gdiplus::Bitmap **bitmap);
  30. CV_API bool GdiReadImage(std::string strImgPath, CBitmap &bitmap);
  31. //////////////////////////////////////////////////////////////////////////
  32. // opencv;
  33. // 1、读取图片;
  34. CV_API bool ReadImage(std::string strImgPath, cv::Mat& img);
  35. // 2、获取图片全局二值化轮廓图像结果
  36. CV_API bool GetBinaryImage(std::string strImgPath, long nThresholdVal, long nMaxThresholdVal, cv::Mat & thresholdImg);
  37. // 3、获取图片OTSU二值化轮廓图像结果
  38. CV_API bool GetOTSUBinaryImage(std::string strImgPath, long nThresholdVal, long nMaxThresholdVal, cv::Mat& thresholdImg);
  39. // 4、获取图片自适应二值化轮廓图像结果
  40. CV_API bool GetAdaptiveBinaryImage(std::string strImgPath, long nMaxThresholdVal, cv::Mat& thresholdImg);
  41. // 5、图片高斯模糊处理,cv::Size一般为(3,3)或(5,5)
  42. CV_API bool GaussianBlur(cv::Mat& img, cv::Size cvSize, cv::Mat& gaussImg);
  43. CV_API bool GaussianBlur(std::string strImgPath, cv::Size cvSize, cv::Mat& gaussImg);
  44. // 6、图片转灰阶处理(BGR三通道转单通道)
  45. CV_API bool Color2Gray(cv::Mat& img, cv::Mat& grayImg);
  46. CV_API bool Color2Gray(std::string strImgPath, cv::Mat& grayImg);
  47. // 7、灰阶图转BGR处理(单通道转BGR三通道)
  48. CV_API bool Gray2Color(cv::Mat& img, cv::Mat& colorImg);
  49. // 8、对图片腐蚀处理
  50. CV_API bool ErodeImg(cv::Mat& img, cv::MorphShapes kernelShape, cv::Size kernelSize, cv::Mat& erodeImg);
  51. // 9、对图片膨胀处理
  52. CV_API bool DilateImg(cv::Mat& img, cv::MorphShapes kernelShape, cv::Size kernelSize, cv::Mat& dilateImg);
  53. // 10、裁剪图片指定区域
  54. CV_API bool CutPictures(cv::Mat& img, cv::Rect cvRect, cv::Mat& roiImg);
  55. CV_API bool CutPictures(std::string strImgPath, cv::Rect cvRect, cv::Mat& roiImg);
  56. CV_API bool CutPictures(std::string strImgPath, cv::Rect cvRect, std::string strRoiImgPath);
  57. // 11、输出图片二值化轮廓填充图像结果;
  58. // binImg必须为单通道
  59. // drawimg必须在binImg基础上Copyto或在原图上Copyto,即drawImg必须是binImg的克隆或原图的克隆;
  60. // 如果drawImg空,则从函数内部使用binImg来克隆;
  61. CV_API bool DrawContours(cv::Mat& binImg, cv::Mat& drawImg, bool InternalContour, bool bPerimeter, long nMinPerimeter, long nMaxPerimeter, bool bArea, long nMinArea, long nMaxArea);
  62. // 12、单个模板图片匹配
  63. CV_API bool MatchSingleImage(cv::Mat& img, cv::Mat templImg, double& matchVal, cv::Rect& matchRect);
  64. CV_API bool MatchSingleImage(cv::Mat& img, std::string strTmpImg, double &matchVal, cv::Rect &matchRect);
  65. CV_API bool MatchSingleImage(std::string strImg, std::string strTmpImg, double& matchVal, cv::Rect& matchRect);
  66. // 13、将opencv Mat对象转为GDI Bitmap对象和GDI+ Bitmap对象;
  67. CV_API bool Mat2Bitmap(cv::Mat &img, CBitmap &bitmap);
  68. CV_API bool Mat2HBitmap(cv::Mat& img, HBITMAP& bitmap);
  69. CV_API bool Mat2GdiplusBitmap(cv::Mat& img, Gdiplus::Bitmap& bitmap);
  70. CV_API bool Bitmap2Mat(CBitmap& bitmap, cv::Mat& img);
  71. CV_API bool HBitmap2Mat(HBITMAP& bitmap, cv::Mat& img);
  72. CV_API bool GdiplusBitmap2Mat(Gdiplus::Bitmap* bitmap, cv::Mat& img);
  73. // 待开发
  74. // 11、获取图片指定RGB颜色域的轮廓图像结果
  75. // 12、多个模板图片匹配
  76. // 13、获取图片的LUV平均值
  77. // 14、两图片相似度比较