In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces opencv how to draw lines, rectangles, arcs, elliptical arcs, polygons, add text, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Lab code shows the code:
Import numpy as npimport cv2 as cvimport time# Create a black imageimg = np.zeros ((800jue 800jue 3), np.uint8) # Draw a diagonal blue line with thickness of 5 px# draw a straight line # img = cv.line (img, pt1, pt2, color [, thickness [, lineType [, shift]) img = cv.line (img, (0Power0), (799799), (255Lot0), 5) # coordinates of two endpoints, BGR component, width of the line # draw rectangle img = cv.rectangle (img, (384Jing 20) (500128), 3) img = cv.rectangle (img, (104320), (200400), (0Power0255),-1) # coordinates of the upper left point and the lower right corner, BGR value, border width,-1 represents the fill # draws the circle # center point coordinates and radius, sets the line width, where-1 represents the filled closed graph img = cv.circle (img, (77243), 63, (0Min 255vol 0)) -1) # draw the ellipse # img = cv.ellipse (img, center, axes, angle, startAngle, endAngle, color [, thickness [, lineType [, shift]) # the coordinates of the center point of the ellipse, the length of the horizontal and vertical axes, the rotation angle, the angle range of the start and end of the elliptical arc, the arc color, the line width-1 represents the filling cv.ellipse (img, (556256), (100,050), 10re0360, (255) -1) # drawing polygons # img = cv.polylines (img, pts, isClosed, color [, thickness [, lineType [, shift]) pts1 = np.array ([[10Mague 30], [700130], [770320], [450710], np.int32) pts1 = pts1.reshape (- 1) Magazine 1)) # Dimensions must be ROWSx1x2pts2 = np.array ([500600], [300700], [370320], [150610], np.int32) pts2 = pts2.reshape ((- 1Magol 1) 2)) # Dimension must be ROWSx1x2cv.polylines (img, [pts1], False, (0255255)) # not connecting head and tail vertices cv.polylines (img, [pts2], True, (255255255)) # connection head and tail vertices # drawing text font = cv.FONT_HERSHEY_SIMPLEX# img = cv.putText (img, text, org, fontFace, fontScale, color [, thickness [, lineType [, bottomLeftOrigin]]) # text, display position, font Display text size based on the basic size of the font object, font weight cv.putText (img,'OpenCV', (150400), font, 4, (255255255), 4 LINE display AA) # display picture showTime = time.strftime ("% Y-%m-%d% H:%M:%S", time.localtime ()) cv.imshow ('LinMaZi-frame-LinZuQuan' + showTime, img) k = cv.waitKey (0) # receive a button Otherwise, the program flashes by.
Screenshot of the running result:
Thank you for reading this article carefully. I hope the article "how to draw lines, rectangles, arcs, elliptical arcs, polygons and add text" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.