Python: OpenCV: Plot points on image

4 09 2013

Python: OpenCV: Plot points on image

20130904

use cv2 to plot points on image
point symbol like control point symbol

การพล๊อตข้อมูลจุดลงไปบนภาพ โดยกำหนดลักษณะของจุดเป็นแบบรูปจุดควบคุม

code:

import cv2
 if __name__ == '__main__':
 image067="""
    1,2725.816,1578.254
    2,2339.446,1381.908
    3,2263.594,1318.698
    4,2261.619,1222.698
    6,1941.855,1376.561
    7,1941.188,1288.783
    ...
    68,2357.619,1264.970
    """
 imageFile = r'ladybug067.jpg'
 imagePointList = data2List(image067)
 OriImage = cv2.imread(imageFile)

## plot point on image
 for i in imagePointList:
   pid,cx,cy = i
   cv2.circle(OriImage,(int(cx),int(cy)),10,(255,255,255),-11)
   cv2.circle(OriImage,(int(cx),int(cy)),11,(0,0,255),1) # draw circle
   cv2.ellipse(OriImage, (int(cx),int(cy)), (10,10), 0, 0, 90,(0,0,255),-1 )
   cv2.ellipse(OriImage, (int(cx),int(cy)), (10,10), 0, 180, 270,(0,0,255),-1 )
   cv2.circle(OriImage,(int(cx),int(cy)),1,(0,255,0),1) # draw center
   cv2.putText(OriImage,pid,(int(cx)+10,int(cy)-10),cv2.FONT_HERSHEY_COMPLEX_SMALL,1,(255,180,180))
 print 'plot points completed'
 outputfile = 'PlotPoint'+imageFile
 cv2.imwrite(outputfile,OriImage)

รูปร่างของจุดที่ได้

the symbol will like this cp


Actions

Information

One response

4 09 2013
SutoCom

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: