Commit def34741 几米阳光

增加测试程序

1 个父辈 e91fec9c
......@@ -23,7 +23,7 @@ namespace CodeTest
{
Directory.CreateDirectory(targetFilePath);
}
for (int i = 1; i <= count; i++)
for (int i = 100000; i <= 100000+count; i++)
{
string name = "pn;" + i.ToString().PadLeft(6, '0') + ";1000";
Bitmap map = ZXingCode(name, 200, BarcodeFormat.QR_CODE);
......
......@@ -36,6 +36,22 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\AForge.NET\AForge.dll</HintPath>
</Reference>
<Reference Include="AForge.Controls, Version=2.2.5.0, Culture=neutral, PublicKeyToken=a8ac264d1dc6b9d9, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\AForge.NET\AForge.Controls.dll</HintPath>
</Reference>
<Reference Include="AForge.Video, Version=2.2.5.0, Culture=neutral, PublicKeyToken=cbfb6e07d173c401, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\AForge.NET\AForge.Video.dll</HintPath>
</Reference>
<Reference Include="AForge.Video.DirectShow, Version=2.2.5.0, Culture=neutral, PublicKeyToken=61ea4348d43881b7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\AForge.NET\AForge.Video.DirectShow.dll</HintPath>
</Reference>
<Reference Include="Basler.Pylon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\Basler.Pylon.dll</HintPath>
......@@ -52,6 +68,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -77,6 +94,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VideoPlayer.cs" />
<EmbeddedResource Include="FrmTest.resx">
<DependentUpon>FrmTest.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -28,20 +28,112 @@
/// </summary>
private void InitializeComponent()
{
this.videoSourcePlayer = new AForge.Controls.VideoSourcePlayer();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.btnGetImage = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// videoSourcePlayer
//
this.videoSourcePlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.videoSourcePlayer.Location = new System.Drawing.Point(12, 12);
this.videoSourcePlayer.Name = "videoSourcePlayer";
this.videoSourcePlayer.Size = new System.Drawing.Size(464, 426);
this.videoSourcePlayer.TabIndex = 0;
this.videoSourcePlayer.Text = "videoSourcePlayer";
this.videoSourcePlayer.VideoSource = null;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(500, 116);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(92, 41);
this.button1.TabIndex = 1;
this.button1.Text = "开始";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(619, 116);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(92, 41);
this.button2.TabIndex = 2;
this.button2.Text = "停止";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(498, 63);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(228, 29);
this.comboBox1.TabIndex = 3;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(495, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(91, 14);
this.label1.TabIndex = 4;
this.label1.Text = "请选择相机:";
//
// btnGetImage
//
this.btnGetImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnGetImage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnGetImage.Location = new System.Drawing.Point(500, 189);
this.btnGetImage.Name = "btnGetImage";
this.btnGetImage.Size = new System.Drawing.Size(92, 41);
this.btnGetImage.TabIndex = 5;
this.btnGetImage.Text = "抓图";
this.btnGetImage.UseVisualStyleBackColor = true;
this.btnGetImage.Click += new System.EventHandler(this.btnGetImage_Click);
//
// FrmTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(750, 450);
this.Controls.Add(this.btnGetImage);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.videoSourcePlayer);
this.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "FrmTest";
this.Text = "FrmTest";
this.Load += new System.EventHandler(this.FrmTest_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private AForge.Controls.VideoSourcePlayer videoSourcePlayer;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnGetImage;
}
}
\ No newline at end of file
using System;
using AForge.Video;
using AForge.Video.DirectShow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
......@@ -16,14 +20,75 @@ namespace CodeTest
InitializeComponent();
}
private FilterInfoCollection videoDevices;
private void FrmTest_Load(object sender, EventArgs e)
{
var zipHelper = new CompressHelper();
zipHelper.CompressSingle(@"D:\Data Matrix ECC 200.dcm");
List<string> strList = new List<string>() { @"D:\Data Matrix ECC 200.dcm", @"D:\ilmergeTest.txt", @"D:\QR Code.dcm" };
zipHelper.CompressMulti(strList.ToArray(), @"D:\test.gz");
zipHelper.DeCompressMulti(@"D:\test.gz", @"D:\web\");
//var zipHelper = new CompressHelper();
//zipHelper.CompressSingle(@"D:\Data Matrix ECC 200.dcm");
//List<string> strList = new List<string>() { @"D:\Data Matrix ECC 200.dcm", @"D:\ilmergeTest.txt", @"D:\QR Code.dcm" };
//zipHelper.CompressMulti(strList.ToArray(), @"D:\test.gz");
//zipHelper.DeCompressMulti(@"D:\test.gz", @"D:\web\");
comboBox1.Items.Clear();
this.videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo v in videoDevices)
{
comboBox1.Items.Add(v.Name);
}
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
}
private void button1_Click(object sender, EventArgs e)
{
int index = comboBox1.SelectedIndex;
if (this.videoDevices.Count > index)
{
VideoCaptureDevice source = new VideoCaptureDevice(this.videoDevices[index].MonikerString);
this.videoSourcePlayer.SignalToStop();
this.videoSourcePlayer.WaitForStop();
this.videoSourcePlayer.VideoSource = source;
this.videoSourcePlayer.Start();
}
comboBox1.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
videoSourcePlayer.Stop();
comboBox1.Enabled = true;
}
private int flag = 0;
private void btnGetImage_Click(object sender, EventArgs e)
{
if (videoSourcePlayer.IsRunning)
{
flag = 0;
videoSourcePlayer.NewFrame += video_NewFrame;
//string path = Application.StartupPath + @"\ImagePath\Image.bmp";
Bitmap bit = (Bitmap)(videoSourcePlayer.GetCurrentVideoFrame()).Clone() ;
//bit.Save(path, ImageFormat.Bmp);
//MessageBox.Show("成功保存图片至:" + path);
}
}
private void video_NewFrame(object sender, ref Bitmap image)
{
Bitmap bitmap = (Bitmap)image.Clone();
if (flag == 0)
{
string dir = Application.StartupPath + @"/ImagePath/ ";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
string img = dir + DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg";
bitmap.Save(img);
flag = 1;
}
}
}
}
......@@ -18,12 +18,12 @@ namespace CodeTest
[STAThread]
static void Main()
{
//CodeCreater.CreateCode(30);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
HDCodeLearnHelper.LoadConfig(ConfigAppSettings.GetValue(Setting_Init.CameraName), ConfigAppSettings.GetValue(Setting_Init.CodeType));
Application.Run(new FrmCodeDecode());
//Application.Run(new FrmTest());
//CodeCreater.CreateCode(100);
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//HDCodeLearnHelper.LoadConfig(ConfigAppSettings.GetValue(Setting_Init.CameraName), ConfigAppSettings.GetValue(Setting_Init.CodeType));
//Application.Run(new FrmCodeDecode());
Application.Run(new FrmTest());
}
}
......
using AForge.Video.DirectShow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeTest
{
public class VideoPlayerM
{
public static VideoPlayerM instance =new VideoPlayerM();
public AForge.Controls.VideoSourcePlayer videoSourcePlayer = null;
private VideoPlayerM()
{
}
public int CameraIndex = -1;
private FilterInfoCollection videoDevices;
public void Init(string name)
{
int i = -1;
this.videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo v in videoDevices)
{
i++;
if (v.Name.Contains(name))
{
CameraIndex = i;
break;
}
} }
public void Start()
{
if (CameraIndex >= 0)
{
VideoCaptureDevice source = new VideoCaptureDevice(this.videoDevices[CameraIndex].MonikerString);
this.videoSourcePlayer.SignalToStop();
this.videoSourcePlayer.WaitForStop();
this.videoSourcePlayer.VideoSource = source;
this.videoSourcePlayer.Start();
}
}
public void Stop()
{
if (videoSourcePlayer.IsRunning)
{
videoSourcePlayer.Stop();
}
}
}
}
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!