当前位置: 首页>>代码示例>>Python>>正文


Python Camera.hasOpenCV方法代码示例

本文整理汇总了Python中Camera.hasOpenCV方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.hasOpenCV方法的具体用法?Python Camera.hasOpenCV怎么用?Python Camera.hasOpenCV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera的用法示例。


在下文中一共展示了Camera.hasOpenCV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_GET

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import hasOpenCV [as 别名]
	def do_GET(self):
		"""Respond to a GET request."""
		if "?" in self.path:
			page,arg = self.path.split("?",1)
			arg = dict(urlparse.parse_qsl(arg))
		else:
			page = self.path
			arg = None

#		print self.path,type(self.path)
#		print page
#		print arg

		if page == "/send":
			if arg is None: return
			for key,value in arg.items():
				if key=="gcode":
					for line in value.split('\n'):
						httpd.app.queue.put(line+"\n")
				elif key=="cmd":
					httpd.app.pendant.put(urllib.unquote(value))
			#send empty response so browser does not generate errors
			self.do_HEAD(200, "text/text")
			self.wfile.write("")

		elif page == "/state":
			self.do_HEAD(200, content="text/text")
			tmp = {}
			for name in ["controller", "state", "pins", "color", "msg", "wx", "wy", "wz", "G"]:
				tmp[name] = CNC.vars[name]
			self.wfile.write(json.dumps(tmp))

		elif page == "/config":
			self.do_HEAD(200, content="text/text")
			snd = {}
			snd["rpmmax"] = httpd.app.get("CNC","spindlemax")
			self.wfile.write(json.dumps(snd))

		elif page == "/icon":
			if arg is None: return
			self.do_HEAD(200, content="image/gif")
			filename = os.path.join(iconpath, arg["name"]+".gif")
			try:
				f = open(filename,"rb")
				self.wfile.write(f.read())
				f.close()
			except:
				pass

		elif page == "/canvas":
			if not Image: return
			with tempfile.NamedTemporaryFile(suffix='.ps') as tmp:
				httpd.app.canvas.postscript(
					file=tmp.name,
					colormode='color',
				)
				tmp.flush()
				try:
					with tempfile.NamedTemporaryFile(suffix='.gif') as out:
						Image.open(tmp.name).save(out.name, 'GIF')
						out.flush()
						out.seek(0)
						self.do_HEAD(200, content="image/gif")
						self.wfile.write(out.read())
				except:
					self.do_HEAD(200, content="image/gif")
					filename = os.path.join(iconpath, "warn.gif")
					try:
						f = open(filename,"rb")
						self.wfile.write(f.read())
						f.close()
					except:
						pass

		elif page == "/camera":
			if not Camera.hasOpenCV(): return
			if Pendant.camera is None:
				Pendant.camera = Camera.Camera("webcam")
				Pendant.camera.start()

			if Pendant.camera.read():
				Pendant.camera.save("camera.jpg")
				#cv.imwrite("camera.jpg",img)
				self.do_HEAD(200, content="image/jpeg")
				try:
					f = open("camera.jpg","rb")
					self.wfile.write(f.read())
					f.close()
				except:
					pass
		else:
			self.mainPage(page[1:])
开发者ID:ThierryM,项目名称:bCNC,代码行数:94,代码来源:Pendant.py


注:本文中的Camera.hasOpenCV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。