I am drawing a couple of convex polygons (that overlap one another - this could be important) and I wanted to draw them in parallel to speed things up. Here is the code:
vector<Point> face; vector<vector<Point>> faces; //polygon 1 face.push_back((Point)model2D.col(0)); face.push_back((Point)model2D.col(1)); face.push_back((Point)model2D.col(2)); face.push_back((Point)model2D.col(3)); faces.push_back(face); //here I fill other faces //and finally I draw them for (int i = 0; i < faces.size(); i++) fillConvexPoly(img, faces[i], CV_RGB(255, 0, 0));
Now, I thought that adding the following line just before the drawing loop would speed up the process, alas, it makes it actually slower!
#pragma omp parallel for
The OMP is working in general, I set the number of threads to 12. Could it be the problem of accessing the img data, as the polygons overlap one another? Or am I making some basic mistake? How do I speed it up?