Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
face = New HaarCascade("haarcascade_frontalface_default.xml")

      'Try
      Dim Labelsinfo As String = File.ReadAllText(Application.StartupPath & "/TrainedFaces/TrainedLabels.txt")
      Dim Labels As String() = Labelsinfo.Split("%"c)
      NumLabels = Convert.ToInt16(Labels(0))
      ContTrain = NumLabels
      Dim LoadFaces As String

      For tf As Integer = 1 To NumLabels + 1 - 1
          LoadFaces = "face" & tf & ".bmp"
          trainingImages.Add(New Image(Of Gray, Byte)(Application.StartupPath & "/TrainedFaces/" & LoadFaces))


          Labels.Add(Labels(tf))


      Next


What I have tried:

Basically this is c# code which i convert into vb.net successfully but
Error flow 'Add is not a member of System.array

Namespace declare as

Imports System.Collections.Generic

Variable declaration as
Public labels As List(Of String) = New List(Of String)()

Labels.Add(Labels(tf))

Can anybody give reason and solution in simple form.
Posted
Updated 18-Dec-19 22:01pm
v2

See Array Class (System) | Microsoft Docs[^], which has no Add method. If you want to build a list item by item then use a generic such as List<T> Class (System.Collections.Generic) | Microsoft Docs[^].

And please remove that redundant expression:
VB
For tf As Integer = 1 To NumLabels + 1 - 1
 
Share this answer
 
Comments
Member 13893129 19-Dec-19 4:10am    
Dear Sir, please just tell me how to solve error here.

Labels.Add(Labels(tf))
Richard MacCutchan 19-Dec-19 4:19am    
I just did, you need to use a List(T) for your Labels. An array does not have an Add method.
Richard MacCutchan 19-Dec-19 5:12am    
Why are you adding an element of your list into the list a second time?

name1 = recognizer.Recognize(result)

What is the value of result at this point?
Member 13893129 19-Dec-19 5:19am    
Can't explain, Please tell me as your way
This is multi face detection prg by using emgu. I just try to convert it into vb.net
Richard MacCutchan 19-Dec-19 5:28am    
Sorry, but if you cannot understand your code then you cannot expect other people to be able to. I suggest you go back to the original source that you copied it from, and ask the person who wrote it.
Quote:
Can anybody give reason and solution in simple form.

No.

Most probably you're missing a using directive.. something like System.Collections, but I'm not really sure.
 
Share this answer
 
Comments
Member 13893129 19-Dec-19 3:59am    
I already
Imports System.Collections.Generic
Richard MacCutchan 19-Dec-19 4:17am    
No, he is trying to use an Array instead of a List(T).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900