input: Write a python function to recognize handwritten digits using OpenCV library.
  assert recognize_handwritten_digits('test_image1.png') == [5, 3, 8]
  assert recognize_handwritten_digits('test_image2.png') == [2, 7, 1]
  assert recognize_handwritten_digits('test_image3.png') == [4, 6, 9]
output: def recognize_handwritten_digits(image_path):
      import cv2
      import numpy as np
      from keras.models import load_model
  
      # Load pre-trained MNIST model
      model = load_model('mnist_model.h5')
  
      # Read image
      image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
      
      # Threshold the image to binary
      _, thresh = cv2.threshold(image, 128, 255, cv2.THRESH_BINARY_INV)
      
      # Find contours
      contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
      
      digits = []
      
      for cnt in contours:
          # Get bounding box and extract ROI
          x, y, w, h = cv2.boundingRect(cnt)
          digit_roi = thresh[y:y+h, x:x+w]
          
          # Resize ROI to 28x28 pixels as expected by the model
          digit_roi_resized = cv2.resize(digit_roi, (28, 28), interpolation=cv2.INTER_AREA)
          
          # Normalize pixel values
          digit_roi_normalized = digit_roi_resized / 255.0
          
          # Reshape to fit the model input
          digit_roi_reshaped = digit_roi_normalized.reshape(1, 28, 28, 1)
          
          # Predict the digit
          prediction = model.predict(digit_roi_reshaped)
          digit = np.argmax(prediction)
          
          digits.append((x, digit))
      
      # Sort digits based on their x-coordinate
      digits = sorted(digits, key=lambda x: x[0])
      
      # Extract the digits from the sorted list
      result = [digit for _, digit in digits]
      
      return result