Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want recognize faces using Emgu.CV library i selected the trained faces from the database and store them in image list as well as the labels

my problem is that when even i run the program it show me this error
An unhandled exception of type 'System.NullReferenceException' occurred in Emgu.CV.dll

Additional information: Object reference not set to an instance of an object.


please what is the cause of this problem and how can i solve if?

What I have tried:

i have tried this code

VB
Dim trainingImages() As Image(Of Gray, Byte) = New Image(Of Gray, Byte)((5) - 1) {}
        trainingImages(0) = New Image(Of Gray, Byte)(PictureBox1.Image)
        Dim labels() As String = New String() {"Brad"}

        Dim termCrit As New MCvTermCriteria(30, 0.001)
        recognizer = New EigenObjectRecognizer(trainingImages.ToArray, labels.ToArray, 1000, termCrit)
        Dim testImage As Image(Of Gray, Byte) = New Image(Of Gray, Byte)(imgFrame.Bitmap)
        Dim label As String = recognizer.Recognize(testImage).Label
        Console.Write(label)



i'll appreciate your response. thnx
Posted
Updated 26-Mar-16 23:19pm

1 solution

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]

Quote:
Face recognition emgu.cv.dll exception object reference not set to an instance of an object
Either a variable is not initialized or a fail made that a variable received NULL instead of the expected object.
The debugger will help you to to find where is the fail.
 
Share this answer
 
Comments
Engr. S.M. Inuwa 27-Mar-16 6:08am    
Thank you.
i already know the the failure is but don't know why it fails and how to overcome with the correct procedures to achieve what i want.


Dim recognizer As EigenObjectRecognizer = New EigenObjectRecognizer(trainingImages.ToArray, labels.ToArray, 5000, termCrit)

above is where the failure came from

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



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