how to compare non rectangular ROI using opencv python

325 Views Asked by At

I want to detect parking lot, I already detect each slot using cv2.findcontour and draw it cv2.drawContours(imgB, contours, -1, (0, 255, 0), 1).

Then I want to compare the difference between reference image and input image from cctv using compare_ssim.

The problem is, contour that I use is not rectangular. I can't compare using ssim. Is there any way to compare non rectangular ROI?

I have tried to create boundingRect and compare, but the result is inaccurate, because the ROI that I want to compare is intersected with other ROI. compare_ssim can't compare non-rectangular ROI. I try (score, diff) = compare_ssim(grayA[[c]], grayB[[c]], full=True), but that gives me an error like this

IndexError: index 463 is out of bounds for axis 0 with size 360!

I expect the output is know the specific empty or not empty parking slot. But at this point I just want to compare the difference with non rectangular ROI.

0

There are 0 best solutions below