-
-
Notifications
You must be signed in to change notification settings - Fork 55.8k
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
Added ostream-like cv::putText helper function #313
Conversation
This commit brings a ostream-like text rendering on the cv::Mat like the cv::putText does. Unlike existing function, this commit allows to use operator << to print text on cv::Mat and supports newline characters. You can see the demonstration of the new cv::putText in drawing.cpp sample.
Hi Eugene, your contribution looks interesting but it compiles nowhere except Windows. You can find the results of pull request testing here: http://build.opencv.org/pullrequest. Please fix all build problems including MSVC build warnings and update your pull request. After that someone will review and decide is it worth to include it into the library. |
Hi Andrey, thanks for fast response. I'm sorry that i've forgot to check for compilation errors under mac and linux platforms. This issue has been fixed in my recent commit. I've checked it on mac (XCode 4.5, Clang 1.0) and ubuntu (gcc 4.6.3). |
@vpisarev Vadim, can you please look at this interesting request? |
It looks nice; on the other hand, if we extend putText to properly handle "\n" symbols in the text strings (should not be very hard), i.e. without affecting external API, the same thing it's just a little syntax sugar over stringstream s; This feature adds one more external C++ class (a class, which needs to be documented, tested, supported for many years) without adding any essential functionality (and the functionality is only added to C++, not python or java), so I would not include it, sorry. |
@BloodAxe sorry again, but we are closing your request by the reasons Vadim mentioned. |
@vpisarev, Vadim, please don't tell me that support of a tiny class which uses STL-only functions, contains no pointer arithmetics or compicated internal logic is harder than support of four different types that represent image data (CvMat, CvArr, IplImage and cv::Mat)! I perfectly understand that these old types are still in OpenCV for backward compatibility. If there would be a way to implement correct endline handling in putText function - it's already will be done. But there are a lot of code that relies on existing behaviour of putText. Changes in it can (and will) lead to wrong visualization in many apps. During my researches i need to process video sequences and print debug information on top of it. You can imagine what a pain to print ten variables every frame:
You're right, the content of this pull request is syntax sugar. I beleive the helper functions (and text output is a helper function of the library) shoud be easy to use. There is another argument that this PR is worth of merge. The proposed way uses std::cout idiom of printing text. But the existing putText function is more closely to printf() style. By the way i think it's also a good idea to allow putText to accept variable argument list like the printf does. |
first of all, you can always have this class in your project. Secondly, in 2.5 (or 2.6 at the latest) we are going to enable 3rd-party modules to be co-built and used together with the official OpenCV (something similar to Perl CPAN, R packages or 3rd-party Matlab toolboxes). Then you can just make a module with this and probably some other functionality and share it with other people without asking us. Even now it's possible - just make the folder with the same structure as imgproc, photo etc., put it inside opencv/modules and run CMake+make/VS/Xcode. |
Hi everyone above, |
@zeroch It seems this PR will not be merged into OpenCV. |
Why is not integrated? It is kinda ridiculous that OpenCV does not support texts with line spaces. |
This commit brings an ostream-like text rendering on the cv::Mat.
Unlike existing function, a new putText funtion allows to use operator << to print
text on cv::Mat and supports newline characters. You can see the
demonstration of the new cv::putText in drawing.cpp sample.
The proposed request allows to print text on the images in the following way:
The result of the rendering will be: