日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

pythongui界面复选框数值选择并求和_如何使用Python从图像中分离复选框按钮和复......

發布時間:2025/3/15 python 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pythongui界面复选框数值选择并求和_如何使用Python从图像中分离复选框按钮和复...... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我已經拆分了以并行方式排列的圖像,并像下面的圖像一樣保存了它們.

這是我的工作代碼,用于拆分方形復選框和該圖像中的文本.

# Import necessary libraries

from matplotlib import pyplot as plt

import cv2

# Read image

image = cv2.imread('data_2/5.png')

# Height and width of the image

height, width = image.shape[:2]

print("Dimensions of the image.")

print("Height:",height)

print("Width:",width)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

gray = cv2.GaussianBlur(gray, (5,5), 0)

# Finding Edges

edges = cv2.Canny(gray, 60, 255)

# contours -> an outline representing or bounding the shape.

_,cnts, hierarchy = cv2.findContours(edges.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

contours = sorted(cnts, key=cv2.contourArea, reverse=True)[:10]

count = 1

for contour in contours:

if(count<=4):

#print("Count:",count)

count = count + 1

area = cv2.contourArea(contour)

if area > 100000 and area < 1000:

contours.remove(contour)

perimeter = cv2.arcLength(contour, True)

approx = cv2.approxPolyDP(contour, 0.01*perimeter, True)

if len(approx) == 4:

cv2.circle(image, (720, 360), 5, (255,0,0), 5)

cv2.drawContours(image, [approx], -1, (0, 255, 0), 2)

M = cv2.moments(approx)

centers = []

if M["m00"] != 0:

cX = int(M["m10"] / M["m00"])

cY = int(M["m01"] / M["m00"])

else:

cX, cY = 0, 0

P1 = approx[0]

P1x = P1[0][0]

P1y = P1[0][1]

P2 = approx[1]

P2x = P2[0][0]

P2y = P2[0][1]

P3 = approx[2]

P3x = P3[0][0]

P3y = P3[0][1]

P4 = approx[3]

P4x = P4[0][0]

P4y = P4[0][1]

plt.imshow(image)

plt.title('Detecting Square')

plt.show()

# Cropping the square_image using array slices -- it's a NumPy array

cropped_square = image[P1y:P3y, P2x:P3x]

# Cropping the text image

cropped_text = image[P1y:P3y,P3x+5:width]

# Displaying the cropped square and cropped text image.

plt.imshow(cropped_square)

plt.title('Cropped Square')

plt.show()

plt.imshow(cropped_text)

plt.title('Cropped Text')

plt.show()

# Now saving the cropped square and cropped text image

cv2.imwrite('results/square1.png',cropped_square)

cv2.imwrite('results/text1.png',cropped_text)

以上程序的輸出:

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的pythongui界面复选框数值选择并求和_如何使用Python从图像中分离复选框按钮和复......的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。