Program.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using OpenCvSharp;
  2. using System;
  3. namespace OpenCVTest
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //源码 https://gitee.com/CrazyIterBin/opencvsharp.git
  10. Mat base_img = Cv2.ImRead(@"F:/20191204104138.jpg");
  11. get_answer_from_sheet(base_img);
  12. }
  13. public static void get_answer_from_sheet(Mat base_img)
  14. {
  15. Cv2.ImShow("src", base_img);
  16. Mat gray = new Mat();
  17. Cv2.CvtColor(base_img, gray, ColorConversionCodes.BGR2GRAY);
  18. }
  19. public static void get_init_process_img(Mat roi_img) {
  20. Mat h = new Mat();
  21. Cv2.Sobel(roi_img, h, MatType.CV_32F, 0, 1, -1);
  22. Mat v = new Mat();
  23. Cv2.Sobel(roi_img, v, MatType.CV_32F, 1, 0, -1);
  24. Mat img = new Mat();
  25. Cv2.Add(h, v,img);
  26. Cv2.ConvertScaleAbs(img,img);
  27. Cv2.GaussianBlur(img, img, new Size { Width = 3, Height = 3 }, 0);
  28. //Cv2.Threshold(img, img, 120, 255, cv2);
  29. }
  30. }
  31. }