Выберите целочисленный массив из массива OpenCV.Point - PullRequest
0 голосов
/ 19 сентября 2018

Я пытаюсь выбрать целые числа из массива OpenCvSharp.Point.

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

Эта строка завершается ошибкой, компилятор сообщает мне «Ошибка перегрузки, потому что для этих типов аргументов нет [Select]».

Как правильно это сделать?

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 голосов
/ 19 сентября 2018

Я думаю, что вы по ошибке написали лямбду на C # вместо лямбды на VB.Это будет допустимо в C #:

.Select(i => i + 48)

(обратите внимание, что => не >=), а VB-эквивалент следующий:

.Select(Function(i) i + 48)

Решает ли это вашу проблему?

РЕДАКТИРОВАТЬ:

Кроме того, метод Select будет возвращать IEnumerable(Of T), поэтому, если вы хотите массив, вам нужно добавить вызов к ToArray.

...