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


Python Image.drawCircle方法代码示例

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


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

示例1: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [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")
开发者ID:opengimbal,项目名称:ogp,代码行数:55,代码来源:chase2.py

示例2: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [as 别名]
 
display = SimpleCV.Display()

img = Image("ping/source/image3.jpeg")

# parametre pour image1 : (dilate=2), (stretch(200,255), isCircle(0.2)
# parametre pour image2 : non trouvé
# parametre pour image3 : (dilate=2), (stretch(2,120), isCircle(0.2)
# parametre pour image4 : (dilate=2), (stretch(2,120), isCircle(0.2)
# parametre pour image5 : (dilate=2), (stretch(2,120), isCircle(0.2)
# parametre pour image6 : plante
# parametre pour image7 : non trouvé
            
dist = img.colorDistance(SimpleCV.Color.ORANGE).dilate(2)

segmented = dist.stretch(2,120).invert()

blobs = segmented.findBlobs()

if blobs:

        balles = blobs.filter([b.isCircle(0.2) for b in blobs])
                
        if balles:
                for balle in balles:
                        img.drawCircle((balle.x,balle.y),balle.radius(),SimpleCV.Color.BLUE,3 )

img.show()


开发者ID:othebault,项目名称:Trackball,代码行数:30,代码来源:trackball3.py

示例3: histo

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [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"
开发者ID:juoni,项目名称:ogp,代码行数:81,代码来源:ogplab.py

示例4: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [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)
#.........这里部分代码省略.........
开发者ID:juoni,项目名称:ogp,代码行数:103,代码来源:ogplab.py

示例5: __call__

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [as 别名]
    def __call__(self, image):
        params = util.utf8convert(self.inspection.parameters)
        retVal = []
        mask = Image((image.width,image.height))
        if( params.has_key('w') and  params.has_key('h') and params.has_key('x') and params.has_key('y') ): #rectangle
            if( params['x'] + params['w'] < image.width and
                params['y'] + params['h'] < image.height and
                params['y'] >= 0 and 
                params['x'] >= 0 ):
                mask.drawRectangle(params['x'],params['y'],params['w'],params['h'],width=-1,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                   
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2]))
                    ff.setFeature(b) # a little hacky but I am sure that it works
                    retVal = [ff]
  
        elif( params.has_key('x') and  params.has_key('y') and params.has_key('r') ): # circle
            if( params['x'] + params['r'] < image.width and
                params['y'] + params['r'] < image.height and 
                params['x'] - params['r'] >= 0 and 
                params['y'] - params['r'] >= 0 ):

                r = params['r']
                x = params['x']
                y = params['y']

                mask.drawCircle((x,y),r,thickness=-1,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                  
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2]))
                    ff.setFeature(b)
                    retVal = [ff]

        elif( params.has_key('contour') ):
            contour = params['contour'] # this may bail out
            if( len(contour) >=  3 ):
                mask.dl().polygon(contour,filled=True,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                   
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2])) 
                    ff.setFeature(b)
                    retVal = [ff]
            
        if( params.has_key("saveFile") ):
            image.save(params["saveFile"])

        return retVal
开发者ID:kscottz,项目名称:SimpleSeer,代码行数:67,代码来源:region.py

示例6:

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [as 别名]
            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()
             pts = []
             row=2

             scanWin.addstr(1,1,"Distance Map"          )
开发者ID:kgroveshok,项目名称:rasppi,代码行数:32,代码来源:robot.py

示例7: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [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" )
开发者ID:juoni,项目名称:ogp,代码行数:83,代码来源:chase2.py

示例8: histo

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawCircle [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]
#.........这里部分代码省略.........
开发者ID:opengimbal,项目名称:ogp,代码行数:103,代码来源:ogplab.py


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