资源简介

基于OpenCV实现的图片识别功能。 学习示例: 脸部+眼部检测 马路行人检测 特征匹配(示例:微信“跳一跳”棋子匹配)

资源截图

代码片段和文件信息

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using System.Diagnostics;
using System.Drawing;
using System.Linq;

namespace ImageRecognition.Demos
{
    public static class base
    {
        /// 
        /// 灰度
        /// 

        /// 
        /// 
        /// 
        public static Mat Gray(string imgpathout long runTime)
        {
            Stopwatch sp = new Stopwatch();
            sp.Start();
            Mat image = CvInvoke.Imread(imgpath ImreadModes.Grayscale);
            runTime = sp.ElapsedMilliseconds;
            return image;
        }
        /// 
        /// 边缘
        /// 

        /// 
        /// 
        /// 
        public static Mat Canny(string imgpath out long runTime)
        {
            Mat image = CvInvoke.Imread(imgpath ImreadModes.Color);
            Stopwatch sp = new Stopwatch();
            sp.Start();

            Mat result= new Mat();
            CvInvoke.Canny(image result10060);
            runTime = sp.ElapsedMilliseconds;
            return result;
        }

        public static Mat FindContours(Mat image out long runTime)
        {
            Mat result = new Mat(image.SizeDepthType.Cv8S3) ;// new Bitmap(image.Size.Width image.Size.Height);

            Stopwatch sp = new Stopwatch();
            sp.Start();
            using (VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint())
            {
                CvInvoke.FindContours(image contours null RetrType.List ChainApproxMethod.ChainApproxNone);
                int count = contours.Size;
                for (int i = 0; i < count; i++)
                {
                    using (VectorOfPoint contour = contours[i])
                    using (VectorOfPoint approxContour = new VectorOfPoint())
                    {
                        if (contour.ToArray().Max(x => x.Y) < 200)
                            continue;
                        MCvScalar color = new Bgr(Color.Green).MCvScalar;
                        CvInvoke.ApproxPolyDP(contour approxContour CvInvoke.ArcLength(contour true) * 0.05 true);
                        //if (CvInvoke.ContourArea(approxContour false) > 250) //only consider contours with area greater than 250
                        //{
                        if (approxContour.Size == 3) //The contour has 3 vertices it is a triangle
                        {
                            color = new Bgr(Color.Red).MCvScalar;
                        }
                        else if (approxContour.Size == 4) //The contour has 4 vertices.
                        {
                            color = new Bgr(Color.Yellow).MCvScalar;
                        }
                        else
                        {
                            color = new Bgr(Color.Orange).MCvS

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......      2518  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\.gitattributes

    .......      5070  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\.gitignore

     文件        110  2018-06-20 15:26  hgflydream-ImageRecognition-master\ImageRecognition\asp.net免费源码下载.url

    .......      3470  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\base.cs

    .......      6166  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\DrawMatches.cs

    .......      6434  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\FaceDetection.cs

    .......      2472  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\ImageRecognition.Demos.csproj

    .......      3499  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\PedestrianDetection.cs

    .......      1297  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos\Properties\AssemblyInfo.cs

    .......       182  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\App.config

    .......    341406  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\data\haarcascade_eye.xml

    .......    930127  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\data\haarcascade_frontalface_default.xml

    .......      4960  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Forms.cs

    .......      9352  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Forms.Designer.cs

    .......      5698  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Forms.resx

    .......      4635  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\ImageRecognition.Demos.WindowsForms.csproj

    .......       525  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Program.cs

    .......      1332  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Properties\AssemblyInfo.cs

    .......      2812  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Properties\Resources.Designer.cs

    .......      5496  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Properties\Resources.resx

    .......      1092  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Properties\Settings.Designer.cs

    .......       242  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\Properties\Settings.settings

    .......     15724  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\testimages\qizi_mode.png

    .......     50902  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.Demos.WindowsForms\testimages\tiaoyitiao.png

    .......      1904  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\ImageRecognition\ImageRecognition.sln

    .......    115200  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\libs\Emgu.CV.UI.dll

    .......     33928  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\libs\Emgu.CV.UI.xml

    .......    646144  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\libs\Emgu.CV.World.dll

    .......   1671567  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\libs\Emgu.CV.World.xml

    .......    307200  2018-01-10 09:23  hgflydream-ImageRecognition-master\ImageRecognition\libs\ZedGraph.dll

............此处省略19个文件信息

评论

共有 条评论