Skip to content

Commit

Permalink
Revert "Fix libraries version (#64)"
Browse files Browse the repository at this point in the history
This reverts commit f382fe9.
  • Loading branch information
Toufool committed Nov 10, 2021
1 parent f382fe9 commit b9468f2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
15 changes: 6 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
#
# Python: CPython 3.7 (not 3.8 as there is no cp38 wheel for PyQt4)
#
# Usage: pip3.7 install -r requirements.txt
# Usage: pip install -r requirements.txt
#
# If you're having issues with the libraries, you might want to first run:
# pip3.7 uninstall -r requirements.txt
#
# Creating AutoSplit.exe with PyInstaller: pyinstaller -w -F --hidden-import sip --icon=src\icon.ico src\AutoSplit.py
# Creating AutoSplit.exe with PyInstaller: pyinstaller -w -F src\AutoSplit.py
#
# You can find other wheels here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
https://download.lfd.uci.edu/pythonlibs/q4trcu4l/PyQt4-4.11.4-cp37-cp37m-win_amd64.whl
# https://download.lfd.uci.edu/pythonlibs/q4trcu4l/PyQt4-4.11.4-cp37-cp37m-win32.whl

# If you use 32-bit installation of Python, use the the 2nd URL instead.
https://download.lfd.uci.edu/pythonlibs/w4tscw6k/PyQt4-4.11.4-cp37-cp37m-win_amd64.whl
# https://download.lfd.uci.edu/pythonlibs/w4tscw6k/PyQt4-4.11.4-cp37-cp37m-win32.whl
#
# Comment this out if you don't want to create AutoSplit.exe:
PyInstaller
Expand All @@ -21,5 +18,5 @@ PyInstaller
opencv-python
Pillow
ImageHash
pywin32==226
pywin32
keyboard
9 changes: 3 additions & 6 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-

from PyQt4 import QtGui, QtCore, QtTest
from menu_bar import about, VERSION, viewHelp
from win32 import win32gui
import sys
import os
import win32gui
import cv2
import time
import ctypes.wintypes
import ctypes
import keyboard
import glob
import numpy as np

import design
Expand Down Expand Up @@ -970,4 +967,4 @@ def main():


if __name__ == '__main__':
main()
main()
1 change: 0 additions & 1 deletion src/capture_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
import win32ui
import win32con
import numpy as np

# This is an undocumented nFlag value for PrintWindow
PW_RENDERFULLCONTENT = 0x00000002
Expand Down
25 changes: 13 additions & 12 deletions src/compare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PIL import Image
import imagehash
import numpy as np

import numpy
import cv2

def compare_histograms(source, capture):
Expand All @@ -15,10 +16,10 @@ def compare_histograms(source, capture):

source_hist = cv2.calcHist([source], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])
capture_hist = cv2.calcHist([capture], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])

cv2.normalize(source_hist, source_hist)
cv2.normalize(capture_hist, capture_hist)

return 1 - cv2.compareHist(source_hist, capture_hist, cv2.HISTCMP_BHATTACHARYYA)

def compare_histograms_masked(source, capture, mask):
Expand All @@ -33,10 +34,10 @@ def compare_histograms_masked(source, capture, mask):
"""
source_hist = cv2.calcHist([source], [0, 1, 2], mask, [8, 8, 8], [0, 256, 0, 256, 0, 256])
capture_hist = cv2.calcHist([capture], [0, 1, 2], mask, [8, 8, 8], [0, 256, 0, 256, 0, 256])

cv2.normalize(source_hist, source_hist)
cv2.normalize(capture_hist, capture_hist)

return 1 - cv2.compareHist(source_hist, capture_hist, cv2.HISTCMP_BHATTACHARYYA)

def compare_l2_norm(source, capture):
Expand All @@ -50,10 +51,10 @@ def compare_l2_norm(source, capture):
"""

error = cv2.norm(source, capture, cv2.NORM_L2)

# The L2 Error is summed across all pixels, so this normalizes
max_error = (source.size ** 0.5) * 255

return 1 - (error/max_error)

def compare_l2_norm_masked(source, capture, mask):
Expand All @@ -70,7 +71,7 @@ def compare_l2_norm_masked(source, capture, mask):
error = cv2.norm(source, capture, cv2.NORM_L2, mask)

# The L2 Error is summed across all pixels, so this normalizes
max_error = (3 * np.count_nonzero(mask) * 255 * 255) ** 0.5
max_error = (3 * numpy.count_nonzero(mask) * 255 * 255) ** 0.5

return 1 - (error / max_error)

Expand Down Expand Up @@ -110,13 +111,13 @@ def compare_template_masked(source, capture, mask):
result = cv2.matchTemplate(capture, source, cv2.TM_SQDIFF, None, mask)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)

return 1 - (min_val/np.count_nonzero(mask))
return 1 - (min_val/numpy.count_nonzero(mask))

def compare_phash(source, capture):
"""
Compares the pHash of the two given images and returns the similarity between
the two.
@param source: Image of any given shape as a numpy array
@param capture: Image of any given shape as a numpy array
@return: The similarity between the hashes of the image as a number 0 to 1.
Expand All @@ -134,7 +135,7 @@ def compare_phash_masked(source, capture, mask):
"""
Compares the pHash of the two given images and returns the similarity between
the two.
@param source: Image of any given shape as a numpy array
@param capture: Image of any given shape as a numpy array
@param mask: An image matching the dimensions of the source, but 1 channel grayscale
Expand All @@ -148,7 +149,7 @@ def compare_phash_masked(source, capture, mask):
# the same
source = cv2.bitwise_and(source, source, mask=mask)
capture = cv2.bitwise_and(capture, capture, mask=mask)

source = Image.fromarray(source)
capture = Image.fromarray(capture)

Expand Down
9 changes: 7 additions & 2 deletions src/screen_region.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from PyQt4 import QtGui, QtCore, QtTest
from win32 import win32gui
import ctypes
import ctypes.wintypes
import win32gui
import cv2
import capture_windows
from PyQt4 import QtGui, QtCore, QtTest
import ctypes
import ctypes.wintypes
import win32gui
import cv2
import numpy as np

Expand Down Expand Up @@ -286,4 +291,4 @@ def mouseReleaseEvent(self, event):
self.bottom = max(self.begin.y(), self.end.y()) + self.SM_YVIRTUALSCREEN

self.height = self.bottom - self.top
self.width = self.right - self.left
self.width = self.right - self.left
4 changes: 2 additions & 2 deletions src/settings_file.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from win32 import win32gui
from PyQt4 import QtGui
import keyboard
import win32gui
import pickle
import glob
from PyQt4 import QtGui

def getSaveSettingsValues(self):
# get values to be able to save settings
Expand Down

0 comments on commit b9468f2

Please sign in to comment.