Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the code runnable in python3 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/
12 changes: 8 additions & 4 deletions python_scripts/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import cv2
from sklearn.externals import joblib
import pandas as pd
import joblib
import argparse
# from time import gmtime, strftime

Expand Down Expand Up @@ -32,9 +34,11 @@ def calc_hist(img):
# # Load model
clf = None
try:
print(args["name"])
clf = joblib.load(args["name"])
# clf = pd.read_pickle(args["name"])
except IOError as e:
print "Error loading model <"+args["name"]+">: {0}".format(e.strerror)
print ("Error loading model <"+args["name"]+">: {0}".format(e.strerror))
exit(0)

# # Open the camera
Expand All @@ -43,7 +47,7 @@ def calc_hist(img):
else:
cap = cv2.VideoCapture(int(args["device"]))
if not cap.isOpened():
print "Error opening camera"
print ("Error opening camera")
exit(0)

width = 320
Expand All @@ -63,7 +67,7 @@ def calc_hist(img):
while True:
ret, img_bgr = cap.read()
if ret is False:
print "Error grabbing frame from camera"
print ("Error grabbing frame from camera")
break

img_gray = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)
Expand Down Expand Up @@ -95,7 +99,7 @@ def calc_hist(img):

point = (x, y-5)

print measures, np.mean(measures)
print (measures, np.mean(measures))
if 0 not in measures:
text = "True"
if np.mean(measures) >= 0.7:
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scikit-learn==0.22
numpy
opencv-python