我正在尝试显示代码每个阶段的输出,但 imshow 似乎不适用于内部函数
我创建了一个只有 imshow 行的空函数来测试它,它仍然没有显示给它的实际图像,而是显示一个充满 0 的小图像
另一个观察是它在循环结束时将每个循环图像显示在一个名为“测试”和“原始图像”的单独窗口中,您有 n*2 个窗口(重复这 2 个名称),其中 n 是图像数
def test_(clr_img):
cv2.imshow("test image", clr_img)
def loop_folder(folder_path, save_path, debug=True):
"""Applies the label_chars function to every image in a folder and saves at the save_path
"""
json_name_list = []
for file_name in listdir(folder_path):
if file_name.endswith(".json"):
json_name_list.append(file_name)
for json_file_name in tqdm(json_name_list):
json_path = path.join(folder_path, json_file_name)
with open(json_path) as json_file_r:
json_data = json.load(json_file_r)
image_file_path = json_path.replace(".json", ".png")
image = cv2.imread(image_file_path)
if debug:
img = image.copy()
cv2.imshow("original image", image) # this one shows everytime
test_(image) # this one sometimes shows
cv2.waitKey(0)
cv2.destroyAllWindows()
我正在使用 opencv 4.3.0.36 和 python 3.7
SMILET
相关分类