Skip to content

Instantly share code, notes, and snippets.

Avatar

Georgy Skorobogatov LostFan123

  • Spain, Barcelona
View GitHub Profile
@LostFan123
LostFan123 / animation.py
Last active May 23, 2020
Matplotlib animation in Jupyter Lab
View animation.py
"""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
@LostFan123
LostFan123 / random_polygon.py
Last active Jan 31, 2020
Preliminary version of a random polygon generation based on Nourollah2017 paper
View random_polygon.py
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)
@LostFan123
LostFan123 / question.md
Last active Nov 19, 2019
How to prevent rectified images to be cropped in OpenCV?
View question.md

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]

View abbreviations_automatic.py
import operator
from itertools import (accumulate,
repeat)
from pathlib import Path
from typing import (Iterator,
List,
Tuple)
FILEPATH = Path('days_of_week.txt')
@LostFan123
LostFan123 / table_alignment.py
Created Oct 27, 2018
Example of how to print aligned a table from a list of dicts
View table_alignment.py
from operator import itemgetter
from typing import (Any,
Dict,
Iterable,
Iterator,
List,
Sequence)
def max_length(objects: Iterable[Any]) -> int:
View inverse_transform.py
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,
@LostFan123
LostFan123 / farthest.py
Last active May 11, 2018
Finding N scattered points in a set of given points.
View farthest.py
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:
@LostFan123
LostFan123 / suppression_via_disk_covering.py
Last active May 18, 2018
Efficiently selecting spatially distributed keypoints for visual tracking
View suppression_via_disk_covering.py
from functools import partial
from typing import Tuple
import numpy as np
def select(points: np.ndarray,
*,
image_shape: Tuple[int, int],
count: int,
@LostFan123
LostFan123 / call_matlab.py
Last active Apr 24, 2018
Example of how to call MATLAB function from Python and get output
View call_matlab.py
"""
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*
@LostFan123
LostFan123 / stereographic.py
Last active Apr 23, 2018
stereographic projections; convert longitude and latitude to meters;
View stereographic.py
from typing import (Union,
Optional,
Tuple)
import numpy as np
def projection(latitudes: np.ndarray,
longitudes: np.ndarray,
*,
You can’t perform that action at this time.