Skip to content

Commit

Permalink
move some helpers to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
timeyyy committed Aug 25, 2023
1 parent c685f81 commit 0c1a89a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 11 additions & 0 deletions poker/tools/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
from configparser import ConfigParser, ExtendedInterpolation
from logging import handlers

import cv2
import numpy as np
import pandas as pd
from PIL import Image
import requests

if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
Expand Down Expand Up @@ -338,3 +341,11 @@ def open_payment_link():
c = requests.post(URL + "get_internal").json()[0]
payment_link = c['payment_link']
webbrowser.open(payment_link, new=1)


def pil_to_cv2(img):
return cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)


def cv2_to_pil(img):
return Image.fromarray(img)
10 changes: 1 addition & 9 deletions poker/tools/screen_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pytesseract import pytesseract
from tesserocr import PyTessBaseAPI, PSM, OEM

from poker.tools.helper import memory_cache, get_dir
from poker.tools.helper import memory_cache, get_dir, pil_to_cv2, cv2_to_pil
from poker.tools.mongo_manager import MongoManager
from poker.tools.swc import swc_ocr
from poker.tools.vbox_manager import VirtualBoxController
Expand Down Expand Up @@ -220,14 +220,6 @@ def binary_pil_to_cv2(img):
return cv2.cvtColor(np.array(Image.open(io.BytesIO(img))), cv2.COLOR_BGR2RGB)


def pil_to_cv2(img):
return cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)


def cv2_to_pil(img):
return Image.fromarray(img)


def rotate_image(image, angle):
image_center = tuple(np.array(image.shape[1::-1]) / 2)
rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0)
Expand Down
3 changes: 1 addition & 2 deletions poker/tools/swc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from PIL import Image
from tesserocr import PyTessBaseAPI, PSM, OEM

from poker.tools.helper import get_dir
from poker.tools.screen_operations import pil_to_cv2, cv2_to_pil
from poker.tools.helper import get_dir, pil_to_cv2, cv2_to_pil

log = logging.getLogger(__name__)

Expand Down

0 comments on commit 0c1a89a

Please sign in to comment.