随笔分类 - Python
Python zone
摘要:PIL resize from PIL import Image # Open the image img = Image.open("20230222100736979.jpg") # Resize the image img = img.resize((img.width*2, img.heig
阅读全文
摘要:python opencv Sharpened import cv2 import numpy as np # Load the image img = cv2.imread('20230222100736979.jpg') # Define the sharpening kernel kernel
阅读全文
摘要:python 调用java import subprocess # Replace "path/to/java/program" with the actual path to your Java program java_program_path = "path/to/java/program"
阅读全文
摘要:import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('20230222100736979.jpg', 0) hist = cv2.calcHist([img], [0], None,
阅读全文
摘要:python opencv 分割像素通道 import cv2 import numpy as np # Load the image img = cv2.imread('path/to/image.jpg') # Split the image into its channels b, g, r
阅读全文
摘要:python 操作csv 写csv import csv with open('path/to/file.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile, delimiter=',', quotechar='"', quo
阅读全文
摘要:python操作excel pip install openpyxl 写: import openpyxl # Load the workbook workbook = openpyxl.load_workbook('path/to/file.xlsx') # Select the workshee
阅读全文
摘要:python opencv putText import cv2 # Load image img = cv2.imread("image.jpg") # Define text to draw text = "Hello, World!" # Define position to draw tex
阅读全文
摘要:python播放视频 pip install pygame import pygame pygame.init() # Set the dimensions of the window screen = pygame.display.set_mode((640, 480)) # Load the v
阅读全文
摘要:python time测试 import time def timer(seconds): start_time = time.time() while True: elapsed_time = time.time() - start_time if elapsed_time >= seconds:
阅读全文
摘要:python opencv inRange import cv2 import numpy as np # Load the image img = cv2.imread('20220320151016_144_c.jpg') hsv = cv2.cvtColor(img,cv2.COLOR_BGR
阅读全文
摘要:python opencv line import cv2 # Load an image img = cv2.imread("image1.jpg") # Draw a red line from (0, 0) to (100, 100) with a thickness of 5 pixels
阅读全文
摘要:python datetime日期格式化 from datetime import datetime currentDateTime = datetime.now() print(currentDateTime.strftime("%Y-%m-%d %H:%M:%S")) #############
阅读全文
摘要:QHBoxLayout清空子控件 layout = QHBoxLayout() widget1 = QLabel("Widget 1") widget2 = QLabel("Widget 2") widget3 = QLabel("Widget 3") layout.addWidget(widget
阅读全文
摘要:python判断是否是零时 from datetime import datetime now = datetime.now() if now.hour == 0 and now.minute == 0 and now.second == 0: print("It's midnight!") ###
阅读全文
摘要:QLabel 显示opencv Mat import cv2 from PyQt5.QtGui import QImage, QPixmap from PyQt5.QtWidgets import QLabel label = QLabel() # Load the image using Open
阅读全文
摘要:QDateTime计算时间差 from PyQt5.QtCore import QDateTime # Create two QDateTime objects dt1 = QDateTime.currentDateTime() dt2 = QDateTime(2022, 1, 1, 0, 0) #
阅读全文
摘要:python pygame播放音频文件 pip install pygame import pygame # Initialize pygame pygame.init() # Load the MP3 file pygame.mixer.music.load("1.mp3") # Play the
阅读全文
摘要:pyqt播放音频 from PyQt5.QtCore import QUrl from PyQt5.QtMultimedia import QMediaPlayer from PyQt5.QtWidgets import QApplication import sys app = QApplicat
阅读全文
摘要:python opencv line import cv2 # Load the image img = cv2.imread('path/to/image.jpg') # Draw a red line from (0, 0) to (100, 100) with a thickness of 5
阅读全文