Note that there are some explanatory texts on larger screens.

plurals
  1. POError copying data into iplimage
    primarykey
    data
    text
    <p>Hi I have the following piece of code:</p> <pre><code>void ViewPlane::colourPixel(const int u, const int v, const Colour c){ int step = img-&gt;widthStep; cout &lt;&lt; "U: " &lt;&lt; u &lt;&lt; ", V: " &lt;&lt; v &lt;&lt; ", step: " &lt;&lt; step &lt;&lt; "\n"; cout &lt;&lt; "Colour: " &lt;&lt; c.r &lt;&lt; ", " &lt;&lt; c.g &lt;&lt; ", " &lt;&lt; c.b &lt;&lt; "\n"; cout &lt;&lt; "Data: " &lt;&lt; v*step+u*3 &lt;&lt; ", " &lt;&lt; v*step+u*3+1 &lt;&lt; ", " &lt;&lt; v*step+u*3+2 &lt;&lt; "\n"; cout &lt;&lt; "Data: " &lt;&lt; data[v*step+u*3] &lt;&lt; ", " &lt;&lt; data[v*step+u*3+1] &lt;&lt; ", " &lt;&lt; data[v*step+u*3+2] &lt;&lt; "\n"; //swap colours round as opencv default image is bgr, not rgb data[v*step+u*3] = c.b; cout &lt;&lt; "done it\n"; data[v*step+u*3+1] = c.g; cout &lt;&lt; "done it\n"; data[v*step+u*3+2] = c.r; cout &lt;&lt;"done it\n"; } </code></pre> <p>img is an IplImage pointer, and data is </p> <pre><code>data = (uchar *)img-&gt;imageData; </code></pre> <p>I am looping through lots of values of u and v (image coordinates) and assigning a colour to each pixel. However the code just stops half way through this pixel when it reaches u = 148.</p> <p>Printing out the values reveals the green pixel at this point originally contains '*', and is the only one up to that point which does so. Here is a copy of the output:</p> <pre><code>.... U: 146, V: 0, step: -1219934912 Colour: 0, 0, 0 Data: 438, 439, 440 Data: done it done it done it U: 147, V: 0, step: -1219934912 Colour: 0, 0, 0 Data: 441, 442, 443 Data: done it done it done it U: 148, V: 0, step: -1219934912 Colour: 0, 0, 0 Data: 444, 445, 446 Data: �, *, � done it </code></pre> <p>So my question is, what does this star mean? And why is it stopping me from assigning data there?</p> <p>EDIT: The image size is 400x400px</p> <p>PS: I just tried commenting out the green channel assignment and this error happens again for the red channel further on. This time it held '@' before assignment, so this makes me think it has no bearing on what's going wrong...In that case, what on earth? I'm not out of bounds of the array, the value I'm inserting is an integer 0...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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