Ask Your Question
0

opencv stereo correspondence "OpenCV Error: Bad argument (Unknown array type) in cvarrToMat"

asked 2013-03-02 02:50:31 -0500

superawesomepandacat gravatar image

updated 2013-03-02 04:27:10 -0500

I'm trying to compute depth using stereo correspondence but keep getting the error in the title of this question. I don't really know how to debug this.

Code:

        void imageprocess::get_depth()
        {
            Size size = bridge[0]->image.size();
            Mat imgl, imgr, disp;

            cvtColor(bridge[0]->image, imgl, CV_RGB2GRAY, 1);
            cvtColor(bridge[1]->image, imgr, CV_RGB2GRAY, 1);

            CvStereoBMState* state = cvCreateStereoBMState(0, 16);
            cvFindStereoCorrespondenceBM(&imgl, &imgr, &disp, state);
            cvReleaseStereoBMState(&state);

            imshow(WINDOWM, disp);
            waitKey(3);

        }

Unless my C++ is a lot rustier than I thought, I think I'm using the functions correctly. Which is why I don't see any problem with my code.

It works fine without:

cvFindStereoCorrespondenceBM(&imgl, &imgr, &disp, state);

and the function decleration is:

cvFindStereoCorrespondenceBM(const CvArr* left, const CvArr* right, CvArr* disparity, CvStereoBMState* state)

Edit: I also tried from http://stackoverflow.com/questions/11027574/convert-cvmat-to-const-cvmat-or-cvmat:

    Size size = bridge[0]->image.size();
    Mat imgl, imgr;

    cvtColor(bridge[0]->image, imgl, CV_RGB2GRAY, 1);
    cvtColor(bridge[1]->image, imgr, CV_RGB2GRAY, 1);

    CvMat cvimgl, cvimgr, cvdisp;

    cvimgl = imgl;
    cvimgr = imgr;

    CvStereoBMState* state = cvCreateStereoBMState(0, 16);
    cvFindStereoCorrespondenceBM(&cvimgl, &cvimgr, &cvdisp, state);
    cvReleaseStereoBMState(&state);
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-03-02 06:16:38 -0500

superawesomepandacat gravatar image

Solved. All the arguments to the function must be of the same type CvMat apparently. And cvdisp in the edit wasn't created properly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-03-02 02:50:31 -0500

Seen: 5,471 times

Last updated: Mar 02 '13