for i in range(1, n + 1):
angle_step = 2 * math.pi / n
angle = angle_step * i
x1 = 340 + int(radius * math.cos(angle)) // n
y1 = 250 + int(radius * math.sin(angle)) // n
x2 = 340 + int(radius * math.cos(angle + angle_step)) // n
y2 = 250 + int(radius * math.sin(angle + angle_step)) // n
canvas.create_line((x1, y1), (x2, y2), fill="blue")
try:
if doc.get('attachment').get('file') == 'val_1':
name = doc['attachment']['key_4']
print('Success', name)
except:
name = None
print('Bad', name)
try:
if doc['attachment']['file'] == 'val_1':
name = doc['attachment']['key_4']
print('Success', name)
except:
name = None
print('Bad', name)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import numpy as np
import cv2
import pytesseract
# создаем пустую функцию
def nothing(args):pass
# создаем окно для отображения результата и бегунки
cv2.namedWindow("setup")
cv2.createTrackbar("b1", "setup", 0, 255, nothing)
cv2.createTrackbar("g1", "setup", 0, 255, nothing)
cv2.createTrackbar("r1", "setup", 0, 255, nothing)
cv2.createTrackbar("b2", "setup", 255, 255, nothing)
cv2.createTrackbar("g2", "setup", 255, 255, nothing)
cv2.createTrackbar("r2", "setup", 255, 255, nothing)
fn = "/home/debtest/Загрузки/Firefox/lfS9Yjc.png" # путь к файлу с картинкой
img = cv2.imread(fn) # загрузка изображения
# resized
img = cv2.resize(img, (4 * int(img.shape[1]), 4 * int(img.shape[0])), interpolation = cv2.INTER_AREA)
while True:
r1 = cv2.getTrackbarPos('r1', 'setup')
g1 = cv2.getTrackbarPos('g1', 'setup')
b1 = cv2.getTrackbarPos('b1', 'setup')
r2 = cv2.getTrackbarPos('r2', 'setup')
g2 = cv2.getTrackbarPos('g2', 'setup')
b2 = cv2.getTrackbarPos('b2', 'setup')
# собираем значения из бегунков в множества
min_p = (g1, b1, r1)
max_p = (g2, b2, r2)
# применяем фильтр, делаем бинаризацию
img_g = cv2.inRange(img, min_p, max_p)
img_t = (255-cv2.blur(img_g,(10,12)))
txt = pytesseract.image_to_string(img_t, lang="eng",
config="--oem 1 --psm 13 -c classify_bln_numeric_mode=1 tessedit_char_whitelist=0123456789")
print('tesseract\n', txt.strip())
cv2.imshow('img', img_t )
if cv2.waitKey(33) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
У него, пайтона даже Object Inspector-а толком нет,
Ответ 10-летней давности
https://stackoverflow.com/questions/7534409/python...
Эклипс - кошмар