Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building #1

Open
pxuanqui opened this issue Aug 6, 2014 · 23 comments
Open

Error when building #1

pxuanqui opened this issue Aug 6, 2014 · 23 comments

Comments

@pxuanqui
Copy link

pxuanqui commented Aug 6, 2014

When debug to this function, it shows the error "Access violation reading location 0xCDCDCDD1"
Mat RobustTextDetection::createMSERMask(Mat& grey) {
/* Find MSER components */
vector<vector> contours;
MSER mser(8, param.minMSERArea, param.maxMSERArea, 0.25, 0.1, 100, 1.01, 0.03, 5);
mser(grey, contours);

/* Create a binary mask out of the MSER */
Mat mser_mask(grey.size(), CV_8UC1, Scalar(0));

for (size_t i = 0; i < contours.size(); i++) {
    for (Point& point : contours[i])
        mser_mask.at<uchar>(point) = 255;
}

return mser_mask;

}

@subokita
Copy link
Owner

subokita commented Aug 6, 2014

Hi pxuanqui, can I have 3 things before I can debug this issue?

  • The image you tried to apply the robust text detection on.
  • The parameters you supplied
  • The version of your OpenCV

I'm not sure what's the issue (it's still working on mine) ...

MSER mser( 8, param.minMSERArea, param.maxMSERArea, 0.25, 0.1, 100, 1.01, 0.03, 5 );
mser(grey, contours);

but if those two lines are the cause of the error, then I hate to tell you that, those are the APIs from OpenCV. But again, if you're okay with it, please supply me those 3 things so that I can debug it.

For your information, this example uses OpenCV 2.4.9 and Tesseract 3.02.

@pxuanqui
Copy link
Author

pxuanqui commented Aug 6, 2014

I use your TestText.png and the same parameters, I don't modify anything
I also use OpenCV 2.4.9 and Tesseract 3.02 and Visual Studio 2013
Here the project I build,
BTW, I also get the error "unresolved external symbol _cvFontQt referenced in function _main"
https://www.dropbox.com/s/1py0k7x28zaz6k0/textDetection.zip
Thank you !!!

@subokita
Copy link
Owner

subokita commented Aug 6, 2014

Hmmm, I don't have a Visual Studio, I only have a Macbook here, so there are things that I can't do.

First, here's some of the information about my build of OpenCV from home-brew (a package installer in mac)

Required: jpeg ✔, libpng ✘, libtiff ✔
Optional: eigen ✔, jasper ✔, openexr ✔, openni ✘, qt ✔, tbb ✘, ffmpeg ✘

I don't think you need eigen, jasper, or openexr. But the example were compiled with QT functionalities for printing out the text, so you might want to comment the part out.

Second, I wrote a small test function to help me localise the issue, please try this updated main.cpp file: https://www.dropbox.com/s/5pt941ulbp388vh/main.cpp
If it's okay it should print out "Everything is okay!", else it should throw a runtime error with specified message. If it's not one of the messages, then it's highly probably it might be related to OpenCV instead of the logic of the code.

Third, I'd presume that your OpenCV weren't built with QT support, so you might want to comment out

    /* And draw them on screen */
    CvFont font = cvFontQt("Helvetica", 24.0, CV_RGB(0, 0, 0) );
    Point coord = Point( result.second.br().x + 10, result.second.tl().y );
    for( string& line: splitted ) {
        addText( image, line, coord, font );
        coord.y += 25;
    }
    rectangle( image, result.second, Scalar(0, 0, 255), 2);

And print out the detected text from splitted to console instead.

Please update me about the progress, I'm apologise for the inconveniences.

@pxuanqui
Copy link
Author

pxuanqui commented Aug 6, 2014

Now I can build your original project, with the tested image TestText.png, it work well. But when I try to use another image, it doesn't work, for example the following image, it shows an exception
scenetext01

@subokita
Copy link
Owner

subokita commented Aug 6, 2014

First is that I updated RobustTextDetection to have a check on the resulting detected region, to avoid exception

Second, sadly for your example, you require to increase your max connected component count
param.maxConnCompCount to 4000 (or just increase till it doesn't complain about it),

And finally, although it will run now, the result will be way off, and you might need to start with parameter tuning to get the desired result.

@ghost
Copy link

ghost commented Feb 8, 2015

image

Now I can build your original project, with the tested image TestText.png, it work well. But when I try to use another image, it doesn't work, for example the following image, it shows an exception

@subokita
Copy link
Owner

subokita commented Feb 8, 2015

Sadly the application is very fragile, you might need to tweak the parameters a bit when it comes to new images. It's not meant to be a library, it's supposed to be a sample test case on how it works.

@ghost
Copy link

ghost commented Feb 8, 2015

Hmmm,thanks,i am a student who study your paper ,so can you tell something about how to tweak the parameters a bit when it comes to new images.thank you, i need some help about this,thank you very much

image

@subokita
Copy link
Owner

subokita commented Feb 8, 2015

Well, I'm not the one who wrote the paper...
Anyway, if I still recall correctly, here are some of the explanations of the parameters:

param.minMSERArea        = 10;
param.maxMSERArea        = 400;

These are the range of the detected MSER area, for detected regions that are outside of those number of pixels (10 - 400 pixels), it's discarded

param.cannyThresh1       = 30;
param.cannyThresh2       = 100;

Parameters for canny edge detection

param.maxConnCompCount   = 3000;
param.minConnCompArea    = 35;
param.maxConnCompArea    = 300;

These are for connected components. Similar to the MSER params above, any connected component above or below the range, will be discarded

param.minEccentricity    = 0.4;
param.maxEccentricity    = 0.995;
param.minSolidity        = 0.2;
param.maxStdDevMeanRatio = 0.5;

The final 4 params, are bit confusing, even for me. Basically it defines whether the detected region is a blob, or twisted, it's solid, and how spread out it is. You might want to play a bit around it, to see how it affects the detection of letters like 'I' or 'S', etc.

@ghost
Copy link

ghost commented Feb 8, 2015

oh! ! !thank you very much,i can run it now thank you !!

@HerShawn
Copy link

Hello,subokia! I use opencv 2.4.10 for windows(without QT support i guess,so i just replace cvFontQT with fontQT and i don't know wether it works or not),Tesseract 3.02 and Visual Studio 2013. I debuged it for several days but failed in the end. I wonder if thise code could only run at Mac? Did you have a "windows version"? (Sorry,I'm not good at speeking english. But i want to say: you are a nice person!)

@HerShawn
Copy link

1

@subokita
Copy link
Owner

Hi HerShawn, sadly I don't really know what's the main issue when running on Windows (I don't own a Windows PC, sadly).

Anyway, maybe try to comment out the QT part first, and see if that's the issue, sometimes I think it's more of the incompatible library, but maybe not in this case. Below is the snippet of the last few chunk of codes on the main method, just comment out the QT font part.

/* And draw them on screen */
//CvFont font = cvFontQt("Helvetica", 24.0, CV_RGB(0, 0, 0) );
//Point coord = Point( result.second.br().x + 10, result.second.tl().y );
for( string& line: splitted ) {
    //addText( image, line, coord, font );
    //coord.y += 25;

    cout << line << endl;
}

rectangle( image, result.second, Scalar(0, 0, 255), 2);

/* Append the original and stroke width images together */
cvtColor( stroke_width, stroke_width, CV_GRAY2BGR );
Mat appended( image.rows, image.cols + stroke_width.cols, CV_8UC3 );
image.copyTo( Mat(appended, Rect(0, 0, image.cols, image.rows)) );
stroke_width.copyTo( Mat(appended, Rect(image.cols, 0, stroke_width.cols, stroke_width.rows)) );

resize(appended, appended, Size(), 0.5f, 0.5f );

imshow("", appended );
waitKey();

I doubt that commenting QT would resolve the issue, but please keep me updated.
我觉得,你的英语相当不错. 向反来讲,我的华语是蛮差

@HerShawn
Copy link

Thank you very much,Saburo Okita!
I really think you are passionate, Sincerely and kind(说实话,我虽然考到了英语6级,但是我的
真实水平也只是能读懂英语的程度;我并不擅长英语写作)
I‘ll try to solve this problem by following your instructions.
Thanks a lot for your concern and efforts!

@HerShawn
Copy link

Hi,brother:

  Thanks a lot! Finally i worked it out with your help. Now these code could use

in windows. So i send them to you . Good night!

                                                                           best wishes

------------------ 原始邮件 ------------------
发件人: "Saburo Okita";notifications@github.com;
发送时间: 2015年4月11日(星期六) 凌晨0:04
收件人: "subokita/Robust-Text-Detection"Robust-Text-Detection@noreply.github.com;
抄送: "贺翔"hexiangman@qq.com;
主题: Re: [Robust-Text-Detection] Error when building (#1)

Hi HerShawn, sadly I don't really know what's the main issue when running on Windows (I don't own a Windows PC, sadly).

Anyway, maybe try to comment out the QT part first, and see if that's the issue, sometimes I think it's more of the incompatible library, but maybe not in this case. Below is the snippet of the last few chunk of codes on the main method, just comment out the QT font part.
/* And draw them on screen / //CvFont font = cvFontQt("Helvetica", 24.0, CV_RGB(0, 0, 0) ); //Point coord = Point( result.second.br().x + 10, result.second.tl().y ); for( string& line: splitted ) { //addText( image, line, coord, font ); //coord.y += 25; cout << line << endl; } rectangle( image, result.second, Scalar(0, 0, 255), 2); / Append the original and stroke width images together */ cvtColor( stroke_width, stroke_width, CV_GRAY2BGR ); Mat appended( image.rows, image.cols + stroke_width.cols, CV_8UC3 ); image.copyTo( Mat(appended, Rect(0, 0, image.cols, image.rows)) ); stroke_width.copyTo( Mat(appended, Rect(image.cols, 0, stroke_width.cols, stroke_width.rows)) ); resize(appended, appended, Size(), 0.5f, 0.5f ); imshow("", appended ); waitKey();
I doubt that commenting QT would resolve the issue, but please keep me updated.
我觉得,你的英语相当不错. 向反来讲,我的华语是蛮差


Reply to this email directly or view it on GitHub.

@subokita
Copy link
Owner

Great! Have fun with it!

@ctouffet
Copy link

Hi Subokita,

I have an error when building with g++ (-std=gnu++11) :

/usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: no match for call to ‘(ConnectedComponent::apply(const cv::Mat&)::__lambda0) (ComponentProperty&, const ComponentProperty&)’
while (__comp(*__first, __pivot))
^
ConnectedComponent.cpp:156:51: note: candidates are:
sort( properties.begin(), properties.end(), [=](ComponentProperty& a, ComponentProperty& b){

Do you know what it could be?

Thanks in advance!

@swingfox
Copy link

Hello Subokita,

In what line of code will I insert the bounding box part found on part 4 MATLAB implementation?

Thanks :)

@subokita
Copy link
Owner

@swingfox Should be starting around line 123 in RobustTextDetection.cpp

@yunzhongzhuhuo
Copy link

@ctouffet
Do you solve the error.I have the same problem.Can you help me? Thanks.

@mynameischaos
Copy link

Hello, when I compile the project, I get the error: variable type 'cv::MSER' is an abstract class.
Opencv version: 2.4.13
tesseract version: 3.04
But can't run.

@subokita
Copy link
Owner

subokita commented Nov 8, 2016

@mynameischaos Sadly I haven't touched this project for 2 years.

Based on the documentation, it shouldn't be abstract, but I no longer know what's the issue.
http://docs.opencv.org/2.4/modules/features2d/doc/feature_detection_and_description.html

Basically in the createMSERMask() it should call opencv's MSER method

MSER mser( 8, param.minMSERArea, param.maxMSERArea, 0.25, 0.1, 100, 1.01, 0.03, 5 );
mser(grey, contours);

Maybe the version of OpenCV I used were too old, just update it to newest opencv code that apply MSER to the greyscale image.

@mynameischaos
Copy link

@subokita Oh,no. Because of the version, based on the documentation of version 3.1.0, now it's abstract class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants