Commit 1cc8c708 LN

BUG修改

1 个父辈 560f3eda
......@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
......@@ -105,7 +105,7 @@ namespace AccAOI
//
this.btnOpenImage.ImageSize = new System.Drawing.Size(0, 0);
this.btnOpenImage.Inside = false;
this.btnOpenImage.Location = new System.Drawing.Point(1091, 40);
this.btnOpenImage.Location = new System.Drawing.Point(1155, 40);
this.btnOpenImage.Name = "btnOpenImage";
this.btnOpenImage.Size = new System.Drawing.Size(109, 30);
this.btnOpenImage.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -129,14 +129,14 @@ namespace AccAOI
this.cmbCameraList.Inside = false;
this.cmbCameraList.Location = new System.Drawing.Point(730, 40);
this.cmbCameraList.Name = "cmbCameraList";
this.cmbCameraList.Size = new System.Drawing.Size(217, 30);
this.cmbCameraList.Size = new System.Drawing.Size(281, 30);
this.cmbCameraList.TabIndex = 12;
//
// btnGetCameraImg
//
this.btnGetCameraImg.ImageSize = new System.Drawing.Size(0, 0);
this.btnGetCameraImg.Inside = false;
this.btnGetCameraImg.Location = new System.Drawing.Point(967, 40);
this.btnGetCameraImg.Location = new System.Drawing.Point(1031, 40);
this.btnGetCameraImg.Name = "btnGetCameraImg";
this.btnGetCameraImg.Size = new System.Drawing.Size(109, 30);
this.btnGetCameraImg.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -174,7 +174,7 @@ namespace AccAOI
this.imageBox1.Name = "imageBox1";
this.imageBox1.SelectionColor = System.Drawing.Color.Blue;
this.imageBox1.SelectionMode = Acc.ImageBox.ImageBoxSelectionMode.Rectangle;
this.imageBox1.Size = new System.Drawing.Size(637, 517);
this.imageBox1.Size = new System.Drawing.Size(728, 517);
this.imageBox1.TabIndex = 4;
this.imageBox1.SelectionRegionChanged += new System.EventHandler(this.imageBox1_SelectionRegionChanged);
//
......@@ -206,7 +206,7 @@ namespace AccAOI
//
this.btnImageChange.ImageSize = new System.Drawing.Size(0, 0);
this.btnImageChange.Inside = false;
this.btnImageChange.Location = new System.Drawing.Point(838, 76);
this.btnImageChange.Location = new System.Drawing.Point(902, 76);
this.btnImageChange.Name = "btnImageChange";
this.btnImageChange.Size = new System.Drawing.Size(109, 30);
this.btnImageChange.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -218,7 +218,7 @@ namespace AccAOI
//
this.flatButton1.ImageSize = new System.Drawing.Size(0, 0);
this.flatButton1.Inside = false;
this.flatButton1.Location = new System.Drawing.Point(967, 76);
this.flatButton1.Location = new System.Drawing.Point(1031, 76);
this.flatButton1.Name = "flatButton1";
this.flatButton1.Size = new System.Drawing.Size(109, 30);
this.flatButton1.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -230,7 +230,7 @@ namespace AccAOI
//
this.flatButton2.ImageSize = new System.Drawing.Size(0, 0);
this.flatButton2.Inside = false;
this.flatButton2.Location = new System.Drawing.Point(1091, 76);
this.flatButton2.Location = new System.Drawing.Point(1155, 76);
this.flatButton2.Name = "flatButton2";
this.flatButton2.Size = new System.Drawing.Size(109, 30);
this.flatButton2.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -248,7 +248,7 @@ namespace AccAOI
this.testImageBox1.Location = new System.Drawing.Point(668, 101);
this.testImageBox1.Name = "testImageBox1";
this.testImageBox1.SelectionColor = System.Drawing.Color.Blue;
this.testImageBox1.Size = new System.Drawing.Size(561, 421);
this.testImageBox1.Size = new System.Drawing.Size(652, 421);
this.testImageBox1.TabIndex = 21;
this.testImageBox1.Visible = false;
//
......@@ -256,8 +256,8 @@ namespace AccAOI
//
this.lblCurrImage.AutoSize = true;
this.lblCurrImage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblCurrImage.ForeColor = System.Drawing.Color.Green;
this.lblCurrImage.Location = new System.Drawing.Point(628, 87);
this.lblCurrImage.ForeColor = System.Drawing.Color.LawnGreen;
this.lblCurrImage.Location = new System.Drawing.Point(655, 84);
this.lblCurrImage.Name = "lblCurrImage";
this.lblCurrImage.Size = new System.Drawing.Size(74, 22);
this.lblCurrImage.TabIndex = 22;
......@@ -266,7 +266,7 @@ namespace AccAOI
// FrmAoiSetting
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1271, 641);
this.ClientSize = new System.Drawing.Size(1362, 641);
this.Controls.Add(this.lblCurrImage);
this.Controls.Add(this.testImageBox1);
this.Controls.Add(this.flatButton1);
......
......@@ -6,6 +6,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
......@@ -77,10 +78,31 @@ namespace AccAOI
{
cmbCameraList.ItemAdd(str);
}
if (CameraManager.hikNameList.Count > 0)
{
cmbCameraList.Text = CameraManager.hikNameList[0];
}
if (Project != null)
{
ShowPorject();
}
ClearBaseImage();
}
private void ClearBaseImage()
{
try
{
string fileName = Application.StartupPath + @"\aimage\";
if (Directory.Exists(fileName))
{
Directory.Delete(fileName, true);
}
}
catch (Exception EX)
{
Console.Write(EX.ToString());
}
}
private void btnOpenImage_Click(object sender, EventArgs e)
......@@ -113,17 +135,32 @@ namespace AccAOI
private void btnGetCameraImg_Click(object sender, EventArgs e)
{
string camera = cmbCameraList.Text;
if (camera.Equals(""))
{
MessageBox.Show("清先选择相机");
return;
}
Bitmap img = CameraManager.GetCamerImage(camera);
if (img != null)
try
{
string camera = cmbCameraList.Text;
if (camera.Equals(""))
{
MessageBox.Show("清先选择相机");
return;
} //将图片保存到本地重新加载
string fileName = Application.StartupPath + @"\aimage\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond.ToString().PadLeft(3, '0') ;
string file = @"\test.bmp";
using (Bitmap img = CameraManager.GetCamerImage(camera))
{
if (img != null)
{
string path = Path.GetFullPath(fileName);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
img.Save(fileName + file, ImageFormat.Bmp);
}
}
GC.Collect();
BaseImg = (Image)Image.FromFile(fileName+ file).Clone();
//读取图片内容
BaseImg = (Image)img.Clone();
//BaseImg = (Image)img.Clone();
if (Project != null)
{
Project.standardImage = BaseImg;
......@@ -134,6 +171,11 @@ namespace AccAOI
btnImageChange_Click(null, null);
}
}
catch(Exception ex)
{
Console.WriteLine("btnGetCameraImg_Click Error:" + ex.ToString());
MessageBox.Show(ex.ToString());
}
}
private void btnOpenPro_Click(object sender, EventArgs e)
......@@ -349,7 +391,7 @@ namespace AccAOI
{
aoiList.Index = index;
ShowAoi(Project.methodMap[key]);
}
}index++;
}
}
if (imageBox1.Visible.Equals(false))
......@@ -436,6 +478,7 @@ namespace AccAOI
this.testImageBox1.SelectNone();
this.testImageBox1.Image = outImage;
}
GC.Collect();
CanSel = true;
}
......@@ -471,7 +514,7 @@ namespace AccAOI
imageBox1.Visible = true;
btnImageChange.Text = "显示测试图片";
lblCurrImage.Text = "基准图:";
lblCurrImage.ForeColor = Color.Green;
lblCurrImage.ForeColor = Color.LawnGreen;
}
else
{
......
......@@ -46,9 +46,9 @@ namespace AccAOI.camera
HIKCamera.Instance.GrabOne();
if (HIKCamera.Instance.Image != null)
{
bitm = (Bitmap)HIKCamera.Instance.Image;
//HIKCamera.Instance.Close();
bitm = (Bitmap)HIKCamera.Instance.Image;
}
HIKCamera.Instance.Close();
}
else
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!