同步bin
This commit is contained in:
parent
cf89f3d12b
commit
4e415c41ac
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ Superstar_log.ldf
|
||||
.vs
|
||||
build.bat
|
||||
*.exe
|
||||
bin/*
|
||||
bin/logfile.txt
|
||||
.gitignore
|
||||
|
BIN
bin/ButtonImages/服務鈴.png
Normal file
BIN
bin/ButtonImages/服務鈴.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
77245
bin/data/KSongDatabase.sql
Normal file
77245
bin/data/KSongDatabase.sql
Normal file
File diff suppressed because it is too large
Load Diff
BIN
bin/data/歌星.xlsx
Normal file
BIN
bin/data/歌星.xlsx
Normal file
Binary file not shown.
45
bin/py/display_excel_sheets.py
Normal file
45
bin/py/display_excel_sheets.py
Normal file
@ -0,0 +1,45 @@
|
||||
import pandas as pd
|
||||
import sqlite3
|
||||
|
||||
# 读取Excel文件
|
||||
excel_file_path = '歌星.xlsx' # 替换为你的Excel文件路径
|
||||
|
||||
# 使用ExcelFile类获取工作表名称
|
||||
excel_file = pd.ExcelFile(excel_file_path, engine='openpyxl')
|
||||
sheet_names = excel_file.sheet_names
|
||||
|
||||
# 选择你想要导入的工作表
|
||||
sheet_to_import = '工作表1' # 替换为你实际的工作表名称
|
||||
df = pd.read_excel(excel_file_path, sheet_name=sheet_to_import, engine='openpyxl')
|
||||
|
||||
# 打印前五行内容
|
||||
print(f"工作表: {sheet_to_import}")
|
||||
print(df.head(), "\n")
|
||||
|
||||
# 连接到SQLite数据库(如果数据库不存在,会自动创建)
|
||||
conn = sqlite3.connect('KSongDatabase.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取列名
|
||||
columns = df.columns.tolist()
|
||||
|
||||
# 动态生成CREATE TABLE语句
|
||||
table_name = 'ArtistLibrary'
|
||||
create_table_sql = f'CREATE TABLE IF NOT EXISTS {table_name} ('
|
||||
create_table_sql += ', '.join([f'"{col}" TEXT' for col in columns])
|
||||
create_table_sql += ')'
|
||||
|
||||
# 执行CREATE TABLE语句
|
||||
cursor.execute(create_table_sql)
|
||||
|
||||
# 将DataFrame的数据写入SQLite表
|
||||
df.to_sql(table_name, conn, if_exists='append', index=False)
|
||||
|
||||
# 验证数据是否插入成功
|
||||
print("数据插入后前五行内容:")
|
||||
query_result = pd.read_sql_query(f"SELECT * FROM {table_name} LIMIT 5", conn)
|
||||
print(query_result)
|
||||
|
||||
# 提交事务并关闭连接
|
||||
conn.commit()
|
||||
conn.close()
|
58
bin/py/generate_config_ini.py
Normal file
58
bin/py/generate_config_ini.py
Normal file
@ -0,0 +1,58 @@
|
||||
from configparser import ConfigParser
|
||||
|
||||
# Define the base paths for the normal, mouseDown, and mouseOver images
|
||||
normal_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
mouse_down_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
mouse_over_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
|
||||
# Create a ConfigParser object
|
||||
config = ConfigParser()
|
||||
config.optionxform = str # Preserve case for option names
|
||||
|
||||
# # Add the section for EnglishLetterButtonImages
|
||||
# config.add_section("EnglishLetterButtonImages")
|
||||
config.add_section("PinYinLetterButtonImages")
|
||||
|
||||
# # Define the QWERTY layout sequence
|
||||
# qwerty_layout = "QWERTYUIOPASDFGHJKLZXCVBNM"
|
||||
|
||||
# Add the image paths dynamically based on the QWERTY layout coordinates
|
||||
for i in range(26):
|
||||
if i < 19:
|
||||
normal_image_number = i + 3
|
||||
mouse_down_image_number = i + 32
|
||||
mouse_over_image_number = i + 3
|
||||
else:
|
||||
normal_image_number = i + 4
|
||||
mouse_down_image_number = i + 33
|
||||
mouse_over_image_number = i + 4
|
||||
|
||||
normal_image = f"{normal_base_path}{normal_image_number:02}.png"
|
||||
mouse_down_image = f"{mouse_down_base_path}{mouse_down_image_number:02}.png"
|
||||
mouse_over_image = f"{mouse_over_base_path}{mouse_over_image_number:02}.png"
|
||||
|
||||
# Add the image paths to the config
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_normal", normal_image)
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_mouseDown", mouse_down_image)
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_mouseOver", mouse_over_image)
|
||||
|
||||
# Add the image paths dynamically for NumberButtonImages
|
||||
# for i in range(10):
|
||||
# normal_image_number = i + 3
|
||||
# mouse_down_image_number = i + 42
|
||||
# mouse_over_image_number = i + 3
|
||||
|
||||
# normal_image = f"{normal_base_path}{normal_image_number:02}.png"
|
||||
# mouse_down_image = f"{mouse_down_base_path}{mouse_down_image_number:02}.png"
|
||||
# mouse_over_image = f"{mouse_over_base_path}{mouse_over_image_number:02}.png"
|
||||
|
||||
# # Add the image paths to the config
|
||||
# config.set("NumberButtonImages", f"button{i}_normal", normal_image)
|
||||
# config.set("NumberButtonImages", f"button{i}_mouseDown", mouse_down_image)
|
||||
# config.set("NumberButtonImages", f"button{i}_mouseOver", mouse_over_image)
|
||||
|
||||
# Write the config to file
|
||||
with open("config.ini", "a", encoding="utf-8") as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
print("config.ini file has been updated successfully.")
|
43
bin/py/singer_pinyin_converter.py
Normal file
43
bin/py/singer_pinyin_converter.py
Normal file
@ -0,0 +1,43 @@
|
||||
import sqlite3
|
||||
from pypinyin import lazy_pinyin, Style
|
||||
from tqdm import tqdm
|
||||
|
||||
def chinese_to_initials(chinese_str):
|
||||
pinyin_list = lazy_pinyin(chinese_str, style=Style.FIRST_LETTER)
|
||||
initials = ''.join([char.upper() for char in pinyin_list])
|
||||
return initials
|
||||
|
||||
# 連接到 SQLite 資料庫
|
||||
conn = sqlite3.connect('KSongDatabase.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 確保 SongLibrary 表中有 SingerA_pinyin 和 SingerB_pinyin 欄位
|
||||
# cursor.execute('''ALTER TABLE SongLibrary ADD COLUMN 歌星A拼音 TEXT''')
|
||||
# cursor.execute('''ALTER TABLE SongLibrary ADD COLUMN 歌星B拼音 TEXT''')
|
||||
|
||||
# 讀取所有的歌手名稱
|
||||
cursor.execute("SELECT [歌曲編號], [歌星 A], [歌星 B] FROM SongLibrary")
|
||||
rows = cursor.fetchall()
|
||||
|
||||
# 使用 tqdm 來顯示進度條
|
||||
for row in tqdm(rows, desc="Processing songs", unit="song"):
|
||||
song_id, singer_a, singer_b = row
|
||||
if singer_a:
|
||||
singer_a_pinyin = chinese_to_initials(singer_a)
|
||||
else:
|
||||
singer_a_pinyin = None
|
||||
|
||||
if singer_b:
|
||||
singer_b_pinyin = chinese_to_initials(singer_b)
|
||||
else:
|
||||
singer_b_pinyin = None
|
||||
|
||||
# 更新資料庫
|
||||
cursor.execute(
|
||||
"UPDATE SongLibrary SET 歌星A拼音 = ?, 歌星B拼音 = ? WHERE [歌曲編號] = ?",
|
||||
(singer_a_pinyin, singer_b_pinyin, song_id)
|
||||
)
|
||||
|
||||
# 提交變更並關閉資料庫連接
|
||||
conn.commit()
|
||||
conn.close()
|
BIN
bin/sounds/zs.m4a
Normal file
BIN
bin/sounds/zs.m4a
Normal file
Binary file not shown.
33
bin/themes/superstar/py/test.py
Normal file
33
bin/themes/superstar/py/test.py
Normal file
@ -0,0 +1,33 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# Load the image
|
||||
image_path = 'toggle_light.jpg'
|
||||
image = cv2.imread(image_path)
|
||||
|
||||
# Convert to grayscale
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
# Set threshold for non-white color
|
||||
# Note: Adjust the threshold values based on your image's specific conditions
|
||||
upper_threshold = 220 # Anything below this will be considered as non-white
|
||||
|
||||
# Create a mask for non-white regions (below the threshold value)
|
||||
mask = cv2.inRange(gray, 0, upper_threshold)
|
||||
|
||||
# Find contours from the mask
|
||||
contours, hierarchy = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# Draw contours or compute bounding boxes
|
||||
for contour in contours:
|
||||
# Calculate the bounding rectangle for each non-white region
|
||||
x, y, w, h = cv2.boundingRect(contour)
|
||||
print(f"Bounding box coordinates: X: {x}, Y: {y}, Width: {w}, Height: {h}")
|
||||
|
||||
# Optional: Draw the bounding box on the original image
|
||||
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
||||
|
||||
# Display the results
|
||||
cv2.imshow('Image with Bounding Boxes', image)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
80
bin/themes/superstar/py/test2.py
Normal file
80
bin/themes/superstar/py/test2.py
Normal file
@ -0,0 +1,80 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# 初始化坐标点
|
||||
roi_pts = []
|
||||
drawing = False # True if the mouse is pressed down
|
||||
|
||||
# 鼠标回调函数
|
||||
def select_roi(event, x, y, flags, param):
|
||||
global roi_pts, drawing
|
||||
|
||||
# 当按下左键是记录起始位置坐标
|
||||
if event == cv2.EVENT_LBUTTONDOWN:
|
||||
drawing = True
|
||||
roi_pts = [(x, y)]
|
||||
|
||||
# 当鼠标左键按下并移动是绘制图形
|
||||
elif event == cv2.EVENT_MOUSEMOVE:
|
||||
if drawing == True:
|
||||
temp_image = param.copy()
|
||||
cv2.rectangle(temp_image, roi_pts[0], (x, y), (0, 255, 0), 2)
|
||||
cv2.imshow('image', temp_image)
|
||||
|
||||
# 当松开鼠标左键停止绘画
|
||||
elif event == cv2.EVENT_LBUTTONUP:
|
||||
drawing = False
|
||||
roi_pts.append((x, y))
|
||||
cv2.rectangle(param, roi_pts[0], (x, y), (0, 255, 0), 2)
|
||||
cv2.imshow('image', param)
|
||||
|
||||
# 读取图像
|
||||
image = cv2.imread('555024.jpg')
|
||||
image_copy = image.copy()
|
||||
cv2.namedWindow('image')
|
||||
cv2.setMouseCallback('image', select_roi, image)
|
||||
|
||||
# Keep looping until the 'q' key is pressed
|
||||
while True:
|
||||
cv2.imshow('image', image)
|
||||
key = cv2.waitKey(1) & 0xFF
|
||||
|
||||
# 按下'r'重置选择区域
|
||||
if key == ord('r'):
|
||||
image = image_copy.copy()
|
||||
roi_pts = []
|
||||
|
||||
# 按下'q'退出循环
|
||||
elif key == ord('q'):
|
||||
break
|
||||
|
||||
# 关闭所有打开的窗口
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
# 如果选择了区域,那么进行黄色检测
|
||||
if len(roi_pts) == 2:
|
||||
roi = image_copy[roi_pts[0][1]:roi_pts[1][1], roi_pts[0][0]:roi_pts[1][0]]
|
||||
hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV)
|
||||
lower_yellow = np.array([20, 100, 100])
|
||||
upper_yellow = np.array([30, 255, 255])
|
||||
mask = cv2.inRange(hsv_roi, lower_yellow, upper_yellow)
|
||||
|
||||
# 在掩码上找出轮廓
|
||||
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# 如果有轮廓则找出最大的轮廓
|
||||
if contours:
|
||||
max_contour = max(contours, key=cv2.contourArea)
|
||||
x, y, w, h = cv2.boundingRect(max_contour)
|
||||
cv2.rectangle(roi, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
||||
print(f"Yellow area at X: {x}, Y: {y}, W: {w}, H: {h}")
|
||||
|
||||
# 将边界框位置映射回原始图像
|
||||
x += roi_pts[0][0]
|
||||
y += roi_pts[0][1]
|
||||
cv2.rectangle(image_copy, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
||||
print(f"Yellow area at X: {x}, Y: {y}, W: {w}, H: {h}")
|
||||
|
||||
cv2.imshow('Detected Yellow Area in ROI', image_copy)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
55
bin/themes/superstar/py/test3.py
Normal file
55
bin/themes/superstar/py/test3.py
Normal file
@ -0,0 +1,55 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
# 使用絕對路徑
|
||||
image_path = 'image.jpg'
|
||||
# if not os.path.exists(image_path):
|
||||
# print("File does not exist:", image_path)
|
||||
# else:
|
||||
# print("File exists, attempting to load...")
|
||||
image = cv2.imread(image_path)
|
||||
|
||||
if image is None:
|
||||
print("But failed to load.")
|
||||
else:
|
||||
print("Image loaded successfully, processing...")
|
||||
|
||||
# Convert to HSV color space
|
||||
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
||||
|
||||
# Define the range for yellow color in HSV
|
||||
# Adjust these ranges based on your specific yellow color and lighting conditions
|
||||
lower_yellow = np.array([20, 100, 100])
|
||||
upper_yellow = np.array([30, 255, 255])
|
||||
lower_pink = np.array([140, 100, 100])
|
||||
upper_pink = np.array([170, 255, 255])
|
||||
lower_purple = np.array([129, 50, 50]) # Lower bound of purple
|
||||
upper_purple = np.array([158, 255, 255]) # Upper bound of purple
|
||||
lower_blue = np.array([110, 50, 50]) # Lower bound of blue
|
||||
upper_blue = np.array([130, 255, 255]) # Upper bound of blue
|
||||
lower_blue_violet = np.array([120, 50, 50]) # Lower bound of blue-violet
|
||||
upper_blue_violet = np.array([160, 255, 255]) # Upper bound of blue-violet
|
||||
lower_red2 = np.array([170, 100, 100])
|
||||
upper_red2 = np.array([180, 255, 255])
|
||||
|
||||
# Create a mask for yellow color
|
||||
mask = cv2.inRange(hsv, lower_pink, upper_pink)
|
||||
|
||||
# Find contours on the mask
|
||||
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# Draw all contours
|
||||
for contour in contours:
|
||||
x, y, w, h = cv2.boundingRect(contour)
|
||||
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
||||
coordinates_text = f"X: {x}, Y: {y}, W: {w}, H: {h}"
|
||||
# if w > 100:
|
||||
print(coordinates_text)
|
||||
# Display coordinates on the image
|
||||
cv2.putText(image, coordinates_text, (x, y-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
|
||||
|
||||
# Show the image with all bounding boxes drawn
|
||||
cv2.imshow('Image with yellow contours', image)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
40
bin/themes/superstar/py/test4.py
Normal file
40
bin/themes/superstar/py/test4.py
Normal file
@ -0,0 +1,40 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
def detect_light_areas(image_path):
|
||||
# 讀取圖片
|
||||
image = cv2.imread(image_path)
|
||||
if image is None:
|
||||
print("Failed to load image.")
|
||||
return
|
||||
|
||||
# 將圖片從 BGR 轉換到 HSV 色彩空間
|
||||
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
||||
|
||||
# 設定 HSV 閾值範圍來選取淺色區域
|
||||
lower_hsv = np.array([0, 0, 70]) # 較低的 HSV 閾值
|
||||
upper_hsv = np.array([180, 50, 255]) # 較高的 HSV 閾值
|
||||
|
||||
# 創建遮罩
|
||||
mask = cv2.inRange(hsv, lower_hsv, upper_hsv)
|
||||
|
||||
# 找到遮罩上的輪廓
|
||||
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# 在原始圖片上畫框
|
||||
for contour in contours:
|
||||
x, y, w, h = cv2.boundingRect(contour)
|
||||
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) # 綠色方框,2像素寬
|
||||
text = f"X:{x} Y:{y} W:{w} H:{h}"
|
||||
if w < 40 or h < 40:
|
||||
continue
|
||||
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 2) # 白色文字
|
||||
|
||||
# 顯示原圖和結果
|
||||
cv2.imshow('Original', image)
|
||||
# cv2.imshow('Light Areas Detected', mask) # 顯示遮罩
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
# 使用上面的函數
|
||||
detect_light_areas('555011.jpg') # 請更換為實際的圖片路徑
|
30
bin/themes/superstar/py/test5.py
Normal file
30
bin/themes/superstar/py/test5.py
Normal file
@ -0,0 +1,30 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# Load the image
|
||||
image_path = '555020.jpg' # replace with your image path
|
||||
image = cv2.imread(image_path)
|
||||
|
||||
# Convert to grayscale
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
# Apply thresholding to get binary image
|
||||
_, binary = cv2.threshold(gray, 240, 255, cv2.THRESH_BINARY)
|
||||
|
||||
# Find contours of the white regions
|
||||
contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# Draw contours on the original image (optional, for visualization)
|
||||
for contour in contours:
|
||||
cv2.drawContours(image, [contour], -1, (0, 255, 0), 2)
|
||||
|
||||
# Print positions of the white regions
|
||||
for i, contour in enumerate(contours):
|
||||
x, y, w, h = cv2.boundingRect(contour)
|
||||
if w > 100:
|
||||
print(f"White region {i+1}: x={x}, y={y}, width={w}, height={h}")
|
||||
|
||||
# Show the image with contours (optional, for visualization)
|
||||
cv2.imshow('White regions', image)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
25
bin/themes/superstar/py/test6.py
Normal file
25
bin/themes/superstar/py/test6.py
Normal file
@ -0,0 +1,25 @@
|
||||
from PIL import Image
|
||||
|
||||
def change_image_dpi(input_path, output_path, new_dpi):
|
||||
# 打开图像
|
||||
image = Image.open(input_path)
|
||||
|
||||
# 获取当前的dpi值(如果有)
|
||||
dpi = image.info.get('dpi', (72, 72))
|
||||
print(f"当前DPI: {dpi}")
|
||||
|
||||
# 保存图像并设置新的dpi值
|
||||
image.save(output_path, dpi=(new_dpi, new_dpi))
|
||||
print(f"DPI已更改为: {new_dpi}")
|
||||
|
||||
# 输入图像路径
|
||||
input_image_path = "image.jpg"
|
||||
|
||||
# 输出图像路径
|
||||
output_image_path = "image.jpg"
|
||||
|
||||
# 目标DPI
|
||||
new_dpi = 96
|
||||
|
||||
# 调用函数
|
||||
change_image_dpi(input_image_path, output_image_path, new_dpi)
|
Reference in New Issue
Block a user