人脸检测中的空引用异常 [英] Null reference exception in face detection

查看:80
本文介绍了人脸检测中的空引用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用emgu cv在C#中进行人脸检测程序,我现在没有网络摄像头,但是我从.avi捕获图像,

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.

推荐答案

由于这是开源的,所以为什么不
1)询问该社区中的某人
2)下载代码并自行调试
Since this is open source why don''t you
1) Ask someone in that community
2) Download the code and debug it yourself


如果您已从某篇文章中复制了代码,请在此处发布此问题,因为该文章的作者可能会为您提供帮助.

此处提供的信息不足以给出为什么会发生这种情况的确切答案.
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.


您好,
缺少信息,恐怕Abhinav是正确的.大多数错误通常是由avi文件本身引起的.我曾经遇到过此错误,但是通常在avi文件结尾处有人试图读取视频结尾之后才会发生此错误.

自然地,因为没有框架,所以将引发null异常.我希望这是您直接尝试将获取的帧应用于Image< bgr,byte>的类似问题.可变图像,因为没有框架,因此无法应用.

您可以使用try {} catch {}方法,但是它不是首选方法,因为它可以防止其他错误(例如半帧渲染等)变得可见.

但是,您可以尝试进行检查以防止发生此错误,并且已对其进行了充分的记录.

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.

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


希望对您有帮助

干杯
克里斯


I hope this helps

Cheers
Chris


这篇关于人脸检测中的空引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆