久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 OpenCV warpPerspective 時如何顯示整個圖像

How to show the whole image when using OpenCV warpPerspective(使用 OpenCV warpPerspective 時如何顯示整個圖像)
本文介紹了使用 OpenCV warpPerspective 時如何顯示整個圖像的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我這里有 2 張測試圖片.我的問題是,如何在不裁剪圖像的情況下將第一張圖像中的正方形映射到第二張圖像中的四邊形.

I have 2 test images here. My is question is, how to map the square in first image to the quadrilateral in the second image without cropping the image.

圖 1:

圖 2:

這是我當前使用 openCV warpPerspective 函數的代碼.

Here is my current code using openCV warpPerspective function.

import cv2
import numpy as np

img1_square_corners = np.float32([[253,211], [563,211], [563,519],[253,519]])
img2_quad_corners = np.float32([[234,197], [520,169], [715,483], [81,472]])

h, mask = cv2.findHomography(img1_square_corners, img2_quad_corners)
im = cv2.imread("image1.png")
out = cv2.warpPerspective(im, h, (800,800))
cv2.imwrite("result.png", out)

結果:

如您所見,由于 warpPerspective 函數中的 dsize=(800,800) 參數,我無法獲得圖像 1 的完整視圖.如果調整 dsize,正方形將無法正確映射.有沒有辦法調整輸出圖像的大小,以便我可以得到圖像 1 的全圖?

As you can see, because of dsize=(800,800) parameter in the warpPerspective function, I can't get full view of image 1. If I adjust the dsize, the square won't map properly. Is there any way to resize the output image so that I can get whole picture of image 1?

推薦答案

是的,但您應該意識到輸出圖像可能非常大.我很快編寫了以下 Python 代碼,但即使是 3000 x 3000 的圖像也無法適應輸出,由于轉換,它太大了.雖然,這是我的代碼,但我希望它對你有用.

Yes, but you should realise that the output image might be very large. I quickly wrote the following Python code, but even a 3000 x 3000 image could not fit the output, it is just way too big due to the transformation. Although, here is my code, I hope it will be of use to you.

import cv2
import numpy as np
import cv           #the old cv interface

img1_square_corners = np.float32([[253,211], [563,211], [563,519],[253,519]])
img2_quad_corners = np.float32([[234,197], [520,169], [715,483], [81,472]])

h, mask = cv2.findHomography(img1_square_corners, img2_quad_corners)
im = cv2.imread("image1.png")

這里創建一個輸出圖像,我以 (3000, 3000) 為例.

Create an output image here, I used (3000, 3000) as an example.

out_2 = cv.fromarray(np.zeros((3000,3000,3),np.uint8))

通過使用舊的 cv 接口,我直接寫入輸出,因此不會被裁剪.我使用 cv2 接口嘗試了這個,但由于某種原因它不起作用......也許有人可以對此有所了解?

By using the old cv interface, I wrote directly to the output, and so it does not get cropped. I tried this using the cv2 interface, but for some reason it did not work... Maybe someone can shed some light on that?

cv.WarpPerspective(cv.fromarray(im), out_2, cv.fromarray(h))
cv.ShowImage("test", out_2)
cv.SaveImage("result.png", out_2)
cv2.waitKey()

無論如何,這會給出一個非常大的圖像,其中包含您的原始圖像 1,變形.如果您指定輸出圖像足夠大,整個圖像將可見.(這可能確實很大!)

Anyway, this gives a very large image, that contains your original image 1, warped. The entire image will be visible if you specify the output image to be large enough. (Which might be very large indeed!)

我希望這段代碼可以幫助到你.

I hope that this code may help you.

這篇關于使用 OpenCV warpPerspective 時如何顯示整個圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 一级黄色大片 | 欧美日韩成人 | 四虎影院免费在线 | xnxx 日本免费| 国内毛片毛片毛片毛片 | 精品一区二区久久久久久久网站 | 日韩一二三区视频 | 国产精品久久av | 国产欧美日韩综合精品一区二区 | 国产日韩欧美一区二区 | 欧美成人激情视频 | 日韩综合一区 | 成人精品国产免费网站 | 91精品国产综合久久久久久漫画 | 欧美成年人视频在线观看 | 五月婷婷丁香 | 亚洲精品一二三区 | 久久久久久久久久久久久9999 | 午夜成人免费视频 | 日韩在线观看中文字幕 | 不卡的av电影 | 偷拍亚洲色图 | 精品日本久久久久久久久久 | 欧美激情网站 | 日韩欧美一区二区三区免费观看 | 国产aⅴ爽av久久久久久久 | 久久综合久色欧美综合狠狠 | 久久精品91| 婷婷色国产偷v国产偷v小说 | 黄色毛片网站在线观看 | 日本电影韩国电影免费观看 | 二区三区视频 | 伊人伊成久久人综合网站 | 欧产日产国产精品视频 | 国产精品久久久久久久久久免费看 | 久久区二区| 国产真实精品久久二三区 | 久久精品视频一区二区三区 | 亚洲网在线 | 五月网婷婷 | 亚洲最色网站 |