Spaces:
Sleeping
Sleeping
File size: 1,139 Bytes
6a6918c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
import numpy as np
import cv2
from draft_computation_app import calculate_draft
from draft_computation_app.dummy_data import results2 as results
def test_calculate_draft():
pose_results = results.pose
segment_data = results.segment
# Load the test image
image_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "dummy_data", "test2.jpg")
original_image = cv2.imread(image_path)
# Set the ocr placeholder to return a specific value for the test
from draft_computation_app import ocr_placeholder
ocr_placeholder.perform_ocr = lambda image: "12m"
draft = calculate_draft(pose_results, segment_data, original_image)
print(f"The calculated draft is: {draft}")
# Add an assertion to check if the result is within a reasonable range
# This expected value is just a placeholder and should be adjusted
# based on the actual expected output.
expected_draft = 11.41
assert abs(draft - expected_draft) < 0.1
if __name__ == "__main__":
test_calculate_draft()
|