我正在对多个图像执行目标检测,这些图像是从覆盖更广视角的多个摄像头捕获的。由于我想防止对同一物体进行多次计数,我想知道是否可以计算拼接图像上物体相对于源图像坐标的坐标。这样,如果源图像上多个对象的坐标在拼接图像上大致相等,我将只对对象计数一次。下面是图像拼接的示例:拼接的图像由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)发布于 2019-11-25 16:50:37
我们是否可以假设您的拼接不是动态的,并且您总是使用初始图像的固定部分来创建主要图像?
在这种情况下,我将存储对象的中心坐标,并检查(在拼接之后)两个中心是否在某个公差内。(因此,您最初可以容忍冗余,并在缝合后将其删除)。例如x,y +/- 20像素。
https://stackoverflow.com/questions/59027443
复制相似问题