cv2.findContours fails to detect black rectangle aligned with x-axis

black = 0 = false = background. if you want to grasp that rectangle, it has to be foreground, which is the opposite.

threshold the image to obtain a mask (binary image), using appropriate flags (THRESH_BINARY_INV) to the threshold() call, such that the rectangle is foreground.

Canny is a newbie trap. avoid it. show the source image. then we can tell you if Canny is warranted.