Skip to content

Instantly share code, notes, and snippets.

View mattroz's full-sized avatar
:electron:
...

Matt Rozanov mattroz

:electron:
...
  • Germany, München
View GitHub Profile
@mattroz
mattroz / opencv_read_write_video.py
Last active October 11, 2023 16:00
opencv video reader/writer
import cv2
from pathlib import Path
path_to_video = Path("some/path/to/video.mp4")
video_handler = cv2.VideoCapture(str(path_to_video))
n_frames = int(video_handler.get(cv2.CAP_PROP_FRAME_COUNT))
w = int(video_handler.get(cv2.CAP_PROP_FRAME_WIDTH))
h = int(video_handler.get(cv2.CAP_PROP_FRAME_HEIGHT))
@mattroz
mattroz / fast_exp.cpp
Created February 3, 2022 12:02
Fast exponent in C++
inline float fast_exp(float x)
{
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
@mattroz
mattroz / trainval_split.py
Last active January 25, 2022 10:00
Splits and moves data in specified directory to train/ and val/ directories (tested on images)
import logging
import os
import numpy as np
from pathlib import Path
from math import floor
from typing import *
EXTENSIONS = {'.png', '.jpeg', '.jpg'}
@mattroz
mattroz / coco_filter.py
Created January 26, 2021 15:51
This script allows to get a JSON file with specific categories instanses from COCO dataset.
# This code has been taken from https://github.com/immersive-limit/coco-manager/
# Usage: python filter.py --input_json /path/to/instances_train2017.json
# --output_json path_to/saved.json --categories person dog cat
import json
from pathlib import Path
class CocoFilter():
""" Filters the COCO dataset
"""
@mattroz
mattroz / Google Docs API
Last active December 1, 2023 09:55
Instructions for creating a doc and inserting some text
1. Go to https://developers.google.com/docs/api/quickstart/python and download credentials.json by clicking on "DOWNLOAD CLIENT CONFIGURATION"
2. Put credentials.json in your working directory
3. Do `pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib`
4. See the code above.
Useful link on editing, inserting and deleting text: https://developers.google.com/docs/api/how-tos/move-text
git commands and tricks in comments |
v
@mattroz
mattroz / Statistics
Last active August 29, 2017 07:00
Statistics: n vs (n-1) in standard deviation
https://www.youtube.com/watch?v=ANsVodOu1Tg
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -qscale 0 /tmp/out.mpg