第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 cv2.resize() 之后找到新坐標(biāo)

在 cv2.resize() 之后找到新坐標(biāo)

忽然笑 2022-01-18 21:11:30
我正在關(guān)注text-detection-ctpn。該項(xiàng)目的作者resize()在進(jìn)行計(jì)算之前的圖像。如果不調(diào)整圖像大小,內(nèi)存就會(huì)爆炸。我設(shè)法使用此功能將調(diào)整大小的框轉(zhuǎn)換回原始框def transform_boxes(boxes: np.ndarray, h, w, rh, rw):    """    Transform back the original coordinate    :param boxes:    :param h: height of the original    :param w: width of the original    :param rh: re-sized height    :param rw: re-sized height    :return:    """    z = np.copy(boxes)    z[:, 0] = z[:, 0] / rh    z[:, 2] = z[:, 2] / rh    z[:, 4] = z[:, 4] / rh    z[:, 6] = z[:, 6] / rh    z[:, 1] = z[:, 1] / rw    z[:, 3] = z[:, 3] / rw    z[:, 5] = z[:, 5] / rw    z[:, 7] = z[:, 7] / rw    return z變換誤差在大坐標(biāo)數(shù)上顯著
查看完整描述

2 回答

?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊

當(dāng)您嘗試反轉(zhuǎn)框上的調(diào)整大小操作時(shí),您除以rhandrw但您永遠(yuǎn)不會(huì)乘以hand w。


z[:, 0] = h * z[:, 0] / rh

z[:, 1] = w * z[:, 1] / rw

這解釋了為什么您的錯(cuò)誤會(huì)隨著更大的圖像而變大。


作為旁注,您可以使用 numpy 索引來避免每行重復(fù)四次:


z[:, 0::2] = h * z[:, 0::2] / rh

z[:, 1::2] = w * z[:, 1::2] / rw


查看完整回答
反對(duì) 回復(fù) 2022-01-18
?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

我必須轉(zhuǎn)換坐標(biāo)而不是我正在處理的像素。


坐標(biāo),而不是像素....


def transform_boxes(boxes: np.ndarray, im):

    """

    Transform back the original coordinate

    :param boxes:

    :param im: The original image

    :return:

    """

    z = np.copy(boxes)

    (height, width, colors) = im.shape

    new_h, new_w, img_size = get_float_new_wh(im)

    z[:, 0::2] = height * z[:, 0::2] / new_h

    z[:, 1::2] = width * z[:, 1::2] / new_w


    return z


def get_new_wh(img):

    """

    Get only new width and new height

    :param img:

    :return:

    """

    new_h, new_w, img_size = get_float_new_wh(img)

    new_h = int(new_h)

    new_w = int(new_w)


    new_h = new_h if new_h // 16 == 0 else (new_h // 16 + 1) * 16

    new_w = new_w if new_w // 16 == 0 else (new_w // 16 + 1) * 16

    return new_h, new_w, img_size

http://img1.sycdn.imooc.com//61e6bcc00001951805390884.jpg

查看完整回答
反對(duì) 回復(fù) 2022-01-18
  • 2 回答
  • 0 關(guān)注
  • 378 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)