14 Commits
Author SHA1 Message Date
Kq 234cd96109 update 2026-08-12 17:12:58 +02:00
Kq e323482b2e update 2026-08-12 17:12:22 +02:00
Kq 0a781d9cbe Merge branch 'main' of https://gitea.kqnori.pl/kq/qrcode 2026-08-12 03:58:44 +02:00
Kq 9fae9410fb both 2026-08-12 03:58:44 +02:00
kq 6e230b39ba Delete directory 'cache' 2026-08-12 03:58:17 +02:00
Kq 811773062e alot 2026-08-12 03:57:27 +02:00
Kq 084aefbbd7 changed screen
shots
2026-08-12 03:46:45 +02:00
Kq 422a5ccc5d Merge branch 'main' of https://gitea.kqnori.pl/kq/qrcode 2026-08-12 03:45:07 +02:00
Kq 7d28a8cb7c update 2026-08-12 03:42:33 +02:00
kq 44b817fb4b Upload files to "assets" 2026-08-12 03:31:21 +02:00
kq d421fcae3d Update assets/whoa.png 2026-08-12 03:30:02 +02:00
kq 67dedbb9f1 Update assets/test.png 2026-08-12 03:29:53 +02:00
Kq 79e5162e9c modified: Program.cs 2026-08-12 03:13:14 +02:00
Kq c6258cd0ae more 2026-08-12 03:03:16 +02:00
21 changed files with 89 additions and 9 deletions
+4 -1
View File
@@ -1,2 +1,5 @@
/bin /bin
/obj /obj
/cache
/createqrcodes/bin
/createqrcodes/obj
+59 -8
View File
@@ -6,6 +6,8 @@ using ZXing.Windows.Compatibility;
using ZXing.Common; using ZXing.Common;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Drawing; using System.Drawing;
using System.Net;
// using Emgu.CV.CvEnum; // using Emgu.CV.CvEnum;
@@ -22,11 +24,15 @@ namespace BarcodeReaderExample
camera.Set(VideoCaptureProperties.FrameWidth, 1280); camera.Set(VideoCaptureProperties.FrameWidth, 1280);
camera.Set(VideoCaptureProperties.FrameHeight, 720); camera.Set(VideoCaptureProperties.FrameHeight, 720);
camera.Set(VideoCaptureProperties.Fps, 60); camera.Set(VideoCaptureProperties.Fps, 24);
if(Directory.Exists("cache"))
{
Directory.Delete("cache",true);
}
Directory.CreateDirectory("cache");
Mat hey = new Mat("photo.png"); Mat hey = new Mat("photo.png");
Mat[] Cached = new Mat[10];
using var rgb = new Mat(); using var rgb = new Mat();
@@ -39,8 +45,12 @@ namespace BarcodeReaderExample
Cv2.NamedWindow("Camera preview", WindowFlags.AutoSize); Cv2.NamedWindow("Camera preview", WindowFlags.AutoSize);
int photocount = 0; int photocount = 0;
Mat src = Cv2.ImRead("test.png");
string[] files = new string[10];
int files_index =0;
while (true) while (true)
{ {
// if (!camera.Read(frame) || frame.Empty()) // if (!camera.Read(frame) || frame.Empty())
@@ -58,7 +68,8 @@ namespace BarcodeReaderExample
float[] pos1 = new float[2] { points[0].X, points[0].Y }; /// lewy dolny róg float[] pos1 = new float[2] { points[0].X, points[0].Y }; /// lewy dolny róg
float[] pos2 = new float[2] { points[2].X, points[2].Y }; ///prawy górny róg float[] pos2 = new float[2] { points[2].X, points[2].Y }; ///prawy górny róg
float[] pos3 = new float[2] { points[1].X, points[1].Y }; ///lewy górny róg float[] pos3 = new float[2] { points[1].X, points[1].Y }; ///lewy górny róg
int width = (int)(pos2[0] - pos3[0]);
int heigh = (int)(pos1[1] - pos3[1]);
// Cv2.Circle(frame, (int)pos1[0], (int)pos1[1], 5, Scalar.Red, 2); // Cv2.Circle(frame, (int)pos1[0], (int)pos1[1], 5, Scalar.Red, 2);
// Cv2.Circle(frame, (int)pos2[0], (int)pos2[1], 5, Scalar.Green, 2); // Cv2.Circle(frame, (int)pos2[0], (int)pos2[1], 5, Scalar.Green, 2);
// Cv2.Circle(frame, (int)pos3[0], (int)pos3[1], 5, Scalar.Blue, 2); // Cv2.Circle(frame, (int)pos3[0], (int)pos3[1], 5, Scalar.Blue, 2);
@@ -73,7 +84,16 @@ namespace BarcodeReaderExample
continue; continue;
} }
// DrawLine(location);
// 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]}");
// DrawLine(location); //draw red squre
var points1 = new List<OpenCvSharp.Point> var points1 = new List<OpenCvSharp.Point>
@@ -88,14 +108,45 @@ namespace BarcodeReaderExample
IEnumerable<IEnumerable<OpenCvSharp.Point>> contours = new[] { points1 }; IEnumerable<IEnumerable<OpenCvSharp.Point>> contours = new[] { points1 };
Cv2.FillPoly(frame, contours, Scalar.White); // Cv2.FillPoly(frame, contours, Scalar.White); // fill with white
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); 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);
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
// Cv2.Circle(frame, (int)(RightBottomX), (int)(RightBottomY), 5, Scalar.Green, 2); // Cv2.Circle(frame, (int)(RightBottomX), (int)(RightBottomY), 5, Scalar.Green, 2);
//Cv2.Rectangle(frame, new Point((int)X, (int)Y), new Point ((int)Width, (int)Height), Scalar.Red, 2); //Cv2.Rectangle(frame, new Point((int)X, (int)Y), new Point ((int)Width, (int)Height), Scalar.Red, 2);
Console.WriteLine(result.Text); // Console.WriteLine(result.Text);
} }
@@ -106,7 +157,7 @@ namespace BarcodeReaderExample
Cv2.ImShow("Camera preview", frame); Cv2.ImShow("Camera preview", frame);
// Thread.Sleep(1000 / 24); Thread.Sleep(1000 / 24);
// Console.WriteLine("tick"); // Console.WriteLine("tick");
int key = Cv2.WaitKey(1); int key = Cv2.WaitKey(1);
if (key == 27 || key == 'q') if (key == 27 || key == 'q')
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+16
View File
@@ -0,0 +1,16 @@
using System.Diagnostics;
string[] files;
files = Directory.GetFiles("assets");
if(Directory.Exists("qr"))
Directory.Delete("qr", true);
Directory.CreateDirectory("qr");
foreach (var item in files)
{
string name = Path.GetFileName(item);
//https://gitea.kqnori.pl/kq/qrcode/raw/branch/main/assets/gay.png
Process.Start("qrencode",$"https://gitea.kqnori.pl/kq/qrcode/raw/branch/main/assets/{item} -o qr/item{name.Split('.').First()}.png");
}
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
View File

Before

Width:  |  Height:  |  Size: 850 KiB

After

Width:  |  Height:  |  Size: 850 KiB

View File

Before

Width:  |  Height:  |  Size: 980 KiB

After

Width:  |  Height:  |  Size: 980 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB