Пример #1
0
# Import Scorer Library for ROI
sys.path.append("../lib")
import scorer_util

args = sys.argv

# GPIO Set UP
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
pin_list = (24, 23)

# Get ROI Information
roi = scorer_util.ROIStorage(
    os.path.dirname(__file__) + "/raspi_magazine.json")
x1, y1, x2, y2 = roi.get_roi_rect_by_index(0)

# Get Camera Object
cap = scorer.VideoCapture(0)

if len(args) > 1:
    # Get Image Frame
    frame = cap.read()
    if frame == None:
        sys.exit()

    # Get BGR data(CvMati format)
    bgr = frame.get_bgr()

    # Trim the BGR Image
Пример #2
0
import json
import sys
import os
import scorer

sys.path.append("../lib")
import scorer_util

roi = scorer_util.ROIStorage(os.path.dirname(__file__)+"/thermo.json")

count = roi.get_roi_rect_len()
for i in range(count):
    x1,y1,x2,y2 = roi.get_roi_rect_by_index(i)
    print(x1)
    print(y1)
    print(x2)
    print(y2)
Пример #3
0
#!/usr/bin/env python3
import cv2
import sys
import os
import scorer

sys.path.append("../lib")
import scorer_util

args = sys.argv

TARGET_DIR = "./image/"
if not os.path.isdir(TARGET_DIR):
    os.makedirs(TARGET_DIR)

cap = scorer.VideoCapture(0)
roi = scorer_util.ROIStorage(os.path.dirname(__file__) + "/tesseract.json")

x1, y1, x2, y2 = roi.get_roi_rect_by_index(0)

frame = cap.read()
if frame == None:
    sys.exit(1)

bgr = frame.get_bgr()
rect = bgr[y1:y2, x1:x2]

cv2.imwrite("image/tesseract.bmp", rect)
os._exit(0)
args = sys.argv

thresh = 120
minarea = 100
maxarea = 10000

if len(args) > 3:
    thresh = int(args[1])
    minarea = int(args[2])
    maxarea = int(args[3])
elif len(args) > 1:
    thresh = int(args[1])

cap = scorer.VideoCapture(0)
roi = scorer_util.ROIStorage()

starttime = time.time()
while True:
    frame = cap.read()
    if frame == None:
        continue
    bgr = frame.get_bgr()

    x1, y1, x2, y2 = roi.get_roi_rect_by_index(0)
    x1l, y1l, x2l, y2l = roi.get_roi_line_by_index(0)
    width = int(x2 - x1)
    height = int(y2 - y1)
    ret, binary_img = cv2.threshold(bgr, thresh, 255, cv2.THRESH_BINARY)
    crop_img = binary_img[y1:y2, x1:x2]
    binary_crop_img = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY)
Пример #5
0
import cv2
import sys
import os
import scorer

sys.path.append("../lib")
import scorer_util

roi = scorer_util.ROIStorage(os.path.dirname(__file__) + "/switchjudge.json")
x1, y1, x2, y2 = roi.get_roi_rect_by_index(0)
margin = 15

cap = scorer.VideoCapture(0)

frame = cap.read()

if frame == None:
    sys.exit()

bgr = frame.get_bgr()
bgr = bgr[y1 - margin:y2 + margin, x1 - margin:x2 + margin]
cv2.imwrite('image/now.png', bgr)
img_b, img_g, img_r = cv2.split(bgr)
gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY)
img = gray.copy()
#img1 = gray[y1:y2, x1:x2]

#img = cv2.imread('messi5.jpg',0)
template1 = cv2.imread('image/on.png', 1)
template2 = cv2.imread('image/off.png', 1)
template1_b, template1_g, template1_r = cv2.split(template1)