无法将system.drawing.point转化为opencvsharp.point怎么修改
时间: 2023-10-03 17:06:57 浏览: 107
要将System.Drawing.Point转换为OpenCvSharp.Point,可以使用以下代码:
```csharp
System.Drawing.Point sourcePoint = new System.Drawing.Point(10, 20);
OpenCvSharp.Point targetPoint = new OpenCvSharp.Point(sourcePoint.X, sourcePoint.Y);
```
这将创建一个名为`sourcePoint`的System.Drawing.Point实例,然后将其X和Y坐标分配给OpenCvSharp.Point实例的X和Y属性,从而创建一个名为`targetPoint`的OpenCvSharp.Point实例。您可以将其用作所需的类型。
如果您要将OpenCvSharp.Point转换为System.Drawing.Point,可以使用以下代码:
```csharp
OpenCvSharp.Point sourcePoint = new OpenCvSharp.Point(30, 40);
System.Drawing.Point targetPoint = new System.Drawing.Point((int)sourcePoint.X, (int)sourcePoint.Y);
```
这将创建一个名为`sourcePoint`的OpenCvSharp.Point实例,然后将其X和Y坐标转换为int类型后分配给System.Drawing.Point实例的X和Y属性,从而创建一个名为`targetPoint`的System.Drawing.Point实例。同样,您可以将其用作所需的类型。
阅读全文