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


Python Image.hueDistance方法代码示例

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


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

示例1: array

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import hueDistance [as 别名]
def array():
	x = request.form.getlist('values[]')
	images =  x[0].split(",")
	

	results = []
	for file in images:
	    try:
			file = file.split("SPLIT")
			files = file[1]
			identifier = file[0]
			img = Image(files)
			area = img.area()
	        
	        # minimum and maximum areas for a cup relative to the image
	        # proportions estimated and slightly expanded from real samples
			minsize = 0.0015 * area
			maxsize = 0.03 * area
	    
	        # super saturate pixels that most closely approximate red and invert image for blob detection
			im2 = img.hueDistance(color=(212,36,42), minsaturation=200, minvalue=70).invert()
	        # extract blobs within the specified size range
			blobs = im2.findBlobs(minsize=minsize, maxsize=maxsize)
	    
	    
	        # if blob (i.e. cup) detected, draw blue rectangle according to its bounding box.
			if blobs:
	            # for blob in blobs:
	            #     box = blob.mBoundingBox
	            #     img.drawRectangle(box[0],box[1],box[2],box[3], color=Color.BLUE, width=5)

				results.append({"id" : identifier, "src" : files})
				
			# else:
	  #           # determine a reasonable location for text
	  #           # y = img.height / 2
	  #           # x = img.width / 2.5
	  #           # img.drawText('Nothing detected!', x=x, y=y, color=Color.WHITE, fontsize=45)

			# 	results.append({"result" : "not found", "src" : file})
	    
	        
	
	        
	    except Exception as e:
	        print "File : %s, Error : %s" % (files, e)   
	return render_template("results.html" , results = results)   
开发者ID:alokedesai,项目名称:Solo-Cup-Remover,代码行数:49,代码来源:app.py

示例2: detectChargingStation

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import hueDistance [as 别名]
def detectChargingStation(image_file):
	debug = False

	myColor1 = (8,33,64)
	myColor2 = (70,80,100)

	original = Image(image_file)

	only_station = onlyBlueColor(original, myColor1)

	#Different findBlobs
	maskMean = original.hueDistance(color=(200,160,150))
	mask = only_station.hueDistance(color=myColor1).binarize()
	meanColor = (round(((maskMean.meanColor()[0]+maskMean.meanColor()[1]+maskMean.meanColor()[2])/3) * 10000)/10000)
	blobs = original.findBlobsFromMask(mask, minsize=400)

	if(meanColor > 190):
		return 6

	#print "Number of blobs found" , len(blobs)
	try: 
		blobs.image = original
	except Exception:
		only_station = onlyBlueColor(original, myColor2)
		mask = only_station.hueDistance(color=myColor2).binarize()
		blobs = original.findBlobsFromMask(mask, minsize=400)
		blobs.image = original

	station_blob = chooseBestBlobCosine(blobs)
	station_blob.drawMinRect(color=Color.RED)

	centroidX = station_blob.minRectX()
	centroidY = station_blob.minRectY()

	#Have to find out which part of the screen centroid is in
	maxX = original.getNumpy().shape[0]
	maxY = original.getNumpy().shape[1]+100

	if(debug):
		centroidLayer = DrawingLayer((maxX,maxY))

		centroidLayer.line((0,(1/3.0)*maxY),(maxX, (1/3.0)*maxY), color=Color.GREEN, width=2)
		centroidLayer.line((0,(2/3.0)*maxY),(maxX, (2/3.0)*maxY), color=Color.GREEN, width=2)
		centroidLayer.circle((int(centroidX), int(centroidY)), color=Color.GREEN, radius=5, filled=True)

		original.addDrawingLayer(centroidLayer)
		original.applyLayers()

		mask.save("binarizeMask.png")
		original.save("blobs.png")
		only_station.save("blueFilter.png")

	#print "Coordinates of centroid are "+str(centroidX)+", "+str(centroidY)
	#print "Coordinates of max are "+str(maxX)+", "+str(maxY)

	#if(station_blob.width() * station_blob.height() < 4000):
	#	return 2

	blobArea = station_blob.width() * station_blob.height()

	if(blobArea < 10000):
		return 2

	return chargingStationLocation_New(maxX,maxY,centroidX,centroidY,200, station_blob.width() / float(station_blob.height()), blobArea)
开发者ID:sachinsiby,项目名称:SPARQ,代码行数:66,代码来源:utils.py

示例3: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import hueDistance [as 别名]
#!/usr/bin/python
import subprocess
from SimpleCV import Color, Image
import time
img = Image("/dev/shm/lastsnap.jpg")
img.save("/dev/shm/p1.png")
#img = img.binarize()
#macchie = img.findBlobs()
#img.save("p2.png")
#print "Areas: ", macchie.area()
#print "Angles: ", macchie.angle()
#print "Centers: ", macchie.coordinates()
#colore = (0,255,0)

blue_distance = img.hueDistance(Color.GREEN)
#.invert()
#blue_distance = img.colorDistance(Color.GREEN);
#.invert()

blobs = blue_distance.findBlobs()

blobs.draw(color=Color.PUCE, width=2)
#blue_distance.show()
blue_distance.save("/dev/shm/p3.png")

img.addDrawingLayer(blue_distance.dl())

img.save("/dev/shm/p4.png")
开发者ID:kgroveshok,项目名称:rasppi,代码行数:30,代码来源:blobs.py

示例4: str

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import hueDistance [as 别名]
            pz.forward(speed)
            #statusWin.clear()
            statusWin.addstr(1,1, 'Reverse '+ str(speed)+"    ")
        elif keyp == 'r':
            prefix=str(time.time())
            copyfile("/dev/shm/lastsnap.jpg","/home/pi/"+prefix+"_lastsnap.jpg")
            copyfile("/dev/shm/p3.png","/home/pi/"+prefix+"_p3.png")
            copyfile("/dev/shm/p4.png","/home/pi/"+prefix+"_p4.png")
            statusWin.addstr(1,1, 'Saved webcam and opencv images to prefix '+prefix)
        elif keyp == 'e':


            img = Image("/dev/shm/lastsnap.jpg")


            object = img.hueDistance(Color.BLUE)
            object.save("/dev/shm/p3.png")

            #blobs = blue_distance.findBlobs()

            #object.draw(color=Color.PUCE, width=2)
            #blue_distance.show()
            #blue_distance.save("/dev/shm/p3.png")

            corners=img.findCorners()

            statusWin.clear()
            statusWin.addstr( 1, 1,  str(object.meanColor()))

            num_corners = len(corners)
            statusWin.addstr(2,1, "Corners Found:" + str(num_corners))
开发者ID:kgroveshok,项目名称:rasppi,代码行数:33,代码来源:robot.py

示例5: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import hueDistance [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
from SimpleCV import Color, Image
img = Image("lol.png")

try:
    blue_distance = img.hueDistance(Color.BLUE).invert()
    blobs = blue_distance.findBlobs()
    blobs.draw(color=Color.PUCE, width=3)
    img.addDrawingLayer(blue_distance.dl())
    img.show()
    time.sleep(10)
except:
    print('kill')
开发者ID:anujgtm1,项目名称:cgp-robots,代码行数:18,代码来源:test.py


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