0

誰か助けてくださいプロジェクトをデバッグするたびに苦しんでいますこの例外があり、解決できませんこの例外の原因と解決方法を教えてください。この私のコード:

    ////////////////////////////////////////////////////////////////////////
// This is a simple, introductory OpenCV program. 
////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <cv.h>
#include <highgui.h>
#define PIXEL(img,x,y) (img)->imageData[x*img->widthStep+y]


/**
 * Replacement for Matlab's bwareaopen()
 * Input image must be 8 bits, 1 channel, black and white (objects)
 * with values 0 and 255 respectively
 */
/*void removeSmallBlobs(cv::Mat& im, double size)
{
    // Only accept CV_8UC1
    if (im.channels() != 1 || im.type() != CV_8U)
        return;

    // Find all contours
    std::vector<std::vector<cv::Point> > contours;
    cv::findContours(im.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

    for (int i = 0; i < contours.size(); i++)
    {
        // Calculate contour area
        double area = cv::contourArea(contours[i]);

        // Remove small objects by drawing the contour with black color
        if (area > 0 && area <= size)
            cv::drawContours(im, contours, i, CV_RGB(0,0,0), -1);
    }
}


*/




int main(int argc, char *argv[])
{
    IplImage *Img, *img;

    int height,width;
    int i,j, count=0;
    int morph_elem=0;
    int morph_size = 0;
    int morph_operator = 0;
    //read image
    Img = cvLoadImage("1.jpg",1);
    cvShowImage("original image",Img );

    //RGB to HSV 
    IplImage* hsv = cvCreateImage( cvGetSize(Img), 8, 3 );
    cvCvtColor( Img, hsv, CV_BGR2HSV );
    cvShowImage("hsv image ",hsv );
    //extract the h, s, and v images individualy
    IplImage* h_plane = cvCreateImage( cvGetSize(Img), 8, 1 );
    IplImage* s_plane = cvCreateImage( cvGetSize(Img), 8, 1 );
    IplImage* v_plane = cvCreateImage( cvGetSize(Img), 8, 1 );
    IplImage* planes[] = { h_plane, s_plane };
    cvCvtPixToPlane( hsv, h_plane, s_plane, v_plane, 0 );


    // Now apply each color band's particular thresholds to the color band
    IplImage* yellow = cvCreateImage( cvGetSize(v_plane), 8, 3 );
     cvThreshold( h_plane, h_plane,0.09*255,0.14*255,CV_THRESH_BINARY);
     cvThreshold( s_plane, s_plane,0.1*255,1.0*255,CV_THRESH_BINARY);
     cvThreshold( v_plane, v_plane,0.1*255,1.0*255,CV_THRESH_BINARY);
     cvShowImage("h mask ",h_plane );
     cvShowImage("s mask ",s_plane );
     cvShowImage("v mask ",v_plane );

      CvMat *h_array = cvCreateMat(h_plane->height,h_plane->width,CV_8UC1 );
      CvMat *s_array = cvCreateMat(s_plane->height,s_plane->width,CV_8UC1 );
      CvMat *v_array= cvCreateMat(v_plane->height,v_plane->width,CV_8UC1 );
       cvConvert( h_plane, h_array );
        cvConvert( s_plane,s_array );
         cvConvert( v_plane,v_array );


    // Anding
    CvMat* yellowObjectsMask= cvCreateMat( Img->height,Img->width,CV_8UC1 );
    cvAnd(h_array, s_array,yellowObjectsMask);
    cvShowImage("yellow objects ",yellowObjectsMask );
    cvShowImage("yellow objects ",yellowObjectsMask );

//convert to IplImage
    //IplImage *im = cvLoadImage( "1.jpg");
    //CvMat *mat = cvCreateMat(im->height,im->width,CV_32FC3 ); 
     //cvConvert( im,mat );


/*int count=0;

for (int i=0;i<yellowObjectsMask->rows;i++){
    for int j=0;j<yellowObjectsMask->cols;j++){
        if (yellowObjectsMask(i,j)==0){
           count=count+1;
        }

    }
}
if (count==i*j){
       cout<<"not infected"; 
}

  */





    // wait for a key
    cvWaitKey(0);

    // release the images and close the windows
    cvReleaseImage(&Img );
    //cvDestroyWindow("Output");
    //cvDestroyWindow("Gray");


    return 0;
}

FirstProj.exe の 0x75ba9617 で未処理の例外: Microsoft C++ 例外: cv::Exception at memory location 0x0011fb38..

4

1 に答える 1

0

例外を引き起こしたのはパスエラーです

于 2013-05-10T01:02:11.173 に答える