This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.rcParams["figure.figsize"] = [7.50, 3.50] | |
plt.rcParams["figure.autolayout"] = True | |
raw_rgb = plt.imread("VTA_trial.png") | |
iso_blue = raw_rgb[..., 2] - raw_rgb[..., 0] | |
iso_blue = np.maximum(iso_blue, np.full_like(iso_blue, 0.01)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib import animation | |
import sys | |
# input be of shape n (1d), then (periodic convolution) | |
def get_H(isi: np.ndarray): | |
n = isi.shape[0] | |
result_h = [] | |
for i in range(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
__LOG_10__ = 2.3025851249694824 | |
mse_loss_func = lambda src, dst: ((src - dst) ** 2).mean() | |
psnr_func = lambda x: -10. * np.log(x) / __LOG_10__ | |
def solve_mls(X: np.ndarray, data: np.ndarray) -> np.ndarray: | |
XXt = X.T @ X | |
u, s, _ = np.linalg.svd(XXt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::mpsc; | |
use std::time::Duration; | |
struct AsyncTimerEvent<T> where T: Send + 'static { | |
receiver: Option<mpsc::Receiver<T>>, | |
sleep_time: u64, | |
} | |
impl<T> AsyncTimerEvent<T> where T: Send + 'static { | |
pub fn new(sleep_sec: u64) -> AsyncTimerEvent<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* async returns future, which implicitly blocks the thread (waiting) | |
* | |
*/ | |
#include <future> | |
#include <thread> | |
#include <mutex> | |
#include <iostream> | |
#include <chrono> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* async returns future, which implicitly blocks the thread (waiting) | |
* | |
*/ | |
#include <thread> | |
#include <mutex> | |
#include <iostream> | |
#include <chrono> | |
#include <atomic> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var all_check_box = document.getElementsByClassName("sc-panel-content bh-clearfix bh-mv-8 wjzb-card-jskc"); | |
for (let i=0; i < (all_check_box.length - 1);i++) { | |
let choice = Math.floor(Math.random() * 10) % 2; | |
all_check_box[i].children[1].children[0].children[choice].click(); | |
} | |
var text_box = document.getElementsByClassName("bh-txt-input"); | |
text_box[0].children[0].value = "老师很不错"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#人脸识别开关 | |
import sensor, time, image #导入模块 | |
from pyb import LED #导入模块 | |
from pyb import DAC # DAC | |
# 设定图像基本参数 | |
sensor.reset() #初始化摄像头 | |
sensor.set_contrast(2) #亮度-3至3 | |
sensor.set_gainceiling(2) #增益 | |
sensor.set_framesize(sensor.QVGA) #图像格式 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def distanceField(sp, ep): | |
brx, bry = ep + np.array([25, 25]) | |
direct = (ep - sp).astype(np.float64) | |
direct /= np.linalg.norm(direct) | |
normal = np.array([-direct[1], direct[0]], dtype = np.float64) | |
result = np.zeros((bry, brx)) | |
for i in range(bry): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 as cv | |
import numpy as np | |
import imageio | |
class Link: | |
collision = False | |
def __init__(self, link_len = 10): | |
self.buf_1 = np.zeros(link_len) | |
self.buf_2 = np.zeros(link_len) | |
self.link_len = link_len |