I was trying to use QImage for loading image and checking the equality with a template sub-image that moves all over the image. The code is as:
for i in range(image.height() - backgroundMask.height() + 1):
for j in range(image.width() - backgroundMask.width() + 1):
subsection = image.copy(j, i, j + backgroundMask.width() - 1, i + backgroundMask.height() - 1)
if subsection == backgroundMask:
print 'equality action here'
else:
print 'non-equality action here'
The problem is that its taking too much time to do this. Similar operation using Python Imaging Library was too fast. The two major operations are copy() and operator==() . I think that major time is being spent in the copy() as it performs the copy there only. If it had been just a lazy copy-on-write operation then it would have been faster.
Is there any way to do it faster?