Ask Your Question

cms's profile - activity

2013-01-15 02:06:05 -0500 commented answer Message Box will closed automatically

Sorry ! What do you mean ? Because i'm a beginner for this . And through online researching , i know messagebox can create pop out and thats what i want. But now, i want it to close automatically once the webcam can detect the circle as it is in the beginning .

2013-01-15 01:15:18 -0500 asked a question Message Box will closed automatically

Hi everyone ! i'm using opencv and visual studio 2010 for my codes . I have wrote some codes to allow the messagebox to pop out after 200 counts when the circles is not detected . But instead of waiting the users to click on the "OK" button to close the pop out message box , i want to program the codes in such a way that the message box will be closed automatically when it sense that the circle is being detected again. Can anyone help me with it . Thanks in advance. This is my message box codes

if ( i == 2)//delay reset if all 2 circle are detected
             delay = 0;
         //printf("check = %d\n", check); //to get the current check count
         if ( i < 2 && check > 50 )//condition for when no circle is detected,<== [ALERT ROUTINE]
             delay ++;
             printf ("delay = %d\n", delay); //to get the current delay count.
             if( delay > 200) // after 200 counts the system confirms that there is no circle.
                 printf(" Remove object\n ");//to test the camera;as long as this printf function runs the message box will reopen on closing.
                 MessageBox (NULL, L" Remove Object! " , L"Warning" , MB_ICONWARNING | MB_OK ); //Message box code

2013-01-02 01:26:45 -0500 received badge  Editor (source)
2013-01-02 01:25:37 -0500 asked a question expand the perimeter of a circle

Hi everyone ! I'm using opencv 2.4.2 and visual studio 2010 software for my program. The code is used to program a USB webcam to detect the cooking stoves (circle). Although the edge detection is not stable (keep blinking), but it managed to draw a green line (detection) when i point my webcam onto the screen (where's the picture of the stove is).picture of the stove . My question is how do i extend the detection of the perimeter of the stove ? I have to extend the circle detection of the last layer of the stove outward.

> #include "stdafx.h"

#include <stdio.h>
#include <cv.h>
#include <ml.h>
#include <cxcore.h>
#include <highgui.h>
#include <math.h>

int main(int argc, char* argv[])
    CvCapture *capture = 0;
    IplImage *img = 0;
    int key = 0;
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_PLAIN,1.0,1.0,0,1,CV_AA);

capture = cvCaptureFromCAM(0);

if (!capture) 
    fprintf(stderr, "Cannot open initialize webcam!\n");
    return 1;

//create a wondow in which the captured images will be presented
cvNamedWindow("result", CV_WINDOW_AUTOSIZE);

img = cvQueryFrame(capture); 
IplImage *gray = cvCreateImage(cvGetSize(img), 8,1);
CvMemStorage* storage = cvCreateMemStorage(0);

while(key != 'q') {
    img = cvQueryFrame(capture);
    if(!img) break;

    cvCvtColor(img, gray, CV_BGR2GRAY);
    cvSmooth( gray, gray, CV_GAUSSIAN, 9, 9 );
    CvSeq* circles = cvHoughCircles( gray, storage, CV_HOUGH_GRADIENT, 1, gray->height/8, 200, 100, 0, 0 );
     int i;
     for( i = 0; i < circles->total; i++ )
             float* p = (float*)cvGetSeqElem( circles, i );
             cvCircle( img, cvPoint(cvRound(p[0]),cvRound(p[1])), cvRound(p[2]), CV_RGB(0,255,0), 2, 8, 0 );
             cvLine (img, cvPoint(cvRound(p[0]+40),cvRound(p[1])), cvPoint(cvRound(p[0]),cvRound(p[1])), CV_RGB(0,255,0), 1, CV_AA,0);
             cvLine (img, cvPoint(cvRound(p[0]),cvRound(p[1]+40)), cvPoint(cvRound(p[0]),cvRound(p[1])), CV_RGB(0,255,0), 1, CV_AA,0);
             cvLine (img, cvPoint(cvRound(p[0]-40),cvRound(p[1])), cvPoint(cvRound(p[0]),cvRound(p[1])), CV_RGB(0,255,0), 1, CV_AA,0);
             cvLine (img, cvPoint(cvRound(p[0]),cvRound(p[1]-40)), cvPoint(cvRound(p[0]),cvRound(p[1])), CV_RGB(0,255,0), 1, CV_AA,0);
             cvPutText(img, "Safe",cvPoint(cvRound(p[0]+45),cvRound(p[1]+45)), &font, CV_RGB(0,0,255));
      cvShowImage( "result", img ); 
      key = cvWaitKey( 10 );
      if(key == 27) break;  

//release the device capture housekeeping
cvReleaseCapture( &capture ); 
cvDestroyWindow( "result" ); 
return 0;