Compare commits
5
Commits
0.2
...
44b817fb4b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44b817fb4b | ||
|
|
d421fcae3d | ||
|
|
67dedbb9f1 | ||
|
|
79e5162e9c | ||
|
|
c6258cd0ae |
+22
-6
@@ -22,7 +22,7 @@ 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);
|
||||||
|
|
||||||
|
|
||||||
Mat hey = new Mat("photo.png");
|
Mat hey = new Mat("photo.png");
|
||||||
@@ -39,6 +39,7 @@ 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");
|
||||||
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@@ -58,7 +59,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 +75,16 @@ namespace BarcodeReaderExample
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawLine(location);
|
|
||||||
|
// 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)];
|
||||||
|
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 +99,19 @@ 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);
|
||||||
|
|
||||||
|
// Console.WriteLine(result.Text);
|
||||||
|
|
||||||
|
|
||||||
|
// 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 +122,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: 3.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Reference in New Issue
Block a user