
code
chyao7
这个作者很懒,什么都没留下…
展开
-
Dot product
from torch import nnclass DotProductSimilarity(nn.Module): def __init__(self,scale_output=True): super(DotProductSimilarity,self).__init__() self.scale_output=scale_output def forward(self,tensor_1,tensor_2): result=(tensor原创 2021-06-29 16:34:42 · 368 阅读 · 0 评论 -
TVL1计算光流,并进行warp
TVL1计算光流,并进行warp## TVL1光流import cv2def compute_TVL1(prev, curr): """Compute the TV-L1 optical flow.""" TVL1 = cv2.optflow.DualTVL1OpticalFlow_create() # TVL1 = cv2.DualTVL1OpticalFlow_create() # TVL1=cv2.createOptFlow_DualTVL1()# t原创 2021-06-29 16:28:45 · 2591 阅读 · 3 评论 -
python opencv VideoCapture 视屏获取
控制电脑摄像头,按q结束import cv2 as cv # 0表示摄像头的编号capture = cv.VideoCapture(0)while(True): # 获取一帧 # 第1个参数ret(return value缩写)是一个布尔值,表示当前这一帧是否获取正确 ret, frame = capture.read()# print(frame) # 将这帧转换为灰度图# gray = cv.cvtColor(frame, cv.COLOR_原创 2021-06-08 09:53:58 · 631 阅读 · 0 评论 -
docker 命令
查看运行容器docker psdocker ps -a停止运行容器docker stop id删除容器docker rm id删除镜像docker rmi ***原创 2020-12-14 13:39:54 · 239 阅读 · 0 评论 -
为文字图片添加文本框和文字标注
```pythonimport cv2from PIL import Imagefrom PIL import ImageDraw,ImageFontimport numpy as npdef cv2ImgAddText(img, text, left, top, textColor=(0, 255, 0), textSize=20): if (isinstance(img, np.ndarray)): # 判断是否OpenCV图片类型 img = Image.fro.原创 2020-12-01 15:22:47 · 1175 阅读 · 0 评论 -
python 版本 base64 图片转换
import base64f=open('Image.png','rb') #二进制方式打开图文件ls_f=base64.b64encode(f.read()) #读取文件内容,转换为base64编码f.close()print(ls_f)import base64bs='iVBORw0KGgoAAAANSUhEUg....' # 太长了省略imgdata=base64.b64decode(bs)file=open('2.jpg','wb')file.write(imgdata)fil原创 2020-11-20 10:45:27 · 3828 阅读 · 0 评论 -
缩放图片至固定大小,尺寸不足以0填充
缩放图片至固定大小,尺寸不足以0填充def scale(img, long_size=192,short_size=48): h, w = img.shape[0:2] a = short_size - h b = long_size - w if a > 0: img = np.pad(img,(0,a),(0,0),(0,0),"constant",constant_values=0) if b> 0: img =原创 2020-11-20 09:44:34 · 1404 阅读 · 1 评论