Преглед на файлове

修复OPT相机采集图像缓存未清除

徐孝锋 преди 8 месеца
родител
ревизия
e2aa51ef74

+ 1 - 0
TeamAAS-VM/Core/Cameras/OptCamera.cs

@@ -416,6 +416,7 @@ namespace TeamAAS_VP.Core.Cameras
                             OpenDevice();
                             OpenDevice();
                         }
                         }
                         //nReVal = mvCameraAcq.StartGrabbing();
                         //nReVal = mvCameraAcq.StartGrabbing();
+                        mvCameraAcq.ClearPayloadBuffer();
                         nReVal = mvCameraAcq.Grab(ref payload);
                         nReVal = mvCameraAcq.Grab(ref payload);
                         if (nReVal == SciCam.SCI_CAMERA_OK)
                         if (nReVal == SciCam.SCI_CAMERA_OK)
                         {
                         {

+ 2 - 1
TeamAAS-VM/Services/CameraCalibrationService.cs

@@ -714,6 +714,7 @@ namespace TeamAAS_VP.Services
                 curpos.Y += (float)pos[1];
                 curpos.Y += (float)pos[1];
                 //机器人移动
                 //机器人移动
                 await robot.CalibMotionAsync(curpos, curpos.Z);
                 await robot.CalibMotionAsync(curpos, curpos.Z);
+                await Task.Delay(200);
 
 
                 result = await CaptureAndProcessCallback();
                 result = await CaptureAndProcessCallback();
                 if (!result.IsSuccess)
                 if (!result.IsSuccess)
@@ -725,7 +726,7 @@ namespace TeamAAS_VP.Services
                 offsetx = P0.X - curPixel.X;
                 offsetx = P0.X - curPixel.X;
                 offsety = P0.Y - curPixel.Y;
                 offsety = P0.Y - curPixel.Y;
                 //await Console.Out.WriteLineAsync($"移动后的差异:{offsetx},{offsety}");
                 //await Console.Out.WriteLineAsync($"移动后的差异:{offsetx},{offsety}");
-                if (Math.Abs(offsetx) < 1 && Math.Abs(offsetx) < 1)
+                if (Math.Abs(offsetx) < 3 && Math.Abs(offsetx) < 3)
                 {
                 {
                     IsFinish = true;
                     IsFinish = true;
                     break;
                     break;

+ 26 - 1
TeamAAS-VM/Views/Calibration/CalibrationAuto.xaml.cs

@@ -1,4 +1,7 @@
-using System.Windows.Controls;
+using Cognex.VisionPro;
+using Cognex.VisionPro.Dimensioning;
+using System;
+using System.Windows.Controls;
 using TeamAAS_VP.ViewModels.Calibration;
 using TeamAAS_VP.ViewModels.Calibration;
 
 
 namespace TeamAAS_VP.Views.Calibration
 namespace TeamAAS_VP.Views.Calibration
@@ -20,6 +23,8 @@ namespace TeamAAS_VP.Views.Calibration
             this.display.BackColor = System.Drawing.SystemColors.ActiveCaption;
             this.display.BackColor = System.Drawing.SystemColors.ActiveCaption;
         }
         }
 
 
+        private int _imageWidth;
+        private int _imageHeight;
         private void VM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         private void VM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {
         {
             try
             try
@@ -27,10 +32,30 @@ namespace TeamAAS_VP.Views.Calibration
                 if (e.PropertyName == "Image")
                 if (e.PropertyName == "Image")
                 {
                 {
                     this.display.Image = VM.Image;
                     this.display.Image = VM.Image;
+                    //图像中心点坐标
+                    _imageWidth = this.display.Image.Width;
+                    _imageHeight = this.display.Image.Height;
                 }
                 }
                 else if (e.PropertyName == "Graphic")
                 else if (e.PropertyName == "Graphic")
                 {
                 {
                     this.display.StaticGraphics.Clear();
                     this.display.StaticGraphics.Clear();
+                    CogGraphicCollection graphic = new CogGraphicCollection();
+                    CogCreateLineTool line1 = new CogCreateLineTool();
+                    CogCreateLineTool line2 = new CogCreateLineTool();
+                    line1.InputImage = this.display.Image;
+                    line2.InputImage = this.display.Image;
+                    line1.Line.X = _imageWidth / 2;
+                    line1.Line.Y = _imageHeight / 2;
+                    line1.Line.Rotation = 0;
+                    line2.Line.X = _imageWidth / 2;
+                    line2.Line.Y = _imageHeight / 2;
+                    line2.Line.Rotation = Math.PI / 180 * 90;
+                    line1.Run();
+                    line2.Run();
+                    graphic.Add(line1.GetOutputLine());
+                    graphic.Add(line2.GetOutputLine());
+                    this.display.StaticGraphics.Clear();
+                    this.display.StaticGraphics.AddList(graphic, "");
                     if (VM.Graphic!=null)
                     if (VM.Graphic!=null)
                     {
                     {
                         this.display.StaticGraphics.AddList(VM.Graphic, "");
                         this.display.StaticGraphics.AddList(VM.Graphic, "");

+ 2 - 2
TeamAAS-VM/Views/Calibration/CalibrationTeachCenterPoint.xaml

@@ -132,7 +132,7 @@
                            Grid.ColumnSpan="2"
                            Grid.ColumnSpan="2"
                            Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
                            Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
                     <TextBlock.Text>
                     <TextBlock.Text>
-                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{1:F3} mm">
+                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{2:F3} mm">
                             <Binding Path="SelectCalibration.CenterPoint.X"
                             <Binding Path="SelectCalibration.CenterPoint.X"
                                      TargetNullValue="0.000"
                                      TargetNullValue="0.000"
                                      FallbackValue="0.000" />
                                      FallbackValue="0.000" />
@@ -167,7 +167,7 @@
                            Grid.ColumnSpan="2"
                            Grid.ColumnSpan="2"
                            Visibility="{Binding IsShowTechHome,Converter={StaticResource BooleanToVisibilityConverter}}">
                            Visibility="{Binding IsShowTechHome,Converter={StaticResource BooleanToVisibilityConverter}}">
                     <TextBlock.Text>
                     <TextBlock.Text>
-                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{1:F3} mm">
+                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{2:F3} mm">
                             <Binding Path="SelectCalibration.HomePoint.X"
                             <Binding Path="SelectCalibration.HomePoint.X"
                                      TargetNullValue="0.000"
                                      TargetNullValue="0.000"
                                      FallbackValue="0.000" />
                                      FallbackValue="0.000" />

+ 1 - 1
TeamAAS-VM/Views/Calibration/FixedUpCameraFindP0.xaml

@@ -184,7 +184,7 @@
                     <TextBlock Grid.Row="6"
                     <TextBlock Grid.Row="6"
                                Grid.ColumnSpan="2">
                                Grid.ColumnSpan="2">
                         <TextBlock.Text>
                         <TextBlock.Text>
-                            <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}">
+                            <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{2:F3}">
                                 <Binding Path="SelectCalibration.MarkPoint.X"
                                 <Binding Path="SelectCalibration.MarkPoint.X"
                                          TargetNullValue="0.000"
                                          TargetNullValue="0.000"
                                          FallbackValue="0.000" />
                                          FallbackValue="0.000" />