modified: qrCamera/Program.cs
This commit is contained in:
+30
-13
@@ -9,6 +9,7 @@ using System.Drawing;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.InteropServices.Marshalling;
|
using System.Runtime.InteropServices.Marshalling;
|
||||||
using Emgu.CV.Face;
|
using Emgu.CV.Face;
|
||||||
|
using System.Transactions;
|
||||||
|
|
||||||
// using Emgu.CV.CvEnum;
|
// using Emgu.CV.CvEnum;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ namespace BarcodeReaderExample
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
static bool draw;
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
VideoCapture camera = new VideoCapture("/dev/video0", VideoCaptureAPIs.V4L2);
|
VideoCapture camera = new VideoCapture("/dev/video0", VideoCaptureAPIs.V4L2);
|
||||||
@@ -37,7 +39,7 @@ namespace BarcodeReaderExample
|
|||||||
Directory.CreateDirectory("cache");
|
Directory.CreateDirectory("cache");
|
||||||
Mat hey = new Mat("photo.png");
|
Mat hey = new Mat("photo.png");
|
||||||
Mat[] Cached = new Mat[avalibeImages];
|
Mat[] Cached = new Mat[avalibeImages];
|
||||||
|
draw = true;
|
||||||
|
|
||||||
int imgX = 0;
|
int imgX = 0;
|
||||||
int imgY = 0;
|
int imgY = 0;
|
||||||
@@ -56,7 +58,7 @@ namespace BarcodeReaderExample
|
|||||||
Mat Lastimage = new Mat();
|
Mat Lastimage = new Mat();
|
||||||
IEnumerable<IEnumerable<OpenCvSharp.Point>> contours = null;
|
IEnumerable<IEnumerable<OpenCvSharp.Point>> contours = null;
|
||||||
// PointF[] location;
|
// PointF[] location;
|
||||||
|
Mat previue = new Mat();
|
||||||
string[] files = new string[avalibeImages];
|
string[] files = new string[avalibeImages];
|
||||||
int files_index = 0;
|
int files_index = 0;
|
||||||
while (true)
|
while (true)
|
||||||
@@ -69,9 +71,10 @@ namespace BarcodeReaderExample
|
|||||||
// Console.WriteLine(Lastimage.Empty());
|
// Console.WriteLine(Lastimage.Empty());
|
||||||
if (!(Lastimage.Empty()))
|
if (!(Lastimage.Empty()))
|
||||||
{
|
{
|
||||||
|
Cv2.Resize(Lastimage, previue, new OpenCvSharp.Size(500, 500));
|
||||||
|
|
||||||
Mat roi2 = frame[new Rect(0, 0, Lastimage.Width, Lastimage.Height)];
|
Mat roi2 = frame[new Rect(0, 0, previue.Width, previue.Height)];
|
||||||
Lastimage.CopyTo(roi2);
|
previue.CopyTo(roi2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
@@ -109,7 +112,7 @@ namespace BarcodeReaderExample
|
|||||||
imgY = GetPoint(location[0]).Y;
|
imgY = GetPoint(location[0]).Y;
|
||||||
contours = new[] { points1 };
|
contours = new[] { points1 };
|
||||||
|
|
||||||
|
if (draw)
|
||||||
Cv2.FillPoly(frame, contours, Scalar.White); // fill with white
|
Cv2.FillPoly(frame, contours, Scalar.White); // fill with white
|
||||||
|
|
||||||
//Write Text
|
//Write Text
|
||||||
@@ -145,17 +148,19 @@ namespace BarcodeReaderExample
|
|||||||
Cv2.Resize(Cached[toload],toDraw,new OpenCvSharp.Size(qrWidth,qrHeigh));
|
Cv2.Resize(Cached[toload],toDraw,new OpenCvSharp.Size(qrWidth,qrHeigh));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{continue;}
|
{ continue; }
|
||||||
Lastimage = toDraw;
|
Lastimage = toDraw;
|
||||||
|
|
||||||
// toDraw.Resize(1,3);
|
// toDraw.Resize(1,3);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
Mat roi2 = frame[new Rect(GetPoint(location[0]).X, GetPoint(location[0]).Y, toDraw.Width, toDraw.Height)];
|
// Mat roi2 = frame[new Rect(GetPoint(location[0]).X, GetPoint(location[0]).Y, toDraw.Width, toDraw.Height)];
|
||||||
toDraw.CopyTo(roi2);
|
// toDraw.CopyTo(roi2);
|
||||||
|
DrawImage(toDraw, GetPoint(location[0]).X, GetPoint(location[0]).Y);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch{}
|
catch { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +172,12 @@ namespace BarcodeReaderExample
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Mat roi2 = frame[new Rect(imgX, imgY, Lastimage.Width, Lastimage.Height)];
|
// Mat roi2 = frame[new Rect(imgX, imgY, Lastimage.Width, Lastimage.Height)];
|
||||||
Lastimage.CopyTo(roi2);
|
// Lastimage.CopyTo(roi2);
|
||||||
|
|
||||||
|
DrawImage(Lastimage,imgX,imgY);
|
||||||
}
|
}
|
||||||
catch{}
|
catch { }
|
||||||
whenWasLastTimeQrDetected--;
|
whenWasLastTimeQrDetected--;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -188,8 +195,14 @@ namespace BarcodeReaderExample
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rotate()
|
static void DrawImage(Mat image, int posX, int posY)
|
||||||
{
|
{
|
||||||
|
if(draw)
|
||||||
|
{
|
||||||
|
|
||||||
|
Mat roi2 = frame[new Rect(posX, posY, image.Width, image.Height)];
|
||||||
|
image.CopyTo(roi2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static OpenCvSharp.Point GetPoint(PointF pointf)
|
static OpenCvSharp.Point GetPoint(PointF pointf)
|
||||||
{
|
{
|
||||||
@@ -239,7 +252,11 @@ namespace BarcodeReaderExample
|
|||||||
}
|
}
|
||||||
static void DrawLine(PointF p1, PointF p2)
|
static void DrawLine(PointF p1, PointF p2)
|
||||||
{
|
{
|
||||||
|
if(draw)
|
||||||
|
{
|
||||||
|
|
||||||
Cv2.Line(frame, (int)p1.X, (int)p1.Y, (int)p2.X, (int)p2.Y, Scalar.Red, 2);
|
Cv2.Line(frame, (int)p1.X, (int)p1.Y, (int)p2.X, (int)p2.Y, Scalar.Red, 2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
static void DrawLine(PointF[] Location)
|
static void DrawLine(PointF[] Location)
|
||||||
|
|||||||
Reference in New Issue
Block a user