Project - Add CantConnectCamera.jpg. AppConstant: Add CAMERA_FAILED_IMAGE_PATH. Camera: Add Event OnOpenVideoStreamFailed. LaneIn: Add Event handler for OnOpenVideoStreamFailed
This commit is contained in:
parent
8a8e8c8481
commit
7880d5bced
|
@ -139,6 +139,9 @@
|
|||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Images\CantConnectCamera.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="plate.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -146,6 +149,7 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -28,13 +28,37 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(840, 223);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(840, 267);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 0;
|
||||
this.button2.Text = "button1";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// AIParkingApplicationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1350, 729);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.MinimumSize = new System.Drawing.Size(1366, 768);
|
||||
this.Name = "AIParkingApplicationForm";
|
||||
this.Text = "AIParking Application";
|
||||
|
@ -43,6 +67,9 @@
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,26 @@ namespace AIParkingApplication
|
|||
{
|
||||
public partial class AIParkingApplicationForm : Form
|
||||
{
|
||||
//@"C:\CongRa_1.mp4"; @"C:\HS_test.mp4"; @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
|
||||
LaneIn laneIn = new LaneIn(@"C:\HS_test.mp4", @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", true, false, false);
|
||||
public AIParkingApplicationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
LaneIn laneIn = new LaneIn(@"C:\HS_test.mp4", @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", true, true); //@"C:\CongRa_1.mp4";
|
||||
|
||||
//LaneIn laneOut = new LaneIn();
|
||||
Controls.Add(laneIn);
|
||||
//laneOut.Location = new System.Drawing.Point(550, 0);
|
||||
//Controls.Add(laneOut);
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
laneIn.Stop();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
laneIn.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,7 @@
|
|||
public const string ERROR_TITLE = "Lỗi";
|
||||
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
|
||||
#endregion
|
||||
|
||||
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading;
|
|||
namespace AIParkingApplication
|
||||
{
|
||||
public delegate void CameraEvent(Mat videoFrame);
|
||||
|
||||
public class Camera
|
||||
{
|
||||
private string streamUrl;
|
||||
|
@ -12,6 +13,7 @@ namespace AIParkingApplication
|
|||
|
||||
public event CameraEvent OnVideoFrameReceived;
|
||||
public event CameraEvent OnOneVideoFrameRequested;
|
||||
public event CameraEvent OnOpenVideoStreamFailed;
|
||||
|
||||
public Camera(string streamUrl)
|
||||
{
|
||||
|
@ -43,10 +45,11 @@ namespace AIParkingApplication
|
|||
|
||||
public void ReadVideoStream()
|
||||
{
|
||||
VideoCapture videoCapture = new VideoCapture();
|
||||
VideoCapture videoCapture = new VideoCapture(); //TODO: Need to dispose this videoCapture?
|
||||
Mat videoFrame = new Mat();
|
||||
if (!videoCapture.Open(streamUrl))
|
||||
{
|
||||
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
BIN
AIParkingApplication/Images/CantConnectCamera.jpg
Normal file
BIN
AIParkingApplication/Images/CantConnectCamera.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
|
@ -1,9 +1,9 @@
|
|||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
|
||||
namespace AIParkingApplication
|
||||
{
|
||||
|
@ -29,13 +29,33 @@ namespace AIParkingApplication
|
|||
|
||||
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
|
||||
plateCamera.OnOneVideoFrameRequested += PlateCamera_OnOneVideoFrameRequested;
|
||||
plateCamera.OnOpenVideoStreamFailed += PlateCamera_OnOpenVideoStreamFailed;
|
||||
|
||||
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
|
||||
overviewCamera.OnOneVideoFrameRequested += OverviewCamera_OnOneVideoFrameRequested;
|
||||
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
|
||||
|
||||
plateProcessor = new PlateProcessor(this.isSupportSquarePlate, this.isSupportLongPlate);
|
||||
}
|
||||
|
||||
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
|
||||
{
|
||||
pictureBoxPlateVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateVideo.Image?.Dispose();
|
||||
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
}
|
||||
|
||||
private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame)
|
||||
{
|
||||
pictureBoxOverviewVideo.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxOverviewImage.Image?.Dispose();
|
||||
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
|
||||
}));
|
||||
}
|
||||
|
||||
private void OverviewCamera_OnOneVideoFrameRequested(Mat videoFrame)
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue
Block a user