{"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":"import numpy as np\nimport pandas as pd\ntrain = pd.read_csv('/kaggle/input/tensorflow-great-barrier-reef/train.csv')","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:16:12.392219Z","iopub.execute_input":"2021-11-23T13:16:12.392608Z","iopub.status.idle":"2021-11-23T13:16:12.452685Z","shell.execute_reply.started":"2021-11-23T13:16:12.392540Z","shell.execute_reply":"2021-11-23T13:16:12.451651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:16:20.774888Z","iopub.execute_input":"2021-11-23T13:16:20.775257Z","iopub.status.idle":"2021-11-23T13:16:20.803051Z","shell.execute_reply.started":"2021-11-23T13:16:20.775221Z","shell.execute_reply":"2021-11-23T13:16:20.802325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport cv2\nimport ast","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:22:18.833683Z","iopub.execute_input":"2021-11-23T13:22:18.834020Z","iopub.status.idle":"2021-11-23T13:22:18.838769Z","shell.execute_reply.started":"2021-11-23T13:22:18.833989Z","shell.execute_reply":"2021-11-23T13:22:18.838138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_images_with_annotation(video_number, num_fig, start_frame):\n    images = []\n    fig = plt.figure(figsize=(16, 14))\n    for i in range(num_fig):\n        BASE = '/kaggle/input/tensorflow-great-barrier-reef/train_images/'\n        img = cv2.imread(BASE+'video_'+str(video_number)+'/'+str(i+start_frame)+'.jpg')\n        x = ast.literal_eval(train[train.video_id == video_number].iloc[i+start_frame,:]['annotations'])\n        for l in x:\n            image = cv2.rectangle(img, (l['x'],l['y']) , (l['x']+l['width'],l['y']+l['height']) ,color=(255,0,0), thickness=5)\n        images.append(image)\n\n    rows=3\n    columns=3\n    for i in range(num_fig):\n        fig.add_subplot(rows, columns, i+1)\n        plt.imshow(images[i])\n        plt.axis('off')","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:23:12.474317Z","iopub.execute_input":"2021-11-23T13:23:12.474657Z","iopub.status.idle":"2021-11-23T13:23:12.616692Z","shell.execute_reply.started":"2021-11-23T13:23:12.474626Z","shell.execute_reply":"2021-11-23T13:23:12.615764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_images_with_annotation(0, 9, 50)","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:23:40.848409Z","iopub.execute_input":"2021-11-23T13:23:40.849000Z","iopub.status.idle":"2021-11-23T13:23:43.119899Z","shell.execute_reply.started":"2021-11-23T13:23:40.848961Z","shell.execute_reply":"2021-11-23T13:23:43.118345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_images_with_annotation(1, 9, 470)","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:26:39.008237Z","iopub.execute_input":"2021-11-23T13:26:39.008584Z","iopub.status.idle":"2021-11-23T13:26:41.354280Z","shell.execute_reply.started":"2021-11-23T13:26:39.008548Z","shell.execute_reply":"2021-11-23T13:26:41.353230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_images_with_annotation(2, 9, 3850)","metadata":{"execution":{"iopub.status.busy":"2021-11-23T13:28:30.448769Z","iopub.execute_input":"2021-11-23T13:28:30.449503Z","iopub.status.idle":"2021-11-23T13:28:32.980305Z","shell.execute_reply.started":"2021-11-23T13:28:30.449464Z","shell.execute_reply":"2021-11-23T13:28:32.979166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}