Compare commits
No commits in common. "45db741f35d85dbd7421cd72032442a3abccc9ef" and "65ee0565c2032701516e879a69774091b025df57" have entirely different histories.
45db741f35
...
65ee0565c2
@ -13,7 +13,7 @@ from ultralytics import YOLO
|
|||||||
|
|
||||||
# 添加YOLOv8模型初始化
|
# 添加YOLOv8模型初始化
|
||||||
yolo_model = YOLO("yolov8n.pt") # 可替换为yolov8s/m/l等
|
yolo_model = YOLO("yolov8n.pt") # 可替换为yolov8s/m/l等
|
||||||
yolo_model.to('cuda') # 启用GPU加速
|
yolo_model.to('cuda') # 启用GPU加速(可选)
|
||||||
|
|
||||||
|
|
||||||
def sift_registration(img1, img2):
|
def sift_registration(img1, img2):
|
||||||
@ -125,7 +125,6 @@ def Images_matching(img_base, img_target):
|
|||||||
src_pts = np.array([kp1[m.queryIdx].pt for m in good]) # 查询图像的特征描述子索引 # 134, 2
|
src_pts = np.array([kp1[m.queryIdx].pt for m in good]) # 查询图像的特征描述子索引 # 134, 2
|
||||||
dst_pts = np.array([kp2[m.trainIdx].pt for m in good]) # 训练(模板)图像的特征描述子索引
|
dst_pts = np.array([kp2[m.trainIdx].pt for m in good]) # 训练(模板)图像的特征描述子索引
|
||||||
if len(src_pts) <= 4:
|
if len(src_pts) <= 4:
|
||||||
print("Not enough matches are found - {}/{}".format(len(good), 4))
|
|
||||||
return 0, None, 0
|
return 0, None, 0
|
||||||
else:
|
else:
|
||||||
# print(len(dst_pts), len(src_pts), "配准坐标点")
|
# print(len(dst_pts), len(src_pts), "配准坐标点")
|
||||||
@ -205,66 +204,38 @@ if __name__ == '__main__':
|
|||||||
time_all = 0
|
time_all = 0
|
||||||
dots = 0
|
dots = 0
|
||||||
i = 0
|
i = 0
|
||||||
# fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
||||||
# capture = cv2.VideoCapture("video/20190926_141816_1_8/20190926_141816_1_8/infrared.mp4")
|
capture = cv2.VideoCapture("video/20190926_141816_1_8/20190926_141816_1_8/infrared.mp4")
|
||||||
# capture2 = cv2.VideoCapture("video/20190926_141816_1_8/20190926_141816_1_8/visible.mp4")
|
capture2 = cv2.VideoCapture("video/20190926_141816_1_8/20190926_141816_1_8/visible.mp4")
|
||||||
# fps = capture.get(cv2.CAP_PROP_FPS)
|
fps = capture.get(cv2.CAP_PROP_FPS)
|
||||||
# out = cv2.VideoWriter('output2.mp4', fourcc, fps, (640, 480))
|
out = cv2.VideoWriter('output2.mp4', fourcc, fps, (640, 480))
|
||||||
# # 持续读取摄像头数据
|
# 持续读取摄像头数据
|
||||||
# while True:
|
while True:
|
||||||
# read_code, frame = capture.read() # 红外帧
|
read_code, frame = capture.read() # 红外帧
|
||||||
# read_code2, frame2 = capture2.read() # 可见光帧
|
read_code2, frame2 = capture2.read() # 可见光帧
|
||||||
# if not read_code:
|
if not read_code:
|
||||||
# break
|
break
|
||||||
# i += 1
|
i += 1
|
||||||
# # frame = cv2.resize(frame, (1920, 1080))
|
# frame = cv2.resize(frame, (1920, 1080))
|
||||||
# # frame2 = cv2.resize(frame2, (640, 512))
|
# frame2 = cv2.resize(frame2, (640, 512))
|
||||||
#
|
|
||||||
# # 转换为灰度图(红外图像处理)
|
# 转换为灰度图(红外图像处理)
|
||||||
# frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
#
|
|
||||||
# # 调用main函数进行融合和检测
|
# 调用main函数进行融合和检测
|
||||||
# flag, fusion, dot = main(frame2, frame_gray)
|
flag, fusion, dot = main(frame2, frame_gray)
|
||||||
#
|
|
||||||
# if flag == 1:
|
if flag == 1:
|
||||||
# # 显示带检测结果的融合图像
|
# 显示带检测结果的融合图像
|
||||||
# cv2.imshow("Fusion with YOLOv8 Detection", fusion)
|
cv2.imshow("Fusion with YOLOv8 Detection", fusion)
|
||||||
# out.write(fusion)
|
out.write(fusion)
|
||||||
#
|
|
||||||
# if cv2.waitKey(1) == ord('q'):
|
if cv2.waitKey(1) == ord('q'):
|
||||||
# break
|
break
|
||||||
# # 释放资源
|
# 释放资源
|
||||||
# capture.release()
|
capture.release()
|
||||||
# capture2.release()
|
capture2.release()
|
||||||
# cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
# ave = time_all / i
|
ave = time_all / i
|
||||||
# print(ave, "平均时间")
|
print(ave, "平均时间")
|
||||||
# cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
# === 新增静态图片测试代码 ===
|
|
||||||
# 输入可见光和红外图像路径
|
|
||||||
visible_path = "../test_images/visible.jpg" # 可见光图片路径
|
|
||||||
infrared_path = "../test_images/infrared.jpg" # 红外图片路径
|
|
||||||
|
|
||||||
# 读取图像
|
|
||||||
img_visible = cv2.imread(visible_path)
|
|
||||||
img_infrared = cv2.imread(infrared_path)
|
|
||||||
|
|
||||||
if img_visible is None or img_infrared is None:
|
|
||||||
print("Error: 图片加载失败,请检查路径!")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# 转换为灰度图(红外图像处理)
|
|
||||||
img_inf_gray = cv2.cvtColor(img_infrared, cv2.COLOR_BGR2GRAY)
|
|
||||||
|
|
||||||
# 执行融合与检测
|
|
||||||
flag, fusion_result, _ = main(img_visible, img_inf_gray)
|
|
||||||
|
|
||||||
if flag == 1:
|
|
||||||
# 显示并保存结果
|
|
||||||
cv2.imshow("Fusion with Detection", fusion_result)
|
|
||||||
cv2.imwrite("../output/fusion_result.jpg", fusion_result)
|
|
||||||
cv2.waitKey(0)
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
else:
|
|
||||||
print("融合失败!")
|
|
||||||
|
0
image_fusion/__init__.py
Normal file
0
image_fusion/__init__.py
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 152 KiB |
@ -1,41 +0,0 @@
|
|||||||
certifi==2025.1.31
|
|
||||||
charset-normalizer==3.4.1
|
|
||||||
colorama==0.4.6
|
|
||||||
contourpy==1.3.2
|
|
||||||
cycler==0.12.1
|
|
||||||
filelock==3.18.0
|
|
||||||
fonttools==4.57.0
|
|
||||||
fsspec==2025.3.2
|
|
||||||
idna==3.10
|
|
||||||
Jinja2==3.1.6
|
|
||||||
kiwisolver==1.4.8
|
|
||||||
MarkupSafe==3.0.2
|
|
||||||
matplotlib==3.10.1
|
|
||||||
mpmath==1.3.0
|
|
||||||
networkx==3.4.2
|
|
||||||
numpy==2.1.1
|
|
||||||
opencv-python==4.11.0.86
|
|
||||||
packaging==24.2
|
|
||||||
pandas==2.2.3
|
|
||||||
pillow==11.2.1
|
|
||||||
psutil==7.0.0
|
|
||||||
py-cpuinfo==9.0.0
|
|
||||||
pyparsing==3.2.3
|
|
||||||
python-dateutil==2.9.0.post0
|
|
||||||
pytz==2025.2
|
|
||||||
PyYAML==6.0.2
|
|
||||||
requests==2.32.3
|
|
||||||
scipy==1.15.2
|
|
||||||
seaborn==0.13.2
|
|
||||||
setuptools==78.1.0
|
|
||||||
six==1.17.0
|
|
||||||
sympy==1.13.1
|
|
||||||
torch==2.6.0+cu124
|
|
||||||
torchaudio==2.6.0+cu124
|
|
||||||
torchvision==0.21.0+cu124
|
|
||||||
tqdm==4.67.1
|
|
||||||
typing_extensions==4.13.2
|
|
||||||
tzdata==2025.2
|
|
||||||
ultralytics==8.3.111
|
|
||||||
ultralytics-thop==2.0.14
|
|
||||||
urllib3==2.4.0
|
|
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
Binary file not shown.
Before Width: | Height: | Size: 67 KiB |
Loading…
Reference in New Issue
Block a user