Skip to content

Instantly share code, notes, and snippets.

View allenanie's full-sized avatar
🏔️
Gradient ascending

Allen Nie allenanie

🏔️
Gradient ascending
View GitHub Profile
@allenanie
allenanie / split_image_4_quarters.py
Created August 18, 2020 18:41 — forked from alexlib/split_image_4_quarters.py
Python code using PIL to split the image into 4 quarters. useful for the four-view image splitter 3D-PTV project on http://www.openptv.net
from PIL import Image
import os
import glob
import numpy as np
def crop(im, height, width):
# im = Image.open(infile)
imgwidth, imgheight = im.size
rows = np.int(imgheight/height)
###########################################
# serialization of indexes to byte arrays
###########################################
def serialize_index(index):
""" convert an index to a numpy uint8 array """
writer = faiss.VectorIOWriter()
faiss.write_index(index, writer)
return faiss.vector_to_array(writer.data)
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command:
@allenanie
allenanie / gist:a45d4ac490053ad1a9cf
Created September 26, 2015 22:59 — forked from jeamland/gist:11284662
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))