Skip to content

Instantly share code, notes, and snippets.

View PolarNick239's full-sized avatar

Nikolai Poliarnyi PolarNick239

View GitHub Profile
import os
import time
import subprocess
from collections import namedtuple
def get_memory(key="total"):
# See https://doeidoei.wordpress.com/2009/03/22/python-tip-3-checking-available-ram-with-python/
if os.name == "posix":
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
public class Main {
public static void main(String[] args) throws InterruptedException {
import os
import time
def get_memory(key="total"):
key_to_index = {
"total": 1,
"used": 2,
"free": 3,
"shared": 4,
@PolarNick239
PolarNick239 / CMakeLists.txt
Created May 27, 2019 15:51
Optical flow video tracking with per-triplet consistency check, using calcOpticalFlowFarneback from OpenCV
cmake_minimum_required(VERSION 3.13)
project(video_optflow)
set(CMAKE_CXX_STANDARD 14)
find_package(OpenMP)
if (OpenMP_CXX_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
@PolarNick239
PolarNick239 / morton_code.h
Last active May 22, 2024 12:06
96-bit 3D Morton code (Z-curve)
#pragma once
#include <limits>
#include <cassert>
#include <stdexcept>
#define MORTON_CODE_MAX_LEVEL 32
#define UINT8 unsigned char
#define UINT32 unsigned int
@PolarNick239
PolarNick239 / buildOCV.sh
Created February 13, 2021 18:44
buildOCV.sh + CLion workaround for OpenCV
#!/bin/bash -e
# Adopted from https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html
#
# Changes:
# - version fixed to 4.5.1 - https://github.com/opencv/opencv/releases/tag/4.5.1
# - disabled opencv_contrib
# - RelWithDebInfo instead of Release
#
# How to use:
@PolarNick239
PolarNick239 / DeepForest_Cars.ipynb
Created July 7, 2021 09:36
DeepForest experiments with Cars detection on Dortmund dataset
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import scipy
import scipy.linalg
def ensure_close(P, A):
eps = np.max(np.abs(P)) * 10e-10
assert(np.max(np.abs(P - A)) <= eps)
def qr_decomposition_np(A):
Q, R = np.linalg.qr(A)
@PolarNick239
PolarNick239 / Gaussian kernels.ipynb
Created February 2, 2024 15:24
Gaussian kernels
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.