[ERROR:[email protected]] global D:\a\opencv-python\opencv-python\opencv\modules\core\src\persistence.cpp (505) cv::FileStorage::Impl::open Can't open file: 'E:\PyCh\python\ venv\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml' in read mode Traceback (most recent call last): File "E:\PyCh\python\TTTT\xym\Face recognition2.py", line 43, in <module> yangmi=ReFileName(dirPathyangmi)#调用函数 File "E:\PyCh\python\TTTT\xym\Face recognition2.py", line 32, in ReFileName face, rect = face_detect_demo(img) File "E:\PyCh\python\TTTT\xym\Face recognition2.py", line 9, in face_detect_demo faces = face_detector.detectMultiScale(gray, 1.2, 6) #使用此函数监测图像中的人脸。函数返回一个位置和大小的矩形列表,最后我们在原始图像中绘制矩形,已标记检测到人脸 cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'
时间: 2023-07-30 22:09:28 浏览: 914
根据错误信息,有两个问题需要解决:
1. `Can't open file: 'E:\PyCh\python\ venv\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml' in read mode`:这个错误是由于无法以读取模式打开文件 'E:\PyCh\python\ venv\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml' 所导致的。请确保级联分类器文件存在,并且路径正确。
2. `cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'`:这个错误是由于在 `cv::CascadeClassifier::detectMultiScale` 函数中出现了断言失败的情况。可能是由于级联分类器文件未正确加载或不存在导致的。请确保级联分类器文件存在,并且路径正确。
请检查以上两个问题并进行修正。如果问题仍然存在,请提供更多的代码和错误信息,以便我更好地帮助你解决问题。
相关问题
"D:\Downloads\PyCharm Community Edition 2024.3.4\PCproject\PythonProject\.venv\Scripts\python.exe" "D:\Downloads\PyCharm Community Edition 2024.3.4\PCproject\PythonProject\projectTest8.py" 处理碎片: 0%| | 0/209 [00:00<?, ?it/s][ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\000.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\001.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\002.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\003.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\004.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\005.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\006.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\007.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\008.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\009.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\010.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\011.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\012.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\013.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\014.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\015.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\016.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\017.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\018.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\019.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\020.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\021.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\022.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\023.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\024.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\025.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\026.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\027.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\028.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\029.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\030.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\031.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\032.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\033.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\034.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\035.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\036.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\037.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\038.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\039.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\040.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\041.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\042.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\043.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\044.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\045.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\046.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\047.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\048.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\049.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\050.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\051.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\052.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\053.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\054.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\055.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\056.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\057.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\058.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\059.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\060.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\061.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\062.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\063.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\064.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\065.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\066.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\067.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\068.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\069.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\070.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\071.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\072.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\073.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\074.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\075.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\076.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\077.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\078.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\079.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\080.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\081.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\082.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\083.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\084.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\085.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\086.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\087.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\088.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\089.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\090.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\091.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\092.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\093.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\094.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\095.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\096.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\097.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\098.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\099.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\100.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\101.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\102.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\103.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\104.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\105.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\106.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\107.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\108.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\109.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\110.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\111.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\112.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\113.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\114.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\115.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\116.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\117.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\118.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\119.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\120.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\121.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\122.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\123.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\124.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\125.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\126.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\127.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\128.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\129.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\130.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\131.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\132.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\133.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\134.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\135.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\136.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\137.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\138.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\139.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\140.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\141.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\142.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\143.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\144.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\145.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\146.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\147.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\148.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\149.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\150.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\151.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\152.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\153.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\154.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\155.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\156.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\157.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\158.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\159.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\160.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\161.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\162.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\163.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\164.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\165.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\166.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\167.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\168.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\169.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\170.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\171.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\172.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\173.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\174.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\175.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\176.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\177.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\178.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\179.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\180.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\181.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\182.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\183.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\184.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\185.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\186.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\187.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\188.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\189.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\190.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\191.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\192.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\193.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\194.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\195.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\196.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\197.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\198.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\199.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\200.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\201.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\202.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\203.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\204.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\205.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\206.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\207.bmp'): can't open/read file: check file path/integrity [ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\208.bmp'): can't open/read file: check file path/integrity 处理碎片: 100%|██████████| 209/209 [00:00<00:00, 15821.28it/s] 0it [00:00, ?it/s] Traceback (most recent call last): File "D:\Downloads\PyCharm Community Edition 2024.3.4\PCproject\PythonProject\projectTest8.py", line 282, in <module> chinese_reconstructor.reconstruct(output_folder="output_chinese") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Downloads\PyCharm Community Edition 2024.3.4\PCproject\PythonProject\projectTest8.py", line 265, in reconstruct success = self.reconstruct_grid() File "D:\Downloads\PyCharm Community Edition 2024.3.4\PCproject\PythonProject\projectTest8.py", line 182, in reconstruct_grid print(f"选择左上角碎片: {self.fragments[top_left_id]['filename']}") ~~~~~~~~~~~~~~^^^^^^^^^^^^^ IndexError: list index out of range ================================================== 开始处理中文碎片 (附件3) 正在加载碎片图像从: D:\学习文件\JM\2013B\附件3 无法读取图像: 000.bmp 无法读取图像: 001.bmp 无法读取图像: 002.bmp 无法读取图像: 003.bmp 无法读取图像: 004.bmp 无法读取图像: 005.bmp 无法读取图像: 006.bmp 无法读取图像: 007.bmp 无法读取图像: 008.bmp 无法读取图像: 009.bmp 无法读取图像: 010.bmp 无法读取图像: 011.bmp 无法读取图像: 012.bmp 无法读取图像: 013.bmp 无法读取图像: 014.bmp 无法读取图像: 015.bmp 无法读取图像: 016.bmp 无法读取图像: 017.bmp 无法读取图像: 018.bmp 无法读取图像: 019.bmp 无法读取图像: 020.bmp 无法读取图像: 021.bmp 无法读取图像: 022.bmp 无法读取图像: 023.bmp 无法读取图像: 024.bmp 无法读取图像: 025.bmp 无法读取图像: 026.bmp 无法读取图像: 027.bmp 无法读取图像: 028.bmp 无法读取图像: 029.bmp 无法读取图像: 030.bmp 无法读取图像: 031.bmp 无法读取图像: 032.bmp 无法读取图像: 033.bmp 无法读取图像: 034.bmp 无法读取图像: 035.bmp 无法读取图像: 036.bmp 无法读取图像: 037.bmp 无法读取图像: 038.bmp 无法读取图像: 039.bmp 无法读取图像: 040.bmp 无法读取图像: 041.bmp 无法读取图像: 042.bmp 无法读取图像: 043.bmp 无法读取图像: 044.bmp 无法读取图像: 045.bmp 无法读取图像: 046.bmp 无法读取图像: 047.bmp 无法读取图像: 048.bmp 无法读取图像: 049.bmp 无法读取图像: 050.bmp 无法读取图像: 051.bmp 无法读取图像: 052.bmp 无法读取图像: 053.bmp 无法读取图像: 054.bmp 无法读取图像: 055.bmp 无法读取图像: 056.bmp 无法读取图像: 057.bmp 无法读取图像: 058.bmp 无法读取图像: 059.bmp 无法读取图像: 060.bmp 无法读取图像: 061.bmp 无法读取图像: 062.bmp 无法读取图像: 063.bmp 无法读取图像: 064.bmp 无法读取图像: 065.bmp 无法读取图像: 066.bmp 无法读取图像: 067.bmp 无法读取图像: 068.bmp 无法读取图像: 069.bmp 无法读取图像: 070.bmp 无法读取图像: 071.bmp 无法读取图像: 072.bmp 无法读取图像: 073.bmp 无法读取图像: 074.bmp 无法读取图像: 075.bmp 无法读取图像: 076.bmp 无法读取图像: 077.bmp 无法读取图像: 078.bmp 无法读取图像: 079.bmp 无法读取图像: 080.bmp 无法读取图像: 081.bmp 无法读取图像: 082.bmp 无法读取图像: 083.bmp 无法读取图像: 084.bmp 无法读取图像: 085.bmp 无法读取图像: 086.bmp 无法读取图像: 087.bmp 无法读取图像: 088.bmp 无法读取图像: 089.bmp 无法读取图像: 090.bmp 无法读取图像: 091.bmp 无法读取图像: 092.bmp 无法读取图像: 093.bmp 无法读取图像: 094.bmp 无法读取图像: 095.bmp 无法读取图像: 096.bmp 无法读取图像: 097.bmp 无法读取图像: 098.bmp 无法读取图像: 099.bmp 无法读取图像: 100.bmp 无法读取图像: 101.bmp 无法读取图像: 102.bmp 无法读取图像: 103.bmp 无法读取图像: 104.bmp 无法读取图像: 105.bmp 无法读取图像: 106.bmp 无法读取图像: 107.bmp 无法读取图像: 108.bmp 无法读取图像: 109.bmp 无法读取图像: 110.bmp 无法读取图像: 111.bmp 无法读取图像: 112.bmp 无法读取图像: 113.bmp 无法读取图像: 114.bmp 无法读取图像: 115.bmp 无法读取图像: 116.bmp 无法读取图像: 117.bmp 无法读取图像: 118.bmp 无法读取图像: 119.bmp 无法读取图像: 120.bmp 无法读取图像: 121.bmp 无法读取图像: 122.bmp 无法读取图像: 123.bmp 无法读取图像: 124.bmp 无法读取图像: 125.bmp 无法读取图像: 126.bmp 无法读取图像: 127.bmp 无法读取图像: 128.bmp 无法读取图像: 129.bmp 无法读取图像: 130.bmp 无法读取图像: 131.bmp 无法读取图像: 132.bmp 无法读取图像: 133.bmp 无法读取图像: 134.bmp 无法读取图像: 135.bmp 无法读取图像: 136.bmp 无法读取图像: 137.bmp 无法读取图像: 138.bmp 无法读取图像: 139.bmp 无法读取图像: 140.bmp 无法读取图像: 141.bmp 无法读取图像: 142.bmp 无法读取图像: 143.bmp 无法读取图像: 144.bmp 无法读取图像: 145.bmp 无法读取图像: 146.bmp 无法读取图像: 147.bmp 无法读取图像: 148.bmp 无法读取图像: 149.bmp 无法读取图像: 150.bmp 无法读取图像: 151.bmp 无法读取图像: 152.bmp 无法读取图像: 153.bmp 无法读取图像: 154.bmp 无法读取图像: 155.bmp 无法读取图像: 156.bmp 无法读取图像: 157.bmp 无法读取图像: 158.bmp 无法读取图像: 159.bmp 无法读取图像: 160.bmp 无法读取图像: 161.bmp 无法读取图像: 162.bmp 无法读取图像: 163.bmp 无法读取图像: 164.bmp 无法读取图像: 165.bmp 无法读取图像: 166.bmp 无法读取图像: 167.bmp 无法读取图像: 168.bmp 无法读取图像: 169.bmp 无法读取图像: 170.bmp 无法读取图像: 171.bmp 无法读取图像: 172.bmp 无法读取图像: 173.bmp 无法读取图像: 174.bmp 无法读取图像: 175.bmp 无法读取图像: 176.bmp 无法读取图像: 177.bmp 无法读取图像: 178.bmp 无法读取图像: 179.bmp 无法读取图像: 180.bmp 无法读取图像: 181.bmp 无法读取图像: 182.bmp 无法读取图像: 183.bmp 无法读取图像: 184.bmp 无法读取图像: 185.bmp 无法读取图像: 186.bmp 无法读取图像: 187.bmp 无法读取图像: 188.bmp 无法读取图像: 189.bmp 无法读取图像: 190.bmp 无法读取图像: 191.bmp 无法读取图像: 192.bmp 无法读取图像: 193.bmp 无法读取图像: 194.bmp 无法读取图像: 195.bmp 无法读取图像: 196.bmp 无法读取图像: 197.bmp 无法读取图像: 198.bmp 无法读取图像: 199.bmp 无法读取图像: 200.bmp 无法读取图像: 201.bmp 无法读取图像: 202.bmp 无法读取图像: 203.bmp 无法读取图像: 204.bmp 无法读取图像: 205.bmp 无法读取图像: 206.bmp 无法读取图像: 207.bmp 无法读取图像: 208.bmp 计算碎片相似度矩阵... 未找到明显左上角碎片,使用启发式方法 进程已结束,退出代码为 1 对于上面的Python代码
<think>根据错误信息,程序在尝试重建中文碎片(附件3)时遇到了两个主要问题:
1. 无法读取任何碎片图像(000.bmp到208.bmp),错误信息显示文件路径有问题或文件不完整。
2. 在尝试选择左上角碎片时,出现了`IndexError: list index out of range`错误。
### 问题分析
1. **文件读取失败**:程序尝试从路径`D:\学习文件\JM\2013B\附件3`读取图像,但所有图像都无法打开。可能的原因包括:
- 路径错误:指定的路径下不存在这些文件。
- 文件格式问题:虽然文件扩展名是.bmp,但可能实际格式不符或文件已损坏。
- 权限问题:程序没有读取该目录的权限。
2. **索引越界**:在`reconstruct_grid`方法中,尝试访问`self.fragments[top_left_id]`时发生了索引越界。这通常是因为`top_left_id`的值超出了`self.fragments`列表的范围。而`top_left_id`是通过`np.argmin(top_left_scores)`计算得到的,这表示程序试图找到一个左上角碎片,但可能没有找到合适的碎片(例如,所有碎片都被排除了,或者`top_left_scores`数组为空)。
### 解决方案
#### 1. 解决文件读取问题
- **检查路径**:确保路径`D:\学习文件\JM\2013B\附件3`确实存在,并且包含208个碎片图像文件。
- **检查文件扩展名**:虽然文件名以.bmp结尾,但实际可能是其他格式?或者文件名有前缀后缀?可以尝试打印目录下的文件列表来确认。
- **使用绝对路径**:确保提供的路径是绝对路径,并且正确转义(在Python字符串中,反斜杠需要双写或使用原始字符串)。
在代码中,我们使用`os.listdir`来遍历目录,然后使用`os.path.join`构建完整路径。如果目录不存在,`os.listdir`会抛出异常。但这里并没有异常,而是每个文件都打不开,所以可能是文件本身的问题。
我们可以修改代码,在读取图像时如果失败,则打印出具体的文件路径,以便确认路径是否正确。同时,我们可以检查一下该目录下实际存在的文件列表。
修改`load_fragments`方法中的错误处理部分:
```python
try:
img = cv2.imread(filepath)
if img is None:
print(f"无法读取图像: {filename} (路径: {filepath})")
continue
# ... 其他处理
except Exception as e:
print(f"读取图像{filename}时出错: {e}")
```
#### 2. 解决索引越界问题
索引越界是因为`top_left_id`的值可能为0,而如果`self.fragments`列表为空(因为所有图像都没有加载成功),那么访问`self.fragments[0]`就会越界。
在尝试重建之前,我们需要确保成功加载了一些碎片。如果没有任何碎片被加载,我们应该提前退出并给出错误提示。
在`reconstruct_grid`方法开始处添加检查:
```python
if len(self.fragments) == 0:
print("错误:没有加载到任何碎片图像。")
return False
```
另外,在计算`top_left_scores`时,如果所有碎片都被排除(比如因为边界特征计算失败),也可能导致`top_left_scores`为空数组。因此,在`np.argmin(top_left_scores)`之前,需要确保`top_left_scores`不为空。
### 代码修改
基于以上分析,我们需要对代码进行以下修改:
1. 在`load_fragments`方法中,增加更详细的错误信息。
2. 在`reconstruct_grid`方法开始时,检查碎片列表是否为空。
3. 在计算左上角碎片时,检查`top_left_scores`数组是否为空。
以下是修改后的代码片段(只修改了相关部分):
#### 修改`load_fragments`方法
```python
def load_fragments(self):
print(f"正在加载碎片图像从: {self.folder}")
files = os.listdir(self.folder)
for filename in tqdm(files, desc="加载碎片"):
if not filename.endswith(('.bmp', '.png', '.jpg', '.jpeg')):
continue
filepath = os.path.join(self.folder, filename)
img = cv2.imread(filepath)
if img is None:
print(f"无法读取图像: {filename} (完整路径: {filepath})")
continue
# 转换为灰度图
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 二值化
_, binary = cv2.threshold(gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
self.fragments.append({
'filename': filename,
'image': img,
'gray': gray,
'binary': binary
})
print(f"成功加载 {len(self.fragments)} 个碎片")
```
#### 修改`reconstruct_grid`方法
在方法开始处添加:
```python
if len(self.fragments) == 0:
print("错误:没有碎片可供重建。")
return False
```
在计算左上角碎片的部分,添加检查:
```python
# 计算左上角碎片
top_left_scores = []
for i, frag in enumerate(self.fragments):
# 计算每个碎片的边界特征(比如左边界和上边界的黑色像素比例)
# 左上角碎片:左边和上边应该是全白(或接近全白),而右边和下边应该有黑色(文字)
left_edge = frag['binary'][:, 0]
top_edge = frag['binary'][0, :]
# 计算左边界和上边界的白色像素比例
left_white_ratio = np.sum(left_edge == 255) / len(left_edge)
top_white_ratio = np.sum(top_edge == 255) / len(top_edge)
# 我们希望左上角碎片的左边界和上边界白色比例高,所以得分是(1-白色比例)的和
score = (1 - left_white_ratio) + (1 - top_white_ratio)
top_left_scores.append(score)
# 检查top_left_scores是否为空
if len(top_left_scores) == 0:
print("错误:无法计算左上角碎片的得分。")
return False
top_left_id = np.argmin(top_left_scores) # 得分最小的作为左上角
print(f"选择左上角碎片: {self.fragments[top_left_id]['filename']}")
```
### 其他建议
- 由于中文碎片是文字,且排列规则(横排),可以考虑使用投影法(水平投影和垂直投影)来辅助定位碎片的位置。
- 如果碎片图像确实无法读取,需要检查文件路径是否正确,以及文件是否损坏。
### 重新运行
在修改代码后,重新运行程序。如果文件路径正确且文件可读,那么碎片应该被成功加载。如果仍然无法读取,则需要手动检查文件路径和文件内容。
### 相关问题
§§相关问题§§:
1. 如何检查一个文件路径是否存在,以及如何列出目录中的所有文件?
2. 在OpenCV中,除了`cv2.imread`,还有哪些方法可以读取图像文件?
3. 当处理大量图像文件时,如何优化内存使用?
4. 对于二值图像,有哪些常用的特征提取方法用于图像拼接?</think>根据您提供的错误信息,程序在尝试重建中文碎片(附件3)时遇到了两个主要问题:
1. **文件读取失败**:所有碎片图像(000.bmp - 208.bmp)都无法打开
2. **索引越界错误**:在尝试访问左上角碎片时出现 `IndexError: list index out of range`
### 问题分析与解决方案
#### 1. 文件读取问题
错误信息表明所有图像文件都无法打开:
```
[ WARN:[email protected]] global loadsave.cpp:275 cv::findDecoder imread_('D:\学习文件\JM\2013B\附件3\000.bmp'): can't open/read file: check file path/integrity
```
可能原因:
- 文件路径不正确
- 文件格式不是标准BMP
- 文件损坏或权限问题
**解决方案:**
```python
import os
from PIL import Image
def load_fragments(folder_path):
fragments = []
valid_files = []
for filename in os.listdir(folder_path):
filepath = os.path.join(folder_path, filename)
try:
# 尝试用PIL打开(支持更多格式)
img = Image.open(filepath)
img = img.convert('L') # 转为灰度
fragments.append({
'filename': filename,
'image': img,
'array': np.array(img) # 转为numpy数组
})
valid_files.append(filename)
except Exception as e:
print(f"无法读取 {filename}: {str(e)}")
# 尝试二进制读取
try:
with open(filepath, 'rb') as f:
header = f.read(2)
if header == b'BM':
print(f"文件 {filename} 是BMP格式但无法打开,可能已损坏")
else:
print(f"文件 {filename} 不是标准BMP格式 (头字节: {header})")
except Exception as bin_e:
print(f"二进制读取失败: {str(bin_e)}")
print(f"成功加载 {len(valid_files)}/{len(os.listdir(folder_path))} 个碎片")
return fragments, valid_files
```
#### 2. 索引越界问题
错误发生在:
```python
print(f"选择左上角碎片: {self.fragments[top_left_id]['filename']}")
```
原因:`top_left_id` 计算有误或碎片列表为空
**解决方案:**
```python
def find_top_left(fragments):
if not fragments:
print("错误:碎片列表为空")
return None
top_left_id = 0
min_score = float('inf')
for i, frag in enumerate(fragments):
# 获取图像数组
img = frag['array']
# 计算边界特征
top_edge = img[0, :]
left_edge = img[:, 0]
# 计算边界白色像素比例(假设背景是白色)
top_white = np.mean(top_edge == 255)
left_white = np.mean(left_edge == 255)
# 左上角应有最高的白色比例
score = (1 - top_white) + (1 - left_white)
if score < min_score:
min_score = score
top_left_id = i
if top_left_id >= len(fragments):
print(f"错误:无效的索引 {top_left_id} (最大索引: {len(fragments)-1})")
return None
print(f"选择左上角碎片: {fragments[top_left_id]['filename']}")
return top_left_id
```
### 完整修复建议
```python
import os
import numpy as np
from PIL import Image
import cv2
from tqdm import tqdm
class FragmentReconstructor:
def __init__(self, folder_path):
self.folder = folder_path
self.fragments = []
self.similarity_matrix = None
self.visited = None
self.rows = 0
self.cols = 0
def load_fragments(self):
print(f"正在加载碎片图像从: {self.folder}")
self.fragments = []
for filename in tqdm(os.listdir(self.folder)):
if not filename.lower().endswith(('.bmp', '.png', '.jpg', '.jpeg')):
continue
filepath = os.path.join(self.folder, filename)
try:
# 尝试用PIL打开
img = Image.open(filepath)
img = img.convert('L') # 转为灰度
binary = np.array(img) > 128 # 二值化
self.fragments.append({
'filename': filename,
'image': np.array(img),
'binary': binary.astype(np.uint8) * 255
})
except:
try:
# 尝试OpenCV作为备选
img = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
if img is None:
raise ValueError("OpenCV返回None")
_, binary = cv2.threshold(img, 128, 255, cv2.THRESH_BINARY)
self.fragments.append({
'filename': filename,
'image': img,
'binary': binary
})
except Exception as e:
print(f"无法读取图像 {filename}: {str(e)}")
print(f"成功加载 {len(self.fragments)} 个碎片")
return len(self.fragments) > 0
def calculate_similarity(self, frag1, frag2, direction):
"""计算两个碎片的相似度"""
# 实现你的相似度计算逻辑
# 示例:计算边界像素匹配度
if direction == 'right':
edge1 = frag1['binary'][:, -1]
edge2 = frag2['binary'][:, 0]
elif direction == 'bottom':
edge1 = frag1['binary'][-1, :]
edge2 = frag2['binary'][0, :]
else:
return 0
return np.mean(edge1 == edge2)
def find_top_left(self):
if not self.fragments:
return -1
top_left_id = 0
min_score = float('inf')
for i, frag in enumerate(self.fragments):
# 计算左上角得分(上边界和左边界应主要为背景)
top_edge = frag['binary'][0, :]
left_edge = frag['binary'][:, 0]
# 假设背景为白色(255)
top_score = np.sum(top_edge != 255)
left_score = np.sum(left_edge != 255)
total_score = top_score + left_score
if total_score < min_score:
min_score = total_score
top_left_id = i
return top_left_id
def reconstruct_grid(self):
if not self.fragments:
print("错误:没有碎片可供重建")
return False
# 估计网格大小(假设为正方形网格)
total = len(self.fragments)
self.cols = int(np.sqrt(total))
self.rows = total // self.cols
print(f"估计网格大小: {self.rows}行 x {self.cols}列")
# 找到左上角碎片
top_left_id = self.find_top_left()
if top_left_id == -1:
print("无法确定左上角碎片")
return False
print(f"选择左上角碎片: {self.fragments[top_left_id]['filename']}")
# 重建逻辑(伪代码)
grid = [[None] * self.cols for _ in range(self.rows)]
used = set()
# 实现你的重建算法...
# 示例:从左上角开始,向右和向下匹配
return True
# 使用示例
if __name__ == "__main__":
folder_path = r"D:\学习文件\JM\2013B\附件3"
reconstructor = FragmentReconstructor(folder_path)
if reconstructor.load_fragments():
reconstructor.reconstruct_grid()
```
### 关键修复点解释
1. **多格式支持**:
- 使用PIL作为主要图像加载器(支持更多格式)
- 添加OpenCV作为备选方案
- 详细的错误报告帮助诊断问题
2. **鲁棒的左上角检测**:
- 基于边界像素统计而非简单索引
- 添加空列表检查
- 分数计算更符合左上角特征
3. **错误处理**:
- 所有关键操作添加空值检查
- 提供详细的错误信息
- 防止索引越界崩溃
### 文件路径问题排查建议
1. 手动检查路径是否存在:
```python
print(f"路径是否存在: {os.path.exists(r'D:\学习文件\JM\2013B\附件3')}")
```
2. 检查文件列表:
```python
files = os.listdir(r'D:\学习文件\JM\2013B\附件3')
print(f"找到 {len(files)} 个文件,前5个: {files[:5]}")
```
3. 验证文件头(前2字节应为"BM"表示BMP):
```python
with open(r'D:\学习文件\JM\2013B\附件3\000.bmp', 'rb') as f:
header = f.read(2)
print(f"文件头: {header}") # 应为b'BM'
```
AttributeError: module 'cv2.aruco' has no attribute 'DetectorParameters_create' 07-09 13:59:32.994 DEBUG [test_ae_awb_regions]#teardown_test >>> BEGIN >>> 07-09 13:59:32.994 DEBUG [test_ae_awb_regions]#teardown_test <<< END <<< 07-09 13:59:32.994 DEBUG [test_ae_awb_regions]#on_fail >>> BEGIN >>> 07-09 13:59:32.995 DEBUG test_ae_awb_regions on FAIL. 07-09 13:59:32.995 DEBUG [test_ae_awb_regions]#on_fail <<< END <<< 07-09 13:59:32.995 INFO [Test] test_ae_awb_regions ERROR 07-09 13:59:33.004 DEBUG [AeAwbRegions]#teardown_class >>> BEGIN >>> 07-09 13:59:33.004 DEBUG summary_writer._path: /tmp/CameraITS_kdj2u4ki/cam_id_0/scene8/TEST_BED_TABLET_SCENES/07-09-2025_13-59-14-070/test_summary.yaml 07-09 13:59:33.004 DEBUG [AeAwbRegions]#teardown_class <<< END <<< 07-09 13:59:33.004 DEBUG [AeAwbRegions]#clean_up >>> BEGIN >>> 07-09 13:59:33.007 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.009 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.012 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.014 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.017 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.019 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.022 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.024 DEBUG cmd: 'fastboot devices ', stdout: b'', stderr: b'/bin/sh: 1: fastboot: not found\n', ret: 127 07-09 13:59:33.040 DEBUG Destroying android_device. 07-09 13:59:33.041 DEBUG Stopping standing subprocess 141931 07-09 13:59:33.067 DEBUG Stopped standing subprocess 141931 07-09 13:59:33.067 DEBUG Stopping standing subprocess 141951 07-09 13:59:33.084 DEBUG Stopped standing subprocess 141951 07-09 13:59:33.084 DEBUG [AeAwbRegions]#clean_up <<< END <<< 07-09 13:59:33.084 INFO Summary for test class AeAwbRegions: Error 1, Executed 1, Failed 0, Passed 0, Requested 1, Skipped 0 07-09 13:59:33.085 INFO Summary for test run TEST_BED_TABLET_SCENES@07-09-2025_13-59-14-070: Total time elapsed 19.014907349002897s Artifacts are saved in "/tmp/CameraITS_kdj2u4ki/cam_id_0/scene8/TEST_BED_TABLET_SCENES/07-09-2025_13-59-14-070" Test summary saved in "/tmp/CameraITS_kdj2u4ki/cam_id_0/scene8/TEST_BED_TABLET_SCENES/07-09-2025_13-59-14-070/test_summary.yaml" Test results: Error 1, Executed 1, Failed 0, Passed 0, Requested 1, Skipped 0
<think>首先,用户的问题是:“请使用中文回答问题”,然后提供了一段日志输出。日志中包含错误信息:“AttributeError: module 'cv2.aruco' has no attribute 'DetectorParameters_create'”,以及一些调试信息。
用户要求我:1. 使用中文回答问题。2. 在回答完问题后,必须根据用户的问题及我的回答提出3-5个 §§相关问题§§。3. §§相关问题§§ 必须输出在回答的末尾,第一行必须完整输出 "§§相关问题§§",禁止换行分散。
示例格式显示,回答应该包括对问题的解释或解决建议,然后是代码块(如果需要),最后是相关问题。
核心问题是日志中的错误:"AttributeError: module 'cv2.aruco' has no attribute 'DetectorParameters_create'"。这看起来是Python代码中的错误,涉及到OpenCV的ArUco模块。
ArUco是OpenCV中用于增强现实的一个模块,用于检测和识别标记。这个错误表明代码试图调用`cv2.aruco.DetectorParameters_create()`,但该属性不存在。
在较新版本的OpenCV中,ArUco模块的API发生了变化。在旧版本中(如OpenCV 3.x),`DetectorParameters_create()`是存在的,但在OpenCV 4.x中,它被弃用或更改了。
在OpenCV 4.x中,推荐使用`cv2.aruco.DetectorParameters()`或`cv2.aruco.DetectorParameters_create()`可能被移除或重命名。具体来说,在OpenCV 4.7.0中,我检查了文档,它应该是`cv2.aruco.DetectorParameters()`。
可能的解决方案:
- 如果使用的是旧版本OpenCV,尝试安装旧版本。
- 如果使用的是新版本,修改代码为使用新的API。例如,使用`cv2.aruco.DetectorParameters()`来创建参数对象。
日志中还显示了一些测试框架的信息,如"CameraITS",这表明这可能是一个相机测试套件中的错误。错误发生在测试"test_ae_awb_regions"中。
所以,我的回答应该:
1. 解释错误的原因。
2. 提供解决方案。
3. 使用中文。
4. 在末尾添加3-5个相关问题。
回答结构:
- 先描述错误。
- 解释原因。
- 给出修复建议。
- 然后输出相关问题。
相关问题应该基于用户的问题和我的回答。例如:
1. 如何检查OpenCV的版本?
2. 如何更新代码以使用新的ArUco API?
3. 这个错误如何影响整个测试套件?
4. 有没有其他常见的OpenCV API变化?
5. 如何调试类似的问题?
确保相关问题数量在3-5个。
最后,第一行必须是"§§相关问题§§",然后列出问题,用数字点,如"1. ..."。
完整回答:
- 开头用中文解释。
- 不需要代码块,除非必要。这里可能不需要,因为错误是API变化。
- 结尾是相关问题。</think>根据您提供的日志信息,核心错误是 `AttributeError: module 'cv2.aruco' has no attribute 'DetectorParameters_create'`。这表示在 Python 代码中尝试调用 OpenCV 的 ArUco 模块时,找不到 `DetectorParameters_create` 属性。以下是详细分析和解决方案:
### 错误原因:
- **API 变更**:在 OpenCV 4.x 及以上版本中,ArUco 模块的 API 已更新。旧方法 `DetectorParameters_create()` 被弃用或移除,新版本应使用 `cv2.aruco.DetectorParameters()` 或 `cv2.aruco.getDetectorParameters()`。
- **环境不匹配**:您的代码可能基于旧版 OpenCV (如 3.x) 编写,但当前环境安装的是新版 OpenCV (如 4.7.0),导致兼容性问题。
- **上下文影响**:日志显示错误发生在测试用例 `test_ae_awb_regions` 中(属于 `AeAwbRegions` 测试类),这可能是相机测试套件(如 CameraITS)的一部分。错误导致测试失败(状态为 ERROR),并触发清理流程(如 `fastboot` 命令未找到)。
### 解决方案:
1. **检查 OpenCV 版本**:
- 运行 `pip show opencv-python` 或 `cv2.__version__` 确认版本。如果版本 >= 4.0,需更新代码。
2. **修改代码适配新 API**:
- 替换 `cv2.aruco.DetectorParameters_create()` 为 `cv2.aruco.DetectorParameters()`。
- 示例修正:
```python
# 旧代码(引发错误)
# parameters = cv2.aruco.DetectorParameters_create()
# 新代码(兼容 OpenCV 4.x)
parameters = cv2.aruco.DetectorParameters()
```
3. **降级 OpenCV(临时方案)**:
- 若需兼容旧代码,安装旧版:`pip install opencv-python==3.4.20`。
4. **测试环境修复**:
- 确保测试框架(如 CameraITS)依赖项一致。检查 `fastboot` 是否安装(日志显示 `fastboot: not found`),这可能影响设备清理流程。
### 其他日志分析:
- 测试失败原因为此错误,导致整个测试类 `AeAwbRegions` 结果为 ERROR(1 个测试失败)。
- 清理阶段出现 `fastboot` 未找到(`ret: 127`),建议检查设备连接和 ADB/Fastboot 工具安装。
- 最终测试摘要保存在 `/tmp/CameraITS_.../test_summary.yaml`,错误信息可在此文件追踪。
阅读全文
相关推荐

















