当我尝试扫描护照上的MRZ代码时,应用程序崩溃了。 这是日志:
OpenCV错误:断言失败(0< = roi.x&& 0< = roi.width&& roi.x + roi.width< = m.cols&& 0< ; = roi.y&& 0< = roi.height&& roi.y + roi.height< = m.rows)in Mat,file ../matrix.cpp,line 517 libc ++ abi.dylib:以类型为cv的非捕获异常终止::异常:../ matrix.cpp:517:错误:(-215)0< = roi.x&& 0< = roi.width&& roi.x + roi.width< = m.cols&& 0< = roi.y&& 0< = roi.height&& roi.y + roi.height< = m.rows in function Mat
这是堆栈跟踪:
#12 0x0062662c在cv :: Mat :: operator()(cv :: Rect_ const&)const
#13 0x00628c72 in :: - [PassportScanner realProcessImage:](cv :: Mat&)
以上功能的内容如下:
Mat Mat::operator()( const Rect& roi ) const
{
return Mat(*this, roi);
}
-(void) realProcessImage:(cv::Mat &)cropped {
//Some other code
vector<cv::Rect> rotatedRegions = [self show:cropped gray:rotated2];
// Sort by y
std::sort(rotatedRegions.begin(), rotatedRegions.end(), sortByBoundingRectYPosition);
if (rotatedRegions.size() == 2) {
if(self.delegate)
[self.delegate setVisualIndicatorColor:[PassportScanner getColorForFraction:0.5]];
while (rotatedRegions[0].height + rotatedRegions[0].y >= rotated.rows) {
rotatedRegions[0].height--;
}
image1 = rotated(rotatedRegions[0]);
while (rotatedRegions[1].height + rotatedRegions[1].y >= rotated.rows) {
rotatedRegions[1].height--;
}
image2 = rotated(rotatedRegions[1]); //**——>Problem starts here**
//More code
}
我看过这些链接,但没有一个帮我解决问题:
Error with OpenCV ROI
OpenCv assertion failed