码迷,mamicode.com
首页 > 其他好文 > 详细

【20160924】GOCVHelper综述

时间:2016-09-24 23:35:24      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:

    GOCVHelper(GreenOpen Computer Version Helper )是我在这几年编写图像处理程序的过程中积累下来的函数库。主要是对Opencv的适当扩展和在实现Mfc程序时候的功能增强。

    这里将算法库开放源代码,并且编写一系列blog对函数实现进行说明。目的是在于“取之于互联网,用之于互联网”。并且也希望该库能够继续发展下去。
    由于算法库基于Opencv和Mfc进行编写,所以要求阅读使用者具备一定基础。
    最终提交的是GOCVHelper.h 和GOCVHelper版本号.cpp两个文件。
    
    通过阅读头文件,能够对算法库实现的功能加以了解:
    //名称:GOCVHelper0.7b.cpp
    //功能:图像处理和MFC增强
    //作者:jsxyhelu(1755311380@qq.com http://jsxyhelu.cnblogs.com)
    //组织:GREENOPEN
    //日期:2016-09-24
    #include "stdafx.h"
    #include <windows.h>
    #include <iostream>
    #include <fstream>
    #include <cstdlib>
    #include <io.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <vector>
    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    using namespace std;
    using namespace cv;
    #define  VP  vector<cv::Point>  //用VP符号代替 vector<point>
    #define  DIRECTION_X 0
    #define  DIRECTION_Y 1
    //调用算法库请在Opencv和Mfc正确配置的环境下。
    //并且配置 项目-属性-配置属性-常规-字符集 设置为 使用多字节字符集
    //和 项目-属性-配置属性-c/c++-预处理器-预处理器定义 加入 _CRT_SECURE_NO_WARNINGS
    namespace GO{
        //读取灰度或彩色图片到灰度
        Mat imread2gray(string path);
        //带有上下限的threshold
        Mat threshold2(Mat src,int minvalue,int maxvalue);
        //自适应门限的canny算法 
        Mat canny2(Mat src);
        void AdaptiveFindThresholdMat src,double *low,double *high,int aperture_size=3);
        void _AdaptiveFindThreshold(CvMat *dxCvMat *dydouble *lowdouble *high);
        //填充孔洞
        Mat fillHoles(Mat src);
        float getWhiteRate(Mat src);
        Mat getInnerHoles(Mat src);
        //顶帽去光差,radius为模板半径
        Mat moveLightDiff(Mat src,int radius = 40);
        //将 DEPTH_8U型二值图像进行细化  经典的Zhang并行快速细化算法
        void thin(const Mat &srcMat &dstconst int iterations=100);
        //使得rect区域半透明
        Mat translucence(Mat src,Rect rect,int idepth = 90);
        //使得rect区域打上马赛克
        Mat mosaic(Mat src,Rect rect,int W = 18,int H = 18);
        //----------------------------------------------------------------------------------------------------------------------------------------//
        //寻找最大的轮廓
        VP FindBigestContour(Mat src);
        //寻找并绘制出彩色联通区域
        vector<VPconnection2(Mat src,Matdraw);
        vector<VPconnection2(Mat src);
        //根据轮廓的面积大小进行选择
        vector<VP>  selectShapeArea(Mat src,Matdraw,vector<VPcontours,int minvalue,int maxvalue);
        vector<VP>  selectShapeArea(vector<VPcontours,int minvalue,int maxvalue);
        //根据轮廓的圆的特性进行选择
        vector<VP>  selectShapeArea(Mat src,Matdraw,vector<VPcontours,int minvalue,int maxvalue);
        vector<VP>  selectShapeArea(vector<VPcontours,int minvalue,int maxvalue);
        //计算轮廓的圆的特性
        float calculateCircularity(VP contour);
        //返回两点之间的距离
        float getDistance(Point2f f1,Point2f f2);
        //----------------------------------------------------------------------------------------------------------------------------------------//
        //投影到x或Y轴上,上波形为vup,下波形为vdown,gap为误差间隔
        void projection2(Mat src,vector<int>& vup,vector<int>& vdown,int direction = DIRECTION_X,int gap = 10);
        //----------------------------------------------------------------------------------------------------------------------------------------//
        //递归读取目录下全部文件
        void getFiles(string pathvector<string>& files,string flag ="r"/*如果不想递归这里不写r就可以*/);
        //递归读取目录下全部图片
        void getFiles(string pathvector<Mat>& files,string flag = "r");
        //递归读取目录下全部图片和名称
        void getFiles(string pathvector<pair<Mat,string>>& files,string flag="r");
        //删除目录下的全部文件
        void deleteFiles(string path,string flag = "r");
        //创建或续写目录下的csv文件,填写“文件位置-分类”对
        int writeCsv(const stringfilename,const Vector<pair<string,string>>srcVect,char separator=‘;‘);
        //读取目录下的csv文件,获得“文件位置-分类”对
        vector<pair<string,string>> readCsv(const stringfilenamechar separator = ‘;‘) ;
        //----------------------------------------------------------------------------------------------------------------------------------------//
        //C++的spilt函数
        void SplitString(const stringsvector<string>& vconst stringc);
        //! 通过文件夹名称获取文件名,不包括后缀
        void getFileName(const stringfilepathstringname,stringlastname);
        //-----------------------------------------------------------------------------------------------------------------------------------------//
        //ini 操作
        CString  GetInitStringCString Name1 ,CString Name2);
        void WriteInitStringCString Name1 ,CString Name2 ,CString strvalue);
        //excel操作
        CString ExportListToExcel(CString  sExcelFile,CListCtrlpListCString strTitle);
        BOOL GetDefaultXlsFileName(CStringsExcelFile);
    }
 





【20160924】GOCVHelper综述

标签:

原文地址:http://www.cnblogs.com/jsxyhelu/p/5904251.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!