digits_video.py prints warning if trained classifier (should be created by digits.py) not found
This commit is contained in:
parent
3804ca3e20
commit
b987154ebc
@ -1,18 +1,26 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
#import video
|
|
||||||
import digits
|
import digits
|
||||||
|
import os
|
||||||
|
import video
|
||||||
from common import mosaic
|
from common import mosaic
|
||||||
|
|
||||||
#cap = video.create_capture()
|
|
||||||
cap = cv2.VideoCapture(0)
|
|
||||||
|
|
||||||
model = digits.SVM()
|
|
||||||
model.load('digits_svm.dat')
|
|
||||||
|
|
||||||
SZ = 20
|
def main():
|
||||||
|
cap = video.create_capture()
|
||||||
|
|
||||||
while True:
|
classifier_fn = 'digits_svm.dat'
|
||||||
|
if not os.path.exists(classifier_fn):
|
||||||
|
print '"%s" not found, run digits.py first' % classifier_fn
|
||||||
|
return
|
||||||
|
|
||||||
|
model = digits.SVM()
|
||||||
|
model.load('digits_svm.dat')
|
||||||
|
|
||||||
|
SZ = 20
|
||||||
|
|
||||||
|
while True:
|
||||||
ret, frame = cap.read()
|
ret, frame = cap.read()
|
||||||
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
@ -61,3 +69,6 @@ while True:
|
|||||||
cv2.imshow('bin', bin)
|
cv2.imshow('bin', bin)
|
||||||
if cv2.waitKey(1) == 27:
|
if cv2.waitKey(1) == 27:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user