Skip to content

Instantly share code, notes, and snippets.

@qzane
qzane / test.py
Last active August 26, 2022 03:04
Python3 global and nonlocal
View test.py
a = 0 # global
def change1():
a = 1 # nonlocal
def change2():
nonlocal a
a = 3
def change3():
global a
print('change3', a)
a = 4
View txt2epub.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import sys, os, re, time, pkgutil, logging, click, subprocess, zipfile
from jinja2 import Template, Environment, PackageLoader
from datetime import datetime
__version__ = "1.1"
RE_CHAPTER_AND_SECTIONS=[
View imgs2video.py
import os,sys,shutil
import cv2
import numpy as np
USAGE = "python %s video [outPath]"%sys.argv[0]
USAGE += "\n example: python %s video.mp4 ./output"%sys.argv[0]
if len(sys.argv) < 2 or '-h' in sys.argv or '--help' in sys.argv:
print(USAGE)
@qzane
qzane / smplx_uv.py
Created October 10, 2020 20:39
get colored uv map for SMPL/SMPLX model
View smplx_uv.py
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 10 15:29:24 2020
@author: qzane
The SMPLX models can be find at: https://smpl-x.is.tue.mpg.de/
"""
import numpy as np
import scipy
from scipy.ndimage.measurements import label
View solve_RT1_RT2.py
def solve_RT1_RT2(A, B):
''' solve for B = x1.dot(A).dot(x2)
A = [[[R1,T1],[0,1]]...] # shape: (n,4,4)
B = [[[R2,T2],[0,1]]...] # shape: (n,4,4)
minimize{np.einsum('jk,ikp,pq->ijq', x1, A, x2)-B}
return: x1,x2: shape(4,4)
'''
def func(x,a,b):
x1 = x[:16].reshape(4,4)
x2 = x[16:].reshape(4,4)
@qzane
qzane / utils.py
Created April 29, 2020 19:19
Some scripts for medical image processing
View utils.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 28 14:34:17 2018
@author: qzane
"""
import os,sys
import numpy as np
@qzane
qzane / detectron2-on-longleaf.md
Created November 10, 2019 19:46
detectron2-on-longleaf.md
View detectron2-on-longleaf.md

how to run detectron2 on longleaf

1. install anaconda

module add anaconda
module add gcc/4.9.1
module add cuda/9.2
module save
@qzane
qzane / make_dataset.py
Last active August 17, 2022 08:55
dataset maker for CIHP_PGN
View make_dataset.py
# dataset maker for https://github.com/Engineering-Course/CIHP_PGN
# author: qzane@live.com
import os,sys,shutil
from PIL import Image
import numpy as np
DATA_TYPE = ['png','PNG','jpg','JPG']
def main():
USAGE = "python %s /path_to_images name_of_dataset" % sys.argv[0]
@qzane
qzane / Kaizo_Trap.py
Last active May 14, 2018 06:20
Kaizo_Trap.py
View Kaizo_Trap.py
"""
Created on May 14 2018
@author: qzane
"""
import os,sys
import requests
from lxml import etree
MOVIE0 = r'https://www.youtube.com/watch?v=lIES3ii-IOg'
@qzane
qzane / touch.ino
Last active April 22, 2018 04:14
FEH auto play script for arduino leonardo
View touch.ino
#include<Mouse.h>
//sleep 5;sudo ./arduino --board arduino:avr:leonardo --upload ~/arduino/touch/touch.ino --port /dev/ttyACM7
void setup(){
delay(5000);
Mouse.begin();
}
void tap(unsigned long x,unsigned long y){
int tmpX, tmpY;
x = x / 3; //I dont know why, x, y is in pixel