how to link a web page for playing a video created using html5 and google app engine with a python code that detects smile? -
i have created web page (that has video embeded in it) using google app engine , html5. there python code detecing smile.what should invoke python code when play button clicked (i.e.)when video starts play automatically viewers face should detected... app engine code given below....
import webapp2 class mainpage(webapp2.requesthandler): def get(self): self.response.out.write("""<!doctype html> <html> <body> <video width="320" height="240" controls> <source src="/video/mov_bbb.mp4" type="video/mp4"> <source src="/video/mov_bbb.ogg" type="video/ogg"> browser not support video tag. </video> </body> </html>""") app = webapp2.wsgiapplication([('/', mainpage)])
the app.yaml file is....
application: video version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /video static_dir: video - url: /.* script: video.app - url: /(.*\.mp4) static_files: video/\1 mime_type: video/mp4 upload: video/(.*\.mp4) - url: /(.*\.ogg) static_files: video/\1 mime_type: video/ogg upload: video/(.*\.ogv)
the python code smile detection is....
import cv haar_cascade_path = "haarcascade_smile.xml" camera_index = 0 def detect_faces(image): faces = [] detected = cv.haardetectobjects(image, cascade, storage, 1.1,99,0,(40,40)) if detected: (x,y,w,h),n in detected: faces.append((x,y,w,h)) return faces if __name__ == "__main__": cv.namedwindow("video", cv.cv_window_autosize) capture = cv.capturefromcam(camera_index) storage = cv.creatememstorage() cascade = cv.load(haar_cascade_path) faces = [] = 0 c = -1 while (c == -1): image = cv.queryframe(capture) #only run detection algorithm every 5 frames improve performance if i%5==0: faces = detect_faces(image) (x,y,w,h) in faces: cv.rectangle(image, (x,y), (x+w,y+h), 255) cv.showimage("video", image) += 1 c = cv.waitkey(10)
you can't.
the video streamed client browser , played on client browser. since it's running in browser, you'll need run smile detection code in browser. it'll have javascript instead of python.
Comments
Post a Comment