hello evryone, im new in C++ programing.
currently i working on my final year project. at the first place, im study in INFO COMM. ,more specific in network management area but since my project is assigned by my lecturer and the project itself involved some programming skill, i gt to study in c++.
i has been learnt c++ basic function. my project is some sort of speech recognition system which integrated with vision part, and im currently working in this vision part too.
the vision involved the OPENCV source file in order for human face tracking.
i gt a open source code from opencvsite suit my project requirment, and i had try very hard to understand what is the function of each part.
i able to track a human face, and printf "sucessful" msg for each successful detection, and sofore the "failure" msg for when no detection, after this, send the result to another machine via tcp socket connection.
now my problem is , i have to write in a function to set a threshold for detection. mean, when detection successful, i would not send a msg (success/failure) immediately but wait for maybe 2secs, if there is still detection occurs/ no more detection, den send a final msg to another machine.
[ to summarize, the purpose is to send single result for all the detections within 2sec, such that can prevent the traffic being hoged by keep on sending result]
i had read thru many posts and also c++ cookbook guide , but i still cannot find my need. can anyone please give me some clue mayb what function can implement or other better suggestion way to get the same result i want ?
this is my current outcomes for testing result:
<tracking part> <result>
elapsed time 192ms detected //send "successful" to another host
elapsed time 176ms no object //send "successful" to another host
. . . //send " " to another host
. . . //send " l" to another host
elapsed time 176ms detected //send "successful" to another host
elapsed time 219ms detected //send "successful" to another host
my expected outcome
<tracking part> <result>
elapsed time 192ms detected // hold
elapsed time 176ms no object //hold
. . . //hold
. . . //hold
elapsed time 176ms detected //hold
elapsed time 219ms detected // finalise result ( successful>failure)
// send final result "succcessful" to another host
below is part of opencv source code involve tracking, can anyone point to me how to implement the above expexted function i need ? your opinion and guide i willbe greatly appreciated. thank you!
if( cascade )
{ double t = (double)cvGetTickCount();
CvSeq* faces = cvHaarDetectObjects( small_img, cascade, storage,
1.1, /*increase search scale by 10% each pass*/
6, /*drop group of fewer than 2 detection*/
0/*CV_HAAR_DO_CANNY_PRUNING*/,
cvSize(25, 15) );/*use xml default for smallest search scale*/
t = (double)cvGetTickCount() - t;
printf( "detection time = %gms\n", t/((double)cvGetTickFrequency()*1000.) );
for( i = 0; i < (faces ? faces->total : 0); i++ ) /* draw circle*/
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
CvPoint center;/*CvPoint is a structure which has just two members they store x coordinate and the y coordinate*/
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
printf("detection_successful\n");
/* print msg when object is detected*/
}
printf("no_object\n"); /* print msg2 when no object is detected */
}
//testing
//testing
cvShowImage( "result", img );
cvReleaseImage( &gray );
cvReleaseImage( &small_img );
}