import os
import cv2 as cv
import numpy as np
import random
back_dir = "Z:/data/back"
back = []
for file in os.listdir(back_dir):
if file.split('.')[-1] not in ['jpg']:
continue
path = back_dir + "/" + file
back.append(path)
np.random.shuffle(back)
data_dir = "./data/phone"
dst_dir = "Z:/data/train_data/screen/screen_07"
annt_file = "screen_07.txt"
writer = open(annt_file, "w+")
file_count = 0
pixel_value = 20
for file in os.listdir(data_dir): # 5
path = data_dir + '/' + file
# image_name = file.split('/')[-1].split('.')[0]
src = cv.imread(path, cv.IMREAD_COLOR)
size_count = 0
for w_size in range(100, 241, 5): # 28
# w_size = np.random.choice(np.arange(120, 220, 5))
src = cv.resize(src, dsize=(w_size, w_size * 2)) # 手
OpenCV实现数据的旋转、尺度和背景增强(个人笔记)
最新推荐文章于 2024-07-09 12:39:41 发布
这篇博客详细记录了如何使用OpenCV库进行图像数据的旋转、缩放和背景增强操作,适用于图像处理和机器学习的数据预处理。通过实例介绍了相关函数的用法,帮助理解图像增强在提升模型性能中的作用。
摘要由CSDN通过智能技术生成