如何使用OpenCV在Plone站点中显示网络摄像头捕获?

时间:2014-06-09 12:06:00

标签: python opencv plone

我正在使用Plone 4.3。我正在尝试在Plone网站上创建一个人脸识别系统。我需要使用模板页面显示网络摄像头捕获。我的示例代码如下。但是,当我运行此代码时,我无法在模板文件中获取捕获的图像。

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>

1 个答案:

答案 0 :(得分:1)

这是一个很好的起点:http://plone.org/products/collective.takeaportrait(激活可选的OpenCV集成)。

请注意,在屏幕上显示相机输出(简称HTML 5)和执行面部识别服务器端之间存在差异。