Ejemplo n.º 1
0
int main( int argc, char** argv )
{
    char* filename = argc == 2 ? argv[1] : (char*)"fruits.jpg";
    
    if( (image = cvLoadImage( filename, 1)) == 0 )
        return -1;

    // Create the output image
    cedge = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 3);

    // Convert to grayscale
    gray = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 1);
    edge = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 1);
    cvCvtColor(image, gray, CV_BGR2GRAY);

    // Create a window
    cvNamedWindow(wndname, 1);

    // create a toolbar 
    cvCreateTrackbar(tbarname, wndname, &edge_thresh, 100, on_trackbar);

    // Show the image
    on_trackbar(0);

    // Wait for a key stroke; the same function arranges events processing
    cvWaitKey(0);
    cvReleaseImage(&image);
    cvReleaseImage(&gray);
    cvReleaseImage(&edge);
    cvDestroyWindow(wndname);

    return 0;
}
Ejemplo n.º 2
0
	int contours2( int argc, char** argv)
	{
	    cv::CommandLineParser parser(argc, argv, "{help h||}");
	    if (parser.has("help"))
	    {
	        help();
	        return 0;
	    }
	    Mat img = Mat::zeros(w, w, CV_8UC1);
	    //Draw 6 faces
	    for( int i = 0; i < 6; i++ )
	    {
	        int dx = (i%2)*250 - 30;
	        int dy = (i/2)*150;
	        const Scalar white = Scalar(255);
	        const Scalar black = Scalar(0);
	
	        if( i == 0 )
	        {
	            for( int j = 0; j <= 10; j++ )
	            {
	                double angle = (j+5)*CV_PI/21;
	                line(img, Point(cvRound(dx+100+j*10-80*cos(angle)),
	                    cvRound(dy+100-90*sin(angle))),
	                    Point(cvRound(dx+100+j*10-30*cos(angle)),
	                    cvRound(dy+100-30*sin(angle))), white, 1, 8, 0);
	            }
	        }
	
	        ellipse( img, Point(dx+150, dy+100), Size(100,70), 0, 0, 360, white, -1, 8, 0 );
	        ellipse( img, Point(dx+115, dy+70), Size(30,20), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+185, dy+70), Size(30,20), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+115, dy+70), Size(15,15), 0, 0, 360, white, -1, 8, 0 );
	        ellipse( img, Point(dx+185, dy+70), Size(15,15), 0, 0, 360, white, -1, 8, 0 );
	        ellipse( img, Point(dx+115, dy+70), Size(5,5), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+185, dy+70), Size(5,5), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+150, dy+100), Size(10,5), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+150, dy+150), Size(40,10), 0, 0, 360, black, -1, 8, 0 );
	        ellipse( img, Point(dx+27, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
	        ellipse( img, Point(dx+273, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
	    }
	    //show the faces
	    namedWindow( "image", 1 );
	    imshow( "image", img );
	    //Extract the contours so that
	    vector<vector<Point> > contours0;
	    findContours( img, contours0, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
	
	    contours.resize(contours0.size());
	    for( size_t k = 0; k < contours0.size(); k++ )
	        approxPolyDP(Mat(contours0[k]), contours[k], 3, true);
	
	    namedWindow( "contours", 1 );
	    createTrackbar( "levels+3", "contours", &levels, 7, on_trackbar );
	
	    on_trackbar(0,0);
	    waitKey();
	
	    return 0;
	}
Ejemplo n.º 3
0
int main(int argc, char** argv)
{
	const char* filename;

	if(argc >= 2)
		filename = argv[1];
	else
		filename = "image.jpg";

	image_src = cv::imread(filename);

	if(image_src.empty())
	{
	 std::cout << "ERROR: Cannot open " << filename << std::endl;
	 return -1;
	}

	on_trackbar(0, (void *)0);
	slider = 0;

	cv::createTrackbar("Hough Threshold = Position + 20", "Display Image", &slider, slider_max, on_trackbar);
	while(char(cv::waitKey(1)) != 'q'){}

	return 0;
}
Ejemplo n.º 4
0
	int connected_components( int argc, const char** argv )
	{
	    CommandLineParser parser(argc, argv, keys);
	    if (parser.has("help"))
	    {
	        help();
	        return 0;
	    }
	    string inputImage = parser.get<string>(0);
	    img = imread(inputImage.c_str(), 0);
	
	    if(img.empty())
	    {
	        cout << "Could not read input image file: " << inputImage << endl;
	        return -1;
	    }
	
	    namedWindow( "Image", 1 );
	    imshow( "Image", img );
	
	    namedWindow( "Connected Components", 1 );
	    createTrackbar( "Threshold", "Connected Components", &threshval, 255, on_trackbar );
	    on_trackbar(threshval, 0);
	
	    waitKey(0);
	    return 0;
	}
int main( int argc, char** argv )
{
    int i, j;
    CvMemStorage* storage = cvCreateMemStorage(0);
    IplImage* img = cvCreateImage( cvSize(w,w), 8, 1 );

    cvZero( img );

    for( i=0; i < 6; i++ )
    {
        int dx = (i%2)*250 - 30;
        int dy = (i/2)*150;
        CvScalar white = cvRealScalar(255);
        CvScalar black = cvRealScalar(0);

        if( i == 0 )
        {
            for( j = 0; j <= 10; j++ )
            {
                double angle = (j+5)*CV_PI/21;
                cvLine(img, cvPoint(cvRound(dx+100+j*10-80*cos(angle)),
                    cvRound(dy+100-90*sin(angle))),
                    cvPoint(cvRound(dx+100+j*10-30*cos(angle)),
                    cvRound(dy+100-30*sin(angle))), white, 1, 8, 0);
            }
        }

        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(100,70), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(10,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+150, dy+150), cvSize(40,10), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+27, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+273, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
    }

    cvNamedWindow( "image", 1 );
    cvShowImage( "image", img );

    cvFindContours( img, storage, &contours, sizeof(CvContour),
                    CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );

    // comment this out if you do not want approximation
    contours = cvApproxPoly( contours, sizeof(CvContour), storage, CV_POLY_APPROX_DP, 3, 1 );

    cvNamedWindow( "contours", 1 );
    cvCreateTrackbar( "levels+3", "contours", &levels, 7, on_trackbar );
    
    on_trackbar(0);
    cvWaitKey(0);
    cvReleaseMemStorage( &storage );
    cvReleaseImage( &img );

    return 0;
}
Ejemplo n.º 6
0
int main(int argc, _TCHAR* argv[])
{
	
	g_image = cvLoadImage( "airplane.jpg" );
	cvNamedWindow( "Contours", 1 );
	cvCreateTrackbar( "Threshold", "Contours", &g_thresh, 255, on_trackbar );
	on_trackbar(0);
	cvWaitKey();

	return 0;
}
Ejemplo n.º 7
0
 /**
  *  @brief          Capture the next frame and reset the trackbar
  *
  *  @return         Returns false if no frame are available
  *
  */
 bool nextFrame(){
   Mat frame;
   Mat featvector;
   if (capture->nextFrame(frame)){
     currframe.release();
     frame.copyTo(currframe);
     on_trackbar(0, this);
     return true;
   } else{
     return false;
   }
 }
Ejemplo n.º 8
0
int main( int argc, char** argv )
{
  if( argc != 2 || !(g_image = cvLoadImage(argv[1])) ){
  printf("\nExample 8_2 Contour retreival using trackbar\nCall is:\n./ch8_ex8_2 image\n");
  return -1;}
  cvNamedWindow( "Contours", 1 );
  cvCreateTrackbar( 
    "Threshold", 
    "Contours", 
    &g_thresh, 
    255, 
    on_trackbar
  );
  on_trackbar(0);
  cvWaitKey();
  return 0; 
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
	img = cv::imread(argv[1]);
	cv::Mat img_b;
	cvtColor(img, img_b, CV_RGB2GRAY);

	cv::Mat edges;
	Canny(img_b, edges, 50, 100);

	// extract contours and heirarchy
	cv::findContours(edges, contours, heirarchy, CV_RETR_TREE, CV_CHAIN_APPROX_NONE);

	cv::namedWindow("Contours");
	cv::createTrackbar("levels", "Contours", &levels, 15, on_trackbar);

	// Initialize by drawing the top level contours (as levels is initialized to 0)
	on_trackbar(0, 0);

	while( char(cv::waitKey(1)) != 'q') {}

	return 0;
}
Ejemplo n.º 10
0
int main( int argc, char** argv )
{

	param1 = 100;
	param2 = 2000;
	
	// open input image
	original = cvLoadImage("pic6.png",0);

	cvNamedWindow("input");
	cvShowImage("input", original );
	
	cvNamedWindow(wndname, 0);
    cvCreateTrackbar( tbarname1, wndname, &param1, 255, on_trackbar );
	cvCreateTrackbar( tbarname2, wndname, &param2, 30000, on_trackbar );
	
	// Call to update the view
	for(;;)
    {
        int c;
        
        // Call to update the view
        on_trackbar(0);

        c = cvWaitKey(0);

	   if( c == 27 )
            break;
	}
    
    cvReleaseImage( &original );
	cvReleaseImage( &originalThr );
	cvReleaseImage( &displayedImage );
    
    cvDestroyWindow( wndname );
    
    return 0;
}
Ejemplo n.º 11
0
int find_rectangle(IplImage  * & g_image) { 
	int i, c;  
	// create memory storage that will contain all the dynamic data  
	storage = cvCreateMemStorage(0); 
		// load i-th image 
		img0 = g_image; 
		img = cvCloneImage( img0 ); 
		// create window and a trackbar (slider) with parent "image" and set callback 
		// (the slider regulates upper threshold, passed to Canny edge detector)  
		cvNamedWindow( wndname, 1 ); 
		cvCreateTrackbar( "canny thresh", wndname, &thresh, 1000, on_trackbar );
		// force the image processing  
		on_trackbar(0);  
		// wait for key. 
		// Also the function cvWaitKey takes care of event processing  
		c = cvWaitKey(0);  
		// release both images  
		cvReleaseImage( &img );
		cvReleaseImage( &img0 );
		// clear memory storage - reset free space position  
		cvClearMemStorage( storage ); 
	cvDestroyWindow( wndname ); 
	return 0;
} 
Ejemplo n.º 12
0
int main( int argc, char** argv )
{
    char* filename = argc == 2 ? argv[1] : (char*)"stuff.jpg";

    if( (gray = cvLoadImage( filename, 0 )) == 0 )
        return -1;

    printf( "Hot keys: \n"
        "\tESC - quit the program\n"
        "\tC - use C/Inf metric\n"
        "\tL1 - use L1 metric\n"
        "\tL2 - use L2 metric\n"
        "\t3 - use 3x3 mask\n"
        "\t5 - use 5x5 mask\n"
        "\t0 - use precise distance transform\n"
        "\tv - switch Voronoi diagram mode on/off\n"
        "\tENTER - loop through all the modes\n" );

    dist = cvCreateImage( cvGetSize(gray), IPL_DEPTH_32F, 1 );
    dist8u1 = cvCloneImage( gray );
    dist8u2 = cvCloneImage( gray );
    dist8u = cvCreateImage( cvGetSize(gray), IPL_DEPTH_8U, 3 );
    dist32s = cvCreateImage( cvGetSize(gray), IPL_DEPTH_32S, 1 );
    edge = cvCloneImage( gray );
    labels = cvCreateImage( cvGetSize(gray), IPL_DEPTH_32S, 1 );

    cvNamedWindow( wndname, 1 );

    cvCreateTrackbar( tbarname, wndname, &edge_thresh, 255, on_trackbar );

    for(;;)
    {
        int c;
        
        // Call to update the view
        on_trackbar(0);

        c = cvWaitKey(0);

        if( (char)c == 27 )
            break;

        if( (char)c == 'c' || (char)c == 'C' )
            dist_type = CV_DIST_C;
        else if( (char)c == '1' )
            dist_type = CV_DIST_L1;
        else if( (char)c == '2' )
            dist_type = CV_DIST_L2;
        else if( (char)c == '3' )
            mask_size = CV_DIST_MASK_3;
        else if( (char)c == '5' )
            mask_size = CV_DIST_MASK_5;
        else if( (char)c == '0' )
            mask_size = CV_DIST_MASK_PRECISE;
        else if( (char)c == 'v' )
            build_voronoi ^= 1;
        else if( (char)c == '\n' || (char)c == '\r' )
        {
            if( build_voronoi )
            {
                build_voronoi = 0;
                mask_size = CV_DIST_MASK_3;
                dist_type = CV_DIST_C;
            }
            else if( dist_type == CV_DIST_C )
                dist_type = CV_DIST_L1;
            else if( dist_type == CV_DIST_L1 )
                dist_type = CV_DIST_L2;
            else if( mask_size == CV_DIST_MASK_3 )
                mask_size = CV_DIST_MASK_5;
            else if( mask_size == CV_DIST_MASK_5 )
                mask_size = CV_DIST_MASK_PRECISE;
            else if( mask_size == CV_DIST_MASK_PRECISE )
                build_voronoi = 1;
        }
    }

    cvReleaseImage( &gray );
    cvReleaseImage( &edge );
    cvReleaseImage( &dist );
    cvReleaseImage( &dist8u );
    cvReleaseImage( &dist8u1 );
    cvReleaseImage( &dist8u2 );
    cvReleaseImage( &dist32s );
    cvReleaseImage( &labels );
    
    cvDestroyWindow( wndname );
    
    return 0;
}
Ejemplo n.º 13
0
int main(int argc, char* argv[])
{
    int i, j;
    CvMemStorage* storage = cvCreateMemStorage(0);
    IplImage* img = cvCreateImage( cvSize(w,w), 8, 1 );
    IplImage* img32f = cvCreateImage( cvSize(w,w), IPL_DEPTH_32F, 1 );
    IplImage* img32s = cvCreateImage( cvSize(w,w), IPL_DEPTH_32S, 1 );
    IplImage* img3 = cvCreateImage( cvSize(w,w), 8, 3 );
    (void)argc; (void)argv;

    help();
    cvZero( img );

    for( i=0; i < 6; i++ )
    {
        int dx = (i%2)*250 - 30;
        int dy = (i/2)*150;
        CvScalar white = cvRealScalar(255);
        CvScalar black = cvRealScalar(0);

        if( i == 0 )
        {
            for( j = 0; j <= 10; j++ )
            {
                double angle = (j+5)*CV_PI/21;
                cvLine(img, cvPoint(cvRound(dx+100+j*10-80*cos(angle)),
                    cvRound(dy+100-90*sin(angle))),
                    cvPoint(cvRound(dx+100+j*10-30*cos(angle)),
                    cvRound(dy+100-30*sin(angle))), white, 3, 8, 0);
            }
        }

        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(100,70), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(10,5), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+150, dy+150), cvSize(40,10), 0, 0, 360, black, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+27, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
        cvEllipse( img, cvPoint(dx+273, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
    }

    cvNamedWindow( "image", 1 );
    cvShowImage( "image", img );
    cvConvert( img, img32f );
    findCComp( img32f );
    cvConvert( img32f, img32s );

    cvFindContours( img32s, storage, &contours, sizeof(CvContour),
                    CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );

    //cvFindContours( img, storage, &contours, sizeof(CvContour),
    //                CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );


    {
    const char* attrs[] = {"recursive", "1", 0};
    cvSave("contours.xml", contours, 0, 0, cvAttrList(attrs, 0));
    contours = (CvSeq*)cvLoad("contours.xml", storage, 0, 0);
    }

    // comment this out if you do not want approximation
    contours = cvApproxPoly( contours, sizeof(CvContour), storage, CV_POLY_APPROX_DP, 3, 1 );

    cvNamedWindow( "contours", 1 );
    cvCreateTrackbar( "levels+3", "contours", &levels, 7, on_trackbar );

    {
        CvRNG rng = cvRNG(-1);

        CvSeq* tcontours = contours;
        cvCvtColor( img, img3, CV_GRAY2BGR );
        while( tcontours->h_next )
            tcontours = tcontours->h_next;

        for( ; tcontours != 0; tcontours = tcontours->h_prev )
        {
            CvScalar color;
            color.val[0] = cvRandInt(&rng) % 256;
            color.val[1] = cvRandInt(&rng) % 256;
            color.val[2] = cvRandInt(&rng) % 256;
            color.val[3] = cvRandInt(&rng) % 256;
            cvDrawContours(img3, tcontours, color, color, 0, -1, 8, cvPoint(0,0));
            if( tcontours->v_next )
            {
                color.val[0] = cvRandInt(&rng) % 256;
                color.val[1] = cvRandInt(&rng) % 256;
                color.val[2] = cvRandInt(&rng) % 256;
                color.val[3] = cvRandInt(&rng) % 256;
                cvDrawContours(img3, tcontours->v_next, color, color, 1, -1, 8, cvPoint(0,0));
            }
        }

    }

    cvShowImage( "colored", img3 );
    on_trackbar(0);
    cvWaitKey(0);
    cvReleaseMemStorage( &storage );
    cvReleaseImage( &img );
    cvReleaseImage( &img32f );
    cvReleaseImage( &img32s );
    cvReleaseImage( &img3 );

    return 0;
}
Ejemplo n.º 14
0
int main(int argc, char **argv)
{
	if (argc != 3)
	{
		help();
		return 0;
	}

	char *image1name = argv[1];
	char *image2name = argv[2];

	//create two windows
	cvNamedWindow(WINDOW1NAME, CV_WINDOW_NORMAL);
	cvNamedWindow(WINDOW2NAME, CV_WINDOW_NORMAL);

	//read two images with gray 
	pGrayImage1 = cvLoadImage(image1name, CV_LOAD_IMAGE_GRAYSCALE);
	pGrayImage2 = cvLoadImage(image2name, CV_LOAD_IMAGE_GRAYSCALE);

	//show two gray images
	cvShowImage(WINDOW1NAME, pGrayImage1);
	cvShowImage(WINDOW2NAME, pGrayImage2);

	cvWaitKey(0);

	//show image1 and with a track slider
	cvNamedWindow(WINDOW1BINARYNAME, CV_WINDOW_NORMAL);
	cvNamedWindow(WINDOW2BINARYNAME, CV_WINDOW_NORMAL);
	pBinaryImage1 = cvCreateImage(cvGetSize(pGrayImage1), IPL_DEPTH_8U, 1);
	pBinaryImage2 = cvCreateImage(cvGetSize(pGrayImage2), IPL_DEPTH_8U, 1);
	int threshold = 0;
	cvCreateTrackbar(TRACKNAME, WINDOW1BINARYNAME, &threshold, 254, on_trackbar);
	on_trackbar(1);
	
	int c = cvWaitKey(0);
	printf("%c, %d, %x, %x, %x, %x\n", c, c, c, 'a', 'o', 'x');
	IplImage * pImageXor = cvCreateImage(cvGetSize(pGrayImage1), IPL_DEPTH_8U, 1);
	if (c == 0x100078) {
		cvXor(pBinaryImage1, pBinaryImage2, pImageXor, NULL);
		cvNamedWindow(WINDOWXORNAME, CV_WINDOW_NORMAL);
		cvShowImage(WINDOWXORNAME, pImageXor);
	} else if (c == 0x100061) {
		cvAnd(pBinaryImage1, pBinaryImage2, pImageXor, NULL);
		cvNamedWindow(WINDOWANDNAME, CV_WINDOW_NORMAL);
		cvShowImage(WINDOWANDNAME, pImageXor);
	} else if (c == 0x10006f) {
		cvOr(pBinaryImage1, pBinaryImage2, pImageXor, NULL);
		cvNamedWindow(WINDOWORNAME, CV_WINDOW_NORMAL);
		cvShowImage(WINDOWORNAME, pImageXor);
	} else {
		goto err_input;
	}

	int s = cvWaitKey(0);
	char* filename = NULL;
	if (s == 0x100073) {
		if (c == 0x100078) {
			filename = "xor.jpg";
		} else if (c == 0x10006f) {
			filename = "or.jpg";
		} else if (c == 0x100061) {
			filename = "and.jpg";
		}
		cvSaveImage(filename, pImageXor, 0);
	}

	//xor two images
	/*cvOr(pGrayImage1, pGrayImage2, pImageXor, NULL);
	cvNamedWindow("xor", CV_WINDOW_NORMAL);
	cvShowImage("xor", pImageXor);
	cvWaitKey(0);
	cvReleaseImage(&pImageXor);
	cvDestroyWindow("xor");*/

err_input:
	cvReleaseImage(&pImageXor);
	cvReleaseImage(&pGrayImage1);
	cvReleaseImage(&pGrayImage2);
	cvReleaseImage(&pBinaryImage1);
	cvReleaseImage(&pBinaryImage2);
	cvDestroyWindow(WINDOW1NAME);
	cvDestroyWindow(WINDOW2NAME);
	cvDestroyWindow(WINDOW1BINARYNAME);
	cvDestroyWindow(WINDOW2BINARYNAME);
	return 0;
}
Ejemplo n.º 15
0
int main(int argc, char** argv){
	// Set up variables
	

	//set the camera capture
	capture = cvCaptureFromCAM(0);

	// create a new window with auto sizing
	cvNamedWindow(window_name, 1);

	// create a window
	//cvNamedWindow("HSV Window", CV_WINDOW_AUTOSIZE); 

	// create a window
	//cvNamedWindow("Grey Window", CV_WINDOW_AUTOSIZE);

	// create a window
	cvNamedWindow("Target", CV_WINDOW_AUTOSIZE);  
	cvNamedWindow("Target2", CV_WINDOW_AUTOSIZE);  
	cvNamedWindow("Before", CV_WINDOW_AUTOSIZE); 
	cvNamedWindow("First", CV_WINDOW_AUTOSIZE); 
	cvNamedWindow("Second", CV_WINDOW_AUTOSIZE); 
	cvNamedWindow("Before2", CV_WINDOW_AUTOSIZE); 
	cvNamedWindow("Third", CV_WINDOW_AUTOSIZE); 

	while(quit != 'q'){

		//grab frame from webcam
		g_image = cvQueryFrame(capture);

		// display frame
		cvShowImage(window_name,g_image);

		on_trackbar(0);

		//cvShowImage("HSV Window", g_gray );

		//cvShowImage("Grey Window", g_grey );

		somethingNew();

		cvShowImage("Target", g_grey );
		cvShowImage("Target2", g_gray );

		/*something();

		cvShowImage("blobOut", g_grey );*/

		/*printf("Thresh is %d\n",new_thresh++);
	
		if(new_thresh == 255){
			new_thresh = 0;
		}*/

		//check for q to quit
		quit = cvWaitKey(1);

		// delay for a moment, delay is under 2 it doesn't seem to work
		cvWaitKey(DELAY);

	}

	// before quitting it releases memory
	cvReleaseCapture(&capture);
	cvDestroyWindow(window_name);

	return 0;
}