分类标签归档:Python

[ docker部署opencv ]


docker部署opencv而且容器内的cv2.show显示到主机外面

  • 目前是在debian12系统中测试

1. 配置ssh打开x服务器转发图形

修改文件/etc/ssh/sshd_config, 搜索X11 ForwardX11 yes,X11Forwarding yes

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bi

< Read more >

[ Python弱引用 ]


weakref

本视频介绍了Python中的弱引用,即通过弱引用实现对对象引用计数,并在引用计数为零时将对象从字典中删除。同时,本视频还讲解了weak valid dictionary和weak key dictionary的概念和使用方法

import weakref

players = weakref.WeakKeyDictionary()

class Player:
    ...

# 报错
players[1]

# ???
players[Player]

< Read more >

[ python人性化时间处理 ]


时间人性化(案例)

import datetime
import pendulum

# 把需要转换的时间字符串转为datetime对象,再转为字符串
now = datetime.datetime.strptime('2022-11-11 14:13:32', '%Y-%m-%d %H:%M:%S')
new_str = now.strftime('%Y-%m-%d %H:%M:%S')

# 把字符串转为pendulum时间对象
pt = pendulum.parse(new_str, tz='Asia/Shanghai')

< Read more >

[ pycharm2023.3.4破解 ]


linux版本pycharm[2023.3.4]

一.pycharm2023.3.4官方linux版本rar(下载后自行修改文件名)

  • 自行安装完成后再破解

二.破解工具下载(下载后自行修改文件名)

1.解压rar文件后

2.进入需要使用的方法(当前使用的是3号方法到2025年)

3.复制jetbra文件夹到一个全英文路径的目录下, 随后进入,执行文件夹scripts内的

sudo bash install.sh

  1. 把vmoptions文件夹里的pycharm.vmoptions最后几行, 添加到pycharm安装目录内bin/pycharm64.vmoptions 这三行
-ja

< Read more >

[ python生成pdf ]


生成Pdf

  1. 页眉, 页尾, 画图, 表格, 画线...
from reportlab.pdfbase import pdfmetrics   # 注册字体
from reportlab.pdfbase.ttfonts import TTFont # 字体类
from reportlab.platypus import Table, SimpleDocTemplate, Paragraph, Image ,Frame, PageTemplate, Spacer, TableStyle, BaseDocTemplate# 报告内容相关类,
from reportlab.lib.pagesize

< Read more >

[ cv2[opencv] ]


基础

hsv_image = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

hsv_image是通过将BGR图像转换为HSV颜色空间而得到的新图像。它包含了与原始图像相同的尺寸,但颜色通道由BGR转换为HSV。

具体地说,hsv_image是一个三维数组,其形状与原始图像相同(通常是高度 x 宽度 x 3)。它的三个通道分别表示色相(Hue)、饱和度(Saturation)和明度(Value),这些通道的值范围如下:

色相(Hue)通道:取值范围为0到179,表示不同类型的颜色。
饱和度(Saturation)通道:取值范围为0到255,表示颜色的纯度或鲜艳

< Read more >

[ 河东楼[htd项目] ]


一. setting.json配置文件

  • 检测视频配置开关
    • 鼠标检测开关
    • 屏幕全屏检测开关
    • 图片检测开关
    • 脱机检测开关
"Abnormal_Screen": {
            "Enabled": true,  // 视频检查
            "Detect_Cursor": {
                "Enabled": true,  // 鼠标检测开关
                "Enable_Mask": false,  // 开启后会使用图1和图2

< Read more >

[ fastapi使用sqlalchemy2.0异步数据库 ]


fastapi使用sqlalchemy2.0异步数据库

pip install SQLAlchemy
pip install aiomysql
pip install pydantic-settings
pip install python-dotenv

配置文件config.py

from pydantic_settings import BaseSettings
from functools import lru_cache

class Settings(BaseSettings):
    app_name: str = "chf-app"
    databa

< Read more >