Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ image processing, counting angles of objects
    text
    copied!<p>I'm trying to write image processing program but I've got a few problems.</p> <p>I managed to count shape's field, circuit(edge detecting) and some other variables I need. Now I need to find out at what angle each arrow is. I was thinking about looking for centre of an arrow and then comparing it with center of mass of image (and line between them would be angle, I'm not sure if it's how it should be done).</p> <p>The problem is that I have no idea how to implement it. I could detect arrows by set colour, but that would only get me their edges. I don't know how to find centre of a mass (searching info about it on internet actually confused me even more), centre of each arrow or how to count the angles.</p> <p>Could you help me counting these angles? I'm out of ideas how to do it already.</p> <p>I'm using DIBLOOK sample. I can't use any non-standard libraries.</p> <p>My current function for this thing is:</p> <pre><code>void CDibDoc::ConvertToGrayImage(CView *view) { trace("start ConvertToGrayImage\r\n"); RGBTRIPLE* rows[500] ; int width, height ; int obwod=0; int pole=0; float w3=0.0; float m00, m01, m02, m20, m10, m11; float M01, M20, M11, M7, M02; if( GetDIBRowsRGB(m_hDIB,rows,&amp;width,&amp;height)) { for( int x=0;x&lt;width;x++) for( int y =0;y&lt;height;y++) { if(x&lt;width-1 &amp;&amp; x&gt;0 &amp;&amp; y&lt;height-1 &amp;&amp; y&gt;0){ //count circuit, edge detection if(rows[x][y].rgbtBlue != rows[x+1][y].rgbtBlue || rows[x][y].rgbtBlue != rows[x][y+1].rgbtBlue ){ obwod++; } } if(rows[x][y].rgbtBlue == 0){ //count field pole++; m00+= 1; m01+= y; m02+= y*y; m20+= x * x; m10+= x; m11=+x * y; } //counting variables for other things M02 = m02 - (m01*m01) / m00; M01 = m01 - (m01/m00) * m00; M11 = m11-m10 * m01 / m00; M20 = m20 - m10*m10 / m00; M7 = (M20*M02 - M11*M11)/(m00*m00*m00*m00); } FreeDIBRows(m_hDIB); w3 = (obwod / (2* sqrt((float)M_PI * pole))) -1; //more counting } UpdateAllViews(NULL); </code></pre> <p>Picture with arrows:</p> <p><img src="https://i.stack.imgur.com/0Qdw7.jpg" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload