您好,请问以下代码如何改为调用opencv库的。
int main (int argc, char * const argv[])
{
int rv;
int PixelFormat = 24, Width, Height;
unsigned char * pImg;
unsigned char * pBin;
if ( argc < 2 )
{
fprintf( stderr, "Usage: GetContour.exe image\n" ) ;
return 0 ;
}
rv = viGetImageWH( argv[1], Width, Height ) ;
if ( rv == 0 )
{
printf( "Could not get image. Program exits!\n" );
exit( 0 );
}
pImg = new unsigned char [ Width*Height*PixelFormat/8 ];
viReadImageFile( argv[1], pImg, Width, Height, PixelFormat );
pBin = new unsigned char [Width*Height];
viColor24toGray8(pImg, Width, Height,1,pBin);
areaSplitCombine( pBin, Width, Height);
viNamedWindow( "Image", GUI_WINDOW_AUTOSIZE );
viShowImage( "Image",pBin, Width, Height, 8, 0 );
viWaitKey( 0 );
delete [] pImg;
delete [] pBin;
viDestroyAllWindows();
return 0;
} |