edgealgorithmen bei opencv liefern leeres bild



  • hi hallo, es gibt mich noch! ^^

    ich habe folgendes Problem:

    /*
     * main.cpp
     *
     *  Created on: 30.08.2010
     *      Author: tecdroid
     */
    #include <opencv/cv.h>
    #include <opencv/highgui.h>
    #include <stdio.h>
    
    // A Simple Camera Capture Framework
    int main() {
    
    	CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
    	if (!capture) {
    		fprintf(stderr, "ERROR: capture is NULL \n");
    		getchar();
    		return -1;
    	}
    
    	// Create a window in which the captured images will be presented
    	cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE);
    
    	// Show the image captured from the camera in the window and repeat
    	while (1) {
    		// Get one frame
    		IplImage* frame = cvQueryFrame(capture);
    		if (!frame) {
    			fprintf(stderr, "ERROR: frame is null...\n");
    			getchar();
    			break;
    		}
    
    		// despeckle
    
    		// grayscale
    		IplImage *gray = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
    		cvCvtColor(frame, gray, CV_RGB2GRAY);
    //		cvEqualizeHist(gray, gray);
    
    		// sobel
    		IplImage *edged = cvCreateImage(cvGetSize(frame), IPL_DEPTH_16S, 1);
    		cvSobel(gray, edged, 0 , 1);
    
    		cvShowImage("mywindow", edged);
    
    		// Do not release the frame!
    		// but the rest
    		cvReleaseImage(&edged);
    		cvReleaseImage(&gray);
    
    		//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
    		//remove higher bits using AND operator
    		if ((cvWaitKey(10) & 255) == 27)
    			break;
    	}
    
    	// Release the capture device housekeeping
    	cvReleaseCapture(&capture);
    	cvDestroyWindow("mywindow");
    	return 0;
    }
    

    Das gargestellte Bild ist komplett grau. Das direkte Kamerabild, sowie das gegraute Bild sind sichtbar. Kann mir wer erklären, warum?


Anmelden zum Antworten