Here is one way in Python/OpenCV.
- Read the input
- Convert to HSV
- Do color thresholding on the green box
- Get the outer contour
- Print the bounding box
- Rotate the image by 10 deg clocwise
- Convert that image to HSV
- Do color thresholding on the rotated green box
- Get the outer contour
- Create a black image with the white filled contour
- Get the white pixel coordinates
- Get the minAreaRect from the coordinates
- Get the vertices of the rotated rectangle
- Draw the rotated rectangle outline on the rotated image
Input:

import cv2
import numpy as np
from scipy import ndimage
# load image
img = cv2.imread("berry.png")
# convert to hsv
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# threshold using inRange or green
range1 = (20,200,170)
range2 = (80,255,255)
thresh = cv2.inRange(hsv,range1,range2)
# get bounding box coordinates from the one outer contour
contours = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contours = contours[0] if len(contours) == 2 else contours[1]
x,y,w,h = cv2.boundingRect(contours[0])
print("bounding_box(x,y,w,h):",x,y,w,h)
# rotate image by 10 degree clockwise
rotated = img.copy()
rotated = ndimage.rotate(img, -10, cval=255)
# convert rotated to hsv
hsv_rotated = cv2.cvtColor(rotated, cv2.COLOR_BGR2HSV)
# threshold using inRange or green
range1 = (20,200,170)
range2 = (80,255,255)
thresh_rotated = cv2.inRange(hsv_rotated,range1,range2)
# get bounding box coordinates from the one outer contour
contours = cv2.findContours(thresh_rotated, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contours = contours[0] if len(contours) == 2 else contours[1]
# draw white filled contour on black background
mask = np.zeros_like(thresh_rotated)
cv2.drawContours(mask, [contours[0]], -1, (255), -1)
# get coordinates of white pixels in mask
coords = np.column_stack(np.where(mask.transpose() > 0))
# get rotated rectangle
rotrect = cv2.minAreaRect(coords)
# rotated rectangle box points
box = np.int0(cv2.boxPoints(rotrect))
print("rotate_box_corners:\n",box)
# draw rotated rectangle on rotated image
result = rotated.copy()
cv2.polylines(result, [box], True, (0,0,255), 1)
# write result to disk
cv2.imwrite("berry_thresh.png", thresh)
cv2.imwrite("berry_rotated.png", rotated)
cv2.imwrite("berry_thresh_rotated.png", thresh_rotated)
cv2.imwrite("berry_mask.png", mask)
cv2.imwrite("berry_rotated_box.png", result)
# display results
cv2.imshow("THRESH", thresh)
cv2.imshow("ROTATED", rotated)
cv2.imshow("THRESH_ROT", thresh_rotated)
cv2.imshow("MASK", mask)
cv2.imshow("RESULT", result)
cv2.waitKey(0)
cv2.destroyAllWindows()
Threshold of green lines in input:

Rotated input:

Threshold of green lines in rotated image:

Filled threshold:

Result showing rotated rectangle on rotated image:

Input Bounding Box:
bounding_box(x,y,w,h): 12 13 212 124
Output Vertices:
rotate_box_corners:
[[222 172]
[ 14 136]
[ 35 14]
[243 51]]