Try to get convexity defects but getting an error

I checked second image, and it gives me same result as before. So in my opinion the problem is finding max contours area. My code does not return max contour area. I tried code sent here. It works smoothly.