Getting contour of important part

I am trying to extract a card from the scanned page, where the original image is this

and my code is as following

import cv2
image = cv2.imread(‘image.jpg’)
image = cv2.resize(image, (image.shape[1]//10,image.shape[0]//10))
image = cv2.GaussianBlur(image, (5,5), 0)
myimage_grey = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
_, background = cv2.threshold(myimage_grey, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
cv2.imwrite(‘card.jpg’, background)

which gives me the following output with some black patches along with the card
Is there any way to remove the black patch along with the card?

Background is not homogeous. You should try adaptativeThreshold or grab a new image with a constant background

Each image is like this might be some scanning problem. The adaptiveThreshold with following code gives refine the image but the image also gets disconnected.

thresh2 = cv2.adaptiveThreshold(myimage_grey, 255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY, 45, 5)