简体   繁体   中英

How to show webcam capture in Plone site using OpenCV?

I am using Plone 4.3. I am trying to create a face recognition system on the Plone site. I need to show webcam captures using a template page. My sample code is below. However, when I run this code, I can't get the captured image in the template file.

sample.py:

class video(BrowserView):
 video=ViewPageTemplateFile('video.pt')
 def chow(self):
   return self.video()
 def show_video(self):
  import cv2.cv as cv
  cv.NamedWindow("camera", 1)
  capture = cv.CaptureFromCAM(0)
  while True:
     img = cv.QueryFrame(capture)
  return img

video.pt:

<div id="res">
 <!--Here face is url name-->
 <img id="draw" tal:attributes="src python:context.absolute_url() + '/face'">
 <!--the above line refers to call a method of show_video()-->
</div>

This is a good starting point: http://plone.org/products/collective.takeaportrait (activate the optional OpenCV integration).

Keep in mind that there's a big difference between showing the camera output on the screen (that is simply HTML 5) and performing face recognition server side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM