<jupyter_start><jupyter_text>DetectNum Function As per coursework requirements. DocString:```Pythondef detectNum(filename,returnimage=False):    '''    Function that detects the white A4 paper and recognises the number written on it     input: image or movie    supported formats: ['jpg','JPG','png','PNG','JPEG','jpeg','mov','MOV','mp4']    returnimage: optional switch that returns the image with a bounding box around the paper. This function is not available for video formats    '''```<jupyter_code># import detectNum function
from ocr import detectNum

# import libraries
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image,ImageDraw
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Examples  1.1 Video File<jupyter_code>detectNum('IMG_0810.mov')<jupyter_output><empty_output><jupyter_text>1.2 Image File<jupyter_code>detectNum('indiv001.jpg')<jupyter_output><empty_output><jupyter_text>1.2.1 Image File with two numbersReturns a list of numbers that were detected. Note: Since this image was created in a photo editing software it does not contain exif infos. Exif info is checked to account for images that are saved in landscape mode but are taken in portrait mode. For more details see report.<jupyter_code>detectNum('two_indiv_numbers.jpg')<jupyter_output>No exif data found, continuing without check for iPhone SE<jupyter_text>1.2.2 Image File with illustration of paper detectionThis is currently only implemented for images containing one rectangle.<jupyter_code>num, img = detectNum('indiv001.jpg',returnimage=True)
print(num)
plt.figure(figsize=(10,10))
plt.imshow(img)<jupyter_output>['01']
{'fraction_non_alphanumeric': 0.08869987849331713, 'fraction_numerical': 0.01701093560145808, 'mean_word_length': 6.880382775119617, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '283701', 'license': 'MIT', 'n_tokens_mistral': 503, 'n_tokens_neox': 480, 'n_words': 166, 'path': 'DetectNum.ipynb', 'repo_name': 'Laibe/INM460_ComputerVision', 'size': '1646'}