static int CheckImage(IplImage* image, char* file, char* /*funcname*/) { //printf("loading %s\n", file ); IplImage* read = cvLoadImage( file, 1 ); if( !read ) { trsWrite( ATS_CON | ATS_LST, "can't read image\n" ); return 1; } int err = 0; #if 0 { IplImage* temp = cvCloneImage( read ); cvAbsDiff( image, read, temp ); cvThreshold( temp, temp, 0, 255, CV_THRESH_BINARY ); cvvNamedWindow( "Original", 0 ); cvvNamedWindow( "Diff", 0 ); cvvShowImage( "Original", read ); cvvShowImage( "Diff", temp ); cvvWaitKey(0); cvvDestroyWindow( "Original" ); cvvDestroyWindow( "Diff" ); } #endif cvAbsDiff( image, read, read ); cvThreshold( read, read, 0, 1, CV_THRESH_BINARY ); err = cvRound( cvNorm( read, 0, CV_L1 ))/3; cvReleaseImage( &read ); return err; }
bool CCapturador::tryCamera(int device) { if (!m_VideoCapture.isOpened()) // check if we succeeded m_VideoCapture = VideoCapture(device); if (!m_VideoCapture.isOpened()) return false; char key = 0; Mat frame; while (key==-1||key==0) { m_VideoCapture >> frame; if (!frame.empty()) imshow("Camara", frame); key = cvWaitKey(30); } cvvDestroyWindow("Camara"); }