本文整理汇总了Python中SimpleCV.Image.findBlobs方法的典型用法代码示例。如果您正苦于以下问题:Python Image.findBlobs方法的具体用法?Python Image.findBlobs怎么用?Python Image.findBlobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.findBlobs方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: encuentraYFiltraBlobs
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def encuentraYFiltraBlobs(self,areaMin, areaMax,
toleranciaWH, desviacionD,
toleranciaLP, tipoDibujo):
imagenBlobs = Image(self.rutaImagenTratada_Fase2).copy()
blobs = imagenBlobs.findBlobs()
self.todosLosCandidatos = blobs
if blobs:
blobs.image = imagenBlobs
self.areaBlobs = blobs.area()
blobs = self.filtroPorArea(blobs, areaMin, areaMax)
self.numBlobsCandidatosPorArea = len(blobs)
# Busca los blobs de forma circular , los blobs que pasan el filtro
# se guardan en la lista self.articulaciones
blobs = self.filtroPorForma(blobs, toleranciaWH, desviacionD, toleranciaLP)
if tipoDibujo == 'blobs':
self.dibujaBlobs(blobs)
elif tipoDibujo == 'estructura':
self.dibujaEstructura(imagenBlobs)
# La imagen tratada tiene que ser guardada porque sino no funciona
# la integracion con Tkinter
imagenBlobs.save(self.rutaImagenBlobs)
return Image(self.rutaImagenBlobs)
示例2: detectBlobs
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def detectBlobs(image_file):
original = Image(image_file)
blobs = original.findBlobs()
for blob in blobs:
blob.drawMinRect(color=Color.RED,width =10)
#blobs[-1].drawMinRect(color=Color.RED,width =10)
blobs.image = original
#original.save("foundBlobs.jpg")
return 1
示例3: main
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def main():
camera = cv2.VideoCapture('video2.avi')
background_subtractor = cv2.BackgroundSubtractorMOG()
# Store previous tracking image
previous_track_image = Image()
while camera.isOpened():
is_success, image = camera.read()
if is_success:
mask = background_subtractor.apply(image, None, 0.1)
# Vehicles will be detected from this image
track_image = Image(ndimage.median_filter(mask, 3), cv2image=True)
blobs = track_image.findBlobs(minsize=250, maxsize=800)
if not blobs:
# print('No Blobs Found.')
continue
else:
# print("Width: {0}; Height: {1}".format(blobs[0].width(), blobs[0].height()))
# Only keep near square blobs
blobs = filter(lambda b: 0.25 < b.width() / b.height() < 4, blobs)
# print("Found {0} Blobs. {1}".format(len(blobs)))
if len(vehicle_track_set_list) == 0:
# Find first batch of blobs
for blob in blobs:
blob.drawRect(color=Color.BLUE, width=3, alpha=225)
# bounding_box = tuple(blob.boundingBox())
# print("Area: {0}".format(blob.area()))
track_set = track_image.track(method='mftrack', img=track_image, bb=blob.boundingBox())
if track_set:
vehicle_track_set_list.append(VehicleTrackSet(track_set))
track_set.drawBB(color=(255, 0, 0))
track_set.drawPath()
track_image.show()
else:
for blob in blobs:
blob.drawRect(color=Color.BLUE, width=3, alpha=225)
# print("Blob Coordinate: ({0}, {1}).".format(blob.x, blob.y))
update_track_set(track_image, previous_track_image, blob.boundingBox())
# Save current image
previous_track_image = track_image
# time.sleep(0.1)
else:
camera.release()
break
示例4: run
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def run(self):
cam_mode=self.cam_mode
wsh = self.wsh
js = self.js
wsh2 = self.wsh2
d = "n"
c2 = self.c2
c = self.c
sqx = self.sqx
sqy = self.sqy
x = 0
y = 0
stat="live cam"
if cam_mode == 3:
img1 = c2.getImage()
if cam_mode==1:
img1 = c.getImage()
time.sleep(1)
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img2 = Image('imagesmall.jpg')
time.sleep(.5)
img1 = img1.sideBySide(img2)
img1 = img1.scale(544,288)
time.sleep(.5)
if cam_mode==2:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
self.img1 = img1
blobs = img1.findBlobs()
if blobs :
##blobs.draw()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
blobx1 = blobs[-1].x
bloby1 = blobs[-1].y
print blobx1
print bloby1
img1.drawText("ogp: live cam", 10, 10, fontsize=50)
img1.drawText(str(blobx1), blobx1, 250, color=(255,255,255), fontsize=20)
img1.drawText(str(bloby1), 10, bloby1, color=(255,255,255), fontsize=20)
img1.save(js.framebuffer)
sqx2=sqx+20
sqy2=sqy+20
time.sleep(.5)
wsh.write_message(wsh2, "live")
else:
wsh.write_message(wsh2, "live")
示例5: update
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def update(self, dt):
self.img = GameInstance().cam.getImage().flipHorizontal()
GameInstance().lower = np.array((float(self.val[0]), float(self.val[1]), float(self.val[2])))
GameInstance().upper = np.array((float(self.val[3]), float(self.val[4]), float(self.val[5])))
hsv = self.img.toHSV()
mask = cv2.inRange(hsv.getNumpy(), GameInstance().lower, GameInstance().upper)
img2 = Image(source=mask)
img2 = img2.erode(1)
img2 = img2.dilate(2)
if self.cvActiveBloops.active:
blops = img2.findBlobs()
if blops:
self.cvBlob.texture = getKivyTexture(blops[-1].getMaskedImage())
self.cvFilter.texture = getKivyTexture(img2)
self.cvImage.texture = getKivyTexture(self.img)
示例6: get_puzzle_from_image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def get_puzzle_from_image(raw_image):
# Returns None if no puzzle found
# Returns puzzle, x offset, y offset
# if puzzle found. Offsets are top
# left corner of puzzle
# Remove color
gray_image = raw_image.grayscale()
# Smooth to remove speckle
smooth_image = gray_image.gaussianBlur((5,5),0)
# Convert to Numpy Array For OpenCV use
cv_image = smooth_image.getGrayNumpyCv2()
# Adaptive threshold does much better than linear
raw_thresh_image = cv2.adaptiveThreshold(cv_image,255,1,1,11,2)
# Convert back to a SimpleCV image
thresh_image = Image(raw_thresh_image)
# For some reason it gets rotated and flipped, reverse
thresh_image = thresh_image.rotate90().flipVertical()
# Find "blobs" which are interesting items in the image
blobs = thresh_image.findBlobs()
# Assume the largest rectangular blob is our puzzle
puzzle_blob = None
puzzle_area = 0
for blob in blobs:
if blob.isRectangle() and blob.area() > puzzle_area:
puzzle_blob = blob
puzzle_area = blob.area()
# Only continue if there is a puzzle
if puzzle_blob is None: return None, 0, 0
# Crop image to just the puzzle
puzzle_image = puzzle_blob.crop()
offset_x, offset_y = puzzle_blob.topLeftCorner()
return puzzle_image, offset_x, offset_y
示例7: histo
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def histo(self):
cam_mode = self.cam_mode
js = self.js
ms = self.ms
w = self.w
cent = 0
rgb1 = 0
c2 = self.c2
wsh = self.wsh
wsh2 = self.wsh2
s.write('s')
if cam_mode == 3:
img1 = c2.getImage()
if cam_mode==1:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
if cam_mode==2:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
self.img1 = img1
blobs = img1.findBlobs()
if blobs:
print "blob"
x = self.x
y = self.y
p = self.p
p = p + 1
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[0].centroid()),10,color=(255,100,100))
print blobs[-1].meanColor()
rgb1 = blobs[-1].meanColor()
cent = blobs[-1].centroid()
pth1 = "/var/www/images/image"
pth3 = ".png"
pth = pth1 + str(p) + pth3
print pth
img1.save(pth)
thumbnail = img1.crop(150,25,250,250)
thumbnail = thumbnail.scale(20,20)
thumb1 = "/var/www/images/thumbs/thumb"
thumb3 = ".png"
thumbpath = thumb1 + str(p) + thumb3
print thumbpath
thumbnail.save(thumbpath)
self.p = p
mySet.add((p,x,y,w,cent,rgb1))
self.mySet = mySet
wshx = str(self.x)
wshy = str(self.y)
centroidx = int(cent[0])
centroidy=int(cent[1])
rcolor=rgb1[0]
gcolor=rgb1[1]
bcolor=rgb1[2]
rcolor=int(rcolor)
gcolor=int(gcolor)
bcolor=int(bcolor)
wsh.write_message(wsh2, "rgb_" + str(rcolor)+"_"+str(gcolor)+"_"+str(bcolor))
wsh.write_message(wsh2, "x_" + str(centroidx)+"_"+str(centroidy))
img1.save(js.framebuffer)
wsh.write_message(wsh2, "d_" + wshx + "_" + wshy + "_" + str(p) )
else:
wshx = str(self.x)
wshy = str(self.y)
wsh.write_message(wsh2, wshx + " " + wshy + "dark")
print "dark"
示例8: run
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def run(self):
wsh = self.wsh
## c = self.c
js = self.js
wsh2 = self.wsh2
acu = int(1)
acd = int(1)
acl = int(1)
acr = int(1)
irpic = pinoir2(js)
img1 = Image('imagesmall.jpg')
blobs = img1.findBlobs()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
acx1 = blobs[-1].x
acy1 = blobs[-1].y
img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)
img1.save(js.framebuffer)
d = 'r'
ms = 50
s.write('4')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
time.sleep(1)
img1 = c.getImage()
blobs = img1.findBlobs()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
acx2 = blobs[-1].x
acy2 = blobs[-1].y
img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
img1.save(js.framebuffer)
d = 'd'
ms = 50
s.write('9')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
time.sleep(1)
img1 = c.getImage()
blobs = img1.findBlobs()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
acx3 = blobs[-1].x
acy3 = blobs[-1].y
img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx3), 70, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy3), 70, 75, color=(255,255,255), fontsize=20)
img1.save(js.framebuffer)
d = 'l'
ms = 50
s.write('2')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
time.sleep(1)
img1 = c.getImage()
blobs = img1.findBlobs()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
acx4 = blobs[-1].x
acy4 = blobs[-1].y
img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx3), 70, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy3), 70, 75, color=(255,255,255), fontsize=20)
img1.drawText(str(acx4), 100, 50, color=(255,255,255), fontsize=20)
img1.drawText(str(acy4), 100, 75, color=(255,255,255), fontsize=20)
img1.save(js.framebuffer)
d = 'u'
ms = 50
s.write('6')
mov = acx(s, d, ms, acu, acd, acl, acr)
#.........这里部分代码省略.........
示例9: str
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
statusWin.addstr( 1, 1, str(object.meanColor()))
num_corners = len(corners)
statusWin.addstr(2,1, "Corners Found:" + str(num_corners))
corners.draw()
img.addDrawingLayer(object.dl())
# circle tracking
#dist = img.colorDistance(Color.BLACK).dilate(2)
#segmented = dist.stretch(200,255)
blobs = img.findBlobs()
if blobs:
circles = blobs.filter([b.isCircle(0.2) for b in blobs])
if circles:
img.drawCircle((circles[-1].x, circles[-1].y), circles[-1].radius(),Color.BLUE,3)
img.save("/dev/shm/p4.png")
#img.save(js.framebuffer)
elif keyp == 'v':
pz.stop()
示例10: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
smooth_image = gray_image.gaussianBlur((5,5),0)
# Convert to Numpy Array For OpenCV use
cv_image = smooth_image.getGrayNumpyCv2()
# Adaptive threshold does much better than linear
raw_thresh_image = cv2.adaptiveThreshold(cv_image,255,1,1,11,2)
# Convert back to a SimpleCV image
thresh_image = Image(raw_thresh_image)
# For some reason it gets rotated and flipped, reverse
thresh_image = thresh_image.rotate90().flipVertical()
# Find "blobs" which are interesting items in the image
blobs = thresh_image.findBlobs()
# Assume the largest rectangular blob is our puzzle
puzzle_blob = None
puzzle_area = 0
for blob in blobs:
if blob.isRectangle() and blob.area() > puzzle_area:
puzzle_blob = blob
puzzle_area = blob.area()
# Only continue if there is a puzzle
#if puzzle_blob is None: return
# Crop image to just the puzzle
puzzle_image = puzzle_blob.crop()
示例11: run
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def run(self):
cam_mode=self.cam_mode
s.write('s')
wsh = self.wsh
js = self.js
wsh2 = self.wsh2
ms = 50
d = "n"
acu = int(1)
acd = int(1)
acl = int(1)
acr = int(1)
c2=self.c2
sqx=self.sqx
sqy=self.sqy
x=0
y=0
stat="centering"
if cam_mode == 3:
img1 = c2.getImage()
if cam_mode==1:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
if cam_mode==2:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
self.img1 = img1
blobs = img1.findBlobs()
if blobs :
##blobs.draw()
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
blobx1 = blobs[-1].x
bloby1 = blobs[-1].y
print blobx1
print bloby1
img1.drawText("ogp: centering", 10, 10, fontsize=50)
img1.drawText(str(blobx1), 10, 200, color=(255,255,255), fontsize=50)
##img1.drawText(str(bloby1), 50, 200, color=(255,255,255), fontsize=50)
img1.drawText(str(bloby1), 10, 250, color=(255,255,255), fontsize=50)
img1.save(js.framebuffer)
sqx2=sqx+20
sqy2=sqy+20
if blobx1 > sqx2:
d = '_r'
s.write('4')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
wsh.write_message(wsh2, "g_"+ str(d))
if blobx1 < sqx:
d = 'l'
s.write('2')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
wsh.write_message(wsh2, "g_"+ str(d))
if bloby1 > sqy2:
d = 'd'
s.write('9')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
wsh.write_message(wsh2, "g_"+ str(d))
if bloby1 < sqy:
d = 'u'
s.write('6')
mov = acx(s, d, ms, acu, acd, acl, acr)
mov.run()
wsh.write_message(wsh2, "g_"+ str(d))
wsh.write_message(wsh2, "c")
else:
wsh.write_message(wsh2, "c_" + "null" )
示例12: call
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
from SimpleCV import Image
import time
#using opencv captured image, but purpose is make by video
call(“raspistill -n -t 0 -w %s -h %s -o image.bmp” % 640 480, shell=True)
img = Image(“image.bmp”)
img.show()
time.sleep(5)
#--------
cam = Camera()
img = cam.getImage()
#-----
img = img.edges()
img.show()
time.sleep(5)
img = img.binarize()
img.show()
time.sleep(5)
img = img.findBlobs()
for blob in blobs:
blob.draw()
img.show()
time.sleep(5)
#연속적인 이미지 촬영으로 영상을 만들면 속도가 너무 느리다 한방으로 가자
示例13: histo
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBlobs [as 别名]
def histo(self): ## this def is the "light meter" part---
cam_mode = self.cam_mode ## the pic gets cataloged if true ---
js = self.js
w = self.w
cent = 0
rgb1 = 0
c2 = self.c2
wsh = self.wsh
wsh2 = self.wsh2
i=0
brightpixels=0
darkpixels=0
blobs = 0
if cam_mode == 3: ## sort out the confusing cam modes
img1 = c2.getImage()
time.sleep(.25)
if cam_mode==1:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
if cam_mode==2:
with picamera.PiCamera() as camera:
camera.resolution = (544, 288)
camera.capture('imagesmall.jpg')
img1 = Image('imagesmall.jpg')
blobs = img1.findBlobs()
time.sleep(0.5)
if blobs:
##find the blob centroid and cut it out 20x20
crop1 = blobs[-1].x
crop2 = blobs[-1].y
crop3 = crop1 - 10
crop4 = crop2 - 10
thumbnail = img1.crop(crop3,crop4,20,20)
img2 = thumbnail
hist = img2.histogram(20)
## split the thumb into 20 levels of darkness
brightpixels = hist[10]
## 10 is where the darkest of the light pixels accumulate
print brightpixels
##while i < 20:
##old code for if you want to split the histogram in two
##if (i < 10):
##darkpixels = darkpixels + hist[i]
##self.darkpixels = darkpixels
##print hist[i]
##else:
##brightpixels = brightpixels + hist[i]
##self.brightpixels = brightpixels
##print hist[i]
##i = i + 1
if (brightpixels<400): ## heres where it decides to catalog the pic or not...
wsh.write_message(wsh2, "histo_" + str(darkpixels) + "_" + str(brightpixels))
print "blob"
x = self.x
y = self.y
p = self.p
p = p + 1
thumb1 = "/var/www/html/images/thumbs/thumb"
thumb3 = ".png"
thumbpath = thumb1 + str(p) + thumb3
print thumbpath
thumbnail.save(thumbpath)
img1.drawText("blob = True", 10, 35, color=(255,255,255),fontsize=30)
img1.drawText("search_mode", 10, 5, color=(0,0,255),fontsize=40)
img1.drawText("blob centroid", blobs[-1].x,blobs[-1].y, color=(255,255,255),fontsize=20)
img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,0))
img1.drawCircle((blobs[0].centroid()),10,color=(255,255,255))
print blobs[-1].meanColor()
rgb1 = blobs[-1].meanColor()
cent = blobs[-1].centroid()
pth1 = "/var/www/html/images/image"
pth3 = ".png"
pth = pth1 + str(p) + pth3
print pth
img1.save(pth)
time.sleep(0.5)
self.p = p
mySet.add((p,x,y,w,cent,rgb1))
self.mySet = mySet
wshx = str(self.x)
wshy = str(self.y)
centroidx = int(cent[0])
centroidy=int(cent[1])
rcolor=rgb1[0]
gcolor=rgb1[1]
bcolor=rgb1[2]
#.........这里部分代码省略.........