本文介紹了如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我的 python 代碼中的 import cv
有問(wèn)題.
I'm having trouble with import cv
in my python code.
我的問(wèn)題是我需要在圖像中的感興趣區(qū)域周圍繪制一個(gè)矩形.這怎么能在python中完成?我正在進(jìn)行對(duì)象檢測(cè),并想在我認(rèn)為在圖像中找到的對(duì)象周圍繪制一個(gè)矩形.
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.
推薦答案
請(qǐng)不要嘗試使用舊的 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
以附加以下后續(xù)問(wèn)題:
cv2.imwrite("my.png",img)
cv2.imshow("lalala", img)
k = cv2.waitKey(0) # 0==wait forever
這篇關(guān)于如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!