以下の内容はhttps://anton0825.hatenablog.com/entry/2016/09/11/000000より取得しました。


画像認識の結果を画像に重ねて表示する

例えば、物体検出などのタスクではどこにどんな物体があると検出したかを可視化するために、赤枠を画像に重ねることが多い。 画像は予測のインプットにするためにndarrayにされていることが多いので、以下のようにndarrayをImageオブジェクトに変換し、それに 多角形を描画する。

        shape = dLicense.edited_image.shape
        image: np.ndarray = dLicense.edited_image.reshape(1, shape[0], shape[1], shape[2])
        pred: np.ndarray = model.predict(image)[0]
        pil_img: Image = Image.fromarray(np.uint8(cv2.cvtColor(dLicense.edited_image, cv2.COLOR_BGR2RGB)))
        draw_img: ImageDraw = ImageDraw.Draw(pil_img)
        draw_img.polygon(((pred[0], pred[1]), (pred[2], pred[3]), (pred[4], pred[5]), (pred[6], pred[7])),
                         outline=(255, 0, 0))
        pil_img.save("tmp.jpg")

参考:

d.hatena.ne.jp

note.nkmk.me




以上の内容はhttps://anton0825.hatenablog.com/entry/2016/09/11/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14