Skip to content

Instantly share code, notes, and snippets.

View HViktorTsoi's full-sized avatar

KINO HViktorTsoi

  • BUAA
View GitHub Profile
@HViktorTsoi
HViktorTsoi / List.xml
Created October 18, 2018 14:11
解决Android的ScrollVIew嵌套一个ListView之后多个条目ListView显示不全的问题
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:fadingEdge="vertical"
@HViktorTsoi
HViktorTsoi / FrameItemAdapter.java
Created October 22, 2018 15:48
android gridview多选的坑
package buaa.ldmc.hvt.videoabstract.Adapters;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
@HViktorTsoi
HViktorTsoi / mayavi_point3d.py
Created January 23, 2019 14:49
mayavi在不改变大小的情况下设置colormap
cl_rst = np.array(clustering.labels_)
print(frame_file)
fig = mayavi.mlab.figure(mlab.gcf(), bgcolor=(0, 0, 0), size=(640 * 2, 360 * 2))
nodes = mayavi.mlab.points3d(
xx, yy, zz,
# clustering.labels_,
# mode="cube",
mode="cube",
# color=(0, 1, 0),
@HViktorTsoi
HViktorTsoi / mpl_poly.py
Created February 24, 2019 13:57
matplotlib绘制多边形
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
fig, ax = plt.subplots()
patches = []
num_polygons = 5
@HViktorTsoi
HViktorTsoi / np_linepace_matrix.py
Last active March 22, 2019 09:41
numpy 从长序列中采样一批段序列 (linespace 等差矩阵)
# 如果我们要生成一个等差递增的矩阵,而不仅仅是等差递增的向量
# linescape仍然能满足我们的需求
# 需要实现的是,从一个长度为L的连续的序列中随机选取BATCH_SIZE数量的,长度为l(较短)的若干短序列
# 举个例子,想象我们有一篇文章,每一个词向量是一个元素,那么整个文章就构成了一个长度为L的词序列
# 现在我们要实现的就是,从这篇文章重随机抽取一批短的词序列,比如抽取100条,长度为5的词序列
# 我们要实现的就是这样的功能
batch_size=512
L=20000
l=5 # 要取的长度
@HViktorTsoi
HViktorTsoi / numeric_file_sort.py
Created April 12, 2019 08:31
python 名称含数字文件排序
dir = '/media/f214/workspace/sky/logs/AUDIT/2019-04-12_16-12-42'
file_list = os.listdir(os.path.join(dir, 'output_log'))
# -4 denotes the length of file extension, ie, '.csv' is -4, '.mpeg' is-5.
file_list.sort(key=lambda f: int(f[:-4]))
@HViktorTsoi
HViktorTsoi / kalman_acc.py
Created April 18, 2019 06:52
Python opencv 卡尔曼滤波 加速运动方程问题
# dt是数值,可通过调整dt的数量级来实现不同阶数的运动方程
# 比如匀加速运动, 其中X=X(n-1)+V(n-1)dt+a(n-1)dt^2
# 这时可以在运动描述矩阵中,将dt设置为0.1,dt^2设置为0.01
@HViktorTsoi
HViktorTsoi / dataset_generate.md
Last active May 1, 2019 17:06
insight face 生成自己的数据集

首先将数据集组织成

|--数据集名称

|--人脸ID_1

  |--人脸ID_1的脸部图像.jpg

  |--人脸ID_1的脸部图像.jpg
@HViktorTsoi
HViktorTsoi / calc_roc.py
Created May 7, 2019 09:45
计算ROC曲线
import scipy
import scipy.io as scio
import numpy as np
import cv2
import sklearn
from sklearn.decomposition import PCA
from sklearn.neighbors import KNeighborsClassifier
from sklearn import metrics
import matplotlib.pyplot as plt
import pickle as pkl
@HViktorTsoi
HViktorTsoi / calc_roc.py
Last active May 7, 2019 09:52
计算ROC曲线 其中calc_roc.py是给定预测结果和gt计算tpr和fpr数据的函数 example.py是调用clac_roc绘制roc的样例代码
import scipy
import scipy.io as scio
import numpy as np
import cv2
import sklearn
from sklearn.decomposition import PCA
from sklearn.neighbors import KNeighborsClassifier
from sklearn import metrics
import matplotlib.pyplot as plt
import pickle as pkl