<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OpenCV: cvPosit berechnet falsche Werte]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein Problem mit cvPosit().<br />
Ich möchte damit die Orientierung eines Gesichts berechnen. Dazu habe ich beispielhaft mal dieses Bild hier:<br />
<a href="http://s1.directupload.net/images/121005/en7u2vhf.jpg" rel="nofollow">http://s1.directupload.net/images/121005/en7u2vhf.jpg</a></p>
<p>Die 5 weißen Punkte sind meine KeyPoints, deren Pixelkoordinaten ich von außerhalb bekomme. Augen und Mundwinkel liegen in einer Ebene, die Nase liegt natürlich nicht in dieser. Somit sollte die Vorraussetzung für POSIT (4 nichtkomplanare Punkte) erfüllt sein.</p>
<p>Hier mein Code, der größtenteils aus dem <a href="http://opencv.willowgarage.com/wiki/Posit" rel="nofollow">POSIT-Tutorial</a> stammt:</p>
<pre><code class="language-cpp">int main()
    int depth = 40; //Nasenhoehe
    calculateHeadPosition(depth);
}

void HeadPosition::calculateHeadPosition(float depth)
{

//create the model points
std::vector&lt;CvPoint3D32f&gt; modelPoints;
modelPoints.push_back(cvPoint3D32f(  0.0f,   0.0f, 0.0f));  //Nose - (the first must be 0,0,0)
modelPoints.push_back(cvPoint3D32f(-52.0f, -58.0f, depth)); //left eye
modelPoints.push_back(cvPoint3D32f( 52.0f, -58.0f, depth)); //right eye
modelPoints.push_back(cvPoint3D32f(-43.0f,  60.0f, depth)); //left mouth corner
modelPoints.push_back(cvPoint3D32f( 43.0f,  60.0f, depth)); //right mouth corner

//create the image points 
std::vector&lt;CvPoint2D32f&gt; srcImagePoints;
srcImagePoints.push_back( cvPoint2D32f( 256, 256) ); //hier sind die Pixelwerte fest kodiert, normal
srcImagePoints.push_back( cvPoint2D32f( 205, 200) ); //bekomme ich sie, wie gesagt, übergeben
srcImagePoints.push_back( cvPoint2D32f( 306, 200) );
srcImagePoints.push_back( cvPoint2D32f( 216, 316) );
srcImagePoints.push_back( cvPoint2D32f( 296, 316) );

//create the POSIT object with the model points
CvPOSITObject* positObject = cvCreatePOSITObject( &amp;modelPoints[0], (int)modelPoints.size() );

//calculate the orientation
float* rotation_matrix = new float[9];
float* translation_vector = new float[3];
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 100, 1.0e-4f);
double FOCAL_LENGTH = 760.0;
cvPOSIT( positObject, &amp;srcImagePoints[0], FOCAL_LENGTH, criteria, rotation_matrix, translation_vector );

//calculate rotation angles
double beta  = atan2((double)(-rotation_matrix[2]), (double)(sqrt(pow(rotation_matrix[0], 2) + pow(rotation_matrix[3], 2))));
double alpha = atan2((rotation_matrix[3]/cos(beta)),(rotation_matrix[0]/cos(beta)));
double gamma = atan2((rotation_matrix[7]/cos(beta)),(rotation_matrix[8]/cos(beta)));

//conversion and prints
beta = beta * 180 / M_PI;
alpha = alpha * 180 / M_PI;
gamma = gamma * 180 / M_PI;
printf(&quot;beta:  %f\t&quot;, beta);
printf(&quot;alpha: %f\t&quot;, alpha);
printf(&quot;gamma: %f\n&quot;, gamma);
}
</code></pre>
<p>Da das Bild eine Frontalansicht des Gesichts zeigt erwarte ich für die Rotationswinkel (0, 0, 0), ich bekomme aber immer ca. (-16, -5, -18).<br />
Woran liegt das?</p>
<p>Für Hilfe und/oder einen Tipp bin ich sehr dankbar!</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/308773/opencv-cvposit-berechnet-falsche-werte</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 07:52:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/308773.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Oct 2012 09:06:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OpenCV: cvPosit berechnet falsche Werte on Fri, 05 Oct 2012 09:56:23 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein Problem mit cvPosit().<br />
Ich möchte damit die Orientierung eines Gesichts berechnen. Dazu habe ich beispielhaft mal dieses Bild hier:<br />
<a href="http://s1.directupload.net/images/121005/en7u2vhf.jpg" rel="nofollow">http://s1.directupload.net/images/121005/en7u2vhf.jpg</a></p>
<p>Die 5 weißen Punkte sind meine KeyPoints, deren Pixelkoordinaten ich von außerhalb bekomme. Augen und Mundwinkel liegen in einer Ebene, die Nase liegt natürlich nicht in dieser. Somit sollte die Vorraussetzung für POSIT (4 nichtkomplanare Punkte) erfüllt sein.</p>
<p>Hier mein Code, der größtenteils aus dem <a href="http://opencv.willowgarage.com/wiki/Posit" rel="nofollow">POSIT-Tutorial</a> stammt:</p>
<pre><code class="language-cpp">int main()
    int depth = 40; //Nasenhoehe
    calculateHeadPosition(depth);
}

void HeadPosition::calculateHeadPosition(float depth)
{

//create the model points
std::vector&lt;CvPoint3D32f&gt; modelPoints;
modelPoints.push_back(cvPoint3D32f(  0.0f,   0.0f, 0.0f));  //Nose - (the first must be 0,0,0)
modelPoints.push_back(cvPoint3D32f(-52.0f, -58.0f, depth)); //left eye
modelPoints.push_back(cvPoint3D32f( 52.0f, -58.0f, depth)); //right eye
modelPoints.push_back(cvPoint3D32f(-43.0f,  60.0f, depth)); //left mouth corner
modelPoints.push_back(cvPoint3D32f( 43.0f,  60.0f, depth)); //right mouth corner

//create the image points 
std::vector&lt;CvPoint2D32f&gt; srcImagePoints;
srcImagePoints.push_back( cvPoint2D32f( 256, 256) ); //hier sind die Pixelwerte fest kodiert, normal
srcImagePoints.push_back( cvPoint2D32f( 205, 200) ); //bekomme ich sie, wie gesagt, übergeben
srcImagePoints.push_back( cvPoint2D32f( 306, 200) );
srcImagePoints.push_back( cvPoint2D32f( 216, 316) );
srcImagePoints.push_back( cvPoint2D32f( 296, 316) );

//create the POSIT object with the model points
CvPOSITObject* positObject = cvCreatePOSITObject( &amp;modelPoints[0], (int)modelPoints.size() );

//calculate the orientation
float* rotation_matrix = new float[9];
float* translation_vector = new float[3];
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 100, 1.0e-4f);
double FOCAL_LENGTH = 760.0;
cvPOSIT( positObject, &amp;srcImagePoints[0], FOCAL_LENGTH, criteria, rotation_matrix, translation_vector );

//calculate rotation angles
double beta  = atan2((double)(-rotation_matrix[2]), (double)(sqrt(pow(rotation_matrix[0], 2) + pow(rotation_matrix[3], 2))));
double alpha = atan2((rotation_matrix[3]/cos(beta)),(rotation_matrix[0]/cos(beta)));
double gamma = atan2((rotation_matrix[7]/cos(beta)),(rotation_matrix[8]/cos(beta)));

//conversion and prints
beta = beta * 180 / M_PI;
alpha = alpha * 180 / M_PI;
gamma = gamma * 180 / M_PI;
printf(&quot;beta:  %f\t&quot;, beta);
printf(&quot;alpha: %f\t&quot;, alpha);
printf(&quot;gamma: %f\n&quot;, gamma);
}
</code></pre>
<p>Da das Bild eine Frontalansicht des Gesichts zeigt erwarte ich für die Rotationswinkel (0, 0, 0), ich bekomme aber immer ca. (-16, -5, -18).<br />
Woran liegt das?</p>
<p>Für Hilfe und/oder einen Tipp bin ich sehr dankbar!</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257262</guid><dc:creator><![CDATA[orderline]]></dc:creator><pubDate>Fri, 05 Oct 2012 09:56:23 GMT</pubDate></item><item><title><![CDATA[Reply to OpenCV: cvPosit berechnet falsche Werte on Wed, 21 Nov 2012 14:11:42 GMT]]></title><description><![CDATA[<p>Hilfe, stehe gerade vor genau dem selben Problem. Hast du denn eine Antwort gefunden? Wäre schön wenn du sie hier posten könntest. Danke, mfg!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2273077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2273077</guid><dc:creator><![CDATA[Escore]]></dc:creator><pubDate>Wed, 21 Nov 2012 14:11:42 GMT</pubDate></item></channel></rss>