2

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

and there is a problem as following:

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'

and if I run this command:

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

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

2 Answers 2

1

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.

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.

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);
}

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

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: (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.

Sign up to request clarification or add additional context in comments.

Comments

0

Just in case it helps, I had this same error because I was dealing (trying to show) with very large images.

So I had to segment the images and process it chunk by chunk.

(I was using OpenCV 3.0 for Python, I know this was for C++ but it is basically what is running underneath).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.