After using the detectTextSWT function, the program crashes

problem : hi, why After using the detectTextSWT function, the program crashes? Where am I wrong?

my codes :

// read image
cv::Mat imageInputBgr = OpenImage("imageInputBgr", cv::ImreadModes::IMREAD_COLOR); // read as 3-channel-BGR
if (imageInputBgr.empty())
{
	qDebug() << "Could not load the image file";
	return;
}


cv::Mat imageOutputBgr1 = imageInputBgr.clone();
std::vector<cv::Rect> components;
bool dark_on_light = false;
cv::Mat out;
std::vector<cv::Rect> regions;
cv::text::detectTextSWT(imageOutputBgr1, components, dark_on_light, out, regions);


return;


// other codes
// .
// .
// .

Application output :
12:21:02: The program has unexpectedly finished.
12:21:02: The process was ended forcefully.
12:21:02: C:\Users\mahdi\Documents\build-untitled-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug\debug\untitled.exe crashed.

similar :

(probably not your fault, but a bug)

can you add the image, please ?

yes sure, for example this image :

scenetext_segmented_word03

or

scenetext_segmented_word01

Test1

crnn

cv::Mat imageOutputBgr1 = imageInputBgr.clone();
std::vector<cv::Rect> components;
bool dark_on_light = false;
cv::Mat out;
std::vector<cv::Rect> regions;
cv::text::detectTextSWT(imageOutputBgr1, components, dark_on_light, out, regions);
//---
// Show Result
AddImage(out, "Letter Candidates");

I tested with the image above, When the value of the variable [dark_on_light] is false, I have no problem and no error occurs! BUT!!! When the value of the variable [dark_on_light] is true, it shows the following errors [ WHY??? ] :

OpenCV(4.5.4) Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in cv::Mat::copyTo, file F:…\4.5.4\opencv\modules\core\src\copy.cpp, line 320

OpenCV: terminate handler is called! The last OpenCV error is:

OpenCV(4.5.4) Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in cv::Mat::copyTo, file F:…\4.5.4\opencv\modules\core\src\copy.cpp, line 320




Test2

when use this image, app crash [ dark_on_light == true /// and /// dark_on_light == false, in both, app crash ]

scenetext_segmented_word03

error message :

18:12:49: The program has unexpectedly finished.
18:12:49: The process was ended forcefully.
18:12:49: C:…\build-untitled-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug\debug\untitled.exe crashed.




Test3

scenetext_word01

dark_on_light == true ::: no error, no crash, show best result
dark_on_light == false ::: no error, no crash, The output is not the same as the previous test and is poor.




1 Like

outTextRegions is empty here:

i think it must be checked (bug)