Click here to Skip to main content
15,900,405 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,
I am doing face detection program in C# using emgu cv ,I dont have a webcam right now but I capture images from a .avi,

vidCapture = New Capture("video.avi")


I having a problem I am using

image = capture.QueryFrame()


This line is giving me error.

Null reference exception error at run time

I Don't know why this error is encountered.
Posted
Updated 29-Sep-11 8:02am
v3

Since this is open source why don't you
1) Ask someone in that community
2) Download the code and debug it yourself
 
Share this answer
 
If you have copied code from an article, post this question there, as the author of that article might be able to help you.

The information provided here is not enough to give an exact answer as to why this could be happening.
 
Share this answer
 
v2
Hi,
I'm afraid Abhinav is correct in the lack of information. A majority of errors are usually caused by the avi files themselves. I have come across this error before however usually it occurs at the end of avi files were someone is attempting to read past the end of the video.

Naturally as there is no frame a null exception is thrown. I would expect it's a similar problem your directly trying to apply the frame acquired to the Image<bgr,byte> variable image as there is no frame it can't be applied.

You could use a try{}catch{} method however this is less preferred as it will prevent other errors from becoming visible such as half rendered frames etc.

However there is a check you could attempt to prevent this error from occurring and it's well documented.

C#
using (Image<Bgr, byte> frame = capture.QueryFrame())
{
    if (frame != null)
        {
           var bmp = frame.Bitmap;
        }
    }
}

I hope this helps

Cheers
Chris
 
Share this answer
 

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