最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

手勢(shì)檢測(cè) |Part 1 數(shù)據(jù)集收集 |c(diǎn)vzone Hand Detector

2023-07-21 16:42 作者:四處張望的w  | 我要投稿

感謝up我導(dǎo)[微笑]

我剛剛跑完,在我電腦上有兩個(gè)小問(wèn)題:

1.offset那里不能直接設(shè)置成20像素,因?yàn)閤-20或者y-20他倆有可能會(huì)小于零,當(dāng)小于零的時(shí)候會(huì)直接報(bào)錯(cuò)退出imshow的展示窗口

2.我用0.08*y和0.08*x分別代替x和y方向的offset,但是生成圖片會(huì)出現(xiàn)一個(gè)問(wèn)題,crop會(huì)直接把紅色的邊界框一起切下來(lái)

下面是代碼:

import math

import os.path


import CV2

import numpy as np



from cvzone.HandTrackingModule import HandDetector



# 調(diào)用攝像頭,并展示窗口

cap = CV2.VideoCapture(0)

detector = HandDetector(maxHands=1)


folder6 = "./images/six"

imgsize = 300

counter = 0


while True:

success, img = cap.read()

hands, img = detector.findHands(img)


if hands:

hand = hands[0]

x, y, w, h = hand['bbox']

img_white = np.ones((imgsize, imgsize, 3), np.uint8) * 255



a_y = 0.08*y

a_x = 0.08*x

imgcrop = img[y - int(a_y):y + h + int(a_y), x - int(a_x):x + w + int(a_x)]


aspectRatio = h / w


if aspectRatio > 1:

k = imgsize / h

wcal = math.ceil(k * w)

resized_img = CV2.resize(imgcrop, (wcal, imgsize))


w_offset = math.ceil((imgsize - wcal) / 2)

img_white[:, w_offset:wcal + w_offset] = resized_img

else:

k = imgsize/w

hcal = math.ceil(k*h)

resized_img = CV2.resize(imgcrop, (imgsize, hcal))

h_offset = math.ceil((imgsize - hcal) / 2)

img_white[h_offset:hcal+h_offset, :] =resized_img


CV2.imshow('imgcrop', img_white)

CV2.imshow('image', img)

key = CV2.waitKey(1)


if key == ord("s"):

counter += 1

CV2.imwrite(os.path.join(folder6,f'{counter}.jpg'),img_white)

print(counter)


手勢(shì)檢測(cè) |Part 1 數(shù)據(jù)集收集 |c(diǎn)vzone Hand Detector的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
连云港市| 武定县| 临漳县| 昌图县| 如皋市| 龙川县| 钟祥市| 汤阴县| 高阳县| 宁德市| 长治县| 英吉沙县| 腾冲县| 巴林右旗| 榆中县| 汝城县| 克东县| 梧州市| 闸北区| 光山县| 毕节市| 靖安县| 阳曲县| 夹江县| 铁岭市| 抚松县| 古蔺县| 乾安县| 珠海市| 平果县| 马边| 大兴区| 诸城市| 东乡族自治县| 桑日县| 山阳县| 南华县| 万宁市| 米脂县| 右玉县| 宿迁市|