I'm working on a C++ code for image manipulation that works pixel-by-pixel (using Magick++), and I want to use it with OpenMP, but I have the next issue:
Magick: Semaphore operation failed (unable to destroy semaphore) [Dispositivo o recurso ocupado].
img_test: magick/pixel_cache.c:2765: ModifyCache: La declaración `image->cache != (Cache) ((void *)0)' no se cumple.
And, also, it keeps stuck in an infinite loop.
Here is the code snippet:
int main(int argc,char **argv)
{
InitializeMagick(*argv);
Image img1, img2;
img1.read(argv[1]);
img2.read(argv[2]);
int sx = img1.columns();
int sy = img1.rows();
Image out;
out.size(Geometry(sx,sy));
cout << "Processing pictures..." << endl;
int iy;
#pragma omp for private(iy)
for (iy=0;iy<sy;iy++)
{
#pragma omp parallel for
for (int ix=0;ix<sx;ix++)
{
double _r = 0.0, _g = 0.0, _b = 0.0;
ColorRGB ppix1(img1.pixelColor(ix,iy));
ColorRGB ppix2(img2.pixelColor(ix,iy));
// do some image processing...
ColorRGB opix(_r*MaxRGB,_g*MaxRGB,_b*MaxRGB);
out.pixelColor(ix,iy,opix);
}
}
out.write("Output.png");
}
Is there a way to solve this?

iywill give you your desired parallelization. Which line is your error occurring at? What is line2765?