{"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\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\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\nimport os\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\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":"2023-05-01T12:13:39.672073Z","iopub.execute_input":"2023-05-01T12:13:39.672565Z","iopub.status.idle":"2023-05-01T12:13:39.708203Z","shell.execute_reply.started":"2023-05-01T12:13:39.672526Z","shell.execute_reply":"2023-05-01T12:13:39.706966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Source\n - https://github.com/Gil-Mor/iFish.git\n - https://docs.opencv.org/3.4/db/d58/group__calib3d__fisheye.html\n - https://medium.com/@kennethjiang/calibrate-fisheye-lens-using-opencv-333b05afa0b0","metadata":{}},{"cell_type":"code","source":"!pip3 install numpy imageio\n","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:09:53.992384Z","iopub.execute_input":"2023-05-01T12:09:53.993023Z","iopub.status.idle":"2023-05-01T12:10:06.566463Z","shell.execute_reply.started":"2023-05-01T12:09:53.992987Z","shell.execute_reply":"2023-05-01T12:10:06.565218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# input image file (RAW format)\n# Opening the input image (RAW)\nfin = open('/kaggle/input/image-matching-challenge-2023/train/heritage/cyprus/images/DSC_6480.JPG')     \nprint(fin)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:13:53.231717Z","iopub.execute_input":"2023-05-01T12:13:53.232129Z","iopub.status.idle":"2023-05-01T12:13:53.246948Z","shell.execute_reply.started":"2023-05-01T12:13:53.232086Z","shell.execute_reply":"2023-05-01T12:13:53.245643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ROWS = 512    \nCOLS =  512\n# Loading the input image\nprint(\"... Load input image\")\nimg = np.fromfile(fin, dtype = np.uint8, count = ROWS * COLS)\nprint(\"Dimension of the old image array: \", img.ndim)\nprint(\"Size of the old image array: \", img.size)","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:13:59.473302Z","iopub.execute_input":"2023-05-01T12:13:59.473773Z","iopub.status.idle":"2023-05-01T12:13:59.493394Z","shell.execute_reply.started":"2023-05-01T12:13:59.473735Z","shell.execute_reply":"2023-05-01T12:13:59.491786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import IPython\nfrom IPython.display import display\nfrom PIL import Image\n%matplotlib inline\nimport os\nprint(os.listdir(\"../input\"))","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:10:06.611326Z","iopub.execute_input":"2023-05-01T12:10:06.611802Z","iopub.status.idle":"2023-05-01T12:10:06.626189Z","shell.execute_reply.started":"2023-05-01T12:10:06.611765Z","shell.execute_reply":"2023-05-01T12:10:06.624412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IPython.display.Image(filename='/kaggle/input/image-matching-challenge-2023/train/heritage/cyprus/images/DSC_6488.JPG') ","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:10:06.627767Z","iopub.execute_input":"2023-05-01T12:10:06.628143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\n# open the image\nimg = Image.open('/kaggle/input/image-matching-challenge-2023/train/heritage/cyprus/images/DSC_6480.JPG')\n# Get the image size\nimg_size = img.size\n\nprint(\"The image size is: {}\".format(img_size))\n","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:18:39.221598Z","iopub.execute_input":"2023-05-01T12:18:39.222013Z","iopub.status.idle":"2023-05-01T12:18:39.294849Z","shell.execute_reply.started":"2023-05-01T12:18:39.221976Z","shell.execute_reply":"2023-05-01T12:18:39.293321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from skimage.io import imread, imshow\nimport matplotlib.pyplot as plt\ndef read_image(image_path):\n    image_building = imread(image_path, as_gray=False)\n    image_building1 = imread(image_path, as_gray=True)\n    color_shape = image_building.shape\n    gray_shape = image_building1.shape\n    print(\"Color image shape: \", color_shape)\n    print(\"Gray image shape: \", gray_shape)\n    plt.figure(figsize=(10,8))\n    plt.subplot(1,2,1)\n    imshow(image_building)\n    plt.title(\"Color image\")\n    plt.subplot(1,2,2)\n    imshow(image_building1)\n    plt.title(\"Gray image\")\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:21:29.603036Z","iopub.execute_input":"2023-05-01T12:21:29.604309Z","iopub.status.idle":"2023-05-01T12:21:29.612838Z","shell.execute_reply.started":"2023-05-01T12:21:29.604259Z","shell.execute_reply":"2023-05-01T12:21:29.611676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"read_image('/kaggle/input/image-matching-challenge-2023/train/phototourism/british_museum/images/00742386_5921667484.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:21:31.772027Z","iopub.execute_input":"2023-05-01T12:21:31.772498Z","iopub.status.idle":"2023-05-01T12:21:32.500462Z","shell.execute_reply.started":"2023-05-01T12:21:31.772459Z","shell.execute_reply":"2023-05-01T12:21:32.498623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !pip install opencv-python==3.2.0.8\n!pip install omnicv","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:32:15.349720Z","iopub.execute_input":"2023-05-01T12:32:15.351907Z","iopub.status.idle":"2023-05-01T12:32:33.906829Z","shell.execute_reply.started":"2023-05-01T12:32:15.351835Z","shell.execute_reply":"2023-05-01T12:32:33.904972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMAGE_PATH = '/kaggle/input/image-matching-challenge-2023/train/phototourism/british_museum/images/00742386_5921667484.jpg'","metadata":{"execution":{"iopub.status.busy":"2023-05-01T12:33:13.892214Z","iopub.execute_input":"2023-05-01T12:33:13.892753Z","iopub.status.idle":"2023-05-01T12:33:13.899564Z","shell.execute_reply.started":"2023-05-01T12:33:13.892708Z","shell.execute_reply":"2023-05-01T12:33:13.897993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}