Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a781d9cbe | ||
|
|
9fae9410fb | ||
|
|
6e230b39ba | ||
|
|
811773062e | ||
|
|
084aefbbd7 | ||
|
|
422a5ccc5d | ||
|
|
7d28a8cb7c |
@@ -1,2 +1,3 @@
|
||||
/bin
|
||||
/obj
|
||||
/obj
|
||||
/cache
|
||||
@@ -6,6 +6,8 @@ using ZXing.Windows.Compatibility;
|
||||
using ZXing.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
|
||||
// using Emgu.CV.CvEnum;
|
||||
|
||||
|
||||
@@ -23,10 +25,14 @@ namespace BarcodeReaderExample
|
||||
camera.Set(VideoCaptureProperties.FrameWidth, 1280);
|
||||
camera.Set(VideoCaptureProperties.FrameHeight, 720);
|
||||
camera.Set(VideoCaptureProperties.Fps, 24);
|
||||
if(Directory.Exists("cache"))
|
||||
{
|
||||
Directory.Delete("cache",true);
|
||||
}
|
||||
|
||||
|
||||
Directory.CreateDirectory("cache");
|
||||
Mat hey = new Mat("photo.png");
|
||||
|
||||
Mat[] Cached = new Mat[10];
|
||||
|
||||
|
||||
using var rgb = new Mat();
|
||||
@@ -42,6 +48,9 @@ namespace BarcodeReaderExample
|
||||
Mat src = Cv2.ImRead("test.png");
|
||||
|
||||
|
||||
|
||||
string[] files = new string[10];
|
||||
int files_index =0;
|
||||
while (true)
|
||||
{
|
||||
// if (!camera.Read(frame) || frame.Empty())
|
||||
@@ -76,13 +85,13 @@ namespace BarcodeReaderExample
|
||||
}
|
||||
|
||||
|
||||
// Mat roi = frame[new Rect((int)pos3[0], (int)pos3[1], width,heigh)];
|
||||
Mat roi = frame[new Rect((int)pos3[0],(int)pos3[1], src.Width+3, src.Height)];
|
||||
// Mat roi = frame[new Rect((int)pos3[0],(int)pos3[1], src.Width+3, src.Height)];
|
||||
Mat roi = frame[new Rect((int)pos3[0], (int)pos3[1], width,heigh)];
|
||||
src.CopyTo(roi);
|
||||
Console.WriteLine($"szerokość:{width}");
|
||||
Console.WriteLine($"wysokosc:{heigh}");
|
||||
Console.WriteLine($"x:{pos3[0]}");
|
||||
Console.WriteLine($"y:{pos3[1]}");
|
||||
// Console.WriteLine($"szerokość:{width}");
|
||||
// Console.WriteLine($"wysokosc:{heigh}");
|
||||
// Console.WriteLine($"x:{pos3[0]}");
|
||||
// Console.WriteLine($"y:{pos3[1]}");
|
||||
|
||||
// DrawLine(location); //draw red squre
|
||||
|
||||
@@ -103,7 +112,33 @@ namespace BarcodeReaderExample
|
||||
|
||||
Cv2.PutText(frame, result.Text, new OpenCvSharp.Point((int)(pos2[0]-pos3[0])/2+(int)pos3[0]-160, (int)(pos2[1]-pos3[1])/2+(int)pos3[1]+60), HersheyFonts.HersheySimplex, 0.8, Scalar.Black, 2);
|
||||
|
||||
// Console.WriteLine(result.Text);
|
||||
if (!files.Contains(result.Text))
|
||||
{
|
||||
files[files_index] = result.Text;
|
||||
Console.WriteLine("downloading: "+result.Text);
|
||||
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.DownloadFile(result.Text, "cache/"+files_index + ".png");
|
||||
// Thread.Sleep(2000);
|
||||
|
||||
}
|
||||
Cached[files_index] = new Mat("cache/" + files_index + ".png");
|
||||
files_index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// try
|
||||
// {
|
||||
|
||||
int toload = files.IndexOf(result.Text);
|
||||
|
||||
Mat roi2 = frame[new Rect((int)pos3[0], (int)pos3[1], Cached[toload].Width, Cached[toload].Height)];
|
||||
Cached[toload].CopyTo(roi2);
|
||||
// Console.WriteLine("work");
|
||||
// }
|
||||
// catch { }
|
||||
}
|
||||
|
||||
|
||||
// Cv2.draw
|
||||
|
||||
|
Before Width: | Height: | Size: 3.0 MiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |