从OpenCV中选择整数数组。点数组

时间:2018-09-19 10:36:34

标签: vb.net linq select opencvsharp

我正在尝试从OpenCvSharp.Point数组中选择整数。

Dim hull() As Integer = Cv2.ConvexHullIndices(origPoints.Skip(48)).Select(i >= i + 48)

此行失败,编译器告诉我“错误重载,因为这些类型的参数没有[选择]”。

正确的方法是什么?

origPoints的声明如下:

Dim origPoints() As OpenCvSharp.Point 

ConverHullIndices的声明如下:

Public Shared Function ConvexHullIndices(points As IEnumerable(Of Point), Optional clockwise As Boolean = False) As Integer()

OpenCvSharp.Point的声明如下:

#Region "Assembly OpenCvSharp, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=6adad1e807fea099"
' D:\Dev\Projects\faceshift\faceshift\packages\OpenCvSharp3- 
AnyCPU.3.4.1.20180830\lib\net46\OpenCvSharp.dll
#End Region

Imports System

Namespace OpenCvSharp
'
Public Structure Point
    Implements IEquatable(Of Point)
    '
    Public Const SizeOf As Integer = 8
    '
    Public X As Integer
    '
    Public Y As Integer

    '
    ' Parameter:
    '   x:
    '
    '   y:
    Public Sub New(x As Integer, y As Integer)
    '
    ' Parameter:
    '   x:
    '
    '   y:
    Public Sub New(x As Double, y As Double)

    '
    ' Zusammenfassung:
    '     Calculates the dot product of two 2D vectors.
    '
    ' Parameter:
    '   p1:
    '
    '   p2:
    Public Shared Function DotProduct(p1 As Point, p2 As Point) As Double
    '
    ' Zusammenfassung:
    '     Returns the distance between the specified two points
    '
    ' Parameter:
    '   p1:
    '
    '   p2:
    Public Shared Function Distance(p1 As Point, p2 As Point) As Double
    '
    ' Zusammenfassung:
    '     Calculates the cross product of two 2D vectors.
    '
    ' Parameter:
    '   p1:
    '
    '   p2:
    Public Shared Function CrossProduct(p1 As Point, p2 As Point) As Double
    '
    ' Zusammenfassung:
    '     Calculates the dot product of two 2D vectors.
    '
    ' Parameter:
    '   p:
    Public Function DotProduct(p As Point) As Double
    '
    ' Zusammenfassung:
    '     Returns the distance between the specified two points
    '
    ' Parameter:
    '   p:
    Public Function DistanceTo(p As Point) As Double
    '
    ' Zusammenfassung:
    '     Converts this object to a human readable string.
    '
    ' Rückgabewerte:
    '     A string that represents this object.
    Public Overrides Function ToString() As String
    '
    ' Zusammenfassung:
    '     Returns a hash code for this object.
    '
    ' Rückgabewerte:
    '     An integer value that specifies a hash value for this object.
    Public Overrides Function GetHashCode() As Integer
    '
    ' Zusammenfassung:
    '     Specifies whether this object contains the same members as the specified Object.
    '
    ' Parameter:
    '   obj:
    '     The Object to test.
    '
    ' Rückgabewerte:
    '     This method returns true if obj is the same type as this object and has the same
    '     members as this object.
    Public Overrides Function Equals(obj As Object) As Boolean
    '
    ' Zusammenfassung:
    '     Calculates the cross product of two 2D vectors.
    '
    ' Parameter:
    '   p:
    Public Function CrossProduct(p As Point) As Double
    '
    ' Zusammenfassung:
    '     Specifies whether this object contains the same members as the specified Object.
    '
    ' Parameter:
    '   obj:
    '     The Object to test.
    '
    ' Rückgabewerte:
    '     This method returns true if obj is the same type as this object and has the same
    '     members as this object.
    Public Function Equals(obj As Point) As Boolean

    '
    ' Zusammenfassung:
    '     Unary plus operator
    '
    ' Parameter:
    '   pt:
    Public Shared Operator +(pt As Point) As Point
    '
    ' Zusammenfassung:
    '     Shifts point by a certain offset
    '
    ' Parameter:
    '   p1:
    '
    '   p2:
    Public Shared Operator +(p1 As Point, p2 As Point) As Point
    '
    ' Zusammenfassung:
    '     Unary minus operator
    '
    ' Parameter:
    '   pt:
    Public Shared Operator -(pt As Point) As Point
    '
    ' Zusammenfassung:
    '     Shifts point by a certain offset
    '
    ' Parameter:
    '   p1:
    '
    '   p2:
    Public Shared Operator -(p1 As Point, p2 As Point) As Point
    '
    ' Zusammenfassung:
    '     Shifts point by a certain offset
    '
    ' Parameter:
    '   pt:
    '
    '   scale:
    Public Shared Operator *(pt As Point, scale As Double) As Point
    '
    ' Zusammenfassung:
    '     Compares two Point objects. The result specifies whether the values of the X
    '     and Y properties of the two Point objects are equal.
    '
    ' Parameter:
    '   lhs:
    '     A Point to compare.
    '
    '   rhs:
    '     A Point to compare.
    '
    ' Rückgabewerte:
    '     This operator returns true if the X and Y values of left and right are equal;
    '     otherwise, false.
    Public Shared Operator =(lhs As Point, rhs As Point) As Boolean
    '
    ' Zusammenfassung:
    '     Compares two Point objects. The result specifies whether the values of the X
    '     or Y properties of the two Point objects are unequal.
    '
    ' Parameter:
    '   lhs:
    '     A Point to compare.
    '
    '   rhs:
    '     A Point to compare.
    '
    ' Rückgabewerte:
    '     This operator returns true if the values of either the X properties or the Y
    '     properties of left and right differ; otherwise, false.
    Public Shared Operator <>(lhs As Point, rhs As Point) As Boolean
    Public Shared Widening Operator CType(vec As Vec2i) As Point
    Public Shared Widening Operator CType(point As Point) As Vec2i
End Structure

结束命名空间

1 个答案:

答案 0 :(得分:1)

我认为您错误地编写了C#lambda而不是VB lambda。这将在C#中有效:

.Select(i => i + 48)

(请注意=>不是>=),而VB等效项是这样的:

.Select(Function(i) i + 48)

能解决您的问题吗?

编辑:

此外,Select方法将返回一个IEnumerable(Of T),因此,如果需要数组,则需要向ToArray追加调用。