コード例 #1
0
ファイル: camera.py プロジェクト: nacokite/cicuito_v1
 def getSimpleCVImage(self):
     """Grabs a frame from the camera and returns a SimpleCV image object."""
     img = np.empty((self.vRes * self.hRes * 3), dtype=np.uint8)
     self.picam.capture(img, 'bgr', use_video_port=True)
     img = img.reshape((self.vRes, self.hRes, 3))
     img = Image(img, colorSpace=ColorSpace.RGB)
     img = img.rotate90()
     img = img.flipVertical()
     return img
コード例 #2
0
	def process(self, iname):
		
		cam = picamera.PiCamera()
		cam.capture("imgs/moment.jpg")
	
		img = Image("imgs/moment.jpg")
		flip = img.flipVertical()
		binaryFlip = flip.binarize().invert()
		edges = binaryFlip.edges()
		#boxLayer = DrawingLayer((img.width, img.height))
		#boxLayer.rectangle((0, 0), (img.width, img.height), 
		#	color=Color.BLACK, filled=True)

		print "Processing image..."
		print "Please wait"

		#winsize = (img.width, img.height)#Set size for display
		#display = Display(winsize)#Create a display

		#blobs = flip.edges().findBlobs() #make the image with only edges and finde its blobs
		#blobs.image = img
		#img.addDrawingLayer(boxLayer)

		#blobs[-1].drawHull(color=Color.BLUE)

		#Correct rotation axis
		#correctAngle = blobs[-1].angle()
		#rot = img.rotate(correctAngle)
		#blobs[-1].rotate(correctAngle)
		
		#rotBlob = rot.findBlobs()

		#flip.dl().polygon(blobs[-1].mConvexHull,color=Color.RED, width=2)

		#rot.addDrawingLayer(boxLayer)#make the rot layer black

		lines = edges.findLines(threshold=10)#find lines in rotated image
		lines.draw(width=2, color=(255,0,0))#draw all lines in rotated image

		# while not display.isDone():
		# 	#rotBlob[-1].show()
		# 	rot.show()

		flip.save("imgs/raw-" + iname + ".jpg")
		edges.save("imgs/cv-" + iname + ".jpg")
		#rot.save("imgs/" + iname + ".jpg")
		# writeToServer('imgs/saved/1.jpg')
		return [lines]