<Window x:Class="ShelfMapping.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Shelf Mapping" Height="1080" Width="1920"
Loaded="Window_Loaded" Unloaded="Window_Unloaded">
<Grid>
<Image Name="camera" />
<Image Name="depthOut"/>
<Canvas Name="canvas"/>
<Grid Style="{StaticResource GridButtonsStyle}">
<StackPanel Style="{StaticResource StackPanelButtonsStyle}">
<Button Content="Screenshot" Style="{StaticResource ButtonStyle}" Click="buttonScreenshotClick" />
<Button Content="OCR" Style="{StaticResource ButtonStyle}" Click="click_OCR" />
<Button Content="Back to stream" Style="{StaticResource ButtonStyle}" Click="click_backToStream" />
<TextBox Name="txtCode" Height="50" Width="150"/>
</StackPanel>
</Grid>
</Grid>
</Window>
这是我的XAML文件。
Ellipse ellipse = new Ellipse();
ellipse.Width = 20;
ellipse.Height = 20;
SolidColorBrush blueBrush = new SolidColorBrush();
blueBrush.Color = Colors.Blue;
SolidColorBrush redBrush = new SolidColorBrush();
redBrush.Color = Colors.DarkRed;
// Set Ellipse's width and color
ellipse.StrokeThickness = 4;
ellipse.Stroke = redBrush;
// Fill rectangle with blue color
ellipse.Fill = blueBrush;
Canvas.SetLeft(ellipse, infoInt[0] - ellipse.Width / 2);
Canvas.SetTop(ellipse, infoInt[1] - ellipse.Height / 2);
canvas.Children.Add(ellipse);
这是我绘制点的地方。根据绘制在画布中其他位置的图像像素,点的输出是正确的。椭圆应该精确地绘制在数字上,但它是在其他地方绘制的。我不知道如何解决它。帮助我解决这个问题。