int numVerts = mesh.getNumVertices();
for (int i = 0; i < numVerts; ++i) {
ofVec3f vert = mesh.getVertex(i);
int x = int(vert.x);
int y = int(vert.y);
ofColor couleur = image.getColor(x, y);
ofSetColor(couleur);
ofFill();
ofDrawEllipse(vert.x, vert.y, 10, 10);
}
The problem seems to be with the getColor function maybe
I am a beginner with openframeworks and visual studio
If you have any question or if I am not clear, ask me
Thanks! But it didn’t work. I cleaned and rebuilt both the solution and the project but it’s still not working. Now it never works.
I don’t have the Microsoft Visual Studio warning window anymore, but it is stuck at the same line.
I am with of 0.9.2
that’s usually because you are trying to access a position in the pixels that doesn’t exist. try printing out the values or at least storing them in a variable so you can see them in the debugger:
auto pixelIndex = image.getPixels().getPixelIndex(x,y);
auto maxIndex = image.getPixels().size();
if pixelIndex is >= than maxIndex then you are outside of the pixels memory. you can also use an if condition to not try to get the color in that case
Both the pixelIndex and the maxIndex are 48600, which is quite strange because my image is originally 1600654px, I resized it to 200x81px (so 16 200px). 48600 is 162003 but I don’t see if there’s a link.
I think the problem happens the first time as you say, when I tried to access position of pixels that doesn’t exist, with this code (because I had a strange color pattern) :
for (int i = 0; i < numVerts*2; ++i) {
…
}
But even after I have changed it and cleaned the project it seems to be like it is still “in cache”.
Edit : I scaled ofColor couleur = image.getColor(x, y); to ofColor couleur = image.getColor(x/8, y/8); (8 is the factor I used for resizing) and it works, the problem should initially come from that.