Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 3 14:34:44 2022
@author: aktas
"""
# import necessary layers
from tensorflow.keras.layers import Input, Conv2D , Dropout, MaxPool2D, Flatten, Dense, Activation, BatchNormalization
from tensorflow.keras import Model
# import necessary layers
from tensorflow.keras.layers import Input, Conv2D , Dropout, MaxPool2D, Flatten, Dense
from tensorflow.keras import Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.regularizers import l2
import tensorflow as tf
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
import os
import matplotlib.pyplot as plt
import sys
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 29 20:56:04 2021
@author: aktas
"""
# import necessary layers
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.regularizers import l2
# import necessary layers
from tensorflow.keras.layers import Input, Conv2D , Dropout, MaxPool2D, Flatten, Dense
from tensorflow.keras import Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.regularizers import l2
import tensorflow as tf
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
import os
import matplotlib.pyplot as plt
import sys
import numpy as np
def loss_function(prediction, ground_truth): #mean square error with batch size = 1
cost = (ground_truth-prediction)**2
return cost
def prediction(x,current_weights,current_bias):
y_predicted = np.sum((current_weights * x)) + current_bias
% reference : https://medium.com/data-breach/introduction-to-harris-corner-detector-32a88850b3f6
clear all;
close all;
clc;
% Take the grayscale of the original image
im=imread('corner2.png');
figure
%% Obtain 2 cameras seeing the same scene
clear all;
close all;
clc;
PTS= load('pts3D.txt');
count_3d_points = length(PTS);
tmp = ones(count_3d_points,1);
PTS_homogenous = [PTS, tmp];
clear all;
close all;
clc;
PTS1 = load('pts2D_1.txt'); % 300 x 2 matrix
PTS2 = load('pts2D_2.txt'); % 300 x 2 matrix
tmp = ones(length(PTS1),1);
Homogenous_PTS1 = [PTS1, tmp];
@YCAyca
YCAyca / zhang.m
Last active October 1, 2021 14:18
clear all;
close all;
clc;
%We have simulated a regular checkerboard pattern, comprising 10x10 points, and a camera observing it.
%The checkerboard is moved around the camera and 10 images of it are acquired in the process.
%PTS_world = load('ptsXY.txt'); % Cartesian coordinates of the checkerboard points,
%Pixel coordinates of the 2D points in the 10 images, given in pts2D_i.txt, i = 1, 2, ..., 10.
@YCAyca
YCAyca / DLT.m
Last active September 28, 2021 13:45
% Apply DLT using the following functions
% World_PTS : 3D world points, GT_PTS: 2D Projected image points of these 3D world points,
% Calibration_Points_Count : the quantity of points we use for realizing calibration
function DLT(World_PTS, GT_PTS, Calibration_Points_Count)
A = Create_Matrix_A(Calibration_Points_Count, World_PTS, GT_PTS)
P = Obtain_Projection_Matrix(A)
[K,R,T] = QR_Decomposition(P)
[Projected_X, Projected_Y] = Projection(P, World_PTS, GT_PTS);
end