This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
RUN apt-get update \ | |
&& apt-get install -y python3-pip python3-dev \ | |
&& cd /usr/local/bin \ | |
&& ln -s /usr/bin/python3 python \ | |
&& pip3 install --upgrade pip | |
# INSTALL DEPENDENCIES | |
RUN apt-get install -y curl unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver' | |
WINDOW_SIZE = "1920,1080" | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") | |
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE) | |
chrome_options.add_argument('--no-sandbox') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove existing downloads and binaries so we can start from scratch. | |
sudo apt-get remove google-chrome-stable | |
rm ~/selenium-server-standalone-*.jar | |
rm ~/chromedriver_linux64.zip | |
sudo rm /usr/local/bin/chromedriver | |
sudo rm /usr/local/bin/selenium-server-standalone.jar | |
# Install dependencies. | |
sudo apt-get update | |
sudo apt-get install -y unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load base image and template | |
img = cv2.imread(sample_img_path, 0) | |
template = cv2.imread(template_path, 0) | |
# canny edge detection to get edges of base image | |
edged = cv2.Canny(img, 50, 200) | |
# define the orientations | |
methods_arr = [('original',0), ('original',90), ('original',180), ('original',270), | |
('flipped',0), ('flipped',90), ('flipped',180), ('flipped',270)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert image to grayscale | |
imgray = cv2.cvtColor(img, cv.COLOR_BGR2GRAY) | |
# apply threshold | |
thresh = cv2.threshold(imgray, 127, 255, 0)[1] | |
# find contours | |
contours, hierarchy = cv.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) | |
# draw contours on image | |
cv2.drawContours(img, contours, -1, (0, 255, 0), 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color = [211, 227, 191] | |
# Convert our image from BGR to HSV | |
hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) | |
limit = np.uint8([[color]]) | |
# Convert our color of choice to HSV as well | |
limit = cv2.cvtColor(limit,cv2.COLOR_BGR2HSV)[0][0] | |
mask = cv2.inRange(hsv_img, limit, limit) | |
# Filter for the colour | |
res = cv2.bitwise_and(img,img, mask= mask) |