Skip to content

Instantly share code, notes, and snippets.

@insaneyilin
insaneyilin / show_pcd_in_birdeye_view.py
Last active April 23, 2020 08:38
show point cloud data in birdeye view
## reference: http://ronny.rest/tutorials/module/pointclouds_01/point_cloud_birdseye/
## https://blog.csdn.net/weixin_39999955/article/details/83819313
import os
import sys
import numpy as np
import pypcd
from PIL import Image
@insaneyilin
insaneyilin / btc_price.py
Created November 16, 2019 10:07
Python script to query the lastes BTC price.
#!/usr/bin/env python3
import requests
from datetime import datetime
TICKER_API_URL = 'https://api.coinmarketcap.com/v1/ticker/'
def get_latest_crypto_price(crypto='bitcoin'):
return float(requests.get(TICKER_API_URL+crypto).json()[0]['price_usd'])
@insaneyilin
insaneyilin / skimage_optical_flow_demo.py
Created November 15, 2019 02:09
Optical Flow examples
from matplotlib import pyplot as plt
%matplotlib inline
from skimage.color import hsv2rgb
from skimage.color import rgb2gray
from skimage.data import stereo_motorcycle
from skimage.registration import optical_flow_tvl1
import numpy as np
image0, image1, disp = stereo_motorcycle()
@insaneyilin
insaneyilin / histogram_filter_2d_localization.py
Created November 14, 2019 02:47
2D Histogram filter localization example
# -*- coding: utf-8 -*-
# @Author: insaneyilin
# Python version 2.7
# Adapted from
# https://github.com/AtsushiSakai/PythonRobotics/tree/master/Localization/histogram_filter
import copy
import math
import matplotlib.pyplot as plt
@insaneyilin
insaneyilin / multiprocessing_image_resize.py
Created November 13, 2019 18:31
A Python scripts to resize images with multiprocessing.
# -*- coding: utf-8 -*-
# @Author: insaneyilin
# Python version 2.7
import os
import sys
import time
import argparse
import multiprocessing
from PIL import Image
@insaneyilin
insaneyilin / register_factory.cpp
Last active October 7, 2019 16:22
C++ class register factory
// Copyright (c) 2019 Yilin Gui. All rights reserved.
//
// filename: register_factory.cpp
#include "./register_factory.h"
namespace register_factory {
BaseClassFactoryMap& GlobalBaseClassFactoryMap() {
static BaseClassFactoryMap base_factory_map;
@insaneyilin
insaneyilin / newton_sqrt.scm
Created August 12, 2019 16:24
Find square-root using Newton method in Scheme
(define (average x y)
(* (+ x y) 0.5))
(define (good_enough? guess x)
(< (abs (- x (* guess guess))) 0.001))
(define (improve guess x)
(average guess (/ x guess)))
(define (sqrt_itr guess x)
@insaneyilin
insaneyilin / cpp_cmp_struct_using_tie.cpp
Created August 7, 2019 10:51
compare struct using std::tie()
struct Student {
int stu_id;
int age;
float grade;
};
std::vector<Student> students;
// fill students vector
// ...
@insaneyilin
insaneyilin / shared_object_pool.h
Created July 10, 2019 12:58
A simple object pool. (not thread-safe, return std::shared_ptr)
#ifndef IG_SHARED_OBJECT_POOL_H_
#define IG_SHARED_OBJECT_POOL_H_
#include <cstdlib>
#include <queue>
#include <vector>
#include <list>
#include <memory>
namespace ig {
@insaneyilin
insaneyilin / compress_image.py
Created July 1, 2019 17:41
compress image with file size threshold
# -*- coding: utf-8 -*-
# @Author: insaneyilin
# Python version 2.7
# Reference: https://www.cnblogs.com/li1992/p/10675769.html
import os
import sys
import argparse
import glob