digits_video.py prints warning if trained classifier (should be created by digits.py) not found

This commit is contained in:
Alexander Mordvintsev 2012-06-27 08:29:22 +00:00
parent 3804ca3e20
commit b987154ebc

View File

@ -1,11 +1,19 @@
import numpy as np
import cv2
#import video
import digits
import os
import video
from common import mosaic
#cap = video.create_capture()
cap = cv2.VideoCapture(0)
def main():
cap = video.create_capture()
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')
@ -61,3 +69,6 @@ while True:
cv2.imshow('bin', bin)
if cv2.waitKey(1) == 27:
break
if __name__ == '__main__':
main()