五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

用OpenCV實現(xiàn)計算機視覺識別

2023-11-16 17:19 作者:北京IT學院  | 我要投稿

OpenCV是用于計算機視覺、機器學習和圖像處理的大型開源庫,現(xiàn)在它在實時操作中發(fā)揮著重要作用,這在當今的系統(tǒng)中非常重要。通過使用它,人們可以處理圖像和視頻來識別物體、人臉,甚至人類的筆跡。本文的重點是檢測對象。


有關(guān)詳細信息,請參閱機器學習、深度學習、計算機圖像處理及知識圖譜應用與核心技術(shù)實戰(zhàn)課程中對OpenCV的講解。




目標檢測

目標檢測是一種與計算機視覺、圖像處理和深度學習相關(guān)的計算機技術(shù),用于檢測圖像和視頻中的對象實例。在本文中,我們將使用稱為haar級聯(lián)的東西來進行對象檢測。

Haar級聯(lián)分類器?? ? ? ? ? ? ? ? ? ?

Haar級聯(lián)分類器是一種有效的目標檢測方法。該方法由Paul Viola和Michael Jones在他們的論文《使用簡單特征的提升級聯(lián)快速目標檢測》中提出。Haar Cascade是一種基于機器學習的方法,其中使用大量正負圖像來訓練分類器。

正圖像–這些圖像包含我們希望分類器識別的圖像。

Negative Images–其他一切的圖像,不包含我們要檢測的對象。

下載以下需求的步驟

在終端中運行以下命令以安裝opencv。

Pip install opencv python

運行以下命令以在終端中安裝Matplotlib。

Pip ?matplotlib

注意:將XML文件和PNG圖像放在與Python腳本相同的文件夾中。


具體實施

使用的圖像:



(1)打開圖像

Python代碼:

import CV2

from matplotlib import pyplot as plt


# Opening image

img = CV2.imread("image.jpg")


# OpenCV opens images as BRG

# but we want it as RGB and

# we also need a grayscale

# version

img_gray = CV2.cvtColor(img, CV2.COLOR_BGR2GRAY)

img_rgb = CV2.cvtColor(img, CV2.COLOR_BGR2RGB)


# Creates the environment

# of the picture and shows it

plt.subplot(1, 1, 1)

plt.imshow(img_rgb)

plt.show()


輸出:


(2)識別

我們將使用OpenCV的detectMultiScale()函數(shù)來識別大符號和小符號:



# Use minSize because for not

# bothering with extra-small

# dots that would look like STOP signs

stop_data = CV2.CascadeClassifier('stop_data.xml')

found = stop_data.detectMultiScale(img_gray,

minSize =(20, 20))

# Don't do anything if there's

# no sign

amount_found = len(found)


if amount_found != 0:


# There may be more than one

# sign in the image

for (x, y, width, height) in found:


# We draw a green rectangle around

# every recognized sign

CV2.rectangle(img_rgb, (x, y),

(x + height, y + width),

(0, 255, 0), 5)


下面是完整腳本:

import CV2

from matplotlib import pyplot as plt


# Opening image

img = CV2.imread("image.jpg")


# OpenCV opens images as BRG

# but we want it as RGB We'll

# also need a grayscale version

img_gray = CV2.cvtColor(img, CV2.COLOR_BGR2GRAY)

img_rgb = CV2.cvtColor(img, CV2.COLOR_BGR2RGB)



# Use minSize because for not

# bothering with extra-small

# dots that would look like STOP signs

stop_data = CV2.CascadeClassifier('stop_data.xml')


found = stop_data.detectMultiScale(img_gray,

minSize =(20, 20))


# Don't do anything if there's

# no sign

amount_found = len(found)


if amount_found != 0:


# There may be more than one

# sign in the image

for (x, y, width, height) in found:


# We draw a green rectangle around

# every recognized sign

CV2.rectangle(img_rgb, (x, y),

(x + height, y + width),

(0, 255, 0), 5)


# Creates the environment of

# the picture and shows it

plt.subplot(1, 1, 1)

plt.imshow(img_rgb)

plt.show()


輸出:


無論你是在準備你的第一次求職面試,還是在這個不斷發(fā)展的科技景觀中追求更高的技能,中培IT學院機器學習、深度學習、計算機圖像處理及知識圖譜應用與核心技術(shù)實戰(zhàn)課程將是是你成功的關(guān)鍵。本次培訓從實戰(zhàn)的角度對深度學習技術(shù)進行了全面的剖析,并結(jié)合實際案例分析和探討深度學習的應用場景,給深度學習相關(guān)從業(yè)人員以指導和啟迪。中培IT學院累計培訓10萬+人次,期待您的加入。





用OpenCV實現(xiàn)計算機視覺識別的評論 (共 條)

分享到微博請遵守國家法律
邳州市| 富平县| 彩票| 乐昌市| 巫山县| 陇西县| 怀宁县| 贺州市| 贡山| 沅江市| 郑州市| 玛多县| 象山县| 临沂市| 抚顺市| 阿瓦提县| 乌兰浩特市| 科技| 迭部县| 铜梁县| 浦江县| 平罗县| 东宁县| 道孚县| 瑞安市| 衡南县| 大化| 吕梁市| 南木林县| 长宁县| 青铜峡市| 洪泽县| 花莲市| 中卫市| 闻喜县| 屏东县| 崇阳县| 上杭县| 长汀县| 贡山| 玉林市|