{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\n#TODO make sure height is right for boxes\n#TODO Clean, refactor code into seperate notebook and publish\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom PIL import Image, ImageDraw\nimport matplotlib.pyplot as plt\nimport ast\n\nvideo_n = 0\nimage_n = 44\ndata_path = \"/kaggle/input/tensorflow-great-barrier-reef\"\nimg = Image.open(data_path + \"/train_images/video_{}/{}.jpg\".format(video_n, image_n))\n#plt.imshow(img)\n\ntrain_df = pd.read_csv(data_path + \"/train.csv\", converters={'annotations': ast.literal_eval})\ncurr_entry = train_df[train_df[\"image_id\"] == \"{}-{}\".format(video_n, image_n)]\nprint(curr_entry)\nannot_list = curr_entry[\"annotations\"].iloc[0]\njson_box = annot_list[0]\nbox_coords = ((json_box[\"x\"],json_box[\"y\"]),(json_box[\"x\"] + json_box[\"width\"], json_box[\"y\"] + json_box[\"height\"]))\nprint(box_coords)\n\nimg_d = ImageDraw.Draw(img)\nimg_d.rectangle(box_coords, fill=None, outline=\"red\", width=4)\nplt.imshow(img)\n#d = ImageDraw.Draw(txt)\n\n\n#img.show()\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\n\n#import os\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n#    for filename in filenames:\n#        print(os.path.join(dirname, filename))\n        \n\n    \n        \n\n        \n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-01-13T18:59:01.529365Z","iopub.execute_input":"2022-01-13T18:59:01.529649Z","iopub.status.idle":"2022-01-13T18:59:02.416618Z","shell.execute_reply.started":"2022-01-13T18:59:01.529622Z","shell.execute_reply":"2022-01-13T18:59:02.415558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls","metadata":{"execution":{"iopub.status.busy":"2022-01-13T17:41:33.417127Z","iopub.execute_input":"2022-01-13T17:41:33.417512Z","iopub.status.idle":"2022-01-13T17:41:33.729705Z","shell.execute_reply.started":"2022-01-13T17:41:33.4174Z","shell.execute_reply":"2022-01-13T17:41:33.729116Z"},"trusted":true},"execution_count":null,"outputs":[]}]}