书上的例子运行不出来,有谁可以解答下阿

来源:互联网 发布:6.6 udp端口怎么打开 编辑:程序博客网 时间:2024/04/30 19:46

#include <cv.h>
#include <highgui.h>
#include <math.h>
#include  <stdio.h>
IplImage *Igray=0, *It = 0, *Iat;
int main( int argc, char** argv )
{
    char*  filename1="C://Program Files (x86)//OpenCV//LearningOpenCV_Code//LearningOpenCV_Code//HandOutdoorSunColor.jpg";
 if(argc != 7){return -1;          }
     //Command line
     double threshold = (double)atof("100");
     int threshold_type = atoi("0") ?
              CV_THRESH_BINARY : CV_THRESH_BINARY_INV;
     int adaptive_method = atoi("0") ?
              CV_ADAPTIVE_THRESH_MEAN_C : CV_ADAPTIVE_THRESH_GAUSSIAN_C;
     int block_size = atoi("100");
     double offset = (double)atof("100");
     //Read in gray image
     if((Igray = cvLoadImage( filename1, CV_LOAD_IMAGE_GRAYSCALE)) == 0){
          return     -1;}
     // Create the grayscale output images
     It = cvCreateImage(cvSize(Igray->width,Igray->height),
                          IPL_DEPTH_8U, 1);
     Iat = cvCreateImage(cvSize(Igray->width,Igray->height),
                          IPL_DEPTH_8U, 1);
     //Threshold
     cvThreshold(Igray,It,threshold,255,threshold_type);
     cvAdaptiveThreshold(Igray, Iat, 255, adaptive_method,
                          threshold_type, block_size, offset);
     //PUT UP 2 WINDOWS
     cvNamedWindow("Raw",1);
     cvNamedWindow("Threshold",1);
     cvNamedWindow("Adaptive Threshold",1);
     //Show the results
     cvShowImage("Raw",Igray);
     cvShowImage("Threshold",It);
     cvShowImage("Adaptive Threshold",Iat);
     cvWaitKey(0);
     //Clean up
     cvReleaseImage(&Igray);
     cvReleaseImage(&It);
     cvReleaseImage(&Iat);
   cvDestroyWindow("Raw");
   cvDestroyWindow("Threshold");
   cvDestroyWindow("Adaptive Threshold");
   return(0);
}

 

原创粉丝点击