I had a little problem debugging the following code today , After debugging many times, I finally found the solution , Let's share it with you :

Debug code :

res_list=os.listdir(res_path) #print(res_list) mae=[] for i in
range(len(res_list)): #print('res_list',res_list[i])
r_name=res_path+res_list[i] #print('r_name:',r_name)
g_name=gt_path+res_list[i][:-13]+'.png' #print('res_list[i]:', res_list[i])
#print(g_name) res=cv2.imread(r_name) h,w,_=res.shape res = cv2.cvtColor(res,
cv2.COLOR_RGB2GRAY) res=res/255 gt=cv2.imread(g_name) gt = cv2.cvtColor(gt,
cv2.COLOR_RGB2GRAY) gt=gt/255 mae.append(sum(sum(abs(res-gt)))/(h*w))
print(sum(sum(abs(res-gt)))/(h*w)) return sum(mae)/len(mae)

problem :
cv2.error: OpenCV(3.4.2)
c:\projects\opencv-python\opencv\modules\imgproc\src\color.hpp:253: error:
(-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) &&
VDepth::contains(depth) in function 'cv::CvtHelper<struct
cv::Set<3,4,-1>,struct cv::Set<1,-1,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'
In response to this problem , The solution given by the blog is to check the path name , The general path name is not correct .

After checking the path name several times , There is no problem finding the path to the code , Finally, through the output of each read in r_name and g_name The name of the picture found the problem :

The cause of this problem is :

The pictures in the two paths do not correspond , Namely :res_path  and  gt_path  The pictures below are not one-to-one , There is a lack of pictures


Solution :

        Delete the missing pictures in the folder or add extra pictures









©2020 ioDraw All rights reserved
Vue slot slot: Default slot , Named slot , Scope slot algorithm : Longest common subsequence ( Output all longest common subsequences ) Simple student achievement management system 《 How does the program run 》 Chapter 11 Hardware control method FDTD solution—— Material fitting , Light source settings MMKV The principle and implementation of virtual reality ( one )vue-element-admin Step record of adding menu python Simple understanding of decorator Java The realization of snake eating (1 Hour Society ) New photo album app launched by Microsoft : Using cross platform framework React Native to write