在c#中有任何一个代码用于识别货币 [英] have any one code in c# for money recognition

查看:208
本文介绍了在c#中有任何一个代码用于识别货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于我的项目的所有细节和问题

我的项目是手机识别钱币(android)

手机(客户端)是捕获图像并将其发送到计算机(服务器)
服务器中的
我使用开放的cv库(C#)SURF算法

这是算法输入到图像(modelimage,observableimage)并且它正在搜索

modelimage at observableimage

现在我的问题是

i有10个图像(modelimage)我想要((条件))如果在observableimage中找不到第一个modelimage会返回false并且尝试使用第二个modelimage并执行此操作直到在observableimage中找到modelimage(任何一个)并返回true

之后将数字图像(1,2,3 .....)发送到移动设备,例如10, 50,100,.....

请注意计算机上的所有进程(服务器)

这是我的代码

all details and problem about my project
my project is money recognition by mobile (android)
the mobile (client )is capture image and send it to computer (server)
in server i used open cv library (C#) the SURF algorithm
this is algorithm input to image (modelimage,observableimage) and it is searching
modelimage at observableimage
now my problem is
i have 10 image (modelimage) i want ((condition)) if first modelimage not found in observableimage return false and try with second modelimage and do this until find modelimage(any one ) in observableimage and return true
after that send number image (1,2,3.....) to mobile for say 10,50,100,.....
please noted all processes do on computer(server)
this is my code

//extract features from the object image
      modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
      Matrix<float> modelDescriptors = surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);

      watch = Stopwatch.StartNew();

      // extract features from the observed image
      observedKeyPoints = surfCPU.DetectKeyPointsRaw(observedImage, null);
      Matrix<float> observedDescriptors = surfCPU.ComputeDescriptorsRaw(observedImage, null, observedKeyPoints);
      BruteForceMatcher<float> matcher = new BruteForceMatcher<float>(DistanceType.L2);
      matcher.Add(modelDescriptors);

      indices = new Matrix<int>(observedDescriptors.Rows, k);
      using (Matrix<float> dist = new Matrix<float>(observedDescriptors.Rows, k))
      {
         matcher.KnnMatch(observedDescriptors, indices, dist, k, null);
         mask = new Matrix<byte>(dist.Rows, 1);
         mask.SetValue(255);
         Features2DToolbox.VoteForUniqueness(dist, uniquenessThreshold, mask);
      }

      int nonZeroCount = CvInvoke.cvCountNonZero(mask);
      if (nonZeroCount >= 4)
      {
         nonZeroCount = Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints, indices, mask, 1.5, 20);
         if (nonZeroCount >= 4)
            homography = Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints, observedKeyPoints, indices, mask, 2);
      }

      watch.Stop();
   }

   //Draw the matched keypoints
   Image<Bgr, Byte> result = Features2DToolbox.DrawMatches(modelImage, modelKeyPoints, observedImage, observedKeyPoints,
      indices, new Bgr(255, 255, 255), new Bgr(255, 255, 255), mask, Features2DToolbox.KeypointDrawType.DEFAULT);

   #region draw the projected region on the image
   if (homography != null)
   {  //draw a rectangle along the projected model
      Rectangle rect = modelImage.ROI;
      PointF[] pts = new PointF[] {
         new PointF(rect.Left, rect.Bottom),
         new PointF(rect.Right, rect.Bottom),
         new PointF(rect.Right, rect.Top),
         new PointF(rect.Left, rect.Top)};
      homography.ProjectPoints(pts);

      result.DrawPolyline(Array.ConvertAll<PointF, Point>(pts, Point.Round), true, new Bgr(Color.Red), 5);
   }
   #endregion

   matchTime = watch.ElapsedMilliseconds;

   return result;
}

推荐答案

这篇关于在c#中有任何一个代码用于识别货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆