| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using OpenCvSharp;
- using OpenCvSharp.Extensions;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace OpenCvSharpTest
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //Bitmap Bitmapimage = new Bitmap("D:\\work\\WindowsFormsTest\\OpenCvSharpTest\\Image_20231102165054144.bmp");
- Bitmap Bitmapimage = new Bitmap("D:\\work\\WindowsFormsTest\\TestImage\\20250609165353.jpg");
- Stopwatch stopwatch= Stopwatch.StartNew();
- ReadCodeTest.Read10CodeTest1(Bitmapimage);
- //ParticleDetectionTest.ParticleDetectionTest1(Bitmapimage);
- stopwatch.Stop();
- Console.WriteLine(stopwatch.ElapsedMilliseconds+"ms");
- Cv2.WaitKey(0);
- Console.ReadKey();
- //InstructionManualTest.InstructionManualTest1();
- }
- //static void ReadCode(Mat gray)
- //{
- // // 3. 初始化 ZXing 解码器
- // var reader = new BarcodeReader
- // {
- // Options = new DecodingOptions
- // {
- // TryHarder = true,
- // PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.EAN_13, BarcodeFormat.CODE_128 }
- // }
- // };
- // var bitmap = BitmapConverter.ToBitmap(gray);
- // // 4. 解码条码
- // var result = reader.Decode(bitmap);
- // if (result != null)
- // {
- // Console.WriteLine("条码内容: " + result.Text);
- // Console.WriteLine("条码类型: " + result.BarcodeFormat);
- // }
- // else
- // {
- // Console.WriteLine("未检测到条码");
- // }
- //}
- static Mat ResizeMat(Mat mat)
- {
- Mat resizedImage = new Mat();
- double maxSize = 1000;
- double scale = Math.Min(maxSize / mat.Width, maxSize / mat.Height);
- OpenCvSharp.Size scaledSize = new OpenCvSharp.Size(mat.Width * scale, mat.Height * scale);
- Cv2.Resize(mat, resizedImage, scaledSize);
- return resizedImage;
- }
- }
- }
|