Skip to content

Instantly share code, notes, and snippets.

View GeorgySk's full-sized avatar

Georgy Skorobogatov GeorgySk

  • Spain, Barcelona
View GitHub Profile
@GeorgySk
GeorgySk / stereographic.py
Last active April 23, 2018 13:43
stereographic projections; convert longitude and latitude to meters;
from typing import (Union,
Optional,
Tuple)
import numpy as np
def projection(latitudes: np.ndarray,
longitudes: np.ndarray,
*,
@GeorgySk
GeorgySk / call_matlab.py
Last active April 24, 2018 09:17
Example of how to call MATLAB function from Python and get output
"""
For installation see:
https://uk.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
In order to install matlab.engine in non-default location,
e.g. conda environment, see:
https://uk.mathworks.com/help/matlab/matlab_external/install-matlab-engine-api-for-python-in-nondefault-locations.html
(My advice is to install it to a base environment,
installing to different environments seems to be buggy)
If this doesn't work, try `pip install -e .` from *matlabroot\extern\engines\python*
@GeorgySk
GeorgySk / suppression_via_disk_covering.py
Last active May 18, 2018 09:05
Efficiently selecting spatially distributed keypoints for visual tracking
from functools import partial
from typing import Tuple
import numpy as np
def select(points: np.ndarray,
*,
image_shape: Tuple[int, int],
count: int,
@GeorgySk
GeorgySk / farthest.py
Last active May 11, 2018 12:53
Finding N scattered points in a set of given points.
import numpy as np
def points_indices(points: np.ndarray,
*,
count: int) -> np.ndarray:
"""
Finds a set of points quite far apart from each other.
First point in the array is always included.
Based on:
import operator
from typing import Iterator
import numpy as np
import sympy as sym
from scipy.special import lambertw
from sympy.functions.elementary.piecewise import ExprCondPair
def sample(pdf: sym.Function,
@GeorgySk
GeorgySk / table_alignment.py
Created October 27, 2018 22:08
Example of how to print aligned a table from a list of dicts
from operator import itemgetter
from typing import (Any,
Dict,
Iterable,
Iterator,
List,
Sequence)
def max_length(objects: Iterable[Any]) -> int:
import operator
from itertools import (accumulate,
repeat)
from pathlib import Path
from typing import (Iterator,
List,
Tuple)
FILEPATH = Path('days_of_week.txt')
@GeorgySk
GeorgySk / question.md
Last active November 19, 2019 11:34
How to prevent rectified images to be cropped in OpenCV?

This question was originally posted on Stack Overflow by the following link: https://stackoverflow.com/questions/50585255/how-to-prevent-rectified-images-to-be-cropped-in-opencv
Unfortunately, most probably due to my high activity in content moderation, it got several "revenge downvotes" and it was automatically deleted by the system. This question got around 500 views in 1 year, so I assume other people also encounter this issue, hence I decided to save a copy here.
While there is still no answer to the problem of cropping, I think my attempt to solve it which is presented in an edit to the question will be helpful for future readers.

Let's take the following pair of consequent aerial images and do the image rectification (code below):

query.jpg [![query][1]][1]

@GeorgySk
GeorgySk / random_polygon.py
Last active January 31, 2020 11:55
Preliminary version of a random polygon generation based on Nourollah2017 paper
from functools import partial
from _ctypes import ArgumentError
from hypothesis.strategies import (floats,
tuples,
lists)
from lz.iterating import pairwise
from shapely.geometry import (LineString,
Point,
Polygon)
@GeorgySk
GeorgySk / animation.py
Last active May 23, 2020 16:09
Matplotlib animation in Jupyter Lab
"""Example of code for Matplotlib animation in Jupyter Lab"""
%matplotlib qt5
from itertools import count
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation