OpenCV错误:cvGetMat中的空指针(传递NULL数组指针) [英] OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat

查看:408
本文介绍了OpenCV错误:cvGetMat中的空指针(传递NULL数组指针)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的代码为 Caltech-Lanes-Detection < a>。有我的命令:

I have run the code of Caltech-Lanes-Detection. There is my command:

$ ./LaneDetector32 --show --list-file=/home/me/caltech-lanes/cordova1/list.txt --list-path=/home/me/caltech-lanes/cordova1/ --output-suffix=_result

并且有以下问题:

main.cc:187 msg   Loaded camera file
main.cc:194 msg   Loaded lanes config file
main.cc:249 msg   Processing image: /home/me/caltech-lanes/cordova1/f00000.png
OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat, file /home/me/OpenCV-2.0.0/src/cxcore/cxarray.cpp, line 2370
terminate called after throwing an instance of 'cv::Exception'

,如果我运行此命令:

eog /home/me/caltech-lanes/cordova1/f00000.png

我可以看到图片。请帮助我。谢谢。

I can see the picture.Please help me. Thank you.

推荐答案

这个问题最好由Mohamed Aly回答。他的联系人就在您链接的网页上。

This question might better be answered by Mohamed Aly, the guy who actually worked on this. His contact is right on the page you linked.

这就是说,让我们来看看。 (有一个TLDR,如果你想跳过这个错误是由cvGetMat导致的 cxarray.cpp 文件。第一对是:

That said, let's take a look. (There's a TLDR if you want to skip this) The error is caused by the cvGetMat in the cxarray.cpp file. The first couple lines of which are:

2362    cvGetMat( const CvArr* array, CvMat* mat,
2363              int* pCOI, int allowND )
2364    {
2365        CvMat* result = 0;
2366        CvMat* src = (CvMat*)array;
2367        int coi = 0;
2368    
2369        if( !mat || !src )
2370            CV_Error( CV_StsNullPtr, "NULL array pointer is passed" );
        ...
            return result;
        }

直到以后我们才检查您是否有图片数据。

It isn't until later that we actually check if you're image has data in it or not.

现在让我们找到Aly先生使用cvGetMat()。我们很幸运!只有一个地方,他使用它没有注释它:文件是mcv.cc

So now lets find where Mr. Aly used cvGetMat(). We're in luck! Only one place where he's used it without commenting it out: File is mcv.cc

void mcvLoadImage(const char *filename, CvMat **clrImage, CvMat** channelImage)
{
  // load the image
  IplImage* im;
  im = cvLoadImage(filename, CV_LOAD_IMAGE_COLOR);
  // convert to mat and get first channel
  CvMat temp;
  cvGetMat(im, &temp);
  *clrImage = cvCloneMat(&temp);
  // convert to single channel
  CvMat *schannel_mat;
  CvMat* tchannelImage = cvCreateMat(im->height, im->width, INT_MAT_TYPE);
  cvSplit(*clrImage, tchannelImage, NULL, NULL, NULL);
  // convert to float
  *channelImage = cvCreateMat(im->height, im->width, FLOAT_MAT_TYPE);
  cvConvertScale(tchannelImage, *channelImage, 1./255);
  // destroy
  cvReleaseMat(&tchannelImage);
  cvReleaseImage(&im);
}

这显然是指定的文件名。这里没有什么错。这将是很好,如果他仔细检查,图像实际上加载在代码,但不是绝对必要的。 cvGetMat有两个输入,图像和它写入的垫。垫应该很好,所以我们需要检查图像。 cvLoadImage可以使用任何文件名 - 无论文件是否存在 - 不给出错误;所以我们需要检查文件名是否完好无损。 mcvLoadImage在main.cc文件中的ProcessImage(*)中被调用 - 但是这也获得了传递给它的文件名。 ProcessImage在Process()中调用,其中文件名作为打印输出的同一字符串,当它出现

This is clearly where the filename you specified ends up. Nothing wrong here. It would be nice if he double-checked that the image was actually loaded in the code, but not strictly necessary. The cvGetMat has two inputs, the image, and the mat it gets written into. The mat should be fine, so we need to check the image. cvLoadImage would work with any filename - whether or not the file exists - without giving an error; so we need to check that the filename got there intact. mcvLoadImage is called in ProcessImage(*) in the main.cc file - but this also gets the filename passed into it. ProcessImage is called in Process() where the filename is put in as the same string that is printed out when it says


处理图像: home / me / caltech-lanes / cordova1 / f00000.png

Processing image: /home/me/caltech-lanes/cordova1/f00000.png

当然,这只是一个字符串 - 他没有检查他可以预先读入文件,所以当他说处理图像,他真的意味着这是我给予图像的路径 - 但我实际上不知道我是否可以阅读它。

Of course, that's just a string - he didn't check if he could read in the file beforehand, so when he say "Processing Image" he really means "This is the path I was given to the image - but I don't actually know if I can read it yet".

TLDR: (我不能怪ya)所以看来主要的问题是它不能读该文件尽管eog能够显示它。因为 - 我唯一可以建议的是试图将文件夹cordova1移动到类似C:/ Test / cordova1 /或(如果您的计算机上的设置阻止它工作)C:/ Users / [You] / cordova1 /与其中的文件,并做一个

TLDR: (And I can't blame ya) So it seems like the main issue is that it can't read the file despite eog being able to display it. As-is the only thing I can suggest is trying to move the folder cordova1 to something like C:/Test/cordova1/ or (if there are settings on your computer that prevent that from working) C:/Users/[You]/cordova1/ with the files in there and do a

$ ./LaneDetector32 --show --list-file=/home/me/caltech-lanes/cordova1/list.txt --list-path=/home/me/caltech-lanes/cordova1/ --output-suffix=_result

查看是否是权限错误,阻止车道检测程序实际读入文件。

to see if it's a permissions error preventing the lane-detection program from actually reading in the file.

这篇关于OpenCV错误:cvGetMat中的空指针(传递NULL数组指针)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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