import json
import os
import cv2
json_path = 'your_json_path'
json_list = os.listdir(json_path)
i = 0
legal_json_list = []
for json_file in json_list:
one_json_path = json_path + json_file
with open(one_json_path) as f:
ann = json.load(f)
#print(ann)
if(len(ann)== 0):
i = i+1
#print(one_json_path)
legal_json_list.append(one_json_path)
print(i)
#img_path_list = []
for legal_json in legal_json_list:
img_path = '/home/zhaotongdong/goole_download/mmdetection/data/ad_hualu/测试集/'
img_name = legal_json.split('/')[-1].split('.')[0] + '.jpg'
img_path_read = img_path + img_name
#print(img_path_read)
img = cv2.imread(img_path_read)
cv2.imshow('image', img)
cv2.waitKey(0)
#img_path_list.append(img_path_read)
#print(img_path_read)