cv.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. extern CV_API int ncv;
  19. CV_API int fncv(void);
  20. // 1、读取图片;
  21. CV_API bool ReadImage(std::string strImgPath, cv::Mat& img);
  22. // 2、获取图片全局二值化轮廓图像结果
  23. CV_API bool GetBinaryImage(std::string strImgPath, long nThresholdVal, long nMaxThresholdVal, cv::Mat & thresholdImg);
  24. // 3、获取图片OTSU二值化轮廓图像结果
  25. CV_API bool GetOTSUBinaryImage(std::string strImgPath, long nThresholdVal, long nMaxThresholdVal, cv::Mat& thresholdImg);
  26. // 4、获取图片自适应二值化轮廓图像结果
  27. CV_API bool GetAdaptiveBinaryImage(std::string strImgPath, long nMaxThresholdVal, cv::Mat& thresholdImg);
  28. // 5、图片高斯模糊处理,cv::Size一般为(3,3)或(5,5)
  29. CV_API bool GaussianBlur(cv::Mat& img, cv::Size cvSize, cv::Mat& gaussImg);
  30. CV_API bool GaussianBlur(std::string strImgPath, cv::Size cvSize, cv::Mat& gaussImg);
  31. // 6、图片转灰阶处理(BGR三通道转单通道)
  32. CV_API bool Color2Gray(cv::Mat& img, cv::Mat& grayImg);
  33. CV_API bool Color2Gray(std::string strImgPath, cv::Mat& grayImg);
  34. // 7、灰阶图转BGR处理(单通道转BGR三通道)
  35. CV_API bool Gray2Color(cv::Mat& img, cv::Mat& colorImg);
  36. // 8、对图片腐蚀处理
  37. CV_API bool ErodeImg(cv::Mat& img, cv::MorphShapes kernelShape, cv::Size kernelSize, cv::Mat& erodeImg);
  38. // 9、对图片膨胀处理
  39. CV_API bool DilateImg(cv::Mat& img, cv::MorphShapes kernelShape, cv::Size kernelSize, cv::Mat& dilateImg);
  40. // 10、裁剪图片指定区域
  41. CV_API bool CutPictures(cv::Mat& img, cv::Rect cvRect, cv::Mat& roiImg);
  42. CV_API bool CutPictures(std::string strImgPath, cv::Rect cvRect, cv::Mat& roiImg);
  43. CV_API bool CutPictures(std::string strImgPath, cv::Rect cvRect, std::string strRoiImgPath);
  44. // 11、输出图片二值化轮廓填充图像结果;
  45. // binImg必须为单通道
  46. // drawimg必须在binImg基础上Copyto或在原图上Copyto,即drawImg必须是binImg的克隆或原图的克隆;
  47. // 如果drawImg空,则从函数内部使用binImg来克隆;
  48. CV_API bool DrawContours(cv::Mat& binImg, cv::Mat& drawImg, bool InternalContour, bool bPerimeter, long nMinPerimeter, long nMaxPerimeter, bool bArea, long nMinArea, long nMaxArea);
  49. // 12、单个模板图片匹配
  50. CV_API bool MatchSingleImage(cv::Mat& img, cv::Mat templImg, double& matchVal, cv::Rect& matchRect);
  51. CV_API bool MatchSingleImage(cv::Mat& img, std::string strTmpImg, double &matchVal, cv::Rect &matchRect);
  52. CV_API bool MatchSingleImage(std::string strImg, std::string strTmpImg, double& matchVal, cv::Rect& matchRect);
  53. // 13、将opencv Mat对象转为GDI Bitmap对象和GDI+ Bitmap对象;
  54. CV_API bool Mat2Bitmap(cv::Mat &img, CBitmap &bitmap);
  55. CV_API bool Mat2HBitmap(cv::Mat& img, HBITMAP& bitmap);
  56. CV_API bool Mat2GdiplusBitmap(cv::Mat& img, Gdiplus::Bitmap& bitmap);
  57. CV_API bool Bitmap2Mat(CBitmap& bitmap, cv::Mat& img);
  58. CV_API bool HBitmap2Mat(HBITMAP& bitmap, cv::Mat& img);
  59. CV_API bool GdiplusBitmap2Mat(Gdiplus::Bitmap& bitmap, cv::Mat& img);
  60. // 待开发
  61. // 11、获取图片指定RGB颜色域的轮廓图像结果
  62. // 12、多个模板图片匹配
  63. // 13、获取图片的LUV平均值
  64. // 14、两图片相似度比较