mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 06:16:32 +00:00
fe724ef186
* test(pytest) The driver methods added. Wrappers for UI elements added. #67 * test(pytest) Squishserver added #68 * test(pytest) Attach/Detach AUT methods added #69 * test(pytest) Main window handler added #70 * test(pytest) Save screenshot on fail added #71 * test(pytest) Wait for squishserver added #71 * test(pytest) Setup Windows #71 * Generate new keys (#11804) * test(pytest) Image comparison methods added #76 * test(pytest) Tesseract methods added #77 * test(pytest) The Methods to search color on image added #80 * test(onboarding) Test on generation new keys added #75 * test(pytest) Handlers for OS Native File dialog added #81 * test(Onboarding) Test on Profile image added #83 * Allure and TestRail integration (#11806) * test(Allure) Steps descriptions added #72 * test(TestRail) Integration #72
28 lines
1.0 KiB
Python
Executable File
28 lines
1.0 KiB
Python
Executable File
import cv2
|
|
import numpy as np
|
|
|
|
|
|
class Ocv:
|
|
|
|
@classmethod
|
|
def compare_images(cls, lhd: np.ndarray, rhd: np.ndarray) -> float:
|
|
res = cv2.matchTemplate(lhd, rhd, cv2.TM_CCOEFF_NORMED)
|
|
_, correlation, _, _ = cv2.minMaxLoc(res)
|
|
return correlation
|
|
|
|
@classmethod
|
|
def draw_contours(cls, lhd: np.ndarray, rhd: np.ndarray) -> np.ndarray:
|
|
view = rhd.copy()
|
|
|
|
lhd = cv2.cvtColor(lhd, cv2.COLOR_BGRA2GRAY)
|
|
_, thresh = cv2.threshold(lhd, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)
|
|
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
cv2.drawContours(view, contours, -1, (0, 0, 255), 1)
|
|
|
|
rhd = cv2.cvtColor(rhd, cv2.COLOR_BGRA2GRAY)
|
|
_, thresh = cv2.threshold(rhd, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)
|
|
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
cv2.drawContours(view, contours, -1, (0, 255, 0), 1)
|
|
|
|
return view
|