【问题标题】:How to get the coordinates of the stitched image with respect to the original images如何获取拼接图像相对于原始图像的坐标
【发布时间】:2023-04-05 17:05:01
【问题描述】:

我正在对多个图像执行对象检测,这些图像是从覆盖更广视角的多个摄像头捕获的。由于我想防止多次计算同一个对象,我想知道是否可以计算拼接图像上对象相对于源图像坐标的坐标。这样,如果源图像上多个对象的坐标在拼接图像上大致相等,我将只计算一次对象。以下是图像拼接示例:拼接后的图像由 3 个重叠图像组成;在第一张和第二张图像上,检测到同一个物体,应该只计算一次。

这是我为拼接编写的示例代码:

import cv2
import imutils
from videostream import VideoStreamWidget

index = 0
arr = []

stitcher = cv2.createStitcher() if imutils.is_cv3() else cv2.Stitcher_create()


cams_test = 200
for i in range(cams_test):
    cap = cv2.VideoCapture(i)
    test, frame = cap.read()
    if test:
        print("i : " + str(i) + " /// result: " + str(test))
        arr.append(i)

video_captures = [VideoStreamWidget(idx) for idx in arr]
images_to_stitch = []
for i, video_stream_widget in enumerate(video_captures):
    try:
        if video_stream_widget.frame is not None:
            cv2.imshow('Cam {}'.format(i), cv2.resize(video_stream_widget.frame, (0, 0), fx=0.25, fy=0.25))
            images_to_stitch.append(video_stream_widget.frame)
    except Exception as e:
        print(e)
        pass
try:
    (status, stitched) = stitcher.stitch(images_to_stitch)
    if status == 0:
        cv2.imshow("Stitched", cv2.resize(stitched, (0, 0), fx=0.1, fy=0.25))
except:
    print("stitching failed")
print(status)

【问题讨论】:

  • 它是如何缝合的?你能在这里添加一些最小的可重现代码吗?
  • 你可以从cv2.match_template()开始

标签: python opencv computer-vision


【解决方案1】:

我们是否可以假设您的拼接不是动态的,并且您总是从初始图像的固定部分来创建主要图像?

在这种情况下,我会存储您的对象的中心坐标并检查(在拼接之后)两个中心是否在某个公差范围内。 (因此您最初容忍冗余并在缝合后将其删除)。例如x,y +/- 20 像素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-19
    • 2022-01-01
    • 2021-08-01
    • 2016-02-09
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多