I’m new to programming. I want to make an image processing program. My problem is I want my program to send me text message (AT COMMAND) if something passes in front of my camera.
Here’s the code:
for( ; contour != 0; contour = contour->h_next )
{
Sleep(10000);
char buf[20];
DWORD read = 0;
DWORD CommModemStatus;
DWORD write=1; // Number of bytes to write to serial port
buf[0] = 72; // Decimal value to write to serial port
char valor4[26] = ("at+cmgf=1\r");
BOOL bWriteRC4;
static DWORD iBytesWritten4;
bWriteRC4 = WriteFile(hPort, &valor4, 100, &iBytesWritten4,NULL);
char valor[26] = ("at+cmgs=\"+62xxxxxxxxxx\"\r");
BOOL bWriteRC;
static DWORD iBytesWritten;
bWriteRC = WriteFile(hPort, &valor, 100, &iBytesWritten,NULL);
char valor2[17] = ("SOMEONE HAS ENTERED YOU ROOM!!!");
BOOL bWriteRC2;
static DWORD iBytesWritten2;
bWriteRC2 = WriteFile(hPort, &valor2, 100, &iBytesWritten2,NULL);
char valor3 = (char)0x1A;
BOOL bWriteRC3;
static DWORD iBytesWritten3;
bWriteRC3 = WriteFile(hPort, &valor3, 100, &iBytesWritten3,NULL);
}
If something passes in front of my camera and the movement is captured, that’s mean
contour != 0, so I think it’s just like:
for (contour != 0)
//sending text message....
but apparently when turned on, the camera will adapt to the intensity of light, so I give Sleep(10000); in meant to wait the camera 10 second before text sent. In fact it only made my camera (and the rest of program) waiting for 10 seconds to turn on.
Is there any different way to wait without pausing the program?
I’m already Google it, try something like system("pause"), etc, it doesn’t work.
I’m using Visual Studio 2010 in windows.
You could try something like
The clock() function in time.h returns the number of clock ticks since the program has started. A clock tick is not necessarily a millisecond, so dividing by the macro constant expression CLOCKS_PER_SEC, which specifies the relation between a clock tick and a second, will get you the total number of seconds that have elapsed.
You can get more information about clock() here: http://www.cplusplus.com/reference/clibrary/ctime/clock/