本文介紹了如何在python中的感興趣區域周圍繪制一個矩形的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我的 python 代碼中的 import cv
有問題.
I'm having trouble with import cv
in my python code.
我的問題是我需要在圖像中的感興趣區域周圍繪制一個矩形.這怎么能在python中完成?我正在進行對象檢測,并想在我認為在圖像中找到的對象周圍繪制一個矩形.
My issue is I need to draw a rectangle around regions of interest in an image. How can this be done in python? I'm doing object detection and would like to draw a rectangle around the objects I believe I've found in the image.
推薦答案
請不要嘗試使用舊的 cv 模塊,使用 cv2:
please don't try with the old cv module, use cv2:
import cv2
cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)
x1,y1 ------
| |
| |
| |
--------x2,y2
以附加以下后續問題:
cv2.imwrite("my.png",img)
cv2.imshow("lalala", img)
k = cv2.waitKey(0) # 0==wait forever
這篇關于如何在python中的感興趣區域周圍繪制一個矩形的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!