Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondata structure Pin
kkchando25-Mar-09 21:30
kkchando25-Mar-09 21:30 
AnswerRe: data structure Pin
Garth J Lancaster25-Mar-09 23:57
professionalGarth J Lancaster25-Mar-09 23:57 
Questionc++ Pin
kkchando25-Mar-09 21:28
kkchando25-Mar-09 21:28 
AnswerRe: c++ Pin
Chandrasekharan P25-Mar-09 21:34
Chandrasekharan P25-Mar-09 21:34 
AnswerRe: c++ Pin
CPallini25-Mar-09 23:22
mveCPallini25-Mar-09 23:22 
QuestionVideo recording and write to .avi file Pin
tns_ranjith25-Mar-09 21:15
tns_ranjith25-Mar-09 21:15 
AnswerRe: Video recording and write to .avi file Pin
«_Superman_»25-Mar-09 21:24
professional«_Superman_»25-Mar-09 21:24 
QuestionWho know meanshift algorithmic used in track? Pin
onlybluemoon25-Mar-09 20:41
onlybluemoon25-Mar-09 20:41 
We know cvcamshift.cpp in cv.lib of opencv .Do you understand the program's algorithmic about it's Orientation and Scale Calculation.I don't konw how it work.
I show the file cvcamshift.cpp
<br />
/*F///////////////////////////////////////////////////////////////////////////////////////<br />
//    Name:    cvCamShift<br />
//    Purpose: CAMSHIFT algorithm<br />
//    Context:<br />
//    Parameters:<br />
//      imgProb     - 2D object probability distribution<br />
//      windowIn    - CvRect of CAMSHIFT Window intial size<br />
//      criteria    - criteria of stop finding window<br />
//      windowOut   - Location, height and width of converged CAMSHIFT window<br />
//      orientation - If != NULL, return distribution orientation<br />
//      len         - If != NULL, return equivalent len<br />
//      width       - If != NULL, return equivalent width<br />
//      area        - sum of all elements in result window<br />
//      itersUsed   - Returns number of iterations CAMSHIFT took to converge<br />
//    Returns:<br />
//      The function itself returns the area found<br />
//    Notes:<br />
//F*/<br />
CV_IMPL int<br />
cvCamShift( const void* imgProb, CvRect windowIn,<br />
            CvTermCriteria criteria,<br />
            CvConnectedComp* _comp,<br />
            CvBox2D* box )<br />
{<br />
    const int TOLERANCE = 10;<br />
    CvMoments moments;<br />
    double m00 = 0, m10, m01, mu20, mu11, mu02, inv_m00;<br />
    double a, b, c, xc, yc;<br />
    double rotate_a, rotate_c;<br />
    double theta = 0, square;<br />
    double cs, sn;<br />
    double length = 0, width = 0;<br />
    int itersUsed = 0;<br />
    CvConnectedComp comp;<br />
    CvMat  cur_win, stub, *mat = (CvMat*)imgProb;<br />
<br />
    CV_FUNCNAME( "cvCamShift" );<br />
<br />
    comp.rect = windowIn;<br />
<br />
    __BEGIN__;<br />
<br />
    CV_CALL( mat = cvGetMat( mat, &stub ));<br />
<br />
    CV_CALL( itersUsed = cvMeanShift( mat, windowIn, criteria, &comp ));<br />
    windowIn = comp.rect;<br />
<br />
    windowIn.x -= TOLERANCE;<br />
    if( windowIn.x < 0 )<br />
        windowIn.x = 0;<br />
<br />
    windowIn.y -= TOLERANCE;<br />
    if( windowIn.y < 0 )<br />
        windowIn.y = 0;<br />
<br />
    windowIn.width += 2 * TOLERANCE;<br />
    if( windowIn.x + windowIn.width > mat->width )<br />
        windowIn.width = mat->width - windowIn.x;<br />
<br />
    windowIn.height += 2 * TOLERANCE;<br />
    if( windowIn.y + windowIn.height > mat->height )<br />
        windowIn.height = mat->height - windowIn.y;<br />
<br />
    CV_CALL( cvGetSubRect( mat, &cur_win, windowIn ));<br />
<br />
    /* Calculating moments in new center mass */<br />
    <big>CV_CALL( cvMoments( &cur_win, &moments ));//the follow is what i can't understand<br />
<br />
    m00 = moments.m00;<br />
    m10 = moments.m10;<br />
    m01 = moments.m01;<br />
    mu11 = moments.mu11;<br />
    mu20 = moments.mu20;<br />
    mu02 = moments.mu02;<br />
<br />
    if( fabs(m00) < DBL_EPSILON )<br />
        EXIT;<br />
<br />
    inv_m00 = 1. / m00;<br />
    xc = cvRound( m10 * inv_m00 + windowIn.x );<br />
    yc = cvRound( m01 * inv_m00 + windowIn.y );<br />
    a = mu20 * inv_m00;//(x-x的中心)的平方*概率/总概率<br />
    b = mu11 * inv_m00;//(x-x的中心)(y-y的中心)*概率/总概率<br />
    c = mu02 * inv_m00;//(y-y的中心)的平方*概率/总概率<br />
<br />
    /* Calculating width & height */<br />
    square = sqrt( 4 * b * b + (a - c) * (a - c) );<br />
<br />
    /* Calculating orientation */<br />
    theta = atan2( 2 * b, a - c + square );<br />
<br />
	<br />
<br />
    /* Calculating width & length of figure */<br />
    cs = cos( theta );<br />
    sn = sin( theta );<br />
<br />
    rotate_a = cs * cs * mu20 + 2 * cs * sn * mu11 + sn * sn * mu02;<br />
    rotate_c = sn * sn * mu20 - 2 * cs * sn * mu11 + cs * cs * mu02;<br />
    length = sqrt( rotate_a * inv_m00 ) * 4;<br />
    width = sqrt( rotate_c * inv_m00 ) * 4;<br />
<br />
    /* In case, when tetta is 0 or 1.57... the Length & Width may be exchanged */<br />
    if( length < width )<br />
    {<br />
        double t;<br />
        <br />
        CV_SWAP( length, width, t );<br />
        CV_SWAP( cs, sn, t );<br />
        theta = CV_PI*0.5 - theta;<br />
    }<br />
<br />
    /* Saving results */<br />
    if( _comp || box )<br />
    {<br />
        int t0, t1;<br />
        int _xc = cvRound( xc );<br />
        int _yc = cvRound( yc );<br />
<br />
        t0 = cvRound( fabs( length * cs ));<br />
        t1 = cvRound( fabs( width * sn ));<br />
<br />
        t0 = MAX( t0, t1 ) + 2;<br />
        comp.rect.width = MIN( t0, (mat->width - _xc) * 2 );<br />
<br />
        t0 = cvRound( fabs( length * sn ));<br />
        t1 = cvRound( fabs( width * cs ));<br />
<br />
        t0 = MAX( t0, t1 ) + 2;<br />
        comp.rect.height = MIN( t0, (mat->height - _yc) * 2 );<br />
<br />
        comp.rect.x = MAX( 0, _xc - comp.rect.width / 2 );<br />
        comp.rect.y = MAX( 0, _yc - comp.rect.height / 2 );<br />
<br />
        comp.rect.width = MIN( mat->width - comp.rect.x, comp.rect.width );<br />
        comp.rect.height = MIN( mat->height - comp.rect.y, comp.rect.height );<br />
        comp.area = (float) m00;<br />
    }</big><br />
<br />
    __END__;<br />
<br />
    if( _comp )<br />
        *_comp = comp;<br />
    <br />
    if( box )<br />
    {<br />
        box->size.height = (float)length;<br />
        box->size.width = (float)width;<br />
        box->angle = (float)(theta*180./CV_PI);<br />
        box->center = cvPoint2D32f( comp.rect.x + comp.rect.width*0.5f,<br />
                                    comp.rect.y + comp.rect.height*0.5f);<br />
    }<br />
<br />
    return itersUsed;<br />
}<br />
<br />
/* End of file. */<br />


Thank you everybody.I am looking forward to you answer .

hello

AnswerRe: Who know meanshift algorithmic used in track? Pin
onlybluemoon26-Mar-09 1:03
onlybluemoon26-Mar-09 1:03 
Questionfread() returning zero Pin
hemlat25-Mar-09 20:14
hemlat25-Mar-09 20:14 
AnswerRe: fread() returning zero Pin
«_Superman_»25-Mar-09 21:18
professional«_Superman_»25-Mar-09 21:18 
QuestionParent class constructor Pin
chotti3500725-Mar-09 20:06
chotti3500725-Mar-09 20:06 
AnswerRe: Parent class constructor Pin
S p k 52125-Mar-09 20:35
S p k 52125-Mar-09 20:35 
AnswerRe: Parent class constructor Pin
«_Superman_»25-Mar-09 21:19
professional«_Superman_»25-Mar-09 21:19 
QuestionC++ Child class access Pin
chotti3500725-Mar-09 19:42
chotti3500725-Mar-09 19:42 
AnswerRe: C++ Child class access Pin
«_Superman_»25-Mar-09 19:49
professional«_Superman_»25-Mar-09 19:49 
GeneralRe: C++ Child class access Pin
chotti3500725-Mar-09 19:53
chotti3500725-Mar-09 19:53 
GeneralRe: C++ Child class access Pin
«_Superman_»25-Mar-09 19:54
professional«_Superman_»25-Mar-09 19:54 
GeneralRe: C++ Child class access Pin
chotti3500725-Mar-09 19:58
chotti3500725-Mar-09 19:58 
GeneralRe: C++ Child class access Pin
Cedric Moonen25-Mar-09 21:20
Cedric Moonen25-Mar-09 21:20 
GeneralRe: C++ Child class access Pin
«_Superman_»25-Mar-09 21:23
professional«_Superman_»25-Mar-09 21:23 
Question[Message Deleted] Pin
Purish Dwivedi25-Mar-09 19:21
Purish Dwivedi25-Mar-09 19:21 
AnswerRe: Detecting installed language pack through installshield for MFC application Pin
Cedric Moonen25-Mar-09 21:18
Cedric Moonen25-Mar-09 21:18 
General[Message Deleted] Pin
Purish Dwivedi25-Mar-09 23:28
Purish Dwivedi25-Mar-09 23:28 
GeneralRe: Detecting installed language pack through installshield for MFC application Pin
Cedric Moonen25-Mar-09 23:33
Cedric Moonen25-Mar-09 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.