我正在嘗試顯示代碼每個階段的輸出,但 imshow 似乎不適用于內(nèi)部函數(shù)我創(chuàng)建了一個只有 imshow 行的空函數(shù)來測試它,它仍然沒有顯示給它的實際圖像,而是顯示一個充滿 0 的小圖像另一個觀察是它在循環(huán)結(jié)束時將每個循環(huán)圖像顯示在一個名為“測試”和“原始圖像”的單獨窗口中,您有 n*2 個窗口(重復(fù)這 2 個名稱),其中 n 是圖像數(shù)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
添加回答
舉報
0/150
提交
取消