OpenCV 2.1: Laufzeitfehler

Ich habe ein Programm, das OpenCV verwendet. Ich habe eine Webcam und sie erfasst Farbrahmen und ich möchte die Farbrahmen in Graustufenrahmen konvertieren. Also benutzte ich dascvCvtColor(color_frame, gray_frame, CV_BGR2GRAY);, um die Farbrahmen in BW-Rahmen umzuwandeln.

ei Verwendung dieser Farb-> Graustufen-Konvertierungsfunktion erhalte ich den folgenden Laufzeitfehler:

OpenCV Error: Null pointer (NULL array pointer is passed) in unknown function, file ..\..\..\..\ocv\opencv\src\cxcore\cxarray.cpp, line 2376

Hat jemand dieses Problem schon mal erlebt? Irgendwelche Lösungen, wie man das behebt?

Vielen Dan

Mein Programm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/time.h>

#include"cv.h"
#include"highgui.h"
#include"cxtypes.h"

    #define ERROR -1
    #define NO_ERROR 1

int main()
{

    int EXIT_STATUS = NO_ERROR;

    int camera_index = 0;
    CvCapture   *capture = 0;
    IplImage *color_frame = NULL;
    IplImage *gray_frame = NULL;
    int exit_key_press = 0;

    capture = cvCaptureFromCAM(camera_index);
    cvNamedWindow("SURF", CV_WINDOW_AUTOSIZE);

            while(exit_key_press != 's')
            {

                /* Capture a frame */
                color_frame = cvQueryFrame(capture);
                if(color_frame == NULL)
                {
                    break;
                }
                else
                {
                   // When this line is enabled the runtime error occurs.
                    //cvCvtColor(color_frame, gray_frame, CV_BGR2GRAY);
                    cvShowImage("SURF", color_frame );



                }
                exit_key_press = cvWaitKey(1);
            }

    cvDestroyWindow("Output");
    cvReleaseCapture(&capture);

    printf("\n\n~*~The END~*~");
    exit(EXIT_STATUS);

}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage