import cv2 as cv import numpy as np from matplotlib import pyplot as plt import img_processing as ip print(cv.__version__) img_path = 'data/1-D2K286+520-300GD P_1.JPG' img = cv.imread(img_path, cv.IMREAD_COLOR) # 读取图像 三通道彩色图 # 起始点假设为固定位置,即 44 行,65 列 data_interest = img[44:, 65:-2] # 感兴趣的数据区域 number_interest = img[8:20, 64:175] # 感兴趣的数字区域 横向 ip.cv_info(f"data_interest", data_interest) ip.cv_info(f"number_interest", number_interest) # 切割图像 ip.split_img(data_interest) # 获取数字 num = ip.split_num(number_interest) print(type(num)) print(num) # gi.cv_show('data', data_interest) # gi.cv_show('number', a) cv.imwrite('data/saved_img/data_interest.PNG', data_interest) # 保存图片 cv.imwrite('data/saved_img/number_interest.PNG', number_interest) # 保存图片