I try to loop on an image to create several ROIs (their number can be changed) but it appears that the system can only chose one. I need that because I will try to make a LBP face detector.
Here is my loop and the displaying (it's the forst time I post something here so I hope I didn't do any mistake):
for (i=0;i<regionPerLine*regionPerLine;i++) {
if(i%4==0 && i!=0) {
indexLines=0;
indexColumns=indexColumns+height/regionPerLine;
}
if (i%3==0)
color=cvScalar(c,0,0,0);
else if (i%2==0)
color=cvScalar(0,c,0,0);
else
color=cvScalar(0,0,c,0);
roi.x=indexLines;
roi.y=indexColumns;
printf("\n\n%d\t%d", roi.x, roi.y);
cvSetImageROI(img_copy, roi);
cvRectangle(img_copy, cvPoint(roi.x,roi.y), cvPoint(roi.x+roi.width, roi.y+roi.height), color, CV_FILLED);
cvResetImageROI(img_copy);
indexLines=indexLines+width/regionPerLine;
}
cvShowImage("img", img);
cvShowImage("img_copy", img_copy);
cvWaitKey(0);
cvDestroyWindow("img");
cvDestroyWindow("img_copy");
cvReleaseImage(&img);
cvReleaseImage(&img_copy);
return 0;
}
I change the color to see the way my ROIs are changing but when I try to display them (and obtain several color rectanges), I obtain only one blue at the top left of my image which means I think that the first one is chosen but not the others. However, when I display my index in the printf function, all the needed index are well increased as I would like to.
If someone knows what happens please let me know.
Thanks